diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-06-29 19:58:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-29 19:58:24 +0200 |
commit | d295614933bee7991ba65fe89cc34c0cbd17fb07 (patch) | |
tree | 5cc148ab97465f29a2c748adc2a449d54e32d668 /core/src | |
parent | de8c3a6ae696eded5ccf2bc84cce1ccd05f9dfb7 (diff) | |
parent | b47da4205cabec0fc828019ae7d5a51f40e12c52 (diff) | |
download | AntennaPod-d295614933bee7991ba65fe89cc34c0cbd17fb07.zip |
Merge pull request #2048 from domingos86/castdialogimage-issue1910
Fix Cast Dialog image
Diffstat (limited to 'core/src')
6 files changed, 39 insertions, 22 deletions
diff --git a/core/src/free/java/de/danoeh/antennapod/core/CastCallbacks.java b/core/src/free/java/de/danoeh/antennapod/core/CastCallbacks.java new file mode 100644 index 000000000..2e266c736 --- /dev/null +++ b/core/src/free/java/de/danoeh/antennapod/core/CastCallbacks.java @@ -0,0 +1,7 @@ +package de.danoeh.antennapod.core; + +/** + * Callbacks for Chromecast support on the core module + */ +public interface CastCallbacks { +} diff --git a/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java b/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java index d1c93d782..eb2e6fc9e 100644 --- a/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java +++ b/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java @@ -30,6 +30,8 @@ public class ClientConfig { public static DBTasksCallbacks dbTasksCallbacks; + public static CastCallbacks castCallbacks; + private static boolean initialized = false; public static synchronized void initialize(Context context) { 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 76c960607..88b2c70de 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 @@ -28,11 +28,9 @@ import android.support.v7.app.NotificationCompat; import android.text.TextUtils; import android.util.Log; import android.util.Pair; -import android.view.Display; import android.view.InputDevice; import android.view.KeyEvent; import android.view.SurfaceHolder; -import android.view.WindowManager; import android.widget.Toast; import com.bumptech.glide.Glide; @@ -941,35 +939,30 @@ public class PlaybackService extends Service { MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, p.getFeedTitle()); builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, p.getEpisodeTitle()); + builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle()); builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, p.getDuration()); builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle()); - builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle()); + builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, p.getFeedTitle()); - if (p.getImageLocation() != null && UserPreferences.setLockscreenBackground()) { - builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageLocation().toString()); - try { - if (isCasting) { + String imageLocation = p.getImageLocation(); + + if (!TextUtils.isEmpty(imageLocation)) { + if (UserPreferences.setLockscreenBackground()) { + builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, imageLocation); + try { Bitmap art = Glide.with(this) - .load(p.getImageLocation()) + .load(imageLocation) .asBitmap() .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .get(); builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art); - } else { - WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); - Display display = wm.getDefaultDisplay(); - Bitmap art = Glide.with(this) - .load(p.getImageLocation()) - .asBitmap() - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .centerCrop() - .into(display.getWidth(), display.getHeight()) - .get(); - builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art); + } catch (Throwable tr) { + Log.e(TAG, Log.getStackTraceString(tr)); } - } catch (Throwable tr) { - Log.e(TAG, Log.getStackTraceString(tr)); + } else if (isCasting) { + // In the absence of metadata art, the controller dialog takes care of creating it. + builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, imageLocation); } } if (!Thread.currentThread().isInterrupted() && started) { diff --git a/core/src/play/java/de/danoeh/antennapod/core/CastCallbacks.java b/core/src/play/java/de/danoeh/antennapod/core/CastCallbacks.java new file mode 100644 index 000000000..770fee9b9 --- /dev/null +++ b/core/src/play/java/de/danoeh/antennapod/core/CastCallbacks.java @@ -0,0 +1,12 @@ +package de.danoeh.antennapod.core; + +import android.support.annotation.Nullable; +import android.support.v7.app.MediaRouteDialogFactory; + +/** + * Callbacks for Chromecast support on the core module + */ +public interface CastCallbacks { + + @Nullable MediaRouteDialogFactory getMediaRouterDialogFactory(); +} diff --git a/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java b/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java index 9bbccbb82..3dfd6ea65 100644 --- a/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java +++ b/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java @@ -31,6 +31,8 @@ public class ClientConfig { public static DBTasksCallbacks dbTasksCallbacks; + public static CastCallbacks castCallbacks; + private static boolean initialized = false; public static synchronized void initialize(Context context) { diff --git a/core/src/play/java/de/danoeh/antennapod/core/cast/CastManager.java b/core/src/play/java/de/danoeh/antennapod/core/cast/CastManager.java index 66b4558be..0674990f1 100644 --- a/core/src/play/java/de/danoeh/antennapod/core/cast/CastManager.java +++ b/core/src/play/java/de/danoeh/antennapod/core/cast/CastManager.java @@ -62,6 +62,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeUnit; +import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.R; import static com.google.android.gms.cast.RemoteMediaPlayer.RESUME_STATE_PLAY; @@ -130,12 +131,12 @@ public class CastManager extends BaseCastManager implements OnFailedListener { public static synchronized CastManager init(Context context) { if (INSTANCE == null) { - //TODO also setup dialog factory if necessary CastConfiguration castConfiguration = new CastConfiguration.Builder(CAST_APP_ID) .enableDebug() .enableAutoReconnect() .enableWifiReconnection() .setLaunchOptions(true, Locale.getDefault()) + .setMediaRouteDialogFactory(ClientConfig.castCallbacks.getMediaRouterDialogFactory()) .build(); Log.d(TAG, "New instance of CastManager is created"); if (ConnectionResult.SUCCESS != GoogleApiAvailability.getInstance() |