mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 17:05:07 +01:00
Fixed nav bar color for 2/3 button mode
Using an interface to stop switching tabs if an important operation is active (for now just migrations
This commit is contained in:
parent
243bffebf9
commit
8379c69874
@ -16,8 +16,8 @@ import android.webkit.WebView
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.bluelinelabs.conductor.Conductor
|
import com.bluelinelabs.conductor.Conductor
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
@ -49,7 +49,6 @@ import eu.kanade.tachiyomi.ui.extension.ExtensionController
|
|||||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryListController
|
import eu.kanade.tachiyomi.ui.library.LibraryListController
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
|
||||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
||||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
@ -128,22 +127,17 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
|
|
||||||
tabAnimator = TabsAnimator(tabs)
|
tabAnimator = TabsAnimator(tabs)
|
||||||
|
|
||||||
|
var continueSwitchingTabs = false
|
||||||
navigationView.setOnNavigationItemSelectedListener { item ->
|
navigationView.setOnNavigationItemSelectedListener { item ->
|
||||||
val id = item.itemId
|
val id = item.itemId
|
||||||
val currentController = router.backstack.lastOrNull()?.controller()
|
val currentController = router.backstack.lastOrNull()?.controller()
|
||||||
if (currentController is MigrationListController &&
|
if (!continueSwitchingTabs && currentController is BottomNavBarInterface) {
|
||||||
currentController.migrationsJob?.isCancelled == false) {
|
return@setOnNavigationItemSelectedListener currentController.canChangeTabs {
|
||||||
MaterialDialog(this).show {
|
continueSwitchingTabs = true
|
||||||
title(R.string.stop_migration)
|
|
||||||
positiveButton(R.string.action_stop) {
|
|
||||||
currentController.migrationsJob?.cancel()
|
|
||||||
this@MainActivity.navigationView.selectedItemId = id
|
this@MainActivity.navigationView.selectedItemId = id
|
||||||
}
|
}
|
||||||
negativeButton(android.R.string.cancel)
|
|
||||||
}
|
}
|
||||||
return@setOnNavigationItemSelectedListener false
|
continueSwitchingTabs = false
|
||||||
}
|
|
||||||
|
|
||||||
val currentRoot = router.backstack.firstOrNull()
|
val currentRoot = router.backstack.firstOrNull()
|
||||||
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
||||||
when (id) {
|
when (id) {
|
||||||
@ -207,7 +201,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
|
|
||||||
content.setOnApplyWindowInsetsListener { v, insets ->
|
content.setOnApplyWindowInsetsListener { v, insets ->
|
||||||
// if device doesn't support light nav bar
|
// if device doesn't support light nav bar
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
// basically if in landscape on a phone
|
// basically if in landscape on a phone
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||||
(v.rootWindowInsets.systemWindowInsetLeft > 0 ||
|
(v.rootWindowInsets.systemWindowInsetLeft > 0 ||
|
||||||
@ -216,10 +210,10 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
Color.BLACK
|
Color.BLACK
|
||||||
else Color.argb(179, 0, 0, 0)
|
else Color.argb(179, 0, 0, 0)
|
||||||
}
|
}
|
||||||
else {
|
/*else {
|
||||||
getColor(android.R.color.transparent)
|
getColor(android.R.color.transparent)
|
||||||
}
|
}*/
|
||||||
/* // if the android q+ device has gesture nav, transparent nav bar
|
// if the android q+ device has gesture nav, transparent nav bar
|
||||||
// this is here incase some crazy with a notch uses landscape
|
// this is here incase some crazy with a notch uses landscape
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||||
&& (v.rootWindowInsets.systemWindowInsetBottom != v.rootWindowInsets
|
&& (v.rootWindowInsets.systemWindowInsetBottom != v.rootWindowInsets
|
||||||
@ -230,7 +224,12 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
else if (v.rootWindowInsets.systemWindowInsetLeft > 0
|
else if (v.rootWindowInsets.systemWindowInsetLeft > 0
|
||||||
|| v.rootWindowInsets.systemWindowInsetRight > 0) {
|
|| v.rootWindowInsets.systemWindowInsetRight > 0) {
|
||||||
getResourceColor( android.R.attr.colorPrimary )
|
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)
|
||||||
|
}
|
||||||
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
|
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
|
||||||
insets.systemWindowInsetRight, 0)
|
insets.systemWindowInsetRight, 0)
|
||||||
insets
|
insets
|
||||||
@ -585,3 +584,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
internal set
|
internal set
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BottomNavBarInterface {
|
||||||
|
fun canChangeTabs(block: () -> Unit): Boolean
|
||||||
|
}
|
@ -25,6 +25,7 @@ import eu.kanade.tachiyomi.source.Source
|
|||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
|
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationMangaDialog
|
import eu.kanade.tachiyomi.ui.migration.MigrationMangaDialog
|
||||||
import eu.kanade.tachiyomi.ui.migration.SearchController
|
import eu.kanade.tachiyomi.ui.migration.SearchController
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
@ -50,7 +51,7 @@ import java.util.concurrent.atomic.AtomicInteger
|
|||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||||
MigrationProcessAdapter.MigrationProcessInterface,
|
MigrationProcessAdapter.MigrationProcessInterface, BottomNavBarInterface,
|
||||||
CoroutineScope {
|
CoroutineScope {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -426,6 +427,23 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun canChangeTabs(block: () -> Unit): Boolean {
|
||||||
|
if (migrationsJob?.isCancelled == false || adapter?.allMangasDone() == true) {
|
||||||
|
activity?.let {
|
||||||
|
MaterialDialog(it).show {
|
||||||
|
title(R.string.stop_migration)
|
||||||
|
positiveButton (R.string.action_stop) {
|
||||||
|
block()
|
||||||
|
migrationsJob?.cancel()
|
||||||
|
}
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val CONFIG_EXTRA = "config_extra"
|
const val CONFIG_EXTRA = "config_extra"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user