From 2ee691bffe69faeaf771c9ce76c89816612913ff Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 4 Feb 2020 01:13:37 -0800 Subject: [PATCH] Removed insets logic for bottom nav/added option to use side drawer again --- app/build.gradle | 2 +- .../data/preference/PreferenceKeys.kt | 2 + .../data/preference/PreferencesHelper.kt | 3 +- .../browse/BrowseCatalogueController.kt | 11 +- .../ui/library/LibraryCategoryView.kt | 2 +- .../tachiyomi/ui/library/LibraryController.kt | 3 +- .../kanade/tachiyomi/ui/main/MainActivity.kt | 105 +++++++++++------- .../ui/manga/chapter/ChaptersController.kt | 14 ++- .../ui/manga/info/MangaInfoController.kt | 12 +- .../ui/manga/track/TrackController.kt | 14 ++- .../ui/setting/SettingsGeneralController.kt | 17 +++ .../ui/setting/SettingsMainController.kt | 5 + .../tachiyomi/ui/webview/WebViewActivity.kt | 3 +- .../tachiyomi/util/view/ViewExtensions.kt | 16 ++- .../main/res/layout/catalogue_list_item.xml | 3 + .../main/res/layout/chapters_controller.xml | 8 +- app/src/main/res/layout/main_activity.xml | 19 ++-- app/src/main/res/values/strings.xml | 5 +- 18 files changed, 163 insertions(+), 81 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cf15138ddb..7e4c3978a1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -113,7 +113,7 @@ dependencies { // Android support library implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'com.google.android.material:material:1.2.0-alpha04' + implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.preference:preference:1.1.0' implementation 'androidx.annotation:annotation:1.1.0' diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index ea3d9eb08a..40e1591bc9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -135,6 +135,8 @@ object PreferenceKeys { const val refreshCoversToo = "refresh_covers_too" + const val useBottomNav = "use_bottom_nav" + @Deprecated("Use the preferences of the source") fun sourceUsername(sourceId: Long) = "pref_source_username_$sourceId" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index ab2c49be7a..6bc1c1b2fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -8,7 +8,6 @@ import androidx.preference.PreferenceManager import com.f2prateek.rx.preferences.Preference import com.f2prateek.rx.preferences.RxSharedPreferences import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.source.Source import java.io.File @@ -232,6 +231,8 @@ class PreferencesHelper(val context: Context) { fun extensionUpdatesCount() = rxPrefs.getInteger("ext_updates_count", 0) + fun useBottonNav() = rxPrefs.getBoolean(Keys.useBottomNav, true) + fun lastExtCheck() = rxPrefs.getLong("last_ext_check", 0) fun upgradeFilters() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt index 6f5dd4d44a..c05454540e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt @@ -36,7 +36,6 @@ import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener -import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.marginTop @@ -45,6 +44,7 @@ import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.system.connectivityManager +import eu.kanade.tachiyomi.util.view.marginBottom import eu.kanade.tachiyomi.widget.AutofitRecyclerView import kotlinx.android.synthetic.main.catalogue_controller.* import kotlinx.android.synthetic.main.main_activity.* @@ -191,14 +191,15 @@ open class BrowseCatalogueController(bundle: Bundle) : statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener) val titleView = navView.findViewById(R.id.title_background) as View val titleMarginTop = titleView.marginTop - navView.doOnApplyWindowInsets { v, insets, padding -> - v.updatePaddingRelative( - bottom = padding.bottom + insets.systemWindowInsetBottom, - end = padding.right + insets.systemWindowInsetRight + navView.setOnApplyWindowInsetsListener { v, insets -> + navView.recycler.updatePaddingRelative( + bottom = navView.recycler.marginBottom + insets.systemWindowInsetBottom, + top = navView.recycler.marginTop + insets.systemWindowInsetTop ) titleView.updateLayoutParams { topMargin = titleMarginTop + insets.systemWindowInsetTop } + insets } return navView } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt index 84024e4e22..722ac16c50 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt @@ -104,7 +104,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att recycler.doOnApplyWindowInsets { v, insets, padding -> v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom) - fast_scroller?.updateLayoutParams { + fast_scroller?.updateLayoutParams { bottomMargin = insets.systemWindowInsetBottom } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 78a1a1215b..0dac779a62 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -279,11 +279,12 @@ class LibraryController( View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION val statusScrim = view.findViewById(R.id.status_bar_scrim) as View statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener) - view.doOnApplyWindowInsets { _, insets, _ -> + view.setOnApplyWindowInsetsListener { _, insets -> view.recycler.updatePaddingRelative( bottom = view.recycler.marginBottom + insets.systemWindowInsetBottom, top = view.recycler.marginTop + insets.systemWindowInsetTop ) + insets } return view } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 9bce1d74f1..564161b8fe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.main +import android.animation.ObjectAnimator import android.app.SearchManager import android.content.Intent import android.content.res.Configuration @@ -154,6 +155,7 @@ open class MainActivity : BaseActivity() { openInBrowser(URL_HELP) } } + //navigationView.selectedItemId = id } drawer.closeDrawer(GravityCompat.START) true @@ -183,57 +185,60 @@ open class MainActivity : BaseActivity() { openInBrowser(URL_HELP) } } + nav_view.setCheckedItem(id) } true } val container: ViewGroup = findViewById(R.id.controller_container) val content: ViewGroup = findViewById(R.id.main_content) - container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + val drawerEnabled = !preferences.useBottonNav().getOrDefault() + content.fitsSystemWindows = drawerEnabled + if (drawerEnabled) { + container.systemUiVisibility = + View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + } + content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION nav_view.doOnApplyWindowInsets { v, _, _ -> v.updatePaddingRelative( bottom = v.marginBottom, top = v.marginTop ) } + navigationView.visibility = if (drawerEnabled) View.GONE else View.VISIBLE content.setOnApplyWindowInsetsListener { v, insets -> window.navigationBarColor = - // if the os does not support light nav bar and is portrait, draw a dark translucent - // nav bar - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && - (v.rootWindowInsets.systemWindowInsetLeft > 0 || - v.rootWindowInsets.systemWindowInsetRight > 0)) - // For lollipop, draw opaque nav bar - Color.BLACK - else Color.argb(179, 0, 0, 0) - } - // if the android q+ device has gesture nav, transparent nav bar - else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q - && (v.rootWindowInsets.systemWindowInsetBottom != v.rootWindowInsets - .tappableElementInsets.bottom)) { - getColor(android.R.color.transparent) - } - // if in landscape with 2/3 button mode, fully opaque nav bar - else {/*if (v.rootWindowInsets.systemWindowInsetLeft > 0 - || v.rootWindowInsets.systemWindowInsetRight > 0) {*/ - getResourceColor(android.R.attr.colorPrimary) - } - // if in portrait with 2/3 button mode, translucent nav bar - /* else { - ColorUtils.setAlphaComponent( - getResourceColor(android.R.attr.colorPrimary), 179) - }*/ + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && + (v.rootWindowInsets.systemWindowInsetLeft > 0 || + v.rootWindowInsets.systemWindowInsetRight > 0)) + // For lollipop, draw opaque nav bar + Color.BLACK + else Color.argb(179, 0, 0, 0) + } + // if the android q+ device has gesture nav, transparent nav bar + else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q + && (v.rootWindowInsets.systemWindowInsetBottom != v.rootWindowInsets + .tappableElementInsets.bottom)) { + getColor(android.R.color.transparent) + } + // if in landscape with 2/3 button mode, fully opaque nav bar + else if (v.rootWindowInsets.systemWindowInsetLeft > 0 + || v.rootWindowInsets.systemWindowInsetRight > 0) { + getResourceColor( + if (drawerEnabled) android.R.attr.colorBackground + else android.R.attr.colorPrimary) + } + // if in portrait with 2/3 button mode, translucent nav bar + else { + ColorUtils.setAlphaComponent( + getResourceColor(if (drawerEnabled) android.R.attr.colorBackground + else android.R.attr.colorPrimary), 179) + } v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop, insets.systemWindowInsetRight, 0) - view_offset.updateLayoutParams { - height = insets.systemWindowInsetBottom - } insets } val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK @@ -247,6 +252,7 @@ open class MainActivity : BaseActivity() { content.systemUiVisibility = content.systemUiVisibility.or(View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) + val navBarScrim: View = findViewById(R.id.nav_bar_scrim) val drawerContainer: FrameLayout = findViewById(R.id.drawer_container) drawerContainer.setOnApplyWindowInsetsListener { v, insets -> val contextView = window?.decorView?.findViewById(R.id.action_mode_bar) @@ -260,6 +266,9 @@ open class MainActivity : BaseActivity() { left = insets.systemWindowInsetLeft, right = insets.systemWindowInsetRight ) + nav_bar_scrim.updateLayoutParams { + height = if (!drawerEnabled) insets.systemWindowInsetBottom else 0 + } insets.replaceSystemWindowInsets( 0, insets.systemWindowInsetTop, 0, insets.systemWindowInsetBottom @@ -337,7 +346,10 @@ open class MainActivity : BaseActivity() { if (updates > 0) { extUpdateText.text = updates.toString() extUpdateText.visible() - navigationView.getOrCreateBadge(R.id.nav_drawer_settings).number = updates + val badge = navigationView.getOrCreateBadge(R.id.nav_drawer_settings) + badge.number = updates + badge.backgroundColor = getResourceColor(R.attr.colorAccent) + badge.badgeTextColor = Color.WHITE } else { extUpdateText.text = null @@ -446,9 +458,11 @@ open class MainActivity : BaseActivity() { val backstackSize = router.backstackSize if (drawer.isDrawerOpen(GravityCompat.START) || drawer.isDrawerOpen(GravityCompat.END)) { drawer.closeDrawers() - //} else if (backstackSize == 1 && router.getControllerWithTag("$startScreenId") == null) { - // setSelectedDrawerItem(startScreenId) - } else if (!router.handleBack()) { + } else if (!preferences.useBottonNav().getOrDefault() + && backstackSize == 1 && router.getControllerWithTag + ("$startScreenId") == null) { + setSelectedDrawerItem(startScreenId) + } else if (!router.handleBack()) { unlocked = false super.onBackPressed() } @@ -538,18 +552,23 @@ open class MainActivity : BaseActivity() { if (from is DialogController || to is DialogController) { return } + val drawerEnabled = !preferences.useBottonNav().getOrDefault() val showHamburger = router.backstackSize == 1 drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED) if (showHamburger) { - toolbar.navigationIcon = null - //drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED) + if (drawerEnabled) + drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED) + else toolbar.navigationIcon = null } else { - toolbar.navigationIcon = drawerArrow - // drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED) + if (drawerEnabled) drawer.setDrawerLockMode( + androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED + ) + else toolbar.navigationIcon = drawerArrow } - drawerArrow?.progress = 1f - //ObjectAnimator.ofFloat(drawerArrow, "alpha", if (showHamburger) 0f else 1f).start() + if (drawerEnabled) + ObjectAnimator.ofFloat(drawerArrow, "progress", if (showHamburger) 0f else 1f).start() + else drawerArrow?.progress = 1f if (from is TabbedController) { from.cleanupTabs(tabs) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt index c9ab74e405..8155ec7a4e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt @@ -25,8 +25,10 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download +import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.main.MainActivity +import eu.kanade.tachiyomi.ui.main.SearchActivity import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.util.system.toast @@ -101,8 +103,10 @@ class ChaptersController() : NucleusController(), adapter?.fastScroller = fast_scroller val fabBaseMarginBottom = fab?.marginBottom ?: 0 - recycler.doOnApplyWindowInsets { v, insets, padding -> - + recycler.setOnApplyWindowInsetsListener { v, insets -> + if (activity !is SearchActivity && + presenter.preferences.useBottonNav().getOrDefault()) + return@setOnApplyWindowInsetsListener insets fab?.updateLayoutParams { bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom } @@ -110,9 +114,9 @@ class ChaptersController() : NucleusController(), bottomMargin = insets.systemWindowInsetBottom } // offset the recycler by the fab's inset + some inset on top - val scale: Float = v.context.resources.displayMetrics.density - val pixels = (88 * scale + 0.5f).toInt() - v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom + pixels) + v.updatePaddingRelative(bottom = insets.systemWindowInsetBottom + + v.context.resources.getDimensionPixelSize(R.dimen.fab_list_padding)) + insets } swipe_refresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index 9c77615287..7d283753f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -60,6 +60,7 @@ import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.main.MainActivity +import eu.kanade.tachiyomi.ui.main.SearchActivity import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets @@ -74,6 +75,8 @@ import jp.wasabeef.glide.transformations.MaskTransformation import kotlinx.android.synthetic.main.manga_info_controller.* import kotlinx.android.synthetic.main.manga_info_controller.manga_cover import kotlinx.android.synthetic.main.manga_info_controller.manga_genres_tags +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy import java.io.File import java.text.DateFormat @@ -195,7 +198,10 @@ class MangaInfoController : NucleusController(), val fabBaseMarginBottom = fab_favorite.marginBottom val mangaCoverMarginBottom = manga_cover.marginBottom val fullMarginBottom = manga_cover_full?.marginBottom ?: 0 - container?.doOnApplyWindowInsets { v, insets, padding -> + container?.setOnApplyWindowInsetsListener { _, insets -> + if (activity !is SearchActivity && + Injekt.get().useBottonNav().getOrDefault()) + return@setOnApplyWindowInsetsListener insets if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) { fab_favorite?.updateLayoutParams { bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom @@ -203,8 +209,7 @@ class MangaInfoController : NucleusController(), manga_cover?.updateLayoutParams { bottomMargin = mangaCoverMarginBottom + insets.systemWindowInsetBottom } - } - else { + } else { manga_genres_tags?.updateLayoutParams { bottomMargin = bottomM + insets.systemWindowInsetBottom } @@ -213,6 +218,7 @@ class MangaInfoController : NucleusController(), bottomMargin = fullMarginBottom + insets.systemWindowInsetBottom } setFullCoverToThumb() + insets } info_scrollview.doOnApplyWindowInsets { v, insets, padding -> if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackController.kt index 169ebca3a5..126a042ec2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackController.kt @@ -5,15 +5,21 @@ import android.net.Uri import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager import com.jakewharton.rxbinding.support.v4.widget.refreshes import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.ui.base.controller.NucleusController +import eu.kanade.tachiyomi.ui.main.SearchActivity import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.util.system.toast -import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener +import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsAlwaysListener import kotlinx.android.synthetic.main.track_controller.* import timber.log.Timber +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get class TrackController : NucleusController(), TrackAdapter.OnClickListener, @@ -42,9 +48,11 @@ class TrackController : NucleusController(), adapter = TrackAdapter(this) with(view) { - track_recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context) + track_recycler.layoutManager = LinearLayoutManager(context) track_recycler.adapter = adapter - track_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener) + if (activity is SearchActivity || + !Injekt.get().useBottonNav().getOrDefault()) + track_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsAlwaysListener) swipe_refresh.isEnabled = false swipe_refresh.refreshes().subscribeUntilDestroy { presenter.refresh() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 06e6b38e2b..a50f0b2605 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -8,6 +8,8 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.updater.UpdaterJob import eu.kanade.tachiyomi.widget.preference.IntListMatPreference import eu.kanade.tachiyomi.util.system.LocaleHelper +import eu.kanade.tachiyomi.ui.main.MainActivity +import kotlinx.android.synthetic.main.main_activity.* import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsGeneralController : SettingsController() { @@ -56,6 +58,20 @@ class SettingsGeneralController : SettingsController() { true } } + + switchPreference { + key = Keys.useBottomNav + titleRes = R.string.use_bottom_nav + defaultValue = true + onChange { + activity?.recreate() + if (it as Boolean) { + (activity as MainActivity).navigationView.selectedItemId = R.id.nav_drawer_settings + } + true + } + } + listPreference(activity) { key= Keys.dateFormat titleRes = R.string.pref_date_format @@ -70,6 +86,7 @@ class SettingsGeneralController : SettingsController() { defaultValue = "" summary = "%s" } + intListPreference(activity) { key = Keys.startScreen titleRes = R.string.pref_start_screen diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt index dc2a0c019d..e534d38efb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt @@ -6,10 +6,13 @@ import android.view.MenuItem import androidx.preference.PreferenceScreen import com.bluelinelabs.conductor.Controller import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.extension.ExtensionController import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.openInBrowser +import uy.kohesive.injekt.injectLazy class SettingsMainController : SettingsController() { @@ -22,10 +25,12 @@ class SettingsMainController : SettingsController() { val tintColor = context.getResourceColor(R.attr.colorAccent) + val prefs:PreferencesHelper by injectLazy() extensionPreference { iconRes = R.drawable.ic_extension_black_24dp iconTint = tintColor titleRes = R.string.label_extensions + isVisible = prefs.useBottonNav().getOrDefault() onClick { navigateTo(ExtensionController()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt index 2167c9d77b..5119a76106 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt @@ -170,13 +170,14 @@ class WebViewActivity : BaseActivity() { } } val marginB = webview.marginBottom - webview.doOnApplyWindowInsets { v, insets, _ -> + webview.setOnApplyWindowInsetsListener { v, insets -> val bottomInset = if (Build.VERSION.SDK_INT >= 29) insets.tappableElementInsets.bottom else insets.systemWindowInsetBottom v.updateLayoutParams { bottomMargin = marginB + bottomInset } + insets } webview.settings.javaScriptEnabled = true webview.settings.userAgentString = source.headers["User-Agent"] diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 9a3c8bd4fa..b21cd9d161 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -22,8 +22,10 @@ import com.google.android.material.snackbar.Snackbar import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.system.getResourceColor +import eu.kanade.tachiyomi.data.preference.getOrDefault import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import uy.kohesive.injekt.injectLazy import kotlin.math.min /** @@ -44,7 +46,7 @@ fun View.getCoordinates() = Point((left + right) / 2, (top + bottom) / 2) fun View.snack(message: String, length: Int = Snackbar.LENGTH_SHORT, f: (Snackbar.() -> Unit)? = null): Snackbar { val snack = Snackbar.make(this, message, length) - val theme =Injekt.get().theme() + val theme = Injekt.get().theme() if (theme == 3 || theme == 6) { val textView: TextView = snack.view.findViewById(com.google.android.material.R.id.snackbar_text) @@ -146,6 +148,16 @@ inline val View.marginLeft: Int get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.leftMargin ?: 0 object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener { + override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets { + val prefs:PreferencesHelper by injectLazy() + if (prefs.useBottonNav().getOrDefault()) return insets + v.setPadding(0,0,0,insets.systemWindowInsetBottom) + //v.updatePaddingRelative(bottom = v.paddingBottom + insets.systemWindowInsetBottom) + return insets + } +} + +object RecyclerWindowInsetsAlwaysListener : View.OnApplyWindowInsetsListener { override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets { v.setPadding(0,0,0,insets.systemWindowInsetBottom) //v.updatePaddingRelative(bottom = v.paddingBottom + insets.systemWindowInsetBottom) @@ -155,6 +167,8 @@ object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener { fun View.doOnApplyWindowInsets(f: (View, WindowInsets, ViewPaddingState) -> Unit) { // Create a snapshot of the view's padding state + val prefs:PreferencesHelper by injectLazy() + if (prefs.useBottonNav().getOrDefault()) return val paddingState = createStateForView(this) setOnApplyWindowInsetsListener { v, insets -> f(v, insets, paddingState) diff --git a/app/src/main/res/layout/catalogue_list_item.xml b/app/src/main/res/layout/catalogue_list_item.xml index 23d01e55b7..9ebe487993 100644 --- a/app/src/main/res/layout/catalogue_list_item.xml +++ b/app/src/main/res/layout/catalogue_list_item.xml @@ -56,6 +56,7 @@ android:maxLines="1" android:text="@string/local_source_badge" android:visibility="gone" + android:textColor="@color/md_white_1000" tools:visibility="visible" android:layout_marginEnd="8dp" app:layout_constraintEnd_toStartOf="@+id/unread_text" @@ -67,6 +68,7 @@ @@ -50,9 +51,8 @@ diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 5e4d91bcba..688487d431 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -7,6 +7,12 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + - - + Language System default Date format + Check for updates + Automatically check for new app versions + Use bottom navigation Display @@ -360,8 +363,6 @@ Version Build time - Check for updates - Automatically check for new app versions Send crash reports Helps fix any bugs. No sensitive data will be sent