Show prompt for first time tapping update all for extensions

This commit is contained in:
Jays2Kings 2021-07-17 22:44:07 -04:00
parent 31d16f421a
commit 3e3e6ee19f
4 changed files with 21 additions and 1 deletions

View File

@ -424,6 +424,8 @@ class PreferencesHelper(val context: Context) {
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false) 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 filterChapterByRead() = flowPrefs.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL)
fun filterChapterByDownloaded() = flowPrefs.getInt(Keys.defaultChapterFilterByDownloaded, Manga.SHOW_ALL) fun filterChapterByDownloaded() = flowPrefs.getInt(Keys.defaultChapterFilterByDownloaded, Manga.SHOW_ALL)

View File

@ -41,7 +41,7 @@ typealias ExtensionIntallInfo = Pair<InstallStep, PackageInstaller.SessionInfo?>
class ExtensionBottomPresenter( class ExtensionBottomPresenter(
private val bottomSheet: ExtensionBottomSheet, private val bottomSheet: ExtensionBottomSheet,
private val extensionManager: ExtensionManager = Injekt.get(), private val extensionManager: ExtensionManager = Injekt.get(),
private val preferences: PreferencesHelper = Injekt.get() val preferences: PreferencesHelper = Injekt.get()
) : BaseCoroutinePresenter(), ExtensionsChangedListener { ) : BaseCoroutinePresenter(), ExtensionsChangedListener {
private var extensions = emptyList<ExtensionItem>() private var extensions = emptyList<ExtensionItem>()

View File

@ -7,6 +7,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
@ -202,6 +203,21 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
} }
override fun onUpdateAllClicked(position: Int) { 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 header = (extAdapter?.getSectionHeader(position)) as? ExtensionGroupItem ?: return
val items = extAdapter?.getSectionItemPositions(header) val items = extAdapter?.getSectionItemPositions(header)
items?.forEach { items?.forEach {

View File

@ -313,6 +313,7 @@
<string name="_must_be_enabled_first">%1$s must be enabled first</string> <string name="_must_be_enabled_first">%1$s must be enabled first</string>
<string name="could_not_install_extension">Could not install extension</string> <string name="could_not_install_extension">Could not install extension</string>
<string name="update_all">Update all</string> <string name="update_all">Update all</string>
<string name="some_extensions_may_prompt">Some extensions may still prompt to be installed first.</string>
<string name="updating_extensions">Updating extensions</string> <string name="updating_extensions">Updating extensions</string>
<plurals name="_updates_pending"> <plurals name="_updates_pending">
<item quantity="one">%d update pending</item> <item quantity="one">%d update pending</item>
@ -984,5 +985,6 @@
<string name="use_default">Use default</string> <string name="use_default">Use default</string>
<string name="view_all_errors">View all errors</string> <string name="view_all_errors">View all errors</string>
<string name="view_chapters">View chapters</string> <string name="view_chapters">View chapters</string>
<string name="warning">Warning</string>
<string name="wifi">Wi-Fi</string> <string name="wifi">Wi-Fi</string>
</resources> </resources>