[Android] OpenSubtitles: add an empty state for the history
Nicolas Pomepuy
git at videolan.org
Thu Nov 21 13:19:11 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Nov 21 09:48:34 2024 +0100| [408efadea35f5ad60de1639d2caa40e82249ebe5] | committer: Duncan McNamara
OpenSubtitles: add an empty state for the history
> https://code.videolan.org/videolan/vlc-android/commit/408efadea35f5ad60de1639d2caa40e82249ebe5
---
application/resources/src/main/res/values/strings.xml | 1 +
.../res/layout/subtitle_downloader_dialog.xml | 18 ++++++++++++++++++
.../gui/dialogs/SubtitleDownloaderDialogFragment.kt | 1 +
.../src/org/videolan/vlc/viewmodels/SubtitlesModel.kt | 1 +
4 files changed, 21 insertions(+)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 9eccab7988..5fd390f276 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -819,6 +819,7 @@
<string name="language_to_download">Language</string>
<string name="delete_the_selected">Delete selection</string>
<string name="download_the_selected">Download selection</string>
+ <string name="no_sub_history">No subtitle for this media</string>
<string name="next">Next</string>
<string name="skip">Skip</string>
<string name="next_step">Next</string>
diff --git a/application/vlc-android/res/layout/subtitle_downloader_dialog.xml b/application/vlc-android/res/layout/subtitle_downloader_dialog.xml
index 2c7bee27c6..8b49f42c1d 100644
--- a/application/vlc-android/res/layout/subtitle_downloader_dialog.xml
+++ b/application/vlc-android/res/layout/subtitle_downloader_dialog.xml
@@ -338,6 +338,24 @@
app:layout_goneMarginTop="40dp"
tools:text="No results found" />
+ <TextView
+ android:id="@+id/no_history"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginBottom="9dp"
+ android:gravity="center_horizontal"
+ android:text="@{viewmodel.observableHistoryEmpty}"
+ android:textColor="?attr/font_light"
+ android:textSize="15sp"
+ android:visibility="@{state == state.History ? View.VISIBLE : View.GONE}"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/subs_history_list"
+ app:layout_constraintBottom_toBottomOf="@+id/subs_history_list"
+ tools:text="No results found" />
+
<Button
android:id="@+id/retry_button"
android:layout_width="wrap_content"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt
index 013bf31996..c75df0eb7b 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt
@@ -246,6 +246,7 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
viewModel.history.observe(this) {
historyAdapter.setList(it)
+ viewModel.observableHistoryEmpty.set(if (it.isEmpty()) getString(R.string.no_sub_history) else "")
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
index 83e7206467..0776e6fdef 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
@@ -84,6 +84,7 @@ class SubtitlesModel(context: Context, private val mediaUri: Uri, private val na
val isApiLoading: MediatorLiveData<Boolean> = MediatorLiveData()
val observableMessage = ObservableField<String>()
val observableError = ObservableField<Boolean>()
+ val observableHistoryEmpty = ObservableField<String>()
val observableResultDescription = ObservableField<Spanned>()
val observableResultDescriptionTalkback = ObservableField<String>()
More information about the Android
mailing list