Removed ExternalMedia
It was used for "open with" actions, which are no longer supported. We have the local folders feature for that now.
This commit is contained in:
parent
d444e8d23e
commit
3ebbacdf60
|
@ -76,7 +76,6 @@ import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
|
||||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
|
||||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlayableException;
|
import de.danoeh.antennapod.core.util.playback.PlayableException;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlayableUtils;
|
import de.danoeh.antennapod.core.util.playback.PlayableUtils;
|
||||||
|
@ -519,8 +518,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false);
|
boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false);
|
||||||
boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false);
|
boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false);
|
||||||
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0);
|
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0);
|
||||||
//If the user asks to play External Media, the casting session, if on, should end.
|
|
||||||
flavorHelper.castDisconnect(playable instanceof ExternalMedia);
|
|
||||||
if (allowStreamAlways) {
|
if (allowStreamAlways) {
|
||||||
UserPreferences.setAllowMobileStreaming(true);
|
UserPreferences.setAllowMobileStreaming(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,281 +0,0 @@
|
||||||
package de.danoeh.antennapod.core.util.playback;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.SharedPreferences.Editor;
|
|
||||||
import android.media.MediaMetadataRetriever;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import de.danoeh.antennapod.core.feed.Chapter;
|
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
|
||||||
import de.danoeh.antennapod.core.util.DateUtils;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
|
|
||||||
/** Represents a media file that is stored on the local storage device. */
|
|
||||||
public class ExternalMedia implements Playable {
|
|
||||||
public static final int PLAYABLE_TYPE_EXTERNAL_MEDIA = 2;
|
|
||||||
public static final String PREF_SOURCE_URL = "ExternalMedia.PrefSourceUrl";
|
|
||||||
public static final String PREF_POSITION = "ExternalMedia.PrefPosition";
|
|
||||||
public static final String PREF_MEDIA_TYPE = "ExternalMedia.PrefMediaType";
|
|
||||||
public static final String PREF_LAST_PLAYED_TIME = "ExternalMedia.PrefLastPlayedTime";
|
|
||||||
|
|
||||||
private final String source;
|
|
||||||
private String episodeTitle;
|
|
||||||
private String feedTitle;
|
|
||||||
private MediaType mediaType;
|
|
||||||
private Date pubDate;
|
|
||||||
private List<Chapter> chapters;
|
|
||||||
private int duration;
|
|
||||||
private int position;
|
|
||||||
private long lastPlayedTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new playable for files on the sd card.
|
|
||||||
* @param source File path of the file
|
|
||||||
* @param mediaType Type of the file
|
|
||||||
*/
|
|
||||||
public ExternalMedia(String source, MediaType mediaType) {
|
|
||||||
super();
|
|
||||||
this.source = source;
|
|
||||||
this.mediaType = mediaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new playable for files on the sd card.
|
|
||||||
* @param source File path of the file
|
|
||||||
* @param mediaType Type of the file
|
|
||||||
* @param position Position to start from
|
|
||||||
* @param lastPlayedTime Timestamp when it was played last
|
|
||||||
*/
|
|
||||||
public ExternalMedia(String source, MediaType mediaType, int position, long lastPlayedTime) {
|
|
||||||
this(source, mediaType);
|
|
||||||
this.position = position;
|
|
||||||
this.lastPlayedTime = lastPlayedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeString(source);
|
|
||||||
dest.writeString(mediaType.toString());
|
|
||||||
dest.writeInt(position);
|
|
||||||
dest.writeLong(lastPlayedTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToPreferences(Editor prefEditor) {
|
|
||||||
prefEditor.putString(PREF_SOURCE_URL, source);
|
|
||||||
prefEditor.putString(PREF_MEDIA_TYPE, mediaType.toString());
|
|
||||||
prefEditor.putInt(PREF_POSITION, position);
|
|
||||||
prefEditor.putLong(PREF_LAST_PLAYED_TIME, lastPlayedTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadMetadata() throws PlayableException {
|
|
||||||
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
|
|
||||||
try {
|
|
||||||
mmr.setDataSource(source);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new PlayableException("IllegalArgumentException when setting up MediaMetadataReceiver");
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
// http://code.google.com/p/android/issues/detail?id=39770
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new PlayableException("RuntimeException when setting up MediaMetadataRetriever");
|
|
||||||
}
|
|
||||||
episodeTitle = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
|
|
||||||
if (episodeTitle == null) {
|
|
||||||
episodeTitle = FilenameUtils.getName(source);
|
|
||||||
}
|
|
||||||
feedTitle = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
|
|
||||||
try {
|
|
||||||
duration = Integer.parseInt(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new PlayableException("NumberFormatException when reading duration of media file");
|
|
||||||
}
|
|
||||||
|
|
||||||
String dateStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE);
|
|
||||||
if (!TextUtils.isEmpty(dateStr)) {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.getDefault());
|
|
||||||
pubDate = simpleDateFormat.parse(dateStr);
|
|
||||||
} catch (ParseException parseException) {
|
|
||||||
pubDate = DateUtils.parse(dateStr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pubDate = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEpisodeTitle() {
|
|
||||||
return episodeTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<String> loadShownotes() {
|
|
||||||
return () -> "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Chapter> getChapters() {
|
|
||||||
return chapters;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getWebsiteLink() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPaymentLink() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFeedTitle() {
|
|
||||||
return feedTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getIdentifier() {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDuration() {
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getPubDate() {
|
|
||||||
return pubDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLastPlayedTime() {
|
|
||||||
return lastPlayedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MediaType getMediaType() {
|
|
||||||
return mediaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLocalMediaUrl() {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStreamUrl() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean localFileAvailable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean streamAvailable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveCurrentPosition(SharedPreferences pref, int newPosition, long timestamp) {
|
|
||||||
SharedPreferences.Editor editor = pref.edit();
|
|
||||||
editor.putInt(PREF_POSITION, newPosition);
|
|
||||||
editor.putLong(PREF_LAST_PLAYED_TIME, timestamp);
|
|
||||||
position = newPosition;
|
|
||||||
lastPlayedTime = timestamp;
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(int newPosition) {
|
|
||||||
position = newPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDuration(int newDuration) {
|
|
||||||
duration = newDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastPlayedTime(long lastPlayedTime) {
|
|
||||||
this.lastPlayedTime = lastPlayedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlaybackStart() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlaybackPause(Context context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlaybackCompleted(Context context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPlayableType() {
|
|
||||||
return PLAYABLE_TYPE_EXTERNAL_MEDIA;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setChapters(List<Chapter> chapters) {
|
|
||||||
this.chapters = chapters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<ExternalMedia> CREATOR = new Parcelable.Creator<ExternalMedia>() {
|
|
||||||
public ExternalMedia createFromParcel(Parcel in) {
|
|
||||||
String source = in.readString();
|
|
||||||
MediaType type = MediaType.valueOf(in.readString());
|
|
||||||
int position = 0;
|
|
||||||
if (in.dataAvail() > 0) {
|
|
||||||
position = in.readInt();
|
|
||||||
}
|
|
||||||
long lastPlayedTime = 0;
|
|
||||||
if (in.dataAvail() > 0) {
|
|
||||||
lastPlayedTime = in.readLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ExternalMedia(source, type, position, lastPlayedTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExternalMedia[] newArray(int size) {
|
|
||||||
return new ExternalMedia[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageLocation() {
|
|
||||||
if (localFileAvailable()) {
|
|
||||||
return getLocalMediaUrl();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,7 +9,6 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
|
||||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
|
|
||||||
|
@ -53,9 +52,6 @@ public abstract class PlayableUtils {
|
||||||
case FeedMedia.PLAYABLE_TYPE_FEEDMEDIA:
|
case FeedMedia.PLAYABLE_TYPE_FEEDMEDIA:
|
||||||
result = createFeedMediaInstance(pref);
|
result = createFeedMediaInstance(pref);
|
||||||
break;
|
break;
|
||||||
case ExternalMedia.PLAYABLE_TYPE_EXTERNAL_MEDIA:
|
|
||||||
result = createExternalMediaInstance(pref);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
result = null;
|
result = null;
|
||||||
break;
|
break;
|
||||||
|
@ -74,17 +70,4 @@ public abstract class PlayableUtils {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Playable createExternalMediaInstance(SharedPreferences pref) {
|
|
||||||
Playable result = null;
|
|
||||||
String source = pref.getString(ExternalMedia.PREF_SOURCE_URL, null);
|
|
||||||
String mediaType = pref.getString(ExternalMedia.PREF_MEDIA_TYPE, null);
|
|
||||||
if (source != null && mediaType != null) {
|
|
||||||
int position = pref.getInt(ExternalMedia.PREF_POSITION, 0);
|
|
||||||
long lastPlayedTime = pref.getLong(ExternalMedia.PREF_LAST_PLAYED_TIME, 0);
|
|
||||||
result = new ExternalMedia(source, MediaType.valueOf(mediaType),
|
|
||||||
position, lastPlayedTime);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import de.danoeh.antennapod.core.feed.Feed;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
|
||||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +52,7 @@ public class CastUtils {
|
||||||
public static final int MAX_VERSION_FORWARD_COMPATIBILITY = 9999;
|
public static final int MAX_VERSION_FORWARD_COMPATIBILITY = 9999;
|
||||||
|
|
||||||
public static boolean isCastable(Playable media) {
|
public static boolean isCastable(Playable media) {
|
||||||
if (media == null || media instanceof ExternalMedia) {
|
if (media == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (media instanceof FeedMedia || media instanceof RemoteMedia) {
|
if (media instanceof FeedMedia || media instanceof RemoteMedia) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.danoeh.antennapod.core.storage;
|
package de.danoeh.antennapod.core.storage;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.util.playback.RemoteMedia;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
@ -17,9 +18,7 @@ import de.danoeh.antennapod.core.feed.FeedComponent;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMother;
|
import de.danoeh.antennapod.core.feed.FeedMother;
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences.EnqueueLocation;
|
import de.danoeh.antennapod.core.preferences.UserPreferences.EnqueueLocation;
|
||||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
|
||||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
|
|
||||||
import static de.danoeh.antennapod.core.preferences.UserPreferences.EnqueueLocation.AFTER_CURRENTLY_PLAYING;
|
import static de.danoeh.antennapod.core.preferences.UserPreferences.EnqueueLocation.AFTER_CURRENTLY_PLAYING;
|
||||||
|
@ -105,7 +104,7 @@ public class ItemEnqueuePositionCalculatorTest {
|
||||||
{"case option after currently playing, no currentlyPlaying is null",
|
{"case option after currently playing, no currentlyPlaying is null",
|
||||||
concat(TFI_ID, QUEUE_DEFAULT_IDS),
|
concat(TFI_ID, QUEUE_DEFAULT_IDS),
|
||||||
AFTER_CURRENTLY_PLAYING, QUEUE_DEFAULT, ID_CURRENTLY_PLAYING_NULL},
|
AFTER_CURRENTLY_PLAYING, QUEUE_DEFAULT, ID_CURRENTLY_PLAYING_NULL},
|
||||||
{"case option after currently playing, currentlyPlaying is externalMedia",
|
{"case option after currently playing, currentlyPlaying is not a feedMedia",
|
||||||
concat(TFI_ID, QUEUE_DEFAULT_IDS),
|
concat(TFI_ID, QUEUE_DEFAULT_IDS),
|
||||||
AFTER_CURRENTLY_PLAYING, QUEUE_DEFAULT, ID_CURRENTLY_PLAYING_NOT_FEEDMEDIA},
|
AFTER_CURRENTLY_PLAYING, QUEUE_DEFAULT, ID_CURRENTLY_PLAYING_NOT_FEEDMEDIA},
|
||||||
{"case empty queue, option after currently playing",
|
{"case empty queue, option after currently playing",
|
||||||
|
@ -270,7 +269,7 @@ public class ItemEnqueuePositionCalculatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Playable externalMedia() {
|
static Playable externalMedia() {
|
||||||
return new ExternalMedia("http://example.com/episode.mp3", MediaType.AUDIO);
|
return new RemoteMedia(createFeedItem(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static final long ID_CURRENTLY_PLAYING_NULL = -1L;
|
static final long ID_CURRENTLY_PLAYING_NULL = -1L;
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
package de.danoeh.antennapod.core.util.playback;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link ExternalMedia} entity.
|
|
||||||
*/
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class ExternalMediaTest {
|
|
||||||
|
|
||||||
private static final int NOT_SET = -1;
|
|
||||||
private static final int POSITION = 50;
|
|
||||||
private static final int LAST_PLAYED_TIME = 1650;
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
clearSharedPrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CommitPrefEdits")
|
|
||||||
private void clearSharedPrefs() {
|
|
||||||
SharedPreferences prefs = getDefaultSharedPrefs();
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.clear();
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private SharedPreferences getDefaultSharedPrefs() {
|
|
||||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSaveCurrentPositionUpdatesPreferences() {
|
|
||||||
assertEquals(NOT_SET, getDefaultSharedPrefs().getInt(ExternalMedia.PREF_POSITION, NOT_SET));
|
|
||||||
assertEquals(NOT_SET, getDefaultSharedPrefs().getLong(ExternalMedia.PREF_LAST_PLAYED_TIME, NOT_SET));
|
|
||||||
|
|
||||||
ExternalMedia media = new ExternalMedia("source", MediaType.AUDIO);
|
|
||||||
media.saveCurrentPosition(getDefaultSharedPrefs(), POSITION, LAST_PLAYED_TIME);
|
|
||||||
|
|
||||||
assertEquals(POSITION, getDefaultSharedPrefs().getInt(ExternalMedia.PREF_POSITION, NOT_SET));
|
|
||||||
assertEquals(LAST_PLAYED_TIME, getDefaultSharedPrefs().getLong(ExternalMedia.PREF_LAST_PLAYED_TIME, NOT_SET));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue