From d9fcf8f3f75c6030d532c265caa60ce60fcf3018 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 8 May 2021 16:09:14 -0400 Subject: [PATCH] Option to turn off app shortcuts Closes #795 --- .../eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../kanade/tachiyomi/data/preference/PreferencesHelper.kt | 1 + .../tachiyomi/ui/setting/SettingsGeneralController.kt | 7 +++++++ .../eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 17 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index f0e6d79be4..c83ebec7f1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -204,6 +204,8 @@ object PreferenceKeys { const val hideBottomNavOnScroll = "hide_bottom_nav_on_scroll" + const val showMangaAppShortcuts = "show_manga_app_shortcuts" + const val createLegacyBackup = "create_legacy_backup" const val dohProvider = "doh_provider" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index f16b80a454..64b7283e3d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -402,6 +402,7 @@ class PreferencesHelper(val context: Context) { fun createLegacyBackup() = flowPrefs.getBoolean(Keys.createLegacyBackup, true) fun dohProvider() = prefs.getInt(Keys.dohProvider, -1) + fun appShortcuts() = prefs.getBoolean(Keys.showMangaAppShortcuts, true) fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false) } 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 c21def6c51..8084a9e152 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 @@ -77,6 +77,13 @@ class SettingsGeneralController : SettingsController() { defaultValue = true } + switchPreference { + key = Keys.showMangaAppShortcuts + titleRes = R.string.app_shortcuts + summaryRes = R.string.show_recent_in_shortcuts + defaultValue = true + } + switchPreference { key = Keys.automaticUpdates titleRes = R.string.check_for_updates diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt b/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt index e656a3519f..ba8f246e15 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt @@ -38,6 +38,11 @@ class MangaShortcutManager( val context: Context = preferences.context fun updateShortcuts() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) { + if (!preferences.appShortcuts()) { + val shortcutManager = context.getSystemService(ShortcutManager::class.java) + shortcutManager.removeAllDynamicShortcuts() + return + } GlobalScope.launchIO { val shortcutManager = context.getSystemService(ShortcutManager::class.java) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a193954755..a13f11acb5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -611,6 +611,8 @@ Automatically check for new app versions Secure screen Auto-hide bottom navigation + App shortcuts + Show recent sources and series in app shortcuts Follow system theme Hides when scrolling Hide app contents when switching apps and block screenshots