7575public final class MainPlayerUi extends VideoPlayerUi implements View .OnLayoutChangeListener {
7676 private static final String TAG = MainPlayerUi .class .getSimpleName ();
7777
78+ // see the Javadoc of calculateMaxEndScreenThumbnailHeight for information
79+ private static final int DETAIL_ROOT_MINIMUM_HEIGHT = 85 ; // dp
80+ private static final int DETAIL_TITLE_TEXT_SIZE_TV = 16 ; // sp
81+ private static final int DETAIL_TITLE_TEXT_SIZE_TABLET = 15 ; // sp
82+
7883 private boolean isFullscreen = false ;
7984 private boolean isVerticalVideo = false ;
8085 private boolean fragmentIsVisible = false ;
@@ -262,13 +267,8 @@ protected void setupElementsVisibility() {
262267 binding .topControls .setClickable (true );
263268 binding .topControls .setFocusable (true );
264269
265- if (isFullscreen ) {
266- binding .titleTextView .setVisibility (View .VISIBLE );
267- binding .channelTextView .setVisibility (View .VISIBLE );
268- } else {
269- binding .titleTextView .setVisibility (View .GONE );
270- binding .channelTextView .setVisibility (View .GONE );
271- }
270+ binding .titleTextView .setVisibility (isFullscreen ? View .VISIBLE : View .GONE );
271+ binding .channelTextView .setVisibility (isFullscreen ? View .VISIBLE : View .GONE );
272272 }
273273
274274 @ Override
@@ -450,13 +450,12 @@ public void hideSystemUIIfNeeded() {
450450 * The calculating follows these rules:
451451 * <ul>
452452 * <li>
453- * Show at least stream title and content creator on TVs and tablets
454- * when in landscape (always the case for TVs) and not in fullscreen mode.
455- * This requires to have at least <code>85dp</code> free space for {@link R.id.detail_root}
456- * and additional space for the stream title text size
457- * ({@link R.id.detail_title_root_layout}).
458- * The text size is <code>15sp</code> on tablets and <code>16sp</code> on TVs,
459- * see {@link R.id.titleTextView}.
453+ * Show at least stream title and content creator on TVs and tablets when in landscape
454+ * (always the case for TVs) and not in fullscreen mode. This requires to have at least
455+ * {@link #DETAIL_ROOT_MINIMUM_HEIGHT} free space for {@link R.id.detail_root} and
456+ * additional space for the stream title text size ({@link R.id.detail_title_root_layout}).
457+ * The text size is {@link #DETAIL_TITLE_TEXT_SIZE_TABLET} on tablets and
458+ * {@link #DETAIL_TITLE_TEXT_SIZE_TV} on TVs, see {@link R.id.titleTextView}.
460459 * </li>
461460 * <li>
462461 * Otherwise, the max thumbnail height is the screen height.
@@ -472,12 +471,12 @@ protected float calculateMaxEndScreenThumbnailHeight(@NonNull final Bitmap bitma
472471 final int screenHeight = context .getResources ().getDisplayMetrics ().heightPixels ;
473472
474473 if (DeviceUtils .isTv (context ) && !isFullscreen ()) {
475- final int videoInfoHeight =
476- DeviceUtils . dpToPx ( 85 , context ) + DeviceUtils .spToPx (16 , context );
474+ final int videoInfoHeight = DeviceUtils . dpToPx ( DETAIL_ROOT_MINIMUM_HEIGHT , context )
475+ + DeviceUtils .spToPx (DETAIL_TITLE_TEXT_SIZE_TV , context );
477476 return Math .min (bitmap .getHeight (), screenHeight - videoInfoHeight );
478477 } else if (DeviceUtils .isTablet (context ) && isLandscape () && !isFullscreen ()) {
479- final int videoInfoHeight =
480- DeviceUtils . dpToPx ( 85 , context ) + DeviceUtils .spToPx (15 , context );
478+ final int videoInfoHeight = DeviceUtils . dpToPx ( DETAIL_ROOT_MINIMUM_HEIGHT , context )
479+ + DeviceUtils .spToPx (DETAIL_TITLE_TEXT_SIZE_TABLET , context );
481480 return Math .min (bitmap .getHeight (), screenHeight - videoInfoHeight );
482481 } else { // fullscreen player: max height is the device height
483482 return Math .min (bitmap .getHeight (), screenHeight );
@@ -933,15 +932,9 @@ public void toggleFullscreen() {
933932 }
934933 fragmentListener .onFullscreenStateChanged (isFullscreen );
935934
936- if (isFullscreen ) {
937- binding .titleTextView .setVisibility (View .VISIBLE );
938- binding .channelTextView .setVisibility (View .VISIBLE );
939- binding .playerCloseButton .setVisibility (View .GONE );
940- } else {
941- binding .titleTextView .setVisibility (View .GONE );
942- binding .channelTextView .setVisibility (View .GONE );
943- binding .playerCloseButton .setVisibility (View .VISIBLE );
944- }
935+ binding .titleTextView .setVisibility (isFullscreen ? View .VISIBLE : View .GONE );
936+ binding .channelTextView .setVisibility (isFullscreen ? View .VISIBLE : View .GONE );
937+ binding .playerCloseButton .setVisibility (isFullscreen ? View .GONE : View .VISIBLE );
945938 setupScreenRotationButton ();
946939 }
947940
0 commit comments