From 7b5edf44d4c09cdfc741d72f2eaba396cc632f78 Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Sat, 3 Oct 2020 01:12:47 +0300 Subject: [PATCH] player title clipping fix --- .../common/exoplayer/selector/track/VideoTrack.java | 2 ++ .../leanback/playerglue/MaxIconNumVideoPlayerGlue.java | 6 +++++- .../tv/ui/settings/AppSettingsFragment.java | 9 +++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/selector/track/VideoTrack.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/selector/track/VideoTrack.java index 3a82ca333..f0acc480b 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/selector/track/VideoTrack.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/selector/track/VideoTrack.java @@ -70,6 +70,8 @@ public class VideoTrack extends MediaTrack { result = 1; } } + } else if (heightLessOrEquals(track2.format.height, format.height)) { + result = 1; } return result; diff --git a/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/playerglue/MaxIconNumVideoPlayerGlue.java b/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/playerglue/MaxIconNumVideoPlayerGlue.java index 1365cb177..56ca7a913 100644 --- a/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/playerglue/MaxIconNumVideoPlayerGlue.java +++ b/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/playerglue/MaxIconNumVideoPlayerGlue.java @@ -7,6 +7,7 @@ import androidx.leanback.media.PlayerAdapter; import androidx.leanback.widget.AbstractDetailsDescriptionPresenter; import androidx.leanback.widget.PlaybackRowPresenter; import androidx.leanback.widget.RowPresenter; +import com.liskovsoft.sharedutils.helpers.Helpers; public class MaxIconNumVideoPlayerGlue extends PlaybackTransportControlGlue { /** @@ -26,7 +27,10 @@ public class MaxIconNumVideoPlayerGlue extends Playback @Override protected void onBindDescription(ViewHolder viewHolder, Object obj) { - PlaybackBaseControlGlue glue = (PlaybackBaseControlGlue) obj; + // Mod: fix clipped title on videos with embedded icons + Helpers.setField(viewHolder, "mTitleMargin", 0); + + PlaybackBaseControlGlue glue = (PlaybackBaseControlGlue) obj; viewHolder.getTitle().setText(glue.getTitle()); viewHolder.getSubtitle().setText(glue.getSubtitle()); } diff --git a/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/settings/AppSettingsFragment.java b/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/settings/AppSettingsFragment.java index 9c92da075..ff56ac342 100644 --- a/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/settings/AppSettingsFragment.java +++ b/smartyoutubetv2/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/settings/AppSettingsFragment.java @@ -118,16 +118,17 @@ public class AppSettingsFragment extends LeanbackSettingsFragment public static class AppPreferenceFragment extends LeanbackPreferenceFragment { private static final String TAG = AppPreferenceFragment.class.getSimpleName(); private List mCategories; - private Context mStyledContext; + private Context mExtractedContext; private AppSettingsFragmentHelper mManager; private String mTitle; @Override public void onCreatePreferences(Bundle bundle, String s) { - mStyledContext = (Context) Helpers.getField(this, "mStyledContext"); - mManager = new AppSettingsFragmentHelper(mStyledContext); + // Note, place in field with different name to avoid field overlapping + mExtractedContext = (Context) Helpers.getField(this, "mStyledContext"); + mManager = new AppSettingsFragmentHelper(mExtractedContext); - PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(mStyledContext); + PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(mExtractedContext); screen.setTitle(mTitle); for (SettingsCategory category : mCategories) {