summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2023-03-31 22:18:37 +0200
committerGitHub <noreply@github.com>2023-03-31 22:18:37 +0200
commit8c9b61e599df6124e39066b409f62cfed083d849 (patch)
tree85e8bbf97ad3f973db9ef8fcaf7940730b83ca93
parentd5321a147b26c80423a4c53428be3b6ff3426e0a (diff)
downloadAntennaPod-8c9b61e599df6124e39066b409f62cfed083d849.zip
Remove 'set lockscreen background' setting (#6385)
Users disable the setting and then wonder why other apps (like Android Auto) do not display the cover image, even though it says so in the setting summary.
-rw-r--r--app/src/main/res/xml/preferences_user_interface.xml6
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java35
-rw-r--r--storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java10
-rw-r--r--ui/i18n/src/main/res/values/strings.xml2
4 files changed, 18 insertions, 35 deletions
diff --git a/app/src/main/res/xml/preferences_user_interface.xml b/app/src/main/res/xml/preferences_user_interface.xml
index ed3f5777a..02d15f6d4 100644
--- a/app/src/main/res/xml/preferences_user_interface.xml
+++ b/app/src/main/res/xml/preferences_user_interface.xml
@@ -73,12 +73,6 @@
android:key="prefCompactNotificationButtons"
android:summary="@string/pref_compact_notification_buttons_sum"
android:title="@string/pref_compact_notification_buttons_title"/>
- <SwitchPreferenceCompat
- android:defaultValue="true"
- android:enabled="true"
- android:key="prefLockscreenBackground"
- android:summary="@string/pref_lockscreen_background_sum"
- android:title="@string/pref_lockscreen_background_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/behavior">
<de.danoeh.antennapod.preferences.MaterialListPreference
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index 488724665..e512f413f 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -13,7 +13,6 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.net.Uri;
@@ -43,7 +42,6 @@ import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.media.MediaBrowserServiceCompat;
-import androidx.preference.PreferenceManager;
import de.danoeh.antennapod.core.service.QuickSettingsTileService;
import de.danoeh.antennapod.core.util.playback.PlayableUtils;
@@ -221,9 +219,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
EventBus.getDefault().register(this);
taskManager = new PlaybackServiceTaskManager(this, taskManagerCallback);
- PreferenceManager.getDefaultSharedPreferences(this)
- .registerOnSharedPreferenceChangeListener(prefListener);
-
recreateMediaSessionIfNeeded();
castStateListener = new CastStateListener(this) {
@Override
@@ -302,7 +297,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
castStateListener.destroy();
cancelPositionObserver();
- PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(prefListener);
if (mediaSession != null) {
mediaSession.release();
mediaSession = null;
@@ -1244,11 +1238,25 @@ public class PlaybackService extends MediaBrowserServiceCompat {
builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle());
builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, p.getFeedTitle());
- if (UserPreferences.setLockscreenBackground() && notificationBuilder.isIconCached()) {
+
+ if (notificationBuilder.isIconCached()) {
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, notificationBuilder.getCachedIcon());
- } else if (isCasting && !TextUtils.isEmpty(p.getImageLocation())) {
- // In the absence of metadata art, the controller dialog takes care of creating it.
- builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, p.getImageLocation());
+ } else {
+ String iconUri = p.getImageLocation();
+ if (p instanceof FeedMedia) { // Don't use embedded cover etc, which Android can't load
+ FeedMedia m = (FeedMedia) p;
+ if (m.getItem() != null) {
+ FeedItem item = m.getItem();
+ if (item.getImageUrl() != null) {
+ iconUri = item.getImageUrl();
+ } else if (item.getFeed() != null) {
+ iconUri = item.getFeed().getImageUrl();
+ }
+ }
+ }
+ if (!TextUtils.isEmpty(iconUri)) {
+ builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, iconUri);
+ }
}
if (stateManager.hasReceivedValidStartCommand()) {
@@ -1820,11 +1828,4 @@ public class PlaybackService extends MediaBrowserServiceCompat {
}
}
};
-
- private final SharedPreferences.OnSharedPreferenceChangeListener prefListener =
- (sharedPreferences, key) -> {
- if (UserPreferences.PREF_LOCKSCREEN_BACKGROUND.equals(key)) {
- updateNotificationAndMediaSession(getPlayable());
- }
- };
}
diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java
index fda95ccd7..1099d356e 100644
--- a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java
+++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java
@@ -55,7 +55,6 @@ public class UserPreferences {
public static final String PREF_SHOW_TIME_LEFT = "showTimeLeft";
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons";
- public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
private static final String PREF_SHOW_AUTO_DOWNLOAD_REPORT = "prefShowAutoDownloadReport";
public static final String PREF_DEFAULT_PAGE = "prefDefaultPage";
@@ -292,15 +291,6 @@ public class UserPreferences {
}
/**
- * Returns true if the lockscreen background should be set to the current episode's image
- *
- * @return {@code true} if the lockscreen background should be set, {@code false} otherwise
- */
- public static boolean setLockscreenBackground() {
- return prefs.getBoolean(PREF_LOCKSCREEN_BACKGROUND, true);
- }
-
- /**
* Returns true if download reports are shown
*
* @return {@code true} if download reports are shown, {@code false} otherwise
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index 2a2f7b6d1..fba8b895e 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -485,8 +485,6 @@
<string name="pref_compact_notification_buttons_sum">Change the playback buttons when the notification is collapsed. The play/pause button is always included.</string>
<string name="pref_compact_notification_buttons_dialog_title">Select a maximum of %1$d items</string>
<string name="pref_compact_notification_buttons_dialog_error">You can only select a maximum of %1$d items.</string>
- <string name="pref_lockscreen_background_title">Set Lockscreen Background</string>
- <string name="pref_lockscreen_background_sum">Set the lockscreen background to the current episode\'s image. As a side effect, this will also show the image in third party apps.</string>
<string name="pref_enqueue_location_title">Enqueue Location</string>
<string name="pref_enqueue_location_sum">Add episodes to: %1$s</string>
<string name="enqueue_location_back">Back</string>