diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt
index ccde935fb..5d4dc3191 100644
--- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt
+++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt
@@ -70,6 +70,9 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
}
}
+ val isNavLabelsVisible: Boolean
+ get() = prefs.getBoolean(KEY_NAV_LABELS, true)
+
var gridSize: Int
get() = prefs.getInt(KEY_GRID_SIZE, 100)
set(value) = prefs.edit { putInt(KEY_GRID_SIZE, value) }
@@ -577,6 +580,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
const val KEY_DISABLE_NSFW = "no_nsfw"
const val KEY_RELATED_MANGA = "related_manga"
const val KEY_NAV_MAIN = "nav_main"
+ const val KEY_NAV_LABELS = "nav_labels"
const val KEY_32BIT_COLOR = "enhanced_colors"
const val KEY_SOURCES_ORDER = "sources_sort_order"
const val KEY_SOURCES_CATALOG = "sources_catalog"
diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainNavigationDelegate.kt b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainNavigationDelegate.kt
index aae22e41e..59b856322 100644
--- a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainNavigationDelegate.kt
+++ b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainNavigationDelegate.kt
@@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
+import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.navigation.NavigationBarView
import com.google.android.material.transition.MaterialFadeThrough
import kotlinx.coroutines.Dispatchers
@@ -34,6 +35,7 @@ import org.koitharu.kotatsu.local.ui.LocalListFragment
import org.koitharu.kotatsu.suggestions.ui.SuggestionsFragment
import org.koitharu.kotatsu.tracker.ui.feed.FeedFragment
import java.util.LinkedList
+import com.google.android.material.R as materialR
private const val TAG_PRIMARY = "primary"
@@ -194,12 +196,15 @@ class MainNavigationDelegate(
private fun observeSettings(lifecycleOwner: LifecycleOwner) {
settings.observe()
- .filter { x -> x == AppSettings.KEY_TRACKER_ENABLED || x == AppSettings.KEY_SUGGESTIONS }
+ .filter { x ->
+ x == AppSettings.KEY_TRACKER_ENABLED || x == AppSettings.KEY_SUGGESTIONS || x == AppSettings.KEY_NAV_LABELS
+ }
.onStart { emit("") }
- .flowOn(Dispatchers.Default)
+ .flowOn(Dispatchers.IO)
.onEach {
setItemVisibility(R.id.nav_suggestions, settings.isSuggestionsEnabled)
setItemVisibility(R.id.nav_feed, settings.isTrackerEnabled)
+ setNavbarIsLabeled(settings.isNavLabelsVisible)
}.launchIn(lifecycleOwner.lifecycleScope)
}
@@ -211,6 +216,23 @@ class MainNavigationDelegate(
return null
}
+ private fun setNavbarIsLabeled(value: Boolean) {
+ if (navBar is BottomNavigationView) {
+ navBar.minimumHeight = navBar.resources.getDimensionPixelSize(
+ if (value) {
+ materialR.dimen.m3_bottom_nav_min_height
+ } else {
+ R.dimen.nav_bar_height_compact
+ },
+ )
+ }
+ navBar.labelVisibilityMode = if (value) {
+ NavigationBarView.LABEL_VISIBILITY_LABELED
+ } else {
+ NavigationBarView.LABEL_VISIBILITY_UNLABELED
+ }
+ }
+
interface OnFragmentChangedListener {
fun onFragmentChanged(fragment: Fragment, fromUser: Boolean)
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 0b16301f0..9225b0922 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -10,6 +10,7 @@
12dp
36dp
+ 62dp
172dp
8dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 58fe9b057..7bc1a3dd0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -593,4 +593,5 @@
The time estimation value may be inaccurate
Suggestions feature is disabled
Checking for new chapters is disabled
+ Show labels in navigation bar
diff --git a/app/src/main/res/xml/pref_appearance.xml b/app/src/main/res/xml/pref_appearance.xml
index 22be13d77..4e4d2492b 100644
--- a/app/src/main/res/xml/pref_appearance.xml
+++ b/app/src/main/res/xml/pref_appearance.xml
@@ -46,8 +46,7 @@
-
+
+
+