Commit 634bfd28 authored by Gilbert Ndresaj's avatar Gilbert Ndresaj

Player Theme & Clean

parent 850bd5ad
......@@ -119,7 +119,6 @@ public class AboutActivity extends ThemedActivity {
/*** SPECIAL THANKS ***/
/*** Patryk Goworowski ***/
((TextView) findViewById(R.id.about_patryk_goworowski_item_sub)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView) findViewById(R.id.about_patryk_goworowski_item_sub)).setLinkTextColor(getAccentColor());
}
private void mail(String mail) {
......@@ -181,6 +180,8 @@ public class AboutActivity extends ThemedActivity {
setNavBarColor();
setRecentApp(getString(R.string.about));
((TextView) findViewById(R.id.about_patryk_goworowski_item_sub)).setLinkTextColor(getAccentColor());
/**** Title Cards ***/
int color = getAccentColor();
((TextView) findViewById(R.id.about_app_title)).setTextColor(color);
......
......@@ -101,20 +101,10 @@ public final class CustomExoPlayerView extends FrameLayout {
layout.addView(surfaceView, 0);
}
/**
* Returns the player currently set on this view, or null if no player is set.
*/
public SimpleExoPlayer getPlayer() {
return player;
}
/**
* Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
* {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
* assignments are overridden.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
......@@ -145,30 +135,14 @@ public final class CustomExoPlayerView extends FrameLayout {
}
}
/**
* Sets the resize mode which can be of value {@link AspectRatioFrameLayout#RESIZE_MODE_FIT},
* {@link AspectRatioFrameLayout#RESIZE_MODE_FIXED_HEIGHT} or
* {@link AspectRatioFrameLayout#RESIZE_MODE_FIXED_WIDTH}.
*
* @param resizeMode The resize mode.
*/
public void setResizeMode(int resizeMode) {
layout.setResizeMode(resizeMode);
}
/**
* Returns whether the playback controls are enabled.
*/
public boolean getUseController() {
return useController;
}
/**
* Sets whether playback controls are enabled. If set to {@code false} the playback controls are
* never visible and are disconnected from the player.
*
* @param useController Whether playback controls should be enabled.
*/
public void setUseController(boolean useController) {
if (this.useController == useController) {
return;
......@@ -182,62 +156,20 @@ public final class CustomExoPlayerView extends FrameLayout {
}
}
/**
* Returns the playback controls timeout. The playback controls are automatically hidden after
* this duration of time has elapsed without user input and with playback or buffering in
* progress.
*
* @return The timeout in milliseconds. A non-positive value will cause the controller to remain
* visible indefinitely.
*/
public int getControllerShowTimeoutMs() {
return controllerShowTimeoutMs;
}
/**
* Sets the playback controls timeout. The playback controls are automatically hidden after this
* duration of time has elapsed without user input and with playback or buffering in progress.
*
* @param controllerShowTimeoutMs The timeout in milliseconds. A non-positive value will cause
* the controller to remain visible indefinitely.
*/
public void setControllerShowTimeoutMs(int controllerShowTimeoutMs) {
this.controllerShowTimeoutMs = controllerShowTimeoutMs;
}
public void setControllerShowTimeoutMs(int controllerShowTimeoutMs) {this.controllerShowTimeoutMs = controllerShowTimeoutMs;}
/**
* Set the {@link CustomPlayBackController.VisibilityListener}.
*
* @param listener The listener to be notified about visibility changes.
*/
public void setControllerVisibilityListener(CustomPlayBackController.VisibilityListener listener) {
controller.setVisibilityListener(listener);
}
public void setControllerVisibilityListener(CustomPlayBackController.VisibilityListener listener) {controller.setVisibilityListener(listener);}
/**
* Sets the rewind increment in milliseconds.
*
* @param rewindMs The rewind increment in milliseconds.
*/
public void setRewindIncrementMs(int rewindMs) {
controller.setRewindIncrementMs(rewindMs);
}
/**
* Sets the fast forward increment in milliseconds.
*
* @param fastForwardMs The fast forward increment in milliseconds.
*/
public void setFastForwardIncrementMs(int fastForwardMs) {
controller.setFastForwardIncrementMs(fastForwardMs);
}
public void setFastForwardIncrementMs(int fastForwardMs) {controller.setFastForwardIncrementMs(fastForwardMs);}
/**
* Get the view onto which video is rendered. This is either a {@link SurfaceView} (default)
* or a {@link TextureView} if the {@code use_texture_view} view attribute has been set to true.
*
* @return either a {@link SurfaceView} or a {@link TextureView}.
*/
public View getVideoSurfaceView() {
return surfaceView;
}
......@@ -257,9 +189,8 @@ public final class CustomExoPlayerView extends FrameLayout {
@Override
public boolean onTrackballEvent(MotionEvent ev) {
if (!useController || player == null) {
if (!useController || player == null)
return false;
}
maybeShowController(true);
return true;
}
......@@ -287,17 +218,14 @@ public final class CustomExoPlayerView extends FrameLayout {
TextRenderer.Output, ExoPlayer.EventListener {
// TextRenderer.Output implementation
@Override
public void onCues(List<Cue> cues) {
subtitleLayout.onCues(cues);
}
// SimpleExoPlayer.VideoListener implementation
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
float pixelWidthHeightRatio) {
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
layout.setAspectRatio(height == 0 ? 1 : (width * pixelWidthHeightRatio) / height);
}
......@@ -312,7 +240,6 @@ public final class CustomExoPlayerView extends FrameLayout {
}
// ExoPlayer.EventListener implementation
@Override
public void onLoadingChanged(boolean isLoading) {
// Do nothing.
......@@ -337,7 +264,5 @@ public final class CustomExoPlayerView extends FrameLayout {
public void onTimelineChanged(Timeline timeline, Object manifest) {
// Do nothing.
}
}
}
......@@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
......@@ -17,10 +18,10 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.ui.PlaybackControlView;
import com.google.android.exoplayer2.util.Util;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.util.ThemeHelper;
import java.util.Formatter;
import java.util.Locale;
......@@ -31,18 +32,14 @@ import java.util.Locale;
public class CustomPlayBackController extends FrameLayout {
/**
* Listener to be notified about changes of the visibility of the UI control.
*/
public interface VisibilityListener {
/**
* Called when the visibility changes.
*
* @param visibility The new visibility. Either {@link View#VISIBLE} or {@link View#GONE}.
*/
//Called when the visibility changes.
//@param visibility The new visibility. Either {@link View#VISIBLE} or {@link View#GONE}.
void onVisibilityChange(int visibility);
}
private ThemeHelper themeHelper;
public static final int DEFAULT_FAST_FORWARD_MS = 15000;
public static final int DEFAULT_REWIND_MS = 5000;
public static final int DEFAULT_SHOW_TIMEOUT_MS = 5000;
......@@ -135,24 +132,19 @@ public class CustomPlayBackController extends FrameLayout {
rewindButton.setOnClickListener(componentListener);
fastForwardButton = findViewById(R.id.ffwd);
fastForwardButton.setOnClickListener(componentListener);
}
/**
* Returns the player currently being controlled by this view, or null if no player is set.
*/
public ExoPlayer getPlayer() {
return player;
/**** THEMING THINGS ****/
themeHelper = ThemeHelper.getThemeHelper(getContext());
themeHelper.themeSeekBar(progressBar);
((LinearLayout) findViewById(R.id.exoplayer_controller_background))
.setBackgroundColor(themeHelper.getPrimaryColor());
}
/**
* Sets the {@link ExoPlayer} to control.
*
* @param player the {@code ExoPlayer} to control.
*/
public ExoPlayer getPlayer() {return player;}
public void setPlayer(ExoPlayer player) {
if (this.player == player) {
if (this.player == player)
return;
}
if (this.player != null) {
this.player.removeListener(componentListener);
}
......@@ -163,61 +155,28 @@ public class CustomPlayBackController extends FrameLayout {
updateAll();
}
/**
* Sets the {@link PlaybackControlView.VisibilityListener}.
*
* @param listener The listener to be notified about visibility changes.
*/
public void setVisibilityListener(VisibilityListener listener) {
this.visibilityListener = listener;
}
/**
* Sets the rewind increment in milliseconds.
*
* @param rewindMs The rewind increment in milliseconds.
*/
public void setRewindIncrementMs(int rewindMs) {
this.rewindMs = rewindMs;
updateNavigation();
}
/**
* Sets the fast forward increment in milliseconds.
*
* @param fastForwardMs The fast forward increment in milliseconds.
*/
public void setFastForwardIncrementMs(int fastForwardMs) {
this.fastForwardMs = fastForwardMs;
updateNavigation();
}
/**
* Returns the playback controls timeout. The playback controls are automatically hidden after
* this duration of time has elapsed without user input.
*
* @return The duration in milliseconds. A non-positive value indicates that the controls will
* remain visible indefinitely.
*/
public int getShowTimeoutMs() {
return showTimeoutMs;
}
/**
* Sets the playback controls timeout. The playback controls are automatically hidden after this
* duration of time has elapsed without user input.
*
* @param showTimeoutMs The duration in milliseconds. A non-positive value will cause the controls
* to remain visible indefinitely.
*/
public void setShowTimeoutMs(int showTimeoutMs) {
this.showTimeoutMs = showTimeoutMs;
}
/**
* Shows the playback controls. If {@link #getShowTimeoutMs()} is positive then the controls will
* be automatically hidden after this duration of time has elapsed without user input.
*/
public void show() {
if (!isVisible()) {
setVisibility(VISIBLE);
......@@ -230,9 +189,8 @@ public class CustomPlayBackController extends FrameLayout {
hideAfterTimeout();
}
/**
* Hides the controller.
*/
//Hides the controller.
public void hide() {
if (isVisible()) {
setVisibility(GONE);
......@@ -245,9 +203,8 @@ public class CustomPlayBackController extends FrameLayout {
}
}
/**
* Returns whether the controller is currently visible.
*/
//Returns whether the controller is currently visible.
public boolean isVisible() {
return getVisibility() == VISIBLE;
}
......@@ -307,9 +264,7 @@ public class CustomPlayBackController extends FrameLayout {
}
private void updateProgress() {
if (!isVisible() || !isAttachedToWindow) {
return;
}
if (!isVisible() || !isAttachedToWindow) return;
long duration = player == null ? 0 : player.getDuration();
long position = player == null ? 0 : player.getCurrentPosition();
time.setText(stringForTime(duration));
......@@ -407,16 +362,12 @@ public class CustomPlayBackController extends FrameLayout {
}
private void rewind() {
if (rewindMs <= 0) {
return;
}
if (rewindMs <= 0) return;
player.seekTo(Math.max(player.getCurrentPosition() - rewindMs, 0));
}
private void fastForward() {
if (fastForwardMs <= 0) {
return;
}
if (fastForwardMs <= 0) return;
player.seekTo(Math.min(player.getCurrentPosition() + fastForwardMs, player.getDuration()));
}
......@@ -450,30 +401,15 @@ public class CustomPlayBackController extends FrameLayout {
}
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
case KeyEvent.KEYCODE_DPAD_RIGHT:
fastForward();
break;
case KeyEvent.KEYCODE_DPAD_RIGHT: fastForward();break;
case KeyEvent.KEYCODE_MEDIA_REWIND:
case KeyEvent.KEYCODE_DPAD_LEFT:
rewind();
break;
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
player.setPlayWhenReady(!player.getPlayWhenReady());
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
player.setPlayWhenReady(true);
break;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
player.setPlayWhenReady(false);
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
next();
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
previous();
break;
default:
return false;
case KeyEvent.KEYCODE_DPAD_LEFT: rewind();break;
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: player.setPlayWhenReady(!player.getPlayWhenReady());break;
case KeyEvent.KEYCODE_MEDIA_PLAY: player.setPlayWhenReady(true);break;
case KeyEvent.KEYCODE_MEDIA_PAUSE :player.setPlayWhenReady(false);break;
case KeyEvent.KEYCODE_MEDIA_NEXT: next();break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS: previous();break;
default:return false;
}
show();
return true;
......@@ -546,6 +482,5 @@ public class CustomPlayBackController extends FrameLayout {
}
hideAfterTimeout();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/md_black_1000"
android:keepScreenOn="true"
tools:targetApi="lollipop">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
android:windowActionBarOverlay="true"
/>
<com.google.android.exoplayer.AspectRatioFrameLayout
android:id="@+id/video_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<SurfaceView android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
<!-- Copyright (C) 2016 The Android Open Source Project
<View android:id="@+id/shutter"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
</com.google.android.exoplayer.AspectRatioFrameLayout>
http://www.apache.org/licenses/LICENSE-2.0
<LinearLayout
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
android:windowActionBarOverlay="true"
/>
<org.horaapps.leafpic.views.videoplayer.CustomExoPlayerView
android:id="@+id/player_view"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#88000000"
android:orientation="vertical">
<LinearLayout android:id="@+id/controls_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/media_player_anchor"
android:layout_gravity="bottom"
/>
android:orientation="horizontal"
android:visibility="gone">
<Button android:id="@+id/retry_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/retry"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
android:windowActionBarOverlay="true"
/>
<org.horaapps.leafpic.views.videoplayer.CustomExoPlayerView
android:id="@+id/player_view"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#88000000"
android:orientation="vertical">
<LinearLayout android:id="@+id/controls_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<Button android:id="@+id/retry_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/retry"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
......@@ -14,74 +14,63 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/exoplayer_controller_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#CC000000"
android:orientation="vertical"
android:layoutDirection="ltr">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="4dp"
android:orientation="horizontal">
<ImageButton android:id="@+id/prev"
android:contentDescription="@string/exo_controls_previous_description"
style="@style/ExoMediaButton.Previous"/>
<ImageButton android:id="@+id/rew"
android:contentDescription="@string/exo_controls_rewind_description"
style="@style/ExoMediaButton.Rewind"/>
<ImageButton android:id="@+id/play"
style="@style/ExoMediaButton"/>
<ImageButton android:id="@+id/ffwd"
android:contentDescription="@string/exo_controls_fastforward_description"
style="@style/ExoMediaButton.FastForward"/>
<ImageButton android:id="@+id/next"
android:contentDescription="@string/exo_controls_previous_description"
style="@style/ExoMediaButton.Next"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:paddingBottom="@dimen/small_spacing"
>
<TextView android:id="@+id/time_current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="14sp"
android:textSize="@dimen/sub_medium_text"
android:textStyle="bold"
android:paddingTop="4dp"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:textColor="#FFBEBEBE"/>
android:paddingTop="@dimen/sub_small_spacing"
android:paddingStart="@dimen/sub_small_spacing"
android:paddingEnd="@dimen/sub_small_spacing"
android:textColor="@color/accent_white"/>
<SeekBar android:id="@+id/mediacontroller_progress"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="32dp"
style="?android:attr/progressBarStyleHorizontal"/>
<TextView android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="14sp"
android:textSize="@dimen/sub_medium_text"
android:textStyle="bold"
android:paddingTop="4dp"
android:paddingEnd="4dp"
android:paddingStart="4dp"
android:textColor="#FFBEBEBE"/>
android:paddingTop="@dimen/sub_small_spacing"
android:paddingEnd="@dimen/sub_small_spacing"
android:paddingStart="@dimen/sub_small_spacing"
android:textColor="@color/accent_white"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#CC000000"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="4dip"
android:orientation="horizontal">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/prev"
android:layout_height="20dp"
android:layout_width="20dp"
app:iiv_icon="gmd-skip-previous"
app:iiv_color="@color/md_white_1000"/>
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/rew"
android:layout_height="20dp"
android:layout_width="20dp"
app:iiv_icon="gmd-fast-rewind"
app:iiv_color="@color/md_white_1000"/>
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/pause"
android:layout_height="20dp"
android:layout_width="20dp"
android:layout_margin="22dp"
app:iiv_icon="gmd-pause"
app:iiv_color="@color/md_white_1000" />
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/ffwd"
android:layout_height="20dp"
android:layout_width="20dp"
app:iiv_icon="gmd-fast-forward"
app:iiv_color="@color/md_white_1000"/>
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/next"
android:layout_height="20dp"