Announce episode download start/end with Talkback (#7272)
This commit is contained in:
parent
a2806562b5
commit
30dca237fd
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -167,6 +167,8 @@ public class EpisodeDownloadWorker extends Worker {
|
||||||
wifiLock = wifiManager.createWifiLock(TAG);
|
wifiLock = wifiManager.createWifiLock(TAG);
|
||||||
wifiLock.acquire();
|
wifiLock.acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadAnnouncer.announceStart(getApplicationContext(), request.getTitle());
|
||||||
try {
|
try {
|
||||||
downloader.call();
|
downloader.call();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -190,6 +192,7 @@ public class EpisodeDownloadWorker extends Worker {
|
||||||
getApplicationContext(), downloader.getResult(), request);
|
getApplicationContext(), downloader.getResult(), request);
|
||||||
handler.run();
|
handler.run();
|
||||||
DBWriter.addDownloadStatus(handler.getUpdatedStatus());
|
DBWriter.addDownloadStatus(handler.getUpdatedStatus());
|
||||||
|
DownloadAnnouncer.announceCompleted(getApplicationContext(), request.getTitle());
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -710,6 +710,8 @@
|
||||||
<string name="next_chapter">Next chapter</string>
|
<string name="next_chapter">Next chapter</string>
|
||||||
<string name="shuffle_suggestions">Shuffle suggestions</string>
|
<string name="shuffle_suggestions">Shuffle suggestions</string>
|
||||||
<string name="add_preset">Add preset</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 -->
|
<!-- Feed settings/information screen -->
|
||||||
<string name="authentication_label">Authentication</string>
|
<string name="authentication_label">Authentication</string>
|
||||||
|
|
Loading…
Reference in New Issue