mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add better dialog formatting for series
This commit is contained in:
parent
5ed9eee407
commit
b5bfc3460b
2 changed files with 40 additions and 10 deletions
|
@ -10,6 +10,7 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
|
import com.lagradost.cloudstream3.isEpisodeBased
|
||||||
import com.lagradost.cloudstream3.isMovieType
|
import com.lagradost.cloudstream3.isMovieType
|
||||||
import com.lagradost.cloudstream3.mvvm.launchSafe
|
import com.lagradost.cloudstream3.mvvm.launchSafe
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
@ -166,19 +167,46 @@ class DownloadViewModel : ViewModel() {
|
||||||
|
|
||||||
val ids = selectedItemsList.map { it.data.id }
|
val ids = selectedItemsList.map { it.data.id }
|
||||||
|
|
||||||
val names = selectedItemsList.mapNotNull {
|
val (seriesNames, names) = selectedItemsList.map { item ->
|
||||||
when (it) {
|
when (item) {
|
||||||
is VisualDownloadCached.Header -> it.data.name
|
is VisualDownloadCached.Header -> {
|
||||||
is VisualDownloadCached.Child -> it.data.name
|
if (item.data.type.isEpisodeBased()) {
|
||||||
}
|
val episodeInfo = "${item.data.name} (${item.totalDownloads} ${
|
||||||
}
|
context.resources.getQuantityString(
|
||||||
|
R.plurals.episodes,
|
||||||
|
item.totalDownloads
|
||||||
|
).lowercase()
|
||||||
|
})"
|
||||||
|
episodeInfo to null
|
||||||
|
} else null to item.data.name
|
||||||
|
}
|
||||||
|
|
||||||
showDeleteConfirmationDialog(context, ids, names)
|
is VisualDownloadCached.Child -> null to item.data.name
|
||||||
|
}
|
||||||
|
}.unzip()
|
||||||
|
|
||||||
|
showDeleteConfirmationDialog(context, ids, names.filterNotNull(), seriesNames.filterNotNull())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showDeleteConfirmationDialog(context: Context, ids: List<Int>, names: List<String>) {
|
private fun showDeleteConfirmationDialog(
|
||||||
|
context: Context,
|
||||||
|
ids: List<Int>,
|
||||||
|
names: List<String>,
|
||||||
|
seriesNames: List<String>
|
||||||
|
) {
|
||||||
val formattedNames = names.joinToString(separator = "\n") { "• $it" }
|
val formattedNames = names.joinToString(separator = "\n") { "• $it" }
|
||||||
val message = context.getString(R.string.delete_message_multiple).format(formattedNames)
|
val formattedSeriesNames = seriesNames.joinToString(separator = "\n") { "• $it" }
|
||||||
|
|
||||||
|
val message = when {
|
||||||
|
seriesNames.isNotEmpty() && names.isEmpty() -> {
|
||||||
|
context.getString(R.string.delete_message_series_only).format(formattedSeriesNames)
|
||||||
|
}
|
||||||
|
seriesNames.isNotEmpty() -> {
|
||||||
|
val seriesSection = context.getString(R.string.delete_message_series_section).format(formattedSeriesNames)
|
||||||
|
context.getString(R.string.delete_message_multiple).format(formattedNames) + "\n\n" + seriesSection
|
||||||
|
}
|
||||||
|
else -> context.getString(R.string.delete_message_multiple).format(formattedNames)
|
||||||
|
}
|
||||||
|
|
||||||
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
|
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
|
||||||
val dialogClickListener =
|
val dialogClickListener =
|
||||||
|
|
|
@ -314,7 +314,9 @@
|
||||||
<string name="go_back_30">-30</string>
|
<string name="go_back_30">-30</string>
|
||||||
<string name="go_forward_30">+30</string>
|
<string name="go_forward_30">+30</string>
|
||||||
<string name="delete_message" formatted="true">This will permanently delete %s\nAre you sure?</string>
|
<string name="delete_message" formatted="true">This will permanently delete %s\nAre you sure?</string>
|
||||||
<string name="delete_message_multiple" formatted="true">Are you sure you want to delete the following items?\n\n%s</string>
|
<string name="delete_message_multiple" formatted="true">Are you sure you want to permanently delete the following items?\n\n%s</string>
|
||||||
|
<string name="delete_message_series_section">You will also permanently delete all episodes in the following series:\n\n%s</string>
|
||||||
|
<string name="delete_message_series_only">Are you sure you want to permanently delete all episodes in the following series?\n\n%s</string>
|
||||||
<string name="resume_time_left" formatted="true">%dm\nremaining</string>
|
<string name="resume_time_left" formatted="true">%dm\nremaining</string>
|
||||||
<string name="resume_remaining" formatted="true">%s\nremaining</string>
|
<string name="resume_remaining" formatted="true">%s\nremaining</string>
|
||||||
<string name="status_ongoing">Ongoing</string>
|
<string name="status_ongoing">Ongoing</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue