Migrate to bottom navigation

This commit is contained in:
arkon 2020-02-25 19:40:14 -05:00
parent 8776a45ee9
commit 11544fe8ef
18 changed files with 169 additions and 189 deletions

View File

@ -33,7 +33,6 @@ import eu.kanade.tachiyomi.ui.base.controller.TabbedController
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.migration.MigrationController
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.inflate
import kotlinx.android.synthetic.main.library_controller.empty_view
@ -396,10 +395,6 @@ class LibraryController(
preferences.downloadBadge().set(item.isChecked)
onDownloadBadgeChanged()
}
R.id.action_source_migration -> {
router.pushController(MigrationController().withFadeTransaction())
}
}
return super.onOptionsItemSelected(item)

View File

@ -1,14 +1,10 @@
package eu.kanade.tachiyomi.ui.main
import android.animation.ObjectAnimator
import android.app.SearchManager
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.ViewGroup
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.bluelinelabs.conductor.*
import eu.kanade.tachiyomi.Migrations
import eu.kanade.tachiyomi.R
@ -18,12 +14,11 @@ import eu.kanade.tachiyomi.ui.base.controller.*
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.extension.ExtensionController
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.more.MoreController
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import kotlinx.android.synthetic.main.main_activity.*
@ -31,15 +26,13 @@ class MainActivity : BaseActivity() {
private lateinit var router: Router
private var drawerArrow: DrawerArrowDrawable? = null
private var secondaryDrawer: ViewGroup? = null
private val startScreenId by lazy {
when (preferences.startScreen()) {
2 -> R.id.nav_drawer_recently_read
3 -> R.id.nav_drawer_recent_updates
else -> R.id.nav_drawer_library
2 -> R.id.nav_history
3 -> R.id.nav_updates
else -> R.id.nav_library
}
}
@ -58,33 +51,25 @@ class MainActivity : BaseActivity() {
setSupportActionBar(toolbar)
drawerArrow = DrawerArrowDrawable(this)
drawerArrow?.color = Color.WHITE
toolbar.navigationIcon = drawerArrow
tabAnimator = TabsAnimator(tabs)
// Set behavior of Navigation drawer
nav_view.setNavigationItemSelectedListener { item ->
// Set behavior of bottom nav
bottom_nav.setOnNavigationItemSelectedListener { item ->
val id = item.itemId
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_catalogues -> setRoot(CatalogueController(), id)
R.id.nav_drawer_extensions -> setRoot(ExtensionController(), id)
R.id.nav_drawer_downloads -> {
router.pushController(DownloadController().withFadeTransaction())
R.id.nav_library -> setRoot(LibraryController(), id)
R.id.nav_updates -> setRoot(RecentChaptersController(), id)
R.id.nav_history -> setRoot(RecentlyReadController(), id)
R.id.nav_catalogues -> setRoot(CatalogueController(), id)
R.id.nav_more -> setRoot(MoreController(), id)
}
R.id.nav_drawer_settings -> {
router.pushController(SettingsMainController().withFadeTransaction())
} else {
router.popToRoot()
}
}
}
drawer.closeDrawer(GravityCompat.START)
true
}
@ -143,18 +128,18 @@ class MainActivity : BaseActivity() {
}
when (intent.action) {
SHORTCUT_LIBRARY -> setSelectedDrawerItem(R.id.nav_drawer_library)
SHORTCUT_RECENTLY_UPDATED -> setSelectedDrawerItem(R.id.nav_drawer_recent_updates)
SHORTCUT_RECENTLY_READ -> setSelectedDrawerItem(R.id.nav_drawer_recently_read)
SHORTCUT_CATALOGUES -> setSelectedDrawerItem(R.id.nav_drawer_catalogues)
SHORTCUT_LIBRARY -> setSelectedDrawerItem(R.id.nav_library)
SHORTCUT_RECENTLY_UPDATED -> setSelectedDrawerItem(R.id.nav_updates)
SHORTCUT_RECENTLY_READ -> setSelectedDrawerItem(R.id.nav_history)
SHORTCUT_CATALOGUES -> setSelectedDrawerItem(R.id.nav_catalogues)
SHORTCUT_MANGA -> {
val extras = intent.extras ?: return false
router.setRoot(RouterTransaction.with(MangaController(extras)))
setSelectedDrawerItem(R.id.nav_library)
router.pushController(RouterTransaction.with(MangaController(extras)))
}
SHORTCUT_DOWNLOADS -> {
if (router.backstack.none { it.controller() is DownloadController }) {
setSelectedDrawerItem(R.id.nav_drawer_downloads)
}
setSelectedDrawerItem(R.id.nav_more)
router.pushController(RouterTransaction.with(DownloadController()))
}
Intent.ACTION_SEARCH, "com.google.android.gms.actions.SEARCH_ACTION" -> {
//If the intent match the "standard" Android search intent
@ -186,7 +171,7 @@ class MainActivity : BaseActivity() {
override fun onDestroy() {
super.onDestroy()
nav_view?.setNavigationItemSelectedListener(null)
bottom_nav?.setOnNavigationItemSelectedListener(null)
toolbar?.setNavigationOnClickListener(null)
}
@ -203,8 +188,7 @@ class MainActivity : BaseActivity() {
private fun setSelectedDrawerItem(itemId: Int) {
if (!isFinishing) {
nav_view.setCheckedItem(itemId)
nav_view.menu.performIdentifierAction(itemId, 0)
bottom_nav.selectedItemId = itemId
}
}
@ -217,14 +201,7 @@ class MainActivity : BaseActivity() {
return
}
val showHamburger = router.backstackSize == 1
if (showHamburger) {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
} else {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
}
ObjectAnimator.ofFloat(drawerArrow, "progress", if (showHamburger) 0f else 1f).start()
supportActionBar?.setDisplayHomeAsUpEnabled(router.backstackSize != 1)
if (from is TabbedController) {
from.cleanupTabs(tabs)

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.setting
package eu.kanade.tachiyomi.ui.more
import android.app.Dialog
import android.content.Intent
@ -16,6 +16,7 @@ import eu.kanade.tachiyomi.data.updater.UpdaterJob
import eu.kanade.tachiyomi.data.updater.UpdaterService
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.main.ChangelogDialogController
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.util.lang.launchNow
import eu.kanade.tachiyomi.util.lang.toTimestampString
import eu.kanade.tachiyomi.util.preference.*
@ -29,7 +30,7 @@ import java.util.Locale
import java.util.TimeZone
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
class SettingsAboutController : SettingsController() {
class AboutController : SettingsController() {
/**
* Checks for new releases

View File

@ -0,0 +1,81 @@
package eu.kanade.tachiyomi.ui.more
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.extension.ExtensionController
import eu.kanade.tachiyomi.ui.migration.MigrationController
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.util.preference.*
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.openInBrowser
class MoreController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
titleRes = R.string.label_more
val tintColor = context.getResourceColor(R.attr.colorAccent)
preferenceCategory {
preference {
titleRes = R.string.label_extensions
iconRes = R.drawable.ic_extension_black_24dp
iconTint = tintColor
onClick {
router.pushController(ExtensionController().withFadeTransaction())
}
}
preference {
titleRes = R.string.label_download_queue
iconRes = R.drawable.ic_file_download_black_24dp
iconTint = tintColor
onClick {
router.pushController(DownloadController().withFadeTransaction())
}
}
preference {
titleRes = R.string.label_migration
iconRes = R.drawable.ic_compare_arrows_black_24dp
iconTint = tintColor
onClick {
router.pushController(MigrationController().withFadeTransaction())
}
}
}
preferenceCategory {
preference {
titleRes = R.string.label_settings
iconRes = R.drawable.ic_settings_black_24dp
iconTint = tintColor
onClick {
router.pushController(SettingsMainController().withFadeTransaction())
}
}
preference {
iconRes = R.drawable.ic_info_black_24dp
iconTint = tintColor
titleRes = R.string.pref_category_about
onClick {
router.pushController(AboutController().withFadeTransaction())
}
}
preference {
titleRes = R.string.label_help
iconRes = R.drawable.ic_help_black_24dp
iconTint = tintColor
onClick {
activity?.openInBrowser(URL_HELP)
}
}
}
}
companion object {
private const val URL_HELP = "https://tachiyomi.org/help/"
}
}

View File

@ -1,33 +1,13 @@
package eu.kanade.tachiyomi.ui.setting
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.util.preference.*
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.openInBrowser
class SettingsMainController : SettingsController() {
init {
setHasOptionsMenu(true)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.settings, menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_help -> activity?.openInBrowser(URL_HELP)
}
return super.onOptionsItemSelected(item)
}
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
titleRes = R.string.label_settings
@ -75,19 +55,9 @@ class SettingsMainController : SettingsController() {
titleRes = R.string.pref_category_advanced
onClick { navigateTo(SettingsAdvancedController()) }
}
preference {
iconRes = R.drawable.ic_info_black_24dp
iconTint = tintColor
titleRes = R.string.pref_category_about
onClick { navigateTo(SettingsAboutController()) }
}
}
private fun navigateTo(controller: SettingsController) {
router.pushController(controller.withFadeTransaction())
}
companion object {
private const val URL_HELP = "https://tachiyomi.org/help/"
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/tabBarIconColor" android:state_checked="true" />
<item android:color="?attr/tabBarIconColor" android:state_enabled="true" android:state_pressed="true" />
<item android:color="?attr/tabBarIconColor" android:state_focused="true" />
<item android:color="?attr/tabBarIconInactive" android:state_focused="false" />
<item android:color="?attr/tabBarIconColor" />
</selector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9.01,14L2,14v2h7.01v3L13,15l-3.99,-4v3zM14.99,13v-3L22,10L22,8h-7.01L14.99,5L11,9l3.99,4z" />
</vector>

View File

@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:fillColor="#FF000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z" />
</vector>

View File

@ -7,7 +7,6 @@
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -40,18 +39,19 @@
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
android:id="@+id/controller_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/colorPrimary"
app:itemIconTint="@drawable/bottom_nav_item_selector"
app:itemTextColor="@drawable/bottom_nav_item_selector"
app:menu="@menu/bottom_nav" />
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:theme="?attr/navigation_view_theme"
app:headerLayout="@layout/navigation_header"
app:menu="@menu/menu_navigation" />
</androidx.drawerlayout.widget.DrawerLayout>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/navigation_drawer_header_height"
android:gravity="bottom"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary" />
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="16dp"
android:layout_marginTop="@dimen/navigation_drawer_header_margin"
android:scaleType="centerCrop"
android:src="@drawable/splash_icon" />
</FrameLayout>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_library"
android:icon="@drawable/ic_book_black_24dp"
android:title="@string/label_library" />
<item
android:id="@+id/nav_updates"
android:icon="@drawable/ic_new_releases_black_24dp"
android:title="@string/label_recent_updates" />
<item
android:id="@+id/nav_history"
android:icon="@drawable/ic_history_black_24dp"
android:title="@string/label_recent_manga" />
<item
android:id="@+id/nav_catalogues"
android:icon="@drawable/ic_explore_black_24dp"
android:title="@string/label_catalogues" />
<item
android:id="@+id/nav_more"
android:icon="@drawable/ic_more_horiz_black_24dp"
android:title="@string/label_more" />
</menu>

View File

@ -42,9 +42,4 @@
</menu>
</item>
<item
android:id="@+id/action_source_migration"
android:title="@string/label_migration"
app:showAsAction="never" />
</menu>

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:id="@+id/group_feature"
android:checkableBehavior="single">
<item
android:id="@+id/nav_drawer_library"
android:checked="true"
android:icon="@drawable/ic_book_black_24dp"
android:title="@string/label_library" />
<item
android:id="@+id/nav_drawer_recent_updates"
android:icon="@drawable/ic_new_releases_black_24dp"
android:title="@string/label_recent_updates" />
<item
android:id="@+id/nav_drawer_recently_read"
android:icon="@drawable/ic_history_black_24dp"
android:title="@string/label_recent_manga" />
<item
android:id="@+id/nav_drawer_catalogues"
android:icon="@drawable/ic_explore_black_24dp"
android:title="@string/label_catalogues" />
<item
android:id="@+id/nav_drawer_extensions"
android:icon="@drawable/ic_extension_black_24dp"
android:title="@string/label_extensions" />
<item
android:id="@+id/nav_drawer_downloads"
android:checkable="false"
android:icon="@drawable/ic_file_download_black_24dp"
android:title="@string/label_download_queue" />
</group>
<group
android:id="@+id/group_settings"
android:checkableBehavior="single">
<item
android:id="@+id/nav_drawer_settings"
android:checkable="false"
android:icon="@drawable/ic_settings_black_24dp"
android:title="@string/label_settings" />
</group>
</menu>

View File

@ -1,11 +0,0 @@
<?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_help"
android:icon="@drawable/ic_help_white_24dp"
android:title="@string/label_help"
app:showAsAction="ifRoom" />
</menu>

View File

@ -20,12 +20,13 @@
<attr name="max_seek" format="integer"/>
</declare-styleable>
<attr name="navigation_view_theme" format="reference"/>
<attr name="selectable_list_drawable" format="reference|integer" />
<attr name="selectable_library_drawable" format="reference|integer"/>
<attr name="text_color_primary" format="reference|integer"/>
<attr name="background_card" format="reference|integer"/>
<attr name="colorBackgroundSplash" format="reference|integer"/>
<attr name="icon_color" format="reference|integer"/>
<attr name="tabBarIconColor" format="reference|integer"/>
<attr name="tabBarIconInactive" format="reference|integer"/>
</resources>

View File

@ -11,6 +11,7 @@
<string name="history">History</string>
<!-- Activities and fragments labels (toolbar title) -->
<string name="label_more">More</string>
<string name="label_settings">Settings</string>
<string name="label_download_queue">Download queue</string>
<string name="label_library">Library</string>

View File

@ -36,15 +36,6 @@
<item name="android:background">@color/colorAmoledPrimary</item>
</style>
<!--==============-->
<!--NavigationView-->
<!--==============-->
<style name="Theme.Widget.NavigationView" />
<style name="Theme.Widget.NavigationView.Dark">
<item name="colorControlHighlight">@color/md_grey_900</item>
<item name="colorPrimary">?colorAccent</item>
</style>
<!--===============-->
<!--Text Appearance-->

View File

@ -40,6 +40,8 @@
<item name="text_color_primary">@color/textColorPrimaryLight</item>
<item name="background_card">@color/dialogLight</item>
<item name="icon_color">@color/iconColorLight</item>
<item name="tabBarIconColor">@android:color/white</item>
<item name="tabBarIconInactive">@color/textColorHintDark</item>
</style>
<!--===========-->
@ -81,14 +83,14 @@
<item name="md_background_color">@color/dialogDark</item>
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
<!-- Custom Attributes-->
<item name="navigation_view_theme">@style/Theme.Widget.NavigationView.Dark</item>
<item name="selectable_list_drawable">@drawable/list_item_selector_dark</item>
<item name="selectable_library_drawable">@drawable/library_item_selector_dark</item>
<item name="text_color_primary">@color/textColorPrimaryDark</item>
<item name="background_card">@color/dialogDark</item>
<item name="icon_color">@color/iconColorDark</item>
<item name="tabBarIconColor">@android:color/white</item>
<item name="tabBarIconInactive">@color/textColorHintDark</item>
</style>
<style name="Theme.Tachiyomi.Dark" parent="Theme.Base.Dark">