mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 05:15:10 +01:00
Set bottom nav down to 4 tabs
Recents now shares recently read and updates
This commit is contained in:
parent
48d12bbecd
commit
b3842cd9ea
@ -233,6 +233,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun useBottonNav() = rxPrefs.getBoolean(Keys.useBottomNav, true)
|
||||
|
||||
fun showRecentUpdates() = rxPrefs.getBoolean("show_recents", false)
|
||||
|
||||
fun lastExtCheck() = rxPrefs.getLong("last_ext_check", 0)
|
||||
|
||||
fun upgradeFilters() {
|
||||
|
@ -440,7 +440,7 @@ class LibraryController(
|
||||
val searchView = searchItem.actionView as SearchView
|
||||
searchView.queryHint = resources?.getString(R.string.search_hint)
|
||||
|
||||
menu.findItem(R.id.action_downloads).isVisible = preferences.useBottonNav().getOrDefault()
|
||||
menu.findItem(R.id.action_downloads).isVisible = MainActivity.bottomNav
|
||||
searchItem.collapseActionView()
|
||||
if (!query.isEmpty()) {
|
||||
searchItem.expandActionView()
|
||||
|
@ -19,6 +19,7 @@ import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
@ -168,33 +169,41 @@ open class MainActivity : BaseActivity() {
|
||||
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
||||
when (id) {
|
||||
R.id.nav_drawer_library -> setRoot(LibraryController(), id)
|
||||
R.id.nav_drawer_recent_updates -> setRoot(RecentChaptersController(), id)
|
||||
R.id.nav_drawer_recently_read -> setRoot(RecentlyReadController(), id)
|
||||
R.id.nav_drawer_recents -> {
|
||||
if (preferences.showRecentUpdates().getOrDefault())
|
||||
setRoot(RecentChaptersController(), id)
|
||||
else
|
||||
setRoot(RecentlyReadController(), id)
|
||||
}
|
||||
R.id.nav_drawer_catalogues -> setRoot(CatalogueController(), id)
|
||||
R.id.nav_drawer_extensions -> setRoot(ExtensionController(), id)
|
||||
R.id.nav_drawer_downloads -> {
|
||||
if (router.backstack.isEmpty()) {
|
||||
setRoot(LibraryController(), R.id.nav_drawer_library)
|
||||
}
|
||||
router.pushController(DownloadController().withFadeTransaction())
|
||||
}
|
||||
R.id.nav_drawer_settings -> {
|
||||
setRoot(SettingsMainController(), id)
|
||||
}
|
||||
R.id.nav_drawer_help -> {
|
||||
openInBrowser(URL_HELP)
|
||||
}
|
||||
R.id.nav_drawer_settings -> setRoot(SettingsMainController(), id)
|
||||
}
|
||||
nav_view.setCheckedItem(id)
|
||||
}
|
||||
else if (currentRoot?.tag()?.toIntOrNull() == id) {
|
||||
when (id) {
|
||||
R.id.nav_drawer_recents -> {
|
||||
if (router.backstack.size > 1) router.popToRoot()
|
||||
else {
|
||||
val showRecents = preferences.showRecentUpdates().getOrDefault()
|
||||
if (!showRecents) setRoot(RecentChaptersController(), id)
|
||||
else setRoot(RecentlyReadController(), id)
|
||||
preferences.showRecentUpdates().set(!showRecents)
|
||||
updateRecentsIcon()
|
||||
}
|
||||
}
|
||||
R.id.nav_drawer_library, R.id.nav_drawer_catalogues,
|
||||
R.id.nav_drawer_settings -> router.popToRoot()
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
val container: ViewGroup = findViewById(R.id.controller_container)
|
||||
|
||||
val content: ViewGroup = findViewById(R.id.main_content)
|
||||
val drawerEnabled = !preferences.useBottonNav().getOrDefault()
|
||||
content.fitsSystemWindows = drawerEnabled
|
||||
if (drawerEnabled) {
|
||||
bottomNav = preferences.useBottonNav().getOrDefault()
|
||||
content.fitsSystemWindows = !bottomNav
|
||||
if (!bottomNav) {
|
||||
container.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
}
|
||||
@ -207,7 +216,8 @@ open class MainActivity : BaseActivity() {
|
||||
top = v.marginTop
|
||||
)
|
||||
}
|
||||
navigationView.visibility = if (drawerEnabled) View.GONE else View.VISIBLE
|
||||
navigationView.visibility = if (bottomNav) View.VISIBLE else View.GONE
|
||||
updateRecentsIcon()
|
||||
content.setOnApplyWindowInsetsListener { v, insets ->
|
||||
window.navigationBarColor =
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
@ -228,14 +238,17 @@ open class MainActivity : BaseActivity() {
|
||||
else if (v.rootWindowInsets.systemWindowInsetLeft > 0
|
||||
|| v.rootWindowInsets.systemWindowInsetRight > 0) {
|
||||
getResourceColor(
|
||||
if (drawerEnabled) android.R.attr.colorBackground
|
||||
else android.R.attr.colorPrimary)
|
||||
if (bottomNav) android.R.attr.colorPrimary
|
||||
else android.R.attr.colorBackground
|
||||
)
|
||||
}
|
||||
// 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)
|
||||
getResourceColor(
|
||||
if (bottomNav) android.R.attr.colorPrimary
|
||||
else android.R.attr.colorBackground
|
||||
), 179)
|
||||
}
|
||||
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight, 0)
|
||||
@ -252,7 +265,6 @@ 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)
|
||||
@ -267,7 +279,7 @@ open class MainActivity : BaseActivity() {
|
||||
right = insets.systemWindowInsetRight
|
||||
)
|
||||
nav_bar_scrim.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
height = if (!drawerEnabled) insets.systemWindowInsetBottom else 0
|
||||
height = if (bottomNav) insets.systemWindowInsetBottom else 0
|
||||
}
|
||||
insets.replaceSystemWindowInsets(
|
||||
0, insets.systemWindowInsetTop,
|
||||
@ -319,6 +331,16 @@ open class MainActivity : BaseActivity() {
|
||||
setExtensionsBadge()
|
||||
}
|
||||
|
||||
fun updateRecentsIcon() {
|
||||
if (bottomNav) navigationView.menu.findItem(R.id.nav_drawer_recents).icon =
|
||||
VectorDrawableCompat.create(
|
||||
resources!!,
|
||||
if (preferences.showRecentUpdates().getOrDefault()) R.drawable.ic_update_black_24dp
|
||||
else R.drawable.ic_history_black_24dp,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
override fun startSupportActionMode(callback: androidx.appcompat.view.ActionMode.Callback): androidx.appcompat.view.ActionMode? {
|
||||
window?.statusBarColor = getResourceColor(R.attr.colorPrimary)
|
||||
return super.startSupportActionMode(callback)
|
||||
@ -360,6 +382,7 @@ open class MainActivity : BaseActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
bottomNav = preferences.useBottonNav().getOrDefault()
|
||||
getExtensionUpdates()
|
||||
val useBiometrics = preferences.useBiometrics().getOrDefault()
|
||||
if (useBiometrics && BiometricManager.from(this)
|
||||
@ -458,8 +481,7 @@ open class MainActivity : BaseActivity() {
|
||||
val backstackSize = router.backstackSize
|
||||
if (drawer.isDrawerOpen(GravityCompat.START) || drawer.isDrawerOpen(GravityCompat.END)) {
|
||||
drawer.closeDrawers()
|
||||
} else if (!preferences.useBottonNav().getOrDefault()
|
||||
&& backstackSize == 1 && router.getControllerWithTag
|
||||
} else if (!bottomNav && backstackSize == 1 && router.getControllerWithTag
|
||||
("$startScreenId") == null) {
|
||||
setSelectedDrawerItem(startScreenId)
|
||||
} else if (!router.handleBack()) {
|
||||
@ -468,22 +490,36 @@ open class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
fun setSelectedDrawerItem(itemId: Int) {
|
||||
private fun setSelectedDrawerItem(itemId: Int) {
|
||||
if (!isFinishing) {
|
||||
nav_view.setCheckedItem(itemId)
|
||||
navigationView.selectedItemId = itemId
|
||||
if (bottomNav) navigationView.selectedItemId = itemId
|
||||
else nav_view.setCheckedItem(itemId)
|
||||
jumpToController(itemId)
|
||||
}
|
||||
}
|
||||
|
||||
fun jumpToController(id: Int) {
|
||||
private fun jumpToController(id: Int) {
|
||||
|
||||
val currentRoot = router.backstack.firstOrNull()
|
||||
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
||||
when (id) {
|
||||
R.id.nav_drawer_library -> setRoot(LibraryController(), id)
|
||||
R.id.nav_drawer_recent_updates -> setRoot(RecentChaptersController(), id)
|
||||
R.id.nav_drawer_recently_read -> setRoot(RecentlyReadController(), id)
|
||||
R.id.nav_drawer_recent_updates -> {
|
||||
if (bottomNav)
|
||||
navigationView.selectedItemId = R.id.nav_drawer_recents
|
||||
setRoot(RecentChaptersController(), if (bottomNav) R.id.nav_drawer_recents
|
||||
else id)
|
||||
preferences.showRecentUpdates().set(true)
|
||||
updateRecentsIcon()
|
||||
}
|
||||
R.id.nav_drawer_recently_read -> {
|
||||
if (bottomNav)
|
||||
navigationView.selectedItemId = R.id.nav_drawer_recents
|
||||
setRoot(RecentlyReadController(), if (bottomNav) R.id.nav_drawer_recents
|
||||
else id)
|
||||
preferences.showRecentUpdates().set(false)
|
||||
updateRecentsIcon()
|
||||
}
|
||||
R.id.nav_drawer_catalogues -> setRoot(CatalogueController(), id)
|
||||
R.id.nav_drawer_extensions -> {
|
||||
if (router.backstack.isEmpty()) {
|
||||
@ -552,23 +588,19 @@ 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) {
|
||||
if (drawerEnabled)
|
||||
drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED)
|
||||
else toolbar.navigationIcon = null
|
||||
if (bottomNav) toolbar.navigationIcon = null
|
||||
else drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED)
|
||||
} else {
|
||||
if (drawerEnabled) drawer.setDrawerLockMode(
|
||||
if (bottomNav) toolbar.navigationIcon = drawerArrow
|
||||
else drawer.setDrawerLockMode(
|
||||
androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED
|
||||
)
|
||||
else toolbar.navigationIcon = drawerArrow
|
||||
}
|
||||
if (drawerEnabled)
|
||||
ObjectAnimator.ofFloat(drawerArrow, "progress", if (showHamburger) 0f else 1f).start()
|
||||
else drawerArrow?.progress = 1f
|
||||
if (bottomNav) drawerArrow?.progress = 1f
|
||||
else ObjectAnimator.ofFloat(drawerArrow, "progress", if (showHamburger) 0f else 1f).start()
|
||||
|
||||
if (from is TabbedController) {
|
||||
from.cleanupTabs(tabs)
|
||||
@ -620,6 +652,9 @@ open class MainActivity : BaseActivity() {
|
||||
private const val URL_HELP = "https://tachiyomi.org/help/"
|
||||
|
||||
var unlocked = false
|
||||
|
||||
var bottomNav = false
|
||||
internal set
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class SearchActivity: MainActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
bottomNav = false
|
||||
setContentView(R.layout.search_activity)
|
||||
|
||||
setSupportActionBar(sToolbar)
|
||||
@ -178,6 +179,11 @@ class SearchActivity: MainActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
bottomNav = false
|
||||
}
|
||||
|
||||
override fun handleIntentAction(intent: Intent): Boolean {
|
||||
val notificationId = intent.getIntExtra("notificationId", -1)
|
||||
if (notificationId > -1) NotificationReceiver.dismissNotification(
|
||||
|
@ -104,8 +104,7 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
|
||||
val fabBaseMarginBottom = fab?.marginBottom ?: 0
|
||||
recycler.setOnApplyWindowInsetsListener { v, insets ->
|
||||
if (activity !is SearchActivity &&
|
||||
presenter.preferences.useBottonNav().getOrDefault())
|
||||
if (MainActivity.bottomNav)
|
||||
return@setOnApplyWindowInsetsListener insets
|
||||
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
|
@ -198,9 +198,10 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
val fabBaseMarginBottom = fab_favorite.marginBottom
|
||||
val mangaCoverMarginBottom = manga_cover.marginBottom
|
||||
val fullMarginBottom = manga_cover_full?.marginBottom ?: 0
|
||||
setFullCoverToThumb()
|
||||
container?.setOnApplyWindowInsetsListener { _, insets ->
|
||||
if (activity !is SearchActivity &&
|
||||
Injekt.get<PreferencesHelper>().useBottonNav().getOrDefault())
|
||||
setFullCoverToThumb()
|
||||
if (MainActivity.bottomNav)
|
||||
return@setOnApplyWindowInsetsListener insets
|
||||
if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
fab_favorite?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
@ -217,7 +218,6 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
manga_cover_full?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fullMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
setFullCoverToThumb()
|
||||
insets
|
||||
}
|
||||
info_scrollview.doOnApplyWindowInsets { v, insets, padding ->
|
||||
@ -759,7 +759,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
layoutParams.width = thumbView.width
|
||||
expandedImageView.layoutParams = layoutParams
|
||||
expandedImageView.scaleType = ImageView.ScaleType.FIT_CENTER
|
||||
setUpFullCover = thumbView.height > 0
|
||||
setUpFullCover = expandedImageView.height > 0
|
||||
}
|
||||
|
||||
override fun handleBack(): Boolean {
|
||||
|
@ -8,18 +8,13 @@ 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.RecyclerWindowInsetsAlwaysListener
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
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,
|
||||
@ -50,9 +45,7 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
with(view) {
|
||||
track_recycler.layoutManager = LinearLayoutManager(context)
|
||||
track_recycler.adapter = adapter
|
||||
if (activity is SearchActivity ||
|
||||
!Injekt.get<PreferencesHelper>().useBottonNav().getOrDefault())
|
||||
track_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsAlwaysListener)
|
||||
track_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
swipe_refresh.isEnabled = false
|
||||
swipe_refresh.refreshes().subscribeUntilDestroy { presenter.refresh() }
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.recent_updates
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -18,16 +19,21 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||
import kotlinx.android.synthetic.main.recent_chapters_controller.*
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* Fragment that shows recent chapters.
|
||||
@ -43,6 +49,9 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
ConfirmDeleteChaptersDialog.Listener,
|
||||
RecentChaptersAdapter.OnCoverClickListener {
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
/**
|
||||
* Action mode for multiple selection.
|
||||
*/
|
||||
@ -326,4 +335,22 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
actionMode = null
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.recent_updates, menu)
|
||||
menu.findItem(R.id.action_recents).isVisible = MainActivity.bottomNav
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_recents -> {
|
||||
router.setRoot(
|
||||
RecentlyReadController().withFadeTransaction()
|
||||
.tag(R.id.nav_drawer_recents.toString()))
|
||||
Injekt.get<PreferencesHelper>().showRecentUpdates().set(false)
|
||||
(activity as? MainActivity)?.updateRecentsIcon()
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,21 @@ import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
||||
import eu.kanade.tachiyomi.data.database.models.History
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.ProgressItem
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||
import kotlinx.android.synthetic.main.recently_read_controller.*
|
||||
import kotlinx.android.synthetic.main.recently_read_controller.empty_view
|
||||
import kotlinx.android.synthetic.main.recently_read_controller.recycler
|
||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* Fragment that shows recently read manga.
|
||||
@ -186,6 +192,7 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.recently_read, menu)
|
||||
val searchItem = menu.findItem(R.id.action_search)
|
||||
menu.findItem(R.id.action_recents).isVisible = MainActivity.bottomNav
|
||||
val searchView = searchItem.actionView as SearchView
|
||||
if (query.isNotEmpty()) {
|
||||
searchItem.expandActionView()
|
||||
@ -207,15 +214,18 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
}
|
||||
|
||||
// Fixes problem with the overflow icon showing up in lieu of search
|
||||
searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||
return true
|
||||
searchItem.fixExpand(onExpand = { invalidateMenuOnExpand() })
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||
activity?.invalidateOptionsMenu()
|
||||
return true
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_recents -> {
|
||||
router.setRoot(RecentChaptersController().withFadeTransaction()
|
||||
.tag(R.id.nav_drawer_recents.toString()))
|
||||
Injekt.get<PreferencesHelper>().showRecentUpdates().set(true)
|
||||
(activity as? MainActivity)?.updateRecentsIcon()
|
||||
}
|
||||
})
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,11 @@ 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.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SettingsMainController : SettingsController() {
|
||||
|
||||
@ -25,12 +23,11 @@ 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()
|
||||
isVisible = MainActivity.bottomNav
|
||||
onClick { navigateTo(ExtensionController()) }
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ 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 eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@ -149,16 +150,7 @@ inline val View.marginLeft: Int
|
||||
|
||||
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 {
|
||||
if (MainActivity.bottomNav) return insets
|
||||
v.setPadding(0,0,0,insets.systemWindowInsetBottom)
|
||||
//v.updatePaddingRelative(bottom = v.paddingBottom + insets.systemWindowInsetBottom)
|
||||
return insets
|
||||
@ -167,8 +159,7 @@ object RecyclerWindowInsetsAlwaysListener : 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
|
||||
if (MainActivity.bottomNav) return
|
||||
val paddingState = createStateForView(this)
|
||||
setOnApplyWindowInsetsListener { v, insets ->
|
||||
f(v, insets, paddingState)
|
||||
|
6
app/src/main/res/drawable/ic_history_black_24dp.xml
Normal file
6
app/src/main/res/drawable/ic_history_black_24dp.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<vector android:height="24dp"
|
||||
android:tint="?attr/actionBarTintColor"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
|
||||
</vector>
|
@ -2,7 +2,8 @@
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/actionBarTintColor">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M21,10.12h-6.78l2.74,-2.82c-2.73,-2.7 -7.15,-2.8 -9.88,-0.1 -2.73,2.71 -2.73,7.08 0,9.79 2.73,2.71 7.15,2.71 9.88,0C18.32,15.65 19,14.08 19,12.1h2c0,1.98 -0.88,4.55 -2.64,6.29 -3.51,3.48 -9.21,3.48 -12.72,0 -3.5,-3.47 -3.53,-9.11 -0.02,-12.58 3.51,-3.47 9.14,-3.47 12.65,0L21,3v7.12zM12.5,8v4.25l3.5,2.08 -0.72,1.21L11,13V8h1.5z"/>
|
||||
|
@ -8,13 +8,9 @@
|
||||
android:icon="@drawable/ic_book_black_24dp"
|
||||
android:title="@string/pref_category_library" />
|
||||
<item
|
||||
android:id="@+id/nav_drawer_recent_updates"
|
||||
android:id="@+id/nav_drawer_recents"
|
||||
android:icon="@drawable/ic_update_black_24dp"
|
||||
android:title="@string/short_recent_updates" />
|
||||
<item
|
||||
android:id="@+id/nav_drawer_recently_read"
|
||||
android:icon="@drawable/ic_glasses_black_24dp"
|
||||
android:title="@string/short_recently_read"/>
|
||||
android:title="@string/short_recents" />
|
||||
<item
|
||||
android:id="@+id/nav_drawer_catalogues"
|
||||
android:icon="@drawable/ic_explore_black_24dp"
|
||||
|
10
app/src/main/res/menu/recent_updates.xml
Normal file
10
app/src/main/res/menu/recent_updates.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_recents"
|
||||
android:icon="@drawable/ic_history_black_24dp"
|
||||
android:title="@string/label_recent_manga"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
@ -7,4 +7,10 @@
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="ifRoom|collapseActionView" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_recents"
|
||||
android:icon="@drawable/ic_update_black_24dp"
|
||||
android:title="@string/label_recent_updates"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
@ -16,7 +16,7 @@
|
||||
<string name="label_library">My library</string>
|
||||
<string name="label_recent_manga">Recently read</string>
|
||||
<string name="label_catalogues">Catalogues</string>
|
||||
<string name="label_recent_updates">Library updates</string>
|
||||
<string name="label_recent_updates">Recently updated</string>
|
||||
<string name="label_selected">Selected: %1$d</string>
|
||||
<string name="label_migration">Source migration</string>
|
||||
<string name="label_extensions">Extensions</string>
|
||||
@ -113,7 +113,7 @@
|
||||
<!-- Shortcuts-->
|
||||
<string name="app_not_available">App not available</string>
|
||||
<string name="short_recent_updates">Updates</string>
|
||||
<string name="short_recently_read">Recents</string>
|
||||
<string name="short_recents">Recents</string>
|
||||
<string name="short_catalogues">Browse</string>
|
||||
|
||||
<!-- Preferences -->
|
||||
|
Loading…
Reference in New Issue
Block a user