Add compact navbar option
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<dimen name="list_spacing_large">12dp</dimen>
|
||||
<!-- Navigation -->
|
||||
<dimen name="nav_header_logo_size">36dp</dimen>
|
||||
<dimen name="nav_bar_height_compact">62dp</dimen>
|
||||
|
||||
<dimen name="toolbar_height_expanded">172dp</dimen>
|
||||
<dimen name="grid_spacing">8dp</dimen>
|
||||
|
||||
@@ -593,4 +593,5 @@
|
||||
<string name="reading_time_estimation_summary">The time estimation value may be inaccurate</string>
|
||||
<string name="suggestions_unavailable_text">Suggestions feature is disabled</string>
|
||||
<string name="check_for_new_chapters_disabled">Checking for new chapters is disabled</string>
|
||||
<string name="show_labels_in_navbar">Show labels in navigation bar</string>
|
||||
</resources>
|
||||
|
||||
@@ -46,8 +46,7 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/details">
|
||||
<PreferenceCategory android:title="@string/details">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
@@ -71,6 +70,11 @@
|
||||
android:title="@string/main_screen_sections"
|
||||
app:allowDividerAbove="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="nav_labels"
|
||||
android:title="@string/show_labels_in_navbar" />
|
||||
|
||||
<org.koitharu.kotatsu.settings.utils.ActivityListPreference
|
||||
android:key="app_locale"
|
||||
android:title="@string/language" />
|
||||
|
||||
Reference in New Issue
Block a user