summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteleoflexuous <116514517+teleoflexuous@users.noreply.github.com>2024-07-18 23:14:59 +0200
committerGitHub <noreply@github.com>2024-07-18 23:14:59 +0200
commit30dca237fd2d404b117bb0dc4f7a6dc62e45a227 (patch)
treeba4680e70450b029a1de40d129a1ed89cded9782
parenta2806562b50fd5d871ad0cd5b88a4a8a420add86 (diff)
downloadAntennaPod-30dca237fd2d404b117bb0dc4f7a6dc62e45a227.zip
Announce episode download start/end with Talkback (#7272)
-rw-r--r--net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/DownloadAnnouncer.java27
-rw-r--r--net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java3
-rw-r--r--ui/i18n/src/main/res/values/strings.xml2
3 files changed, 32 insertions, 0 deletions
diff --git a/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/DownloadAnnouncer.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/DownloadAnnouncer.java
new file mode 100644
index 000000000..e06c6d46f
--- /dev/null
+++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/DownloadAnnouncer.java
@@ -0,0 +1,27 @@
+package de.danoeh.antennapod.net.download.service.episode;
+
+import android.content.Context;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+import de.danoeh.antennapod.net.download.service.R;
+
+public abstract class DownloadAnnouncer {
+ public static void announceStart(Context context, String episodeTitle) {
+ announce(context, R.string.download_started_talkback, episodeTitle);
+ }
+
+ public static void announceCompleted(Context context, String episodeTitle) {
+ announce(context, R.string.download_completed_talkback, episodeTitle);
+ }
+
+ private static void announce(Context context, int messageTemplate, String episodeTitle) {
+ String message = context.getString(messageTemplate, episodeTitle);
+ AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
+ if (am != null && am.isEnabled()) {
+ AccessibilityEvent event = AccessibilityEvent.obtain();
+ event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
+ event.getText().add(message);
+ am.sendAccessibilityEvent(event);
+ }
+ }
+}
diff --git a/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java
index ff548c039..c5620695c 100644
--- a/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java
+++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java
@@ -167,6 +167,8 @@ public class EpisodeDownloadWorker extends Worker {
wifiLock = wifiManager.createWifiLock(TAG);
wifiLock.acquire();
}
+
+ DownloadAnnouncer.announceStart(getApplicationContext(), request.getTitle());
try {
downloader.call();
} catch (Exception e) {
@@ -190,6 +192,7 @@ public class EpisodeDownloadWorker extends Worker {
getApplicationContext(), downloader.getResult(), request);
handler.run();
DBWriter.addDownloadStatus(handler.getUpdatedStatus());
+ DownloadAnnouncer.announceCompleted(getApplicationContext(), request.getTitle());
return Result.success();
}
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index 44fd4ba6d..5c1f8fe25 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -710,6 +710,8 @@
<string name="next_chapter">Next chapter</string>
<string name="shuffle_suggestions">Shuffle suggestions</string>
<string name="add_preset">Add preset</string>
+ <string name="download_started_talkback">Download started for %1$s</string>
+ <string name="download_completed_talkback">Download completed for %1$s</string>
<!-- Feed settings/information screen -->
<string name="authentication_label">Authentication</string>