From b9420040f5521278edf7f12a148b49fafe2b4363 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 4 Feb 2020 21:21:07 -0500 Subject: [PATCH] Move help into settings menu --- .../kanade/tachiyomi/ui/main/MainActivity.kt | 6 ---- .../ui/setting/BaseSettingsController.kt | 30 +++++++++++++++++++ .../ui/setting/SettingsAboutController.kt | 2 +- .../ui/setting/SettingsAdvancedController.kt | 2 +- .../ui/setting/SettingsBackupController.kt | 2 +- .../ui/setting/SettingsDownloadController.kt | 2 +- .../ui/setting/SettingsGeneralController.kt | 2 +- .../ui/setting/SettingsLibraryController.kt | 2 +- .../ui/setting/SettingsMainController.kt | 9 +++--- .../ui/setting/SettingsReaderController.kt | 2 +- .../ui/setting/SettingsTrackingController.kt | 2 +- ..._black_24dp.xml => ic_help_white_24dp.xml} | 12 ++++---- .../main/res/drawable/ic_info_black_24dp.xml | 9 ++++++ app/src/main/res/menu/menu_navigation.xml | 5 ---- app/src/main/res/menu/settings.xml | 11 +++++++ 15 files changed, 69 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/setting/BaseSettingsController.kt rename app/src/main/res/drawable/{ic_help_black_24dp.xml => ic_help_white_24dp.xml} (67%) create mode 100644 app/src/main/res/drawable/ic_info_black_24dp.xml create mode 100644 app/src/main/res/menu/settings.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 62cc5f61b..6961ff770 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -23,7 +23,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController import eu.kanade.tachiyomi.ui.setting.SettingsMainController -import eu.kanade.tachiyomi.util.system.openInBrowser import kotlinx.android.synthetic.main.main_activity.* @@ -82,9 +81,6 @@ class MainActivity : BaseActivity() { R.id.nav_drawer_settings -> { router.pushController(SettingsMainController().withFadeTransaction()) } - R.id.nav_drawer_help -> { - openInBrowser(URL_HELP) - } } } drawer.closeDrawer(GravityCompat.START) @@ -265,8 +261,6 @@ class MainActivity : BaseActivity() { const val INTENT_SEARCH = "eu.kanade.tachiyomi.SEARCH" const val INTENT_SEARCH_QUERY = "query" const val INTENT_SEARCH_FILTER = "filter" - - private const val URL_HELP = "https://tachiyomi.org/help/" } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/BaseSettingsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/BaseSettingsController.kt new file mode 100644 index 000000000..902952f86 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/BaseSettingsController.kt @@ -0,0 +1,30 @@ +package eu.kanade.tachiyomi.ui.setting + +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.util.system.openInBrowser + +abstract class BaseSettingsController : 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) + } + + companion object { + private const val URL_HELP = "https://tachiyomi.org/help/" + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAboutController.kt index 0200adf39..c14a48b39 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAboutController.kt @@ -31,7 +31,7 @@ import java.util.Locale import java.util.TimeZone import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsAboutController : SettingsController() { +class SettingsAboutController : BaseSettingsController() { /** * Checks for new releases diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index c4a23f582..16d5a76e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -21,7 +21,7 @@ import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers import uy.kohesive.injekt.injectLazy -class SettingsAdvancedController : SettingsController() { +class SettingsAdvancedController : BaseSettingsController() { private val network: NetworkHelper by injectLazy() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt index 9ebf3339c..477b4018e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt @@ -29,7 +29,7 @@ import java.io.File import java.util.concurrent.TimeUnit import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsBackupController : SettingsController() { +class SettingsBackupController : BaseSettingsController() { /** * Flags containing information of what to backup. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 4c7e87926..6cc1451c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -23,7 +23,7 @@ import uy.kohesive.injekt.injectLazy import java.io.File import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsDownloadController : SettingsController() { +class SettingsDownloadController : BaseSettingsController() { private val db: DatabaseHelper by injectLazy() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 2d589cd4e..30ffe58e7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -5,7 +5,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsGeneralController : SettingsController() { +class SettingsGeneralController : BaseSettingsController() { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { titleRes = R.string.pref_category_general diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 9efc5b6b0..d27605748 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -22,7 +22,7 @@ import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsLibraryController : SettingsController() { +class SettingsLibraryController : BaseSettingsController() { private val db: DatabaseHelper = Injekt.get() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt index eb642f324..1770dcfb1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt @@ -1,11 +1,12 @@ package eu.kanade.tachiyomi.ui.setting import androidx.preference.PreferenceScreen +import com.bluelinelabs.conductor.RouterTransaction import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.util.system.getResourceColor -class SettingsMainController : SettingsController() { +class SettingsMainController : BaseSettingsController() { + override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { titleRes = R.string.label_settings @@ -54,7 +55,7 @@ class SettingsMainController : SettingsController() { onClick { navigateTo(SettingsAdvancedController()) } } preference { - iconRes = R.drawable.ic_help_black_24dp + iconRes = R.drawable.ic_info_black_24dp iconTint = tintColor titleRes = R.string.pref_category_about onClick { navigateTo(SettingsAboutController()) } @@ -62,6 +63,6 @@ class SettingsMainController : SettingsController() { } private fun navigateTo(controller: SettingsController) { - router.pushController(controller.withFadeTransaction()) + router.pushController(RouterTransaction.with(controller)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index f6371c4af..f6b82d258 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -5,7 +5,7 @@ import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsReaderController : SettingsController() { +class SettingsReaderController : BaseSettingsController() { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { titleRes = R.string.pref_category_reader diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt index 08a1bd79b..b2c38c0b6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt @@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.widget.preference.TrackLogoutDialog import uy.kohesive.injekt.injectLazy import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -class SettingsTrackingController : SettingsController(), +class SettingsTrackingController : BaseSettingsController(), TrackLoginDialog.Listener, TrackLogoutDialog.Listener { diff --git a/app/src/main/res/drawable/ic_help_black_24dp.xml b/app/src/main/res/drawable/ic_help_white_24dp.xml similarity index 67% rename from app/src/main/res/drawable/ic_help_black_24dp.xml rename to app/src/main/res/drawable/ic_help_white_24dp.xml index 1517747d0..04c1c00fc 100644 --- a/app/src/main/res/drawable/ic_help_black_24dp.xml +++ b/app/src/main/res/drawable/ic_help_white_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:fillColor="#FFFFFFFF" + 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" /> diff --git a/app/src/main/res/drawable/ic_info_black_24dp.xml b/app/src/main/res/drawable/ic_info_black_24dp.xml new file mode 100644 index 000000000..0cbb99601 --- /dev/null +++ b/app/src/main/res/drawable/ic_info_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/menu_navigation.xml b/app/src/main/res/menu/menu_navigation.xml index c16fb4dfe..bd7d8adb7 100644 --- a/app/src/main/res/menu/menu_navigation.xml +++ b/app/src/main/res/menu/menu_navigation.xml @@ -38,10 +38,5 @@ android:checkable="false" android:icon="@drawable/ic_settings_black_24dp" android:title="@string/label_settings" /> - diff --git a/app/src/main/res/menu/settings.xml b/app/src/main/res/menu/settings.xml new file mode 100644 index 000000000..3f8a0773a --- /dev/null +++ b/app/src/main/res/menu/settings.xml @@ -0,0 +1,11 @@ + + + + + +