mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:31:51 +01:00
Removed insets logic for bottom nav/added option to use side drawer again
This commit is contained in:
parent
ff71b96703
commit
2ee691bffe
@ -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'
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = titleMarginTop + insets.systemWindowInsetTop
|
||||
}
|
||||
insets
|
||||
}
|
||||
return navView
|
||||
}
|
||||
|
@ -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<ViewGroup.MarginLayoutParams> {
|
||||
fast_scroller?.updateLayoutParams<MarginLayoutParams> {
|
||||
bottomMargin = insets.systemWindowInsetBottom
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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<ViewGroup.MarginLayoutParams> {
|
||||
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<View>(R.id.action_mode_bar)
|
||||
@ -260,6 +266,9 @@ open class MainActivity : BaseActivity() {
|
||||
left = insets.systemWindowInsetLeft,
|
||||
right = insets.systemWindowInsetRight
|
||||
)
|
||||
nav_bar_scrim.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
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)
|
||||
|
@ -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<ChaptersPresenter>(),
|
||||
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<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
@ -110,9 +114,9 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
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() }
|
||||
|
||||
|
@ -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<MangaInfoPresenter>(),
|
||||
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<PreferencesHelper>().useBottonNav().getOrDefault())
|
||||
return@setOnApplyWindowInsetsListener insets
|
||||
if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
fab_favorite?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
@ -203,8 +209,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
manga_cover?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = mangaCoverMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
manga_genres_tags?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = bottomM + insets.systemWindowInsetBottom
|
||||
}
|
||||
@ -213,6 +218,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
bottomMargin = fullMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
setFullCoverToThumb()
|
||||
insets
|
||||
}
|
||||
info_scrollview.doOnApplyWindowInsets { v, insets, padding ->
|
||||
if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
|
@ -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<TrackPresenter>(),
|
||||
TrackAdapter.OnClickListener,
|
||||
@ -42,9 +48,11 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
|
||||
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<PreferencesHelper>().useBottonNav().getOrDefault())
|
||||
track_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsAlwaysListener)
|
||||
swipe_refresh.isEnabled = false
|
||||
swipe_refresh.refreshes().subscribeUntilDestroy { presenter.refresh() }
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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()) }
|
||||
}
|
||||
|
||||
|
@ -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<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = marginB + bottomInset
|
||||
}
|
||||
insets
|
||||
}
|
||||
webview.settings.javaScriptEnabled = true
|
||||
webview.settings.userAgentString = source.headers["User-Agent"]
|
||||
|
@ -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<PreferencesHelper>().theme()
|
||||
val theme = Injekt.get<PreferencesHelper>().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)
|
||||
|
@ -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 @@
|
||||
<TextView
|
||||
android:id="@+id/unread_text"
|
||||
style="@style/TextAppearance.Regular.Caption.Light"
|
||||
android:textColor="@color/md_white_1000"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorAccent"
|
||||
@ -91,6 +93,7 @@
|
||||
<TextView
|
||||
android:id="@+id/download_text"
|
||||
style="@style/TextAppearance.Regular.Caption.Light"
|
||||
android:textColor="@color/md_white_1000"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/md_red_500"
|
||||
|
@ -29,8 +29,9 @@
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingBottom="@dimen/fab_list_padding"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
tools:listitem="@layout/chapters_item">
|
||||
@ -50,9 +51,8 @@
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
style="@style/Theme.Widget.FABFixed"
|
||||
style="@style/Theme.Widget.FAB"
|
||||
app:layout_anchor="@id/recycler"
|
||||
app:layout_anchorGravity="bottom|right|end"
|
||||
app:srcCompat="@drawable/ic_play_arrow_white_24dp"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -7,6 +7,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:id="@+id/nav_bar_scrim"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/colorPrimary" />
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
android:id="@+id/drawer"
|
||||
android:layout_width="match_parent"
|
||||
@ -17,7 +23,7 @@
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:fitsSystemWindows="false"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<eu.kanade.tachiyomi.widget.ElevationAppBarLayout
|
||||
@ -56,21 +62,13 @@
|
||||
android:id="@+id/controller_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/view_offset"
|
||||
app:layout_constraintBottom_toTopOf="@+id/navigationView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/appbar">
|
||||
|
||||
</com.bluelinelabs.conductor.ChangeHandlerFrameLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/view_offset"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/navigationView" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/navigationView"
|
||||
android:layout_width="match_parent"
|
||||
@ -86,6 +84,7 @@
|
||||
app:tabBackground="@color/rippleColor"
|
||||
app:tabRippleColor="@color/rippleColor"
|
||||
app:tabTextColor="?attr/tabBarIconColor" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
|
@ -143,6 +143,9 @@
|
||||
<string name="pref_language">Language</string>
|
||||
<string name="system_default">System default</string>
|
||||
<string name="pref_date_format">Date format</string>
|
||||
<string name="pref_enable_automatic_updates">Check for updates</string>
|
||||
<string name="pref_enable_automatic_updates_summary">Automatically check for new app versions</string>
|
||||
<string name="use_bottom_nav">Use bottom navigation</string>
|
||||
|
||||
<!-- Library section -->
|
||||
<string name="pref_category_library_display">Display</string>
|
||||
@ -360,8 +363,6 @@
|
||||
<!-- About section -->
|
||||
<string name="version">Version</string>
|
||||
<string name="build_time">Build time</string>
|
||||
<string name="pref_enable_automatic_updates">Check for updates</string>
|
||||
<string name="pref_enable_automatic_updates_summary">Automatically check for new app versions</string>
|
||||
<!-- ACRA -->
|
||||
<string name="pref_enable_acra">Send crash reports</string>
|
||||
<string name="pref_acra_summary">Helps fix any bugs. No sensitive data will be sent</string>
|
||||
|
Loading…
Reference in New Issue
Block a user