mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 03:01:50 +01:00
Resume on last used tab
This commit is contained in:
parent
5e45c29f58
commit
d82b6fbe04
@ -53,6 +53,8 @@ class PreferencesHelper(val context: Context) {
|
||||
fun getStringPref(key: String, default: String?) = rxPrefs.getString(key, default)
|
||||
fun getStringSet(key: String, default: Set<String>) = rxPrefs.getStringSet(key, default)
|
||||
|
||||
fun lastTab() = rxPrefs.getInteger("last_tab", 0)
|
||||
|
||||
fun clear() = prefs.edit().clear().apply()
|
||||
|
||||
fun theme() = prefs.getInt(Keys.theme, 5)
|
||||
|
@ -61,9 +61,6 @@ import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.updatePadding
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@ -71,6 +68,9 @@ import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
|
||||
open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||
|
||||
@ -141,6 +141,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||
}) return@setOnNavigationItemSelectedListener false
|
||||
}
|
||||
continueSwitchingTabs = false
|
||||
preferences.lastTab().set(item.itemId)
|
||||
val currentRoot = router.backstack.firstOrNull()
|
||||
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
||||
when (id) {
|
||||
@ -223,7 +224,8 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||
if (!router.hasRootController()) {
|
||||
// Set start screen
|
||||
if (!handleIntentAction(intent)) {
|
||||
bottom_nav.selectedItemId = R.id.nav_library
|
||||
val lastItemId = bottom_nav.menu.findItem(preferences.lastTab().getOrDefault())?.itemId
|
||||
bottom_nav.selectedItemId = lastItemId ?: R.id.nav_library
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,14 +389,12 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||
when (intent.action) {
|
||||
SHORTCUT_LIBRARY -> bottom_nav.selectedItemId = R.id.nav_library
|
||||
SHORTCUT_RECENTLY_UPDATED, SHORTCUT_RECENTLY_READ -> {
|
||||
// preferences.showRecentUpdates().set(intent.action == SHORTCUT_RECENTLY_UPDATED)
|
||||
bottom_nav.selectedItemId = R.id.nav_recents
|
||||
val controller: Controller = when (intent.action) {
|
||||
SHORTCUT_RECENTLY_UPDATED -> RecentChaptersController()
|
||||
else -> RecentlyReadController()
|
||||
}
|
||||
router.pushController(controller.withFadeTransaction())
|
||||
// updateRecentsIcon()
|
||||
}
|
||||
SHORTCUT_CATALOGUES -> bottom_nav.selectedItemId = R.id.nav_catalogues
|
||||
SHORTCUT_EXTENSIONS -> {
|
||||
|
Loading…
Reference in New Issue
Block a user