From e47761750a0020a771a8381c0b1dda627e538f2a Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Sun, 14 May 2017 00:32:28 -0300 Subject: [PATCH] Fix 'keep screen on' --- .../java/org/schabi/newpipe/player/MainVideoPlayer.java | 8 +++++++- app/src/main/res/layout/activity_main_player.xml | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 45221325b..7af2c20a1 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -184,6 +184,7 @@ public class MainVideoPlayer extends Activity { repeatButton.setAlpha(77); } + getRootView().setKeepScreenOn(true); } @Override @@ -308,12 +309,14 @@ public class MainVideoPlayer extends Activity { super.onLoading(); playPauseButton.setImageResource(R.drawable.ic_pause_white); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 100); + getRootView().setKeepScreenOn(true); } @Override public void onBuffering() { super.onBuffering(); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 100); + getRootView().setKeepScreenOn(true); } @Override @@ -326,8 +329,8 @@ public class MainVideoPlayer extends Activity { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, true, 200); } }); - showSystemUi(); + getRootView().setKeepScreenOn(true); } @Override @@ -342,12 +345,14 @@ public class MainVideoPlayer extends Activity { }); showSystemUi(); + getRootView().setKeepScreenOn(false); } @Override public void onPausedSeek() { super.onPausedSeek(); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 100); + getRootView().setKeepScreenOn(true); } @@ -365,6 +370,7 @@ public class MainVideoPlayer extends Activity { } }); } + getRootView().setKeepScreenOn(false); super.onCompleted(); } diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index cd76d2f07..07363f7e0 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -5,8 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" - android:gravity="center" - android:keepScreenOn="true"> + android:gravity="center">