From 3e3e6ee19f1ee0576a2a541a118853ceb0578469 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 17 Jul 2021 22:44:07 -0400 Subject: [PATCH] Show prompt for first time tapping update all for extensions --- .../data/preference/PreferencesHelper.kt | 2 ++ .../ui/extension/ExtensionBottomPresenter.kt | 2 +- .../ui/extension/ExtensionBottomSheet.kt | 16 ++++++++++++++++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) 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 41cf0a9e17..795b60fae9 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 @@ -424,6 +424,8 @@ class PreferencesHelper(val context: Context) { fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false) + fun hasPromptedBeforeUpdateAll() = flowPrefs.getBoolean("has_prompted_update_all", false) + fun filterChapterByRead() = flowPrefs.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL) fun filterChapterByDownloaded() = flowPrefs.getInt(Keys.defaultChapterFilterByDownloaded, Manga.SHOW_ALL) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt index 777d89602d..5a26ba60d9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt @@ -41,7 +41,7 @@ typealias ExtensionIntallInfo = Pair class ExtensionBottomPresenter( private val bottomSheet: ExtensionBottomSheet, private val extensionManager: ExtensionManager = Injekt.get(), - private val preferences: PreferencesHelper = Injekt.get() + val preferences: PreferencesHelper = Injekt.get() ) : BaseCoroutinePresenter(), ExtensionsChangedListener { private var extensions = emptyList() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt index 9964cac171..687362ff82 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt @@ -7,6 +7,7 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import androidx.recyclerview.widget.RecyclerView +import com.afollestad.materialdialogs.MaterialDialog import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.tabs.TabLayout import eu.davidea.flexibleadapter.FlexibleAdapter @@ -202,6 +203,21 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At } override fun onUpdateAllClicked(position: Int) { + if (!presenter.preferences.hasPromptedBeforeUpdateAll().get()) { + MaterialDialog(controller.activity!!) + .title(R.string.update_all) + .message(R.string.some_extensions_may_prompt) + .positiveButton(android.R.string.ok) { + presenter.preferences.hasPromptedBeforeUpdateAll().set(true) + updateAllExtensions(position) + } + .show() + } else { + updateAllExtensions(position) + } + } + + fun updateAllExtensions(position: Int) { val header = (extAdapter?.getSectionHeader(position)) as? ExtensionGroupItem ?: return val items = extAdapter?.getSectionItemPositions(header) items?.forEach { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fcc9f427c9..2b2a388a5b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -313,6 +313,7 @@ %1$s must be enabled first Could not install extension Update all + Some extensions may still prompt to be installed first. Updating extensions %d update pending @@ -984,5 +985,6 @@ Use default View all errors View chapters + Warning Wi-Fi