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 48503eda5..2554ef720 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -30,8 +30,10 @@ import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.Settings; +import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; @@ -248,22 +250,6 @@ public final class MainVideoPlayer extends AppCompatActivity // View //////////////////////////////////////////////////////////////////////////*/ - /** - * Prior to Kitkat, hiding system ui causes the player view to be overlaid and require two - * clicks to get rid of that invisible overlay. By showing the system UI on actions/events, - * that overlay is removed and the player view is put to the foreground. - * - * Post Kitkat, navbar and status bar can be pulled out by swiping the edge of - * screen, therefore, we can do nothing or hide the UI on actions/events. - * */ - private void changeSystemUi() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - showSystemUi(); - } else { - hideSystemUi(); - } - } - private void showSystemUi() { if (DEBUG) Log.d(TAG, "showSystemUi() called"); if (playerImpl != null && playerImpl.queueVisible) return; @@ -276,6 +262,14 @@ public final class MainVideoPlayer extends AppCompatActivity } else { visibility = View.STATUS_BAR_VISIBLE; } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + @ColorInt final int systenUiColor = + ActivityCompat.getColor(getApplicationContext(), R.color.video_overlay_color); + getWindow().setStatusBarColor(systenUiColor); + getWindow().setNavigationBarColor(systenUiColor); + } + getWindow().getDecorView().setSystemUiVisibility(visibility); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } @@ -416,15 +410,6 @@ public final class MainVideoPlayer extends AppCompatActivity this.itemsListCloseButton = findViewById(R.id.playQueueClose); this.itemsList = findViewById(R.id.playQueue); - this.windowRootLayout = rootView.findViewById(R.id.playbackWindowRoot); - // Prior to Kitkat, there is no way of setting translucent navbar programmatically. - // Thus, fit system windows is opted instead. - // See https://stackoverflow.com/questions/29069070/completely-transparent-status-bar-and-navigation-bar-on-lollipop - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - windowRootLayout.setFitsSystemWindows(false); - windowRootLayout.invalidate(); - } - titleTextView.setSelected(true); channelTextView.setSelected(true); @@ -732,7 +717,7 @@ public final class MainVideoPlayer extends AppCompatActivity animatePlayButtons(true, 200); }); - changeSystemUi(); + showSystemUi(); getRootView().setKeepScreenOn(false); } @@ -905,7 +890,7 @@ public final class MainVideoPlayer extends AppCompatActivity playerImpl.hideControls(150, 0); } else { playerImpl.showControlsThenHide(); - changeSystemUi(); + showSystemUi(); } return true; } diff --git a/app/src/main/res/drawable/player_controls_bg.xml b/app/src/main/res/drawable/player_controls_bg.xml index 7e1981347..f250e3558 100644 --- a/app/src/main/res/drawable/player_controls_bg.xml +++ b/app/src/main/res/drawable/player_controls_bg.xml @@ -3,5 +3,5 @@ + android:startColor="@color/video_overlay_color"/> \ No newline at end of file diff --git a/app/src/main/res/drawable/player_top_controls_bg.xml b/app/src/main/res/drawable/player_top_controls_bg.xml index f1e8b98fc..ba62ce863 100644 --- a/app/src/main/res/drawable/player_top_controls_bg.xml +++ b/app/src/main/res/drawable/player_top_controls_bg.xml @@ -3,5 +3,5 @@ + android:startColor="@color/video_overlay_color"/> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index d97f1fe72..616f93536 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -129,7 +129,7 @@ android:id="@+id/playbackControlRoot" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#64000000" + android:background="@color/video_overlay_color" android:visibility="gone" tools:visibility="visible"> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 6b43999a0..df2c73ec8 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -40,7 +40,7 @@ #e6000000 #EEFFFFFF #ffffff - #66000000 + #64000000 #323232 #ffffff