-Rollbacks the original main player UI to display nav and status bar on click.

-Changed system UI color to translucent on Lollipop and above.
This commit is contained in:
John Zhen Mo 2018-04-07 16:40:38 -07:00
parent 74199c8624
commit a275d7ff50
5 changed files with 16 additions and 31 deletions

View File

@ -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;
}

View File

@ -3,5 +3,5 @@
<gradient
android:angle="90"
android:endColor="#00000000"
android:startColor="#8c000000"/>
android:startColor="@color/video_overlay_color"/>
</shape>

View File

@ -3,5 +3,5 @@
<gradient
android:angle="-90"
android:endColor="#00000000"
android:startColor="#8c000000"/>
android:startColor="@color/video_overlay_color"/>
</shape>

View File

@ -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">

View File

@ -40,7 +40,7 @@
<color name="playlist_stream_count_background_color">#e6000000</color>
<color name="duration_text_color">#EEFFFFFF</color>
<color name="playlist_stream_count_text_color">#ffffff</color>
<color name="video_overlay_color">#66000000</color>
<color name="video_overlay_color">#64000000</color>
<color name="background_notification_color">#323232</color>
<color name="background_title_color">#ffffff</color>