Some working, some not
This commit is contained in:
parent
ed76fffc30
commit
f5812fe894
|
@ -5,6 +5,7 @@ apply plugin: 'com.android.application'
|
|||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:21.0.3'
|
||||
compile 'com.android.support:appcompat-v7:21.0.3'
|
||||
|
@ -14,7 +15,6 @@ dependencies {
|
|||
exclude group: 'org.json', module: 'json'
|
||||
}
|
||||
compile 'commons-io:commons-io:2.4'
|
||||
compile 'com.jayway.android.robotium:robotium-solo:5.2.1'
|
||||
compile 'org.jsoup:jsoup:1.7.3'
|
||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||
compile 'com.squareup.okhttp:okhttp:2.3.0'
|
||||
|
@ -22,6 +22,7 @@ dependencies {
|
|||
compile 'com.squareup.okio:okio:1.2.0'
|
||||
compile 'de.greenrobot:eventbus:2.4.0'
|
||||
compile 'com.joanzapata.android:android-iconify:1.0.9'
|
||||
|
||||
compile project(':core')
|
||||
compile project(':library:drag-sort-listview')
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.test.antennapod.ui;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.test.FlakyTest;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.robotium.solo.Solo;
|
||||
|
@ -85,6 +86,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
|
|||
solo.waitForText(solo.getString(R.string.subscribed_label));
|
||||
}
|
||||
|
||||
@FlakyTest(tolerance = 3)
|
||||
public void testClickNavDrawer() throws Exception {
|
||||
uiTestUtils.addLocalFeedData(false);
|
||||
|
||||
|
@ -142,6 +144,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
|
|||
return ((MainActivity)solo.getCurrentActivity()).getMainActivtyActionBar().getTitle().toString();
|
||||
}
|
||||
|
||||
@FlakyTest(tolerance = 3)
|
||||
public void testGoToPreferences() {
|
||||
openNavDrawer();
|
||||
solo.clickOnText(solo.getString(R.string.settings_label));
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package de.test.antennapod.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.robotium.solo.Condition;
|
||||
import com.robotium.solo.Solo;
|
||||
import com.robotium.solo.Timeout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.AudioplayerActivity;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
|
@ -28,6 +29,8 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
|
|||
private Solo solo;
|
||||
private UITestUtils uiTestUtils;
|
||||
|
||||
private Context context;
|
||||
|
||||
public PlaybackTest() {
|
||||
super(MainActivity.class);
|
||||
}
|
||||
|
@ -36,28 +39,33 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
|
|||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
solo = new Solo(getInstrumentation(), getActivity());
|
||||
uiTestUtils = new UITestUtils(getInstrumentation().getTargetContext());
|
||||
context = getInstrumentation().getContext();
|
||||
|
||||
uiTestUtils = new UITestUtils(context);
|
||||
uiTestUtils.setup();
|
||||
|
||||
// create database
|
||||
PodDBAdapter adapter = new PodDBAdapter(getInstrumentation().getTargetContext());
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
adapter.open();
|
||||
adapter.close();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getInstrumentation().getTargetContext());
|
||||
prefs.edit().putBoolean(UserPreferences.PREF_UNPAUSE_ON_HEADSET_RECONNECT, false).commit();
|
||||
prefs.edit().putBoolean(UserPreferences.PREF_PAUSE_ON_HEADSET_DISCONNECT, false).commit();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit()
|
||||
.putBoolean(UserPreferences.PREF_UNPAUSE_ON_HEADSET_RECONNECT, false)
|
||||
.putBoolean(UserPreferences.PREF_PAUSE_ON_HEADSET_DISCONNECT, false)
|
||||
.putString(UserPreferences.PREF_HIDDEN_DRAWER_ITEMS, "")
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
uiTestUtils.tearDown();
|
||||
solo.finishOpenedActivities();
|
||||
PodDBAdapter.deleteDatabase(getInstrumentation().getTargetContext());
|
||||
PodDBAdapter.deleteDatabase(context);
|
||||
|
||||
// shut down playback service
|
||||
skipEpisode();
|
||||
getInstrumentation().getTargetContext().sendBroadcast(
|
||||
new Intent(PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
@ -67,70 +75,97 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
|
|||
}
|
||||
|
||||
private void setContinuousPlaybackPreference(boolean value) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getInstrumentation().getTargetContext());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putBoolean(UserPreferences.PREF_FOLLOW_QUEUE, value).commit();
|
||||
}
|
||||
|
||||
private void skipEpisode() {
|
||||
Intent skipIntent = new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||
getInstrumentation().getTargetContext().sendBroadcast(skipIntent);
|
||||
context.sendBroadcast(skipIntent);
|
||||
}
|
||||
|
||||
private void startLocalPlayback() {
|
||||
assertTrue(solo.waitForActivity(MainActivity.class));
|
||||
openNavDrawer();
|
||||
|
||||
solo.clickOnText(solo.getString(R.string.all_episodes_label));
|
||||
solo.waitForView(android.R.id.list);
|
||||
final List<FeedItem> episodes = DBReader.getRecentlyPublishedEpisodes(context, 10);
|
||||
assertTrue(solo.waitForView(solo.getView(R.id.butSecondaryAction)));
|
||||
|
||||
solo.clickOnView(solo.getView(R.id.butSecondaryAction));
|
||||
assertTrue(solo.waitForActivity(AudioplayerActivity.class));
|
||||
assertTrue(solo.waitForView(solo.getView(R.id.butPlay)));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return episodes.get(0).getMedia().isCurrentlyPlaying();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
private void startLocalPlaybackFromQueue() {
|
||||
assertTrue(solo.waitForActivity(MainActivity.class));
|
||||
openNavDrawer();
|
||||
solo.clickOnText(solo.getString(R.string.queue_label));
|
||||
assertTrue(solo.waitForView(solo.getView(R.id.butSecondaryAction)));
|
||||
final List<FeedItem> queue = DBReader.getQueue(context);
|
||||
solo.clickOnImageButton(1);
|
||||
assertTrue(solo.waitForActivity(AudioplayerActivity.class));
|
||||
assertTrue(solo.waitForView(solo.getView(R.id.butPlay)));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return queue.get(0).getMedia().isCurrentlyPlaying();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testStartLocal() throws Exception {
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
DBWriter.clearQueue(getInstrumentation().getTargetContext()).get();
|
||||
DBWriter.clearQueue(context).get();
|
||||
startLocalPlayback();
|
||||
|
||||
solo.clickOnView(solo.getView(R.id.butPlay));
|
||||
}
|
||||
|
||||
public void testContinousPlaybackOffSingleEpisode() throws Exception {
|
||||
setContinuousPlaybackPreference(false);
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
DBWriter.clearQueue(getInstrumentation().getTargetContext()).get();
|
||||
DBWriter.clearQueue(context).get();
|
||||
startLocalPlayback();
|
||||
assertTrue(solo.waitForActivity(MainActivity.class));
|
||||
}
|
||||
|
||||
|
||||
public void testContinousPlaybackOffMultipleEpisodes() throws Exception {
|
||||
setContinuousPlaybackPreference(false);
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
List<FeedItem> queue = DBReader.getQueue(getInstrumentation().getTargetContext());
|
||||
FeedItem second = queue.get(0);
|
||||
List<FeedItem> queue = DBReader.getQueue(context);
|
||||
final FeedItem first = queue.get(0);
|
||||
final FeedItem second = queue.get(1);
|
||||
|
||||
startLocalPlaybackFromQueue();
|
||||
assertTrue(solo.waitForText(second.getTitle()));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return first.getMedia().isCurrentlyPlaying() == false;
|
||||
}
|
||||
}, 10000);
|
||||
Thread.sleep(1000);
|
||||
assertTrue(second.getMedia().isCurrentlyPlaying() == false);
|
||||
}
|
||||
|
||||
public void testContinuousPlaybackOnMultipleEpisodes() throws Exception {
|
||||
setContinuousPlaybackPreference(true);
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
List<FeedItem> queue = DBReader.getQueue(getInstrumentation().getTargetContext());
|
||||
FeedItem second = queue.get(1);
|
||||
List<FeedItem> queue = DBReader.getQueue(context);
|
||||
final FeedItem first = queue.get(0);
|
||||
final FeedItem second = queue.get(1);
|
||||
|
||||
startLocalPlaybackFromQueue();
|
||||
assertTrue(solo.waitForText(second.getTitle()));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return first.getMedia().isCurrentlyPlaying() == false;
|
||||
}
|
||||
}, 10000);
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return second.getMedia().isCurrentlyPlaying() == true;
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,14 +174,24 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
|
|||
private void replayEpisodeCheck(boolean followQueue) throws Exception {
|
||||
setContinuousPlaybackPreference(followQueue);
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
DBWriter.clearQueue(getInstrumentation().getTargetContext()).get();
|
||||
String title = ((TextView) solo.getView(R.id.txtvTitle)).getText().toString();
|
||||
DBWriter.clearQueue(context).get();
|
||||
final List<FeedItem> episodes = DBReader.getRecentlyPublishedEpisodes(context, 10);
|
||||
|
||||
startLocalPlayback();
|
||||
assertTrue(solo.waitForText(title));
|
||||
assertTrue(solo.waitForActivity(MainActivity.class));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return false == episodes.get(0).getMedia().isCurrentlyPlaying();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
|
||||
startLocalPlayback();
|
||||
assertTrue(solo.waitForText(title));
|
||||
assertTrue(solo.waitForActivity(MainActivity.class));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return false == episodes.get(0).getMedia().isCurrentlyPlaying();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testReplayEpisodeContinuousPlaybackOn() throws Exception {
|
||||
|
|
|
@ -0,0 +1,451 @@
|
|||
package de.test.antennapod.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
import com.robotium.solo.Condition;
|
||||
import com.robotium.solo.Solo;
|
||||
import com.robotium.solo.Timeout;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
|
||||
public class PreferencesTest extends ActivityInstrumentationTestCase2<PreferenceActivity> {
|
||||
|
||||
private static final String TAG = "PreferencesTest";
|
||||
|
||||
private Solo solo;
|
||||
private Context context;
|
||||
private Resources res;
|
||||
|
||||
public PreferencesTest() {
|
||||
super(PreferenceActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
solo = new Solo(getInstrumentation(), getActivity());
|
||||
Timeout.setSmallTimeout(500);
|
||||
Timeout.setLargeTimeout(1000);
|
||||
context = getInstrumentation().getTargetContext();
|
||||
res = getActivity().getResources();
|
||||
UserPreferences.createInstance(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
solo.finishOpenedActivities();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testSwitchTheme() {
|
||||
final int theme = UserPreferences.getTheme();
|
||||
int otherTheme;
|
||||
if(theme == de.danoeh.antennapod.core.R.style.Theme_AntennaPod_Light) {
|
||||
otherTheme = R.string.pref_theme_title_dark;
|
||||
} else {
|
||||
otherTheme = R.string.pref_theme_title_light;
|
||||
}
|
||||
solo.clickOnText(solo.getString(R.string.pref_set_theme_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clickOnText(solo.getString(otherTheme));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getTheme() != theme;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testSwitchThemeBack() {
|
||||
final int theme = UserPreferences.getTheme();
|
||||
int otherTheme;
|
||||
if(theme == de.danoeh.antennapod.core.R.style.Theme_AntennaPod_Light) {
|
||||
otherTheme = R.string.pref_theme_title_dark;
|
||||
} else {
|
||||
otherTheme = R.string.pref_theme_title_light;
|
||||
}
|
||||
solo.clickOnText(solo.getString(R.string.pref_set_theme_title));
|
||||
solo.waitForDialogToOpen(1000);
|
||||
solo.clickOnText(solo.getString(otherTheme));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getTheme() != theme;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testExpandNotification() {
|
||||
final int priority = UserPreferences.getNotifyPriority();
|
||||
solo.clickOnText(solo.getString(R.string.pref_expandNotify_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return priority != UserPreferences.getNotifyPriority();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_expandNotify_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return priority == UserPreferences.getNotifyPriority();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testEnablePersistentPlaybackControls() {
|
||||
final boolean persistNotify = UserPreferences.isPersistNotify();
|
||||
solo.clickOnText(solo.getString(R.string.pref_persistNotify_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return persistNotify != UserPreferences.isPersistNotify();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_persistNotify_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return persistNotify == UserPreferences.isPersistNotify();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testEnqueueAtFront() {
|
||||
final boolean enqueueAtFront = UserPreferences.enqueueAtFront();
|
||||
solo.clickOnText(solo.getString(R.string.pref_queueAddToFront_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return enqueueAtFront != UserPreferences.enqueueAtFront();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_queueAddToFront_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return enqueueAtFront == UserPreferences.enqueueAtFront();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testHeadPhonesDisconnect() {
|
||||
final boolean pauseOnHeadsetDisconnect = UserPreferences.isPauseOnHeadsetDisconnect();
|
||||
solo.clickOnText(solo.getString(R.string.pref_pauseOnHeadsetDisconnect_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return pauseOnHeadsetDisconnect != UserPreferences.isPauseOnHeadsetDisconnect();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_pauseOnHeadsetDisconnect_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return pauseOnHeadsetDisconnect == UserPreferences.isPauseOnHeadsetDisconnect();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testHeadPhonesReconnect() {
|
||||
if(UserPreferences.isPauseOnHeadsetDisconnect() == false) {
|
||||
solo.clickOnText(solo.getString(R.string.pref_pauseOnHeadsetDisconnect_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.isPauseOnHeadsetDisconnect();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
final boolean unpauseOnHeadsetReconnect = UserPreferences.isUnpauseOnHeadsetReconnect();
|
||||
solo.clickOnText(solo.getString(R.string.pref_unpauseOnHeadsetReconnect_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return unpauseOnHeadsetReconnect != UserPreferences.isUnpauseOnHeadsetReconnect();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_unpauseOnHeadsetReconnect_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return unpauseOnHeadsetReconnect == UserPreferences.isUnpauseOnHeadsetReconnect();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testContinuousPlayback() {
|
||||
final boolean continuousPlayback = UserPreferences.isFollowQueue();
|
||||
solo.clickOnText(solo.getString(R.string.pref_followQueue_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return continuousPlayback != UserPreferences.isFollowQueue();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_followQueue_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return continuousPlayback == UserPreferences.isFollowQueue();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testAutoDelete() {
|
||||
final boolean autoDelete = UserPreferences.isAutoDelete();
|
||||
solo.clickOnText(solo.getString(R.string.pref_auto_delete_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return autoDelete != UserPreferences.isAutoDelete();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_auto_delete_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override public boolean isSatisfied() {
|
||||
return autoDelete == UserPreferences.isAutoDelete();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testPlaybackSpeeds() {
|
||||
solo.clickOnText(solo.getString(R.string.pref_playback_speed_title));
|
||||
solo.waitForDialogToOpen(1000);
|
||||
assertTrue(solo.searchText(solo.getString(R.string.no_playback_plugin_title)));
|
||||
solo.clickOnText(solo.getString(R.string.close_label));
|
||||
solo.waitForDialogToClose(1000);
|
||||
}
|
||||
|
||||
public void testPauseForInterruptions() {
|
||||
final boolean pauseForFocusLoss = UserPreferences.shouldPauseForFocusLoss();
|
||||
solo.clickOnText(solo.getString(R.string.pref_pausePlaybackForFocusLoss_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return pauseForFocusLoss != UserPreferences.shouldPauseForFocusLoss();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_auto_delete_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return pauseForFocusLoss == UserPreferences.shouldPauseForFocusLoss();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testDisableUpdateInterval() {
|
||||
solo.clickOnText(solo.getString(R.string.pref_autoUpdateIntervall_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clickOnText(solo.getString(R.string.pref_update_interval_hours_manual));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getUpdateInterval() == 0;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
public void testSetUpdateInterval() {
|
||||
solo.clickOnText(solo.getString(R.string.pref_autoUpdateIntervall_title));
|
||||
solo.waitForDialogToOpen();
|
||||
String search = "12 " + solo.getString(R.string.pref_update_interval_hours_plural);
|
||||
solo.clickOnText(search);
|
||||
solo.waitForDialogToClose();
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getUpdateInterval() == 12;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testMobileUpdates() {
|
||||
final boolean mobileUpdates = UserPreferences.isAllowMobileUpdate();
|
||||
solo.clickOnText(solo.getString(R.string.pref_mobileUpdate_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return mobileUpdates != UserPreferences.isAllowMobileUpdate();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_mobileUpdate_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return mobileUpdates == UserPreferences.isAllowMobileUpdate();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testSetSequentialDownload() {
|
||||
solo.clickOnText(solo.getString(R.string.pref_parallel_downloads_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clearEditText(0);
|
||||
solo.enterText(0, "1");
|
||||
solo.clickOnText(solo.getString(android.R.string.ok));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getParallelDownloads() == 1;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testSetParallelDownloads() {
|
||||
solo.clickOnText(solo.getString(R.string.pref_parallel_downloads_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clearEditText(0);
|
||||
solo.enterText(0, "10");
|
||||
solo.clickOnText(solo.getString(android.R.string.ok));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getParallelDownloads() == 10;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testSetParallelDownloadsInvalidInput() {
|
||||
solo.clickOnText(solo.getString(R.string.pref_parallel_downloads_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clearEditText(0);
|
||||
solo.enterText(0, "0");
|
||||
assertEquals("1", solo.getEditText(0).getText().toString());
|
||||
solo.clearEditText(0);
|
||||
solo.enterText(0, "100");
|
||||
assertEquals("50", solo.getEditText(0).getText().toString());
|
||||
}
|
||||
|
||||
public void testSetEpisodeCache() {
|
||||
String[] entries = res.getStringArray(R.array.episode_cache_size_entries);
|
||||
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
||||
String entry = entries[entries.length/2];
|
||||
final int value = Integer.valueOf(values[values.length/2]);
|
||||
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clickOnText(entry);
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getEpisodeCacheSize() == value;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testSetEpisodeCacheMin() {
|
||||
String[] entries = res.getStringArray(R.array.episode_cache_size_entries);
|
||||
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
||||
String minEntry = entries[0];
|
||||
final int minValue = Integer.valueOf(values[0]);
|
||||
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
||||
solo.waitForDialogToOpen(1000);
|
||||
solo.scrollUp();
|
||||
solo.clickOnText(minEntry);
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getEpisodeCacheSize() == minValue;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
|
||||
public void testSetEpisodeCacheMax() {
|
||||
String[] entries = res.getStringArray(R.array.episode_cache_size_entries);
|
||||
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
||||
String maxEntry = entries[entries.length-1];
|
||||
final int maxValue = Integer.valueOf(values[values.length-1]);
|
||||
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
||||
solo.waitForDialogToOpen();
|
||||
solo.clickOnText(maxEntry);
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.getEpisodeCacheSize() == maxValue;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testAutomaticDownload() {
|
||||
final boolean automaticDownload = UserPreferences.isEnableAutodownload();
|
||||
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||
solo.waitForText(solo.getString(R.string.pref_automatic_download_title));
|
||||
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return automaticDownload != UserPreferences.isEnableAutodownload();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
if(UserPreferences.isEnableAutodownload() == false) {
|
||||
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||
}
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return UserPreferences.isEnableAutodownload() == true;
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
final boolean enableAutodownloadOnBattery = UserPreferences.isEnableAutodownloadOnBattery();
|
||||
solo.clickOnText(solo.getString(R.string.pref_automatic_download_on_battery_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return enableAutodownloadOnBattery != UserPreferences.isEnableAutodownloadOnBattery();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_automatic_download_on_battery_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return enableAutodownloadOnBattery == UserPreferences.isEnableAutodownloadOnBattery();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
final boolean enableWifiFilter = UserPreferences.isEnableAutodownloadWifiFilter();
|
||||
solo.clickOnText(solo.getString(R.string.pref_autodl_wifi_filter_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return enableWifiFilter != UserPreferences.isEnableAutodownloadWifiFilter();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
solo.clickOnText(solo.getString(R.string.pref_automatic_download_on_battery_title));
|
||||
solo.waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return enableWifiFilter == UserPreferences.isEnableAutodownloadWifiFilter();
|
||||
}
|
||||
}, Timeout.getLargeTimeout());
|
||||
}
|
||||
|
||||
public void testAbout() throws IOException {
|
||||
int numViews = 0, numLinks = 0;
|
||||
InputStream input = getActivity().getResources().getAssets().open("about.html");
|
||||
List<String> lines = IOUtils.readLines(input);
|
||||
input.close();
|
||||
for(String line : lines) {
|
||||
if(line.contains("(View)")) {
|
||||
numViews++;
|
||||
} else if(line.contains("(Link)")) {
|
||||
numLinks++;
|
||||
}
|
||||
}
|
||||
for(int i=0; i < numViews; i++) {
|
||||
solo.clickOnText(solo.getString(R.string.about_pref));
|
||||
solo.clickOnText("(View)", i);
|
||||
solo.goBack();
|
||||
}
|
||||
for(int i=0; i < numLinks; i++) {
|
||||
solo.clickOnText(solo.getString(R.string.about_pref));
|
||||
solo.clickOnText("(Link)", i);
|
||||
solo.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -141,11 +141,12 @@ public class UITestUtils {
|
|||
// create items
|
||||
List<FeedItem> items = new ArrayList<FeedItem>();
|
||||
for (int j = 0; j < NUM_ITEMS_PER_FEED; j++) {
|
||||
FeedItem item = new FeedItem(0, "item" + j, "item" + j, "http://example.com/feed" + i + "/item/" + j, new Date(), true, feed);
|
||||
FeedItem item = new FeedItem(j, "Feed " + (i+1) + ": Item " + (j+1), "item" + j,
|
||||
"http://example.com/feed" + i + "/item/" + j, new Date(), false, feed);
|
||||
items.add(item);
|
||||
|
||||
File mediaFile = newMediaFile("feed-" + i + "-episode-" + j + ".mp3");
|
||||
item.setMedia(new FeedMedia(0, item, 0, 0, mediaFile.length(), "audio/mp3", null, hostFile(mediaFile), false, null, 0));
|
||||
item.setMedia(new FeedMedia(j, item, 0, 0, mediaFile.length(), "audio/mp3", null, hostFile(mediaFile), false, null, 0));
|
||||
|
||||
}
|
||||
feed.setItems(items);
|
||||
|
@ -169,7 +170,9 @@ public class UITestUtils {
|
|||
* @param downloadEpisodes true if episodes should also be marked as downloaded.
|
||||
*/
|
||||
public void addLocalFeedData(boolean downloadEpisodes) throws Exception {
|
||||
if (localFeedDataAdded) throw new IllegalStateException("addLocalFeedData was called twice on the same instance");
|
||||
if (localFeedDataAdded) {
|
||||
throw new IllegalStateException("addLocalFeedData was called twice on the same instance");
|
||||
}
|
||||
if (!feedDataHosted) {
|
||||
addHostedFeedData();
|
||||
}
|
||||
|
|
|
@ -79,10 +79,10 @@ licensed under the Apache 2.0 license <a href="LICENSE_OKIO.txt">(View)</a>
|
|||
<h2>Material Design Icons <a href="https://github.com/google/material-design-icons">(Link)</a></h2>
|
||||
by Google, licensed under an Attribution-ShareAlike 4.0 International license <a href="LICENSE_MATERIAL_DESIGN_ICONS.txt">(View)</a>
|
||||
|
||||
<h2>EventBus <a href="https://github.com/greenrobot/EventBus">(Link>)</a></h2>
|
||||
<h2>EventBus <a href="https://github.com/greenrobot/EventBus">(Link)</a></h2>
|
||||
by greenrobot, licensed under the Apache 2.0 license <a href="LICENSE_EVENTBUS.txt">(View)</a>
|
||||
|
||||
<h2>Iconify <a href="https://github.com/JoanZapata/android-iconify">(Link>)</a></h2>
|
||||
<h2>Iconify <a href="https://github.com/JoanZapata/android-iconify">(Link)</a></h2>
|
||||
by Joan Zapata, licensed under the Apache 2.0 license <a href="LICENSE_ANDROID_ICONIFY.txt">(View)</a>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core;
|
||||
package de.danoeh.antennapod.core.test;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
|
@ -22,7 +22,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.receiver.FeedUpdateReceiver;
|
||||
|
@ -35,37 +34,51 @@ import de.danoeh.antennapod.core.receiver.FeedUpdateReceiver;
|
|||
*/
|
||||
public class UserPreferences implements
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final String IMPORT_DIR = "import/";
|
||||
|
||||
private static final String TAG = "UserPreferences";
|
||||
|
||||
// User Infercasce
|
||||
public static final String PREF_THEME = "prefTheme";
|
||||
public static final String PREF_HIDDEN_DRAWER_ITEMS = "prefHiddenDrawerItems";
|
||||
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||
public static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
|
||||
|
||||
// Queue
|
||||
public static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront";
|
||||
|
||||
// Playback
|
||||
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";
|
||||
public static final String PREF_UNPAUSE_ON_HEADSET_RECONNECT = "prefUnpauseOnHeadsetReconnect";
|
||||
public static final String PREF_FOLLOW_QUEUE = "prefFollowQueue";
|
||||
public static final String PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY = "prefDownloadMediaOnWifiOnly";
|
||||
public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
|
||||
public static final String PREF_PARALLEL_DOWNLOADS = "prefParallelDownloads";
|
||||
public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate";
|
||||
public static final String PREF_AUTO_DELETE = "prefAutoDelete";
|
||||
public static final String PREF_SMART_MARK_AS_PLAYED_SECS = "prefSmartMarkAsPlayedSecs";
|
||||
public static final String PREF_AUTO_FLATTR = "pref_auto_flattr";
|
||||
public static final String PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD = "prefAutoFlattrPlayedDurationThreshold";
|
||||
public static final String PREF_THEME = "prefTheme";
|
||||
public static final String PREF_DATA_FOLDER = "prefDataFolder";
|
||||
public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl";
|
||||
public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
|
||||
public static final String PREF_ENABLE_AUTODL_ON_BATTERY = "prefEnableAutoDownloadOnBattery";
|
||||
private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
|
||||
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
|
||||
private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
|
||||
private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
|
||||
public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss";
|
||||
public static final String PREF_RESUME_AFTER_CALL = "prefResumeAfterCall";
|
||||
|
||||
// Network
|
||||
public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
|
||||
public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate";
|
||||
public static final String PREF_PARALLEL_DOWNLOADS = "prefParallelDownloads";
|
||||
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
|
||||
public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl";
|
||||
public static final String PREF_ENABLE_AUTODL_ON_BATTERY = "prefEnableAutoDownloadOnBattery";
|
||||
public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
|
||||
public static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
|
||||
|
||||
// Services
|
||||
public static final String PREF_AUTO_FLATTR = "pref_auto_flattr";
|
||||
public static final String PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD = "prefAutoFlattrPlayedDurationThreshold";
|
||||
|
||||
// Other
|
||||
public static final String PREF_DATA_FOLDER = "prefDataFolder";
|
||||
|
||||
// Mediaplayer
|
||||
public static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
|
||||
private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs";
|
||||
private static final String PREF_REWIND_SECS = "prefRewindSecs";
|
||||
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
|
||||
public static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront";
|
||||
public static final String PREF_HIDDEN_DRAWER_ITEMS = "prefHiddenDrawerItems";
|
||||
public static final String PREF_QUEUE_LOCKED = "prefQueueLocked";
|
||||
|
||||
// TODO: Make this value configurable
|
||||
|
@ -76,36 +89,46 @@ public class UserPreferences implements
|
|||
private static UserPreferences instance;
|
||||
private final Context context;
|
||||
|
||||
// Preferences
|
||||
// User Interface
|
||||
private int theme;
|
||||
private List<String> hiddenDrawerItems;
|
||||
private int notifyPriority;
|
||||
private boolean persistNotify;
|
||||
|
||||
// Queue
|
||||
private boolean enqueueAtFront;
|
||||
|
||||
// Playback
|
||||
private boolean pauseOnHeadsetDisconnect;
|
||||
private boolean unpauseOnHeadsetReconnect;
|
||||
private boolean followQueue;
|
||||
private boolean downloadMediaOnWifiOnly;
|
||||
private long updateInterval;
|
||||
private boolean allowMobileUpdate;
|
||||
private boolean autoDelete;
|
||||
private int smartMarkAsPlayedSecs;
|
||||
private boolean autoFlattr;
|
||||
private float autoFlattrPlayedDurationThreshold;
|
||||
private int theme;
|
||||
private boolean enableAutodownload;
|
||||
private boolean enableAutodownloadWifiFilter;
|
||||
private boolean enableAutodownloadOnBattery;
|
||||
private String[] autodownloadSelectedNetworks;
|
||||
private int parallelDownloads;
|
||||
private int episodeCacheSize;
|
||||
private String playbackSpeed;
|
||||
private String[] playbackSpeedArray;
|
||||
private boolean pauseForFocusLoss;
|
||||
private boolean resumeAfterCall;
|
||||
|
||||
// Network
|
||||
private long updateInterval;
|
||||
private boolean allowMobileUpdate;
|
||||
private int parallelDownloads;
|
||||
private int episodeCacheSize;
|
||||
private boolean enableAutodownload;
|
||||
private boolean enableAutodownloadOnBattery;
|
||||
private boolean enableAutodownloadWifiFilter;
|
||||
private String[] autodownloadSelectedNetworks;
|
||||
|
||||
// Services
|
||||
private boolean autoFlattr;
|
||||
private float autoFlattrPlayedDurationThreshold;
|
||||
|
||||
// Settings somewhere in the GUI
|
||||
private String playbackSpeed;
|
||||
private int fastForwardSecs;
|
||||
private int rewindSecs;
|
||||
private boolean isFreshInstall;
|
||||
private int notifyPriority;
|
||||
private boolean persistNotify;
|
||||
private List<String> hiddenDrawerItems;
|
||||
private boolean queueLocked;
|
||||
|
||||
|
||||
private UserPreferences(Context context) {
|
||||
this.context = context;
|
||||
loadPreferences();
|
||||
|
@ -130,50 +153,53 @@ public class UserPreferences implements
|
|||
}
|
||||
|
||||
private void loadPreferences() {
|
||||
SharedPreferences sp = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
EPISODE_CACHE_SIZE_UNLIMITED = context.getResources().getInteger(
|
||||
R.integer.episode_cache_size_unlimited);
|
||||
pauseOnHeadsetDisconnect = sp.getBoolean(
|
||||
PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
|
||||
unpauseOnHeadsetReconnect = sp.getBoolean(
|
||||
PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
// User Interface
|
||||
theme = readThemeValue(sp.getString(PREF_THEME, "0"));
|
||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||
notifyPriority = NotificationCompat.PRIORITY_MAX;
|
||||
} else {
|
||||
notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
|
||||
}
|
||||
hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
|
||||
persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
|
||||
|
||||
// Queue
|
||||
enqueueAtFront = sp.getBoolean(PREF_QUEUE_ADD_TO_FRONT, false);
|
||||
|
||||
// Playback
|
||||
pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
|
||||
unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
|
||||
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
|
||||
downloadMediaOnWifiOnly = sp.getBoolean(
|
||||
PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY, true);
|
||||
updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL,
|
||||
"0"));
|
||||
allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
|
||||
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
|
||||
smartMarkAsPlayedSecs = Integer.valueOf(sp.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
|
||||
autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
|
||||
autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
|
||||
PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
|
||||
theme = readThemeValue(sp.getString(PREF_THEME, "0"));
|
||||
enableAutodownloadWifiFilter = sp.getBoolean(
|
||||
PREF_ENABLE_AUTODL_WIFI_FILTER, false);
|
||||
autodownloadSelectedNetworks = StringUtils.split(
|
||||
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
|
||||
parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
|
||||
episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(
|
||||
PREF_EPISODE_CACHE_SIZE, "20"));
|
||||
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
|
||||
enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
|
||||
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
||||
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
|
||||
PREF_PLAYBACK_SPEED_ARRAY, null));
|
||||
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
|
||||
resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true);
|
||||
|
||||
// Network
|
||||
updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL, "0"));
|
||||
allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
|
||||
parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
|
||||
EPISODE_CACHE_SIZE_UNLIMITED = context.getResources().getInteger(
|
||||
R.integer.episode_cache_size_unlimited);
|
||||
episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(PREF_EPISODE_CACHE_SIZE, "20"));
|
||||
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
|
||||
enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
|
||||
enableAutodownloadWifiFilter = sp.getBoolean(PREF_ENABLE_AUTODL_WIFI_FILTER, false);
|
||||
autodownloadSelectedNetworks = StringUtils.split(
|
||||
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
|
||||
|
||||
// Services
|
||||
autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
|
||||
autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
|
||||
PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
|
||||
|
||||
// MediaPlayer
|
||||
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
||||
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
|
||||
rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
|
||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||
notifyPriority = NotificationCompat.PRIORITY_MAX;
|
||||
}
|
||||
else {
|
||||
notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
|
||||
}
|
||||
persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
|
||||
hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
|
||||
queueLocked = sp.getBoolean(PREF_QUEUE_LOCKED, false);
|
||||
}
|
||||
|
||||
|
@ -224,8 +250,7 @@ public class UserPreferences implements
|
|||
selectedSpeeds[i] = jsonArray.getString(i);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG,
|
||||
"Got JSON error when trying to get speeds from JSONArray");
|
||||
Log.e(TAG, "Got JSON error when trying to get speeds from JSONArray");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -234,76 +259,15 @@ public class UserPreferences implements
|
|||
|
||||
private static void instanceAvailable() {
|
||||
if (instance == null) {
|
||||
throw new IllegalStateException(
|
||||
"UserPreferences was used before being set up");
|
||||
throw new IllegalStateException("UserPreferences was used before being set up");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPauseOnHeadsetDisconnect() {
|
||||
instanceAvailable();
|
||||
return instance.pauseOnHeadsetDisconnect;
|
||||
}
|
||||
|
||||
public static boolean isUnpauseOnHeadsetReconnect() {
|
||||
instanceAvailable();
|
||||
return instance.unpauseOnHeadsetReconnect;
|
||||
}
|
||||
|
||||
public static boolean isFollowQueue() {
|
||||
instanceAvailable();
|
||||
return instance.followQueue;
|
||||
}
|
||||
|
||||
public static boolean isDownloadMediaOnWifiOnly() {
|
||||
instanceAvailable();
|
||||
return instance.downloadMediaOnWifiOnly;
|
||||
}
|
||||
|
||||
public static long getUpdateInterval() {
|
||||
instanceAvailable();
|
||||
return instance.updateInterval;
|
||||
}
|
||||
|
||||
public static boolean isAllowMobileUpdate() {
|
||||
instanceAvailable();
|
||||
return instance.allowMobileUpdate;
|
||||
}
|
||||
|
||||
public static boolean isAutoDelete() {
|
||||
instanceAvailable();
|
||||
return instance.autoDelete;
|
||||
}
|
||||
|
||||
public static int getSmartMarkAsPlayedSecs() {
|
||||
instanceAvailable();;
|
||||
return instance.smartMarkAsPlayedSecs;
|
||||
}
|
||||
|
||||
public static boolean isAutoFlattr() {
|
||||
instanceAvailable();
|
||||
return instance.autoFlattr;
|
||||
}
|
||||
|
||||
public static int getNotifyPriority() {
|
||||
instanceAvailable();
|
||||
return instance.notifyPriority;
|
||||
}
|
||||
|
||||
public static boolean isPersistNotify() {
|
||||
instanceAvailable();
|
||||
return instance.persistNotify;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the time after which an episode should be auto-flattr'd in percent of the episode's
|
||||
* duration.
|
||||
* Returns theme as R.style value
|
||||
*
|
||||
* @return R.style.Theme_AntennaPod_Light or R.style.Theme_AntennaPod_Dark
|
||||
*/
|
||||
public static float getAutoFlattrPlayedDurationThreshold() {
|
||||
instanceAvailable();
|
||||
return instance.autoFlattrPlayedDurationThreshold;
|
||||
}
|
||||
|
||||
public static int getTheme() {
|
||||
instanceAvailable();
|
||||
return instance.theme;
|
||||
|
@ -318,23 +282,70 @@ public class UserPreferences implements
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isEnableAutodownloadWifiFilter() {
|
||||
public static List<String> getHiddenDrawerItems() {
|
||||
instanceAvailable();
|
||||
return instance.enableAutodownloadWifiFilter;
|
||||
return new ArrayList<String>(instance.hiddenDrawerItems);
|
||||
}
|
||||
|
||||
public static String[] getAutodownloadSelectedNetworks() {
|
||||
/**
|
||||
* Returns notification priority.
|
||||
*
|
||||
* @return NotificationCompat.PRIORITY_MAX or NotificationCompat.PRIORITY_DEFAULT
|
||||
*/
|
||||
public static int getNotifyPriority() {
|
||||
instanceAvailable();
|
||||
return instance.autodownloadSelectedNetworks;
|
||||
return instance.notifyPriority;
|
||||
}
|
||||
|
||||
public static int getParallelDownloads() {
|
||||
/**
|
||||
* Returns true if notifications are persistent
|
||||
*
|
||||
* @return {@code true} if notifications are persistent, {@code false} otherwise
|
||||
*/
|
||||
public static boolean isPersistNotify() {
|
||||
instanceAvailable();
|
||||
return instance.parallelDownloads;
|
||||
return instance.persistNotify;
|
||||
}
|
||||
|
||||
public static int getEpisodeCacheSizeUnlimited() {
|
||||
return EPISODE_CACHE_SIZE_UNLIMITED;
|
||||
/**
|
||||
* Returns {@code true} if new queue elements are added to the front
|
||||
*
|
||||
* @return {@code true} if new queue elements are added to the front; {@code false} otherwise
|
||||
*/
|
||||
public static boolean enqueueAtFront() {
|
||||
instanceAvailable();
|
||||
return instance.enqueueAtFront;
|
||||
}
|
||||
|
||||
public static boolean isPauseOnHeadsetDisconnect() {
|
||||
instanceAvailable();
|
||||
return instance.pauseOnHeadsetDisconnect;
|
||||
}
|
||||
|
||||
public static boolean isUnpauseOnHeadsetReconnect() {
|
||||
instanceAvailable();
|
||||
return instance.unpauseOnHeadsetReconnect;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isFollowQueue() {
|
||||
instanceAvailable();
|
||||
return instance.followQueue;
|
||||
}
|
||||
|
||||
public static boolean isAutoDelete() {
|
||||
instanceAvailable();
|
||||
return instance.autoDelete;
|
||||
}
|
||||
|
||||
public static int getSmartMarkAsPlayedSecs() {
|
||||
instanceAvailable();
|
||||
return instance.smartMarkAsPlayedSecs;
|
||||
}
|
||||
|
||||
public static boolean isAutoFlattr() {
|
||||
instanceAvailable();
|
||||
return instance.autoFlattr;
|
||||
}
|
||||
|
||||
public static String getPlaybackSpeed() {
|
||||
|
@ -347,19 +358,28 @@ public class UserPreferences implements
|
|||
return instance.playbackSpeedArray;
|
||||
}
|
||||
|
||||
public static int getFastFowardSecs() {
|
||||
public static boolean shouldPauseForFocusLoss() {
|
||||
instanceAvailable();
|
||||
return instance.fastForwardSecs;
|
||||
return instance.pauseForFocusLoss;
|
||||
}
|
||||
|
||||
public static int getRewindSecs() {
|
||||
public static long getUpdateInterval() {
|
||||
instanceAvailable();
|
||||
return instance.rewindSecs;
|
||||
return instance.updateInterval;
|
||||
}
|
||||
|
||||
public static List<String> getHiddenDrawerItems() {
|
||||
public static boolean isAllowMobileUpdate() {
|
||||
instanceAvailable();
|
||||
return new ArrayList<String>(instance.hiddenDrawerItems);
|
||||
return instance.allowMobileUpdate;
|
||||
}
|
||||
|
||||
public static int getParallelDownloads() {
|
||||
instanceAvailable();
|
||||
return instance.parallelDownloads;
|
||||
}
|
||||
|
||||
public static int getEpisodeCacheSizeUnlimited() {
|
||||
return EPISODE_CACHE_SIZE_UNLIMITED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,9 +402,34 @@ public class UserPreferences implements
|
|||
return instance.enableAutodownloadOnBattery;
|
||||
}
|
||||
|
||||
public static boolean shouldPauseForFocusLoss() {
|
||||
public static boolean isEnableAutodownloadWifiFilter() {
|
||||
instanceAvailable();
|
||||
return instance.pauseForFocusLoss;
|
||||
return instance.enableAutodownloadWifiFilter;
|
||||
}
|
||||
|
||||
public static int getFastFowardSecs() {
|
||||
instanceAvailable();
|
||||
return instance.fastForwardSecs;
|
||||
}
|
||||
|
||||
public static int getRewindSecs() {
|
||||
instanceAvailable();
|
||||
return instance.rewindSecs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the time after which an episode should be auto-flattr'd in percent of the episode's
|
||||
* duration.
|
||||
*/
|
||||
public static float getAutoFlattrPlayedDurationThreshold() {
|
||||
instanceAvailable();
|
||||
return instance.autoFlattrPlayedDurationThreshold;
|
||||
}
|
||||
|
||||
public static String[] getAutodownloadSelectedNetworks() {
|
||||
instanceAvailable();
|
||||
return instance.autodownloadSelectedNetworks;
|
||||
}
|
||||
|
||||
public static boolean shouldResumeAfterCall() {
|
||||
|
@ -392,11 +437,6 @@ public class UserPreferences implements
|
|||
return instance.resumeAfterCall;
|
||||
}
|
||||
|
||||
public static boolean isFreshInstall() {
|
||||
instanceAvailable();
|
||||
return instance.isFreshInstall;
|
||||
}
|
||||
|
||||
public static boolean isQueueLocked() {
|
||||
instanceAvailable();
|
||||
return instance.queueLocked;
|
||||
|
@ -405,77 +445,103 @@ public class UserPreferences implements
|
|||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
|
||||
Log.d(TAG, "Registered change of user preferences. Key: " + key);
|
||||
|
||||
if (key.equals(PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY)) {
|
||||
downloadMediaOnWifiOnly = sp.getBoolean(
|
||||
PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY, true);
|
||||
|
||||
} else if (key.equals(PREF_MOBILE_UPDATE)) {
|
||||
allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
|
||||
|
||||
} else if (key.equals(PREF_FOLLOW_QUEUE)) {
|
||||
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
|
||||
|
||||
} else if (key.equals(PREF_UPDATE_INTERVAL)) {
|
||||
updateInterval = readUpdateInterval(sp.getString(
|
||||
PREF_UPDATE_INTERVAL, "0"));
|
||||
ClientConfig.applicationCallbacks.setUpdateInterval(updateInterval);
|
||||
} else if (key.equals(PREF_AUTO_DELETE)) {
|
||||
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
|
||||
} else if (key.equals(PREF_SMART_MARK_AS_PLAYED_SECS)) {
|
||||
smartMarkAsPlayedSecs = Integer.valueOf(sp.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
|
||||
} else if (key.equals(PREF_AUTO_FLATTR)) {
|
||||
autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
|
||||
} else if (key.equals(PREF_THEME)) {
|
||||
theme = readThemeValue(sp.getString(PREF_THEME, ""));
|
||||
} else if (key.equals(PREF_ENABLE_AUTODL_WIFI_FILTER)) {
|
||||
enableAutodownloadWifiFilter = sp.getBoolean(
|
||||
PREF_ENABLE_AUTODL_WIFI_FILTER, false);
|
||||
} else if (key.equals(PREF_AUTODL_SELECTED_NETWORKS)) {
|
||||
autodownloadSelectedNetworks = StringUtils.split(
|
||||
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
|
||||
} else if(key.equals(PREF_PARALLEL_DOWNLOADS)) {
|
||||
parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
|
||||
} else if (key.equals(PREF_EPISODE_CACHE_SIZE)) {
|
||||
episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(
|
||||
PREF_EPISODE_CACHE_SIZE, "20"));
|
||||
} else if (key.equals(PREF_ENABLE_AUTODL)) {
|
||||
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
|
||||
} else if (key.equals(PREF_ENABLE_AUTODL_ON_BATTERY)) {
|
||||
enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
|
||||
} else if (key.equals(PREF_PLAYBACK_SPEED)) {
|
||||
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
||||
} else if (key.equals(PREF_PLAYBACK_SPEED_ARRAY)) {
|
||||
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
|
||||
PREF_PLAYBACK_SPEED_ARRAY, null));
|
||||
} else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) {
|
||||
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
|
||||
} else if (key.equals(PREF_RESUME_AFTER_CALL)) {
|
||||
resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true);
|
||||
} else if (key.equals(PREF_FAST_FORWARD_SECS)) {
|
||||
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
|
||||
} else if (key.equals(PREF_REWIND_SECS)) {
|
||||
rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
|
||||
} else if (key.equals(PREF_PAUSE_ON_HEADSET_DISCONNECT)) {
|
||||
pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
|
||||
} else if (key.equals(PREF_UNPAUSE_ON_HEADSET_RECONNECT)) {
|
||||
unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
|
||||
} else if (key.equals(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD)) {
|
||||
autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
|
||||
PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
|
||||
} else if (key.equals(PREF_EXPANDED_NOTIFICATION)) {
|
||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||
notifyPriority = NotificationCompat.PRIORITY_MAX;
|
||||
}
|
||||
else {
|
||||
notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
|
||||
}
|
||||
} else if (key.equals(PREF_PERSISTENT_NOTIFICATION)) {
|
||||
persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
|
||||
} else if (key.equals(PREF_HIDDEN_DRAWER_ITEMS)) {
|
||||
hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
|
||||
} else if(key.equals(PREF_QUEUE_LOCKED)) {
|
||||
queueLocked = sp.getBoolean(PREF_QUEUE_LOCKED, false);
|
||||
switch(key) {
|
||||
// User Interface
|
||||
case PREF_THEME:
|
||||
theme = readThemeValue(sp.getString(PREF_THEME, ""));
|
||||
break;
|
||||
case PREF_HIDDEN_DRAWER_ITEMS:
|
||||
hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
|
||||
break;
|
||||
case PREF_EXPANDED_NOTIFICATION:
|
||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||
notifyPriority = NotificationCompat.PRIORITY_MAX;
|
||||
} else {
|
||||
notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case PREF_PERSISTENT_NOTIFICATION:
|
||||
persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
|
||||
break;
|
||||
// Queue
|
||||
case PREF_QUEUE_ADD_TO_FRONT:
|
||||
enqueueAtFront = sp.getBoolean(PREF_QUEUE_ADD_TO_FRONT, false);
|
||||
break;
|
||||
// Playback
|
||||
case PREF_PAUSE_ON_HEADSET_DISCONNECT:
|
||||
pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
|
||||
break;
|
||||
case PREF_UNPAUSE_ON_HEADSET_RECONNECT:
|
||||
unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
|
||||
break;
|
||||
case PREF_FOLLOW_QUEUE:
|
||||
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
|
||||
break;
|
||||
case PREF_AUTO_DELETE:
|
||||
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
|
||||
break;
|
||||
case PREF_SMART_MARK_AS_PLAYED_SECS:
|
||||
smartMarkAsPlayedSecs = Integer.valueOf(sp.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
|
||||
break;
|
||||
case PREF_PLAYBACK_SPEED_ARRAY:
|
||||
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(PREF_PLAYBACK_SPEED_ARRAY, null));
|
||||
break;
|
||||
case PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS:
|
||||
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
|
||||
break;
|
||||
case PREF_RESUME_AFTER_CALL:
|
||||
resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true);
|
||||
break;
|
||||
// Network
|
||||
case PREF_UPDATE_INTERVAL:
|
||||
updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL, "0"));
|
||||
ClientConfig.applicationCallbacks.setUpdateInterval(updateInterval);
|
||||
break;
|
||||
case PREF_MOBILE_UPDATE:
|
||||
allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
|
||||
break;
|
||||
case PREF_PARALLEL_DOWNLOADS:
|
||||
parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
|
||||
break;
|
||||
case PREF_EPISODE_CACHE_SIZE:
|
||||
episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(PREF_EPISODE_CACHE_SIZE, "20"));
|
||||
break;
|
||||
case PREF_ENABLE_AUTODL:
|
||||
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
|
||||
break;
|
||||
case PREF_ENABLE_AUTODL_ON_BATTERY:
|
||||
enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
|
||||
break;
|
||||
case PREF_ENABLE_AUTODL_WIFI_FILTER:
|
||||
enableAutodownloadWifiFilter = sp.getBoolean(PREF_ENABLE_AUTODL_WIFI_FILTER, false);
|
||||
break;
|
||||
case PREF_AUTODL_SELECTED_NETWORKS:
|
||||
autodownloadSelectedNetworks = StringUtils.split(
|
||||
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
|
||||
break;
|
||||
// Services
|
||||
case PREF_AUTO_FLATTR:
|
||||
autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
|
||||
break;
|
||||
case PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD:
|
||||
autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
|
||||
PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
|
||||
break;
|
||||
// Mediaplayer
|
||||
case PREF_PLAYBACK_SPEED:
|
||||
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
||||
break;
|
||||
case PREF_FAST_FORWARD_SECS:
|
||||
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
|
||||
break;
|
||||
case PREF_REWIND_SECS:
|
||||
rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
|
||||
break;
|
||||
case PREF_QUEUE_LOCKED:
|
||||
queueLocked = sp.getBoolean(PREF_QUEUE_LOCKED, false);
|
||||
break;
|
||||
default:
|
||||
Log.w(TAG, "Unhandled key: " + key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,7 +691,6 @@ public class UserPreferences implements
|
|||
}
|
||||
return typeDir;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -653,8 +718,7 @@ public class UserPreferences implements
|
|||
Log.e(TAG, "Could not create .nomedia file");
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, ".nomedia file created");
|
||||
Log.d(TAG, ".nomedia file created");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -418,8 +418,7 @@ public class DBWriter {
|
|||
|
||||
if (item != null) {
|
||||
// add item to either front ot back of queue
|
||||
boolean addToFront = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getBoolean(UserPreferences.PREF_QUEUE_ADD_TO_FRONT, false);
|
||||
boolean addToFront = UserPreferences.enqueueAtFront();
|
||||
|
||||
if(addToFront){
|
||||
queue.add(0, item);
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.EnumSet;
|
|||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.asynctask.FlattrTokenFetcher;
|
||||
|
@ -65,18 +64,15 @@ public class FlattrUtils {
|
|||
|
||||
private static AccessToken retrieveToken() {
|
||||
if (cachedToken == null) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Retrieving access token");
|
||||
Log.d(TAG, "Retrieving access token");
|
||||
String token = PreferenceManager.getDefaultSharedPreferences(
|
||||
ClientConfig.applicationCallbacks.getApplicationInstance())
|
||||
.getString(PREF_ACCESS_TOKEN, null);
|
||||
if (token != null) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Found access token. Caching.");
|
||||
Log.d(TAG, "Found access token. Caching.");
|
||||
cachedToken = new AccessToken(token);
|
||||
} else {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "No access token found");
|
||||
Log.d(TAG, "No access token found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +93,7 @@ public class FlattrUtils {
|
|||
}
|
||||
|
||||
public static void storeToken(AccessToken token) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Storing token");
|
||||
Log.d(TAG, "Storing token");
|
||||
SharedPreferences.Editor editor = PreferenceManager
|
||||
.getDefaultSharedPreferences(ClientConfig.applicationCallbacks.getApplicationInstance()).edit();
|
||||
if (token != null) {
|
||||
|
@ -111,8 +106,7 @@ public class FlattrUtils {
|
|||
}
|
||||
|
||||
public static void deleteToken() {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Deleting flattr token");
|
||||
Log.d(TAG, "Deleting flattr token");
|
||||
storeToken(null);
|
||||
}
|
||||
|
||||
|
@ -169,15 +163,11 @@ public class FlattrUtils {
|
|||
}
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "Got my flattrs list of length " + Integer.toString(myFlattrs.size()) + " comparison date" + firstOfMonthDate);
|
||||
|
||||
for (Flattr fl : myFlattrs) {
|
||||
Thing thing = fl.getThing();
|
||||
Log.d(TAG, "Flattr thing: " + fl.getThingId() + " name: " + thing.getTitle() + " url: " + thing.getUrl() + " on: " + fl.getCreated());
|
||||
}
|
||||
Log.d(TAG, "Got my flattrs list of length " + Integer.toString(myFlattrs.size()) + " comparison date" + firstOfMonthDate);
|
||||
for (Flattr fl : myFlattrs) {
|
||||
Thing thing = fl.getThing();
|
||||
Log.d(TAG, "Flattr thing: " + fl.getThingId() + " name: " + thing.getTitle() + " url: " + thing.getUrl() + " on: " + fl.getCreated());
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.e(TAG, "retrieveFlattrdThings was called with null access token");
|
||||
}
|
||||
|
@ -191,8 +181,7 @@ public class FlattrUtils {
|
|||
}
|
||||
|
||||
public static void revokeAccessToken(Context context) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Revoking access token");
|
||||
Log.d(TAG, "Revoking access token");
|
||||
deleteToken();
|
||||
FlattrServiceCreator.deleteFlattrService();
|
||||
showRevokeDialog(context);
|
||||
|
|
|
@ -88,7 +88,8 @@ public class UndoBarController<T> {
|
|||
}
|
||||
|
||||
public void close() {
|
||||
mHideHandler.post(mHideRunnable);
|
||||
hideUndoBar(true);
|
||||
mUndoListener.onHide(mUndoToken);
|
||||
}
|
||||
|
||||
public void hideUndoBar(boolean immediate) {
|
||||
|
|
Loading…
Reference in New Issue