3
3
Fork 1
mirror of https://github.com/recloudstream/cloudstream.git synced 2024-08-15 01:53:11 +00:00

Add a message to replace delete button if none are selected

This commit is contained in:
Luna712 2024-07-08 21:42:57 -06:00 committed by GitHub
parent 40bfe7210d
commit 0a564b6f33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 4 deletions
app/src/main

View file

@ -126,6 +126,9 @@ class DownloadChildFragment : Fragment() {
handleSelectedChange(it)
binding?.btnDelete?.text =
getString(R.string.delete_count).format(it.count())
binding?.btnDelete?.isVisible = it.isNotEmpty()
binding?.selectItemsText?.isVisible = it.isEmpty()
}
val adapter = DownloadAdapter(
@ -159,7 +162,6 @@ class DownloadChildFragment : Fragment() {
}
private fun handleSelectedChange(selected: MutableList<VisualDownloadCached>) {
val adapter = binding?.downloadChildList?.adapter as? DownloadAdapter
if (selected.isNotEmpty()) {
binding?.downloadDeleteAppbar?.isVisible = true
attachBackPressedCallback()
@ -173,7 +175,7 @@ class DownloadChildFragment : Fragment() {
}
binding?.btnSelectAll?.setOnClickListener {
adapter?.selectAllItems()
(binding?.downloadChildList?.adapter as? DownloadAdapter)?.selectAllItems()
downloadsViewModel.selectAllItems()
}

View file

@ -129,6 +129,9 @@ class DownloadFragment : Fragment() {
handleSelectedChange(it)
binding?.btnDelete?.text =
getString(R.string.delete_count).format(it.count())
binding?.btnDelete?.isVisible = it.isNotEmpty()
binding?.selectItemsText?.isVisible = it.isEmpty()
}
val adapter = DownloadAdapter(
@ -197,7 +200,6 @@ class DownloadFragment : Fragment() {
}
private fun handleSelectedChange(selected: MutableList<VisualDownloadCached>) {
val adapter = binding?.downloadList?.adapter as? DownloadAdapter
if (selected.isNotEmpty()) {
binding?.downloadDeleteAppbar?.isVisible = true
binding?.downloadStorageAppbar?.isVisible = false
@ -212,7 +214,7 @@ class DownloadFragment : Fragment() {
}
binding?.btnSelectAll?.setOnClickListener {
adapter?.selectAllItems()
(binding?.downloadList?.adapter as? DownloadAdapter)?.selectAllItems()
downloadsViewModel.selectAllItems()
}

View file

@ -47,6 +47,16 @@
android:textColor="@android:color/white"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/selectItemsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/downloads_delete_select"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<View
android:layout_width="0dp"
android:layout_height="0dp"

View file

@ -50,6 +50,16 @@
android:textColor="@android:color/white"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/selectItemsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/downloads_delete_select"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<View
android:layout_width="0dp"
android:layout_height="0dp"

View file

@ -149,6 +149,7 @@
<string name="download_canceled">Download Canceled</string>
<string name="download_done">Download Done</string>
<string name="download_format" translatable="false">%s - %s</string>
<string name="downloads_delete_select">Select Items to Delete</string>
<string name="downloads_empty">There are currently no downloads.</string>
<string name="offline_file">Available for watching offline</string>
<string name="select_all">Select All</string>