From 7fa6e846be3479a4b6534f6a0db2580577136c85 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 10 Jul 2022 17:53:17 +0200 Subject: [PATCH 1/2] navbar label visibility option --- .../com/github/libretube/activities/MainActivity.kt | 11 +++++++++++ app/src/main/res/drawable/ic_label.xml | 10 ++++++++++ app/src/main/res/values/array.xml | 12 ++++++++++++ app/src/main/res/values/strings.xml | 4 ++++ app/src/main/res/xml/appearance_settings.xml | 9 +++++++++ 5 files changed, 46 insertions(+) create mode 100644 app/src/main/res/drawable/ic_label.xml diff --git a/app/src/main/java/com/github/libretube/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/activities/MainActivity.kt index d5618ef91..45f032df3 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -38,6 +38,7 @@ import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.ThemeHelper import com.google.android.material.color.DynamicColors import com.google.android.material.elevation.SurfaceColors +import com.google.android.material.navigation.NavigationBarView class MainActivity : AppCompatActivity() { val TAG = "MainActivity" @@ -124,6 +125,16 @@ class MainActivity : AppCompatActivity() { // navigate to the default fragment navController.navigate(startFragmentId) + val labelVisibilityMode = when ( + PreferenceHelper.getString(this, "label_visibility", "always") + ) { + "always" -> NavigationBarView.LABEL_VISIBILITY_LABELED + "selected" -> NavigationBarView.LABEL_VISIBILITY_SELECTED + "never" -> NavigationBarView.LABEL_VISIBILITY_UNLABELED + else -> NavigationBarView.LABEL_VISIBILITY_AUTO + } + binding.bottomNav.labelVisibilityMode = labelVisibilityMode + binding.bottomNav.setOnItemSelectedListener { // clear backstack if it's the start fragment if (startFragmentId == it.itemId) navController.backQueue.clear() diff --git a/app/src/main/res/drawable/ic_label.xml b/app/src/main/res/drawable/ic_label.xml new file mode 100644 index 000000000..fc165149c --- /dev/null +++ b/app/src/main/res/drawable/ic_label.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index f57787c26..6c7eac38c 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -709,4 +709,16 @@ portrait + + @string/always + @string/selected + @string/never + + + + always + selected + never + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6f0f77787..141527a8f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -233,4 +233,8 @@ Playback speed Restart required This change requires an app restart. Do you want to restart the app now? Otherwise the changes will be applied on the next app restart. + Navbar label visibility + Always + Selected + Never \ No newline at end of file diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index f044c2967..a8d3c834b 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -51,6 +51,15 @@ app:title="@string/hideTrendingPage" app:useSimpleSummaryProvider="true" /> + + Date: Sun, 10 Jul 2022 17:55:56 +0200 Subject: [PATCH 2/2] fixes --- .../com/github/libretube/preferences/AppearanceSettings.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt index a69755fc3..2658cb852 100644 --- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt @@ -52,6 +52,13 @@ class AppearanceSettings : PreferenceFragmentCompat() { restartDialog.show(childFragmentManager, "RequireRestartDialog") true } + + val labelVisibilityMode = findPreference("label_visibility") + labelVisibilityMode?.setOnPreferenceChangeListener { _, _ -> + val restartDialog = RequireRestartDialog() + restartDialog.show(childFragmentManager, "RequireRestartDialog") + true + } } // remove material you from accent color option if not available