feat:added way to clear saved manga progress (#522)
This commit is contained in:
parent
5c1c639f53
commit
a993935433
2 changed files with 35 additions and 0 deletions
|
@ -40,6 +40,7 @@ import ani.dantotsu.px
|
||||||
import ani.dantotsu.settings.FAQActivity
|
import ani.dantotsu.settings.FAQActivity
|
||||||
import ani.dantotsu.settings.saving.PrefManager
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
import ani.dantotsu.settings.saving.PrefName
|
import ani.dantotsu.settings.saving.PrefName
|
||||||
|
import ani.dantotsu.snackString
|
||||||
import ani.dantotsu.toast
|
import ani.dantotsu.toast
|
||||||
import ani.dantotsu.util.customAlertDialog
|
import ani.dantotsu.util.customAlertDialog
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
|
@ -86,6 +87,27 @@ class MangaReadAdapter(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode)
|
val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode)
|
||||||
|
//for removing saved progress
|
||||||
|
binding.sourceTitle.setOnLongClickListener{
|
||||||
|
fragment.requireContext().customAlertDialog().apply {
|
||||||
|
setTitle(" Delete Progress for all chapters of ${media.nameRomaji}")
|
||||||
|
setMessage("This will delete all the locally stored progress for chapters")
|
||||||
|
setPosButton(R.string.ok){
|
||||||
|
val currentChapters = PrefManager.getAllCustomValsForMedia("${media.id}_Chapter")
|
||||||
|
currentChapters.forEach { (key) ->
|
||||||
|
PrefManager.removeCustomVal(key)
|
||||||
|
}
|
||||||
|
val currentChapterWithVolume = PrefManager.getAllCustomValsForMedia("${media.id}_Vol")
|
||||||
|
currentChapterWithVolume.forEach { (key) ->
|
||||||
|
PrefManager.removeCustomVal(key)
|
||||||
|
}
|
||||||
|
snackString("Deleted the progress of Chapters for ${media.nameRomaji}")
|
||||||
|
}
|
||||||
|
setNegButton(R.string.no)
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
binding.mediaSourceNameContainer.isGone = offline
|
binding.mediaSourceNameContainer.isGone = offline
|
||||||
binding.mediaSourceSettings.isGone = offline
|
binding.mediaSourceSettings.isGone = offline
|
||||||
|
|
|
@ -235,6 +235,19 @@ object PrefManager {
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun getAllCustomValsForMedia(prefix: String): Map<String, Any?> {
|
||||||
|
val allEntries = mutableMapOf<String, Any?>()
|
||||||
|
|
||||||
|
irrelevantPreferences?.all?.forEach { (key, value) ->
|
||||||
|
if (key.startsWith(prefix)) {
|
||||||
|
allEntries[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return allEntries
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T> getLiveVal(prefName: PrefName, default: T): SharedPreferenceLiveData<T> {
|
fun <T> getLiveVal(prefName: PrefName, default: T): SharedPreferenceLiveData<T> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue