From 88aef190f9082420dc33f0cb571fdf551b9869c5 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 17 Jul 2022 17:35:36 +0200 Subject: [PATCH] add aspect ratio mode --- .../github/libretube/fragments/PlayerFragment.kt | 16 ++++++++++------ .../com/github/libretube/util/ThemeHelper.kt | 10 +++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index ecee9a133..a09a5eb8a 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -445,13 +445,17 @@ class PlayerFragment : Fragment() { } // switching between original aspect ratio (black bars) and zoomed to fill device screen + val aspectRatioModes = arrayOf( + AspectRatioFrameLayout.RESIZE_MODE_FIT, + AspectRatioFrameLayout.RESIZE_MODE_ZOOM, + AspectRatioFrameLayout.RESIZE_MODE_FILL + ) playerBinding.aspectRatioButton.setOnClickListener { - val isZoomed = exoPlayerView.resizeMode != AspectRatioFrameLayout.RESIZE_MODE_FIT - if (isZoomed) { - exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT - } else { - exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM - } + val index = aspectRatioModes.indexOf(exoPlayerView.resizeMode) + val newAspectRatioMode = + if (index + 1 < aspectRatioModes.size) aspectRatioModes[index + 1] + else aspectRatioModes[0] + exoPlayerView.resizeMode = newAspectRatioMode } // lock and unlock the player diff --git a/app/src/main/java/com/github/libretube/util/ThemeHelper.kt b/app/src/main/java/com/github/libretube/util/ThemeHelper.kt index 59e6ff7c3..bf6a8f1ed 100644 --- a/app/src/main/java/com/github/libretube/util/ThemeHelper.kt +++ b/app/src/main/java/com/github/libretube/util/ThemeHelper.kt @@ -72,10 +72,10 @@ object ThemeHelper { // Disable Old Icon(s) for (activityAlias in activityAliases) { val activityClass = "com.github.libretube." + - if (activityAlias == activityAliases[0]) "activities.MainActivity" // default icon/activity - else activityAlias + if (activityAlias == activityAliases[0]) "activities.MainActivity" // default icon/activity + else activityAlias - // remove old icons + // remove old icons context.packageManager.setComponentEnabledSetting( ComponentName(context.packageName, activityClass), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, @@ -85,8 +85,8 @@ object ThemeHelper { // set the class name for the activity alias val newLogoActivityClass = "com.github.libretube." + - if (newLogoActivityAlias == activityAliases[0]) "activities.MainActivity" // default icon/activity - else newLogoActivityAlias + if (newLogoActivityAlias == activityAliases[0]) "activities.MainActivity" // default icon/activity + else newLogoActivityAlias // Enable New Icon context.packageManager.setComponentEnabledSetting( ComponentName(context.packageName, newLogoActivityClass),