diff options
Diffstat (limited to 'app')
13 files changed, 141 insertions, 26 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java index 9281cb319..42fa84d20 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java @@ -20,6 +20,7 @@ import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; +import de.danoeh.antennapod.core.feed.FeedPreferences; import de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer; import de.danoeh.antennapod.core.service.playback.PlayerStatus; import de.danoeh.antennapod.core.storage.PodDBAdapter; @@ -116,6 +117,8 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase { private Playable writeTestPlayable(String downloadUrl, String fileUrl) { final Context c = getInstrumentation().getTargetContext(); Feed f = new Feed(0, new Date(), "f", "l", "d", null, null, null, null, "i", null, null, "l", false); + FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NO, null, null); + f.setPreferences(prefs); f.setItems(new ArrayList<FeedItem>()); FeedItem i = new FeedItem(0, "t", "i", "l", new Date(), FeedItem.UNPLAYED, f); f.getItems().add(i); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java index 357335238..fae8baf65 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java @@ -14,11 +14,15 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; +import android.widget.AbsSpinner; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Spinner; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; import android.widget.Toast; import com.joanzapata.android.iconify.Iconify; @@ -41,6 +45,7 @@ import de.danoeh.antennapod.menuhandler.FeedMenuHandler; */ public class FeedInfoActivity extends ActionBarActivity { private static final String TAG = "FeedInfoActivity"; + private boolean autoDeleteChanged = false; public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId"; @@ -55,6 +60,7 @@ public class FeedInfoActivity extends ActionBarActivity { private EditText etxtUsername; private EditText etxtPassword; private CheckBox cbxAutoDownload; + private Spinner spnAutoDelete; private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() { @Override @@ -92,6 +98,7 @@ public class FeedInfoActivity extends ActionBarActivity { txtvAuthor = (TextView) findViewById(R.id.txtvAuthor); txtvUrl = (TextView) findViewById(R.id.txtvUrl); cbxAutoDownload = (CheckBox) findViewById(R.id.cbxAutoDownload); + spnAutoDelete = (Spinner) findViewById(R.id.spnAutoDelete); etxtUsername = (EditText) findViewById(R.id.etxtUsername); etxtPassword = (EditText) findViewById(R.id.etxtPassword); @@ -111,6 +118,7 @@ public class FeedInfoActivity extends ActionBarActivity { Log.d(TAG, "Language is " + feed.getLanguage()); Log.d(TAG, "Author is " + feed.getAuthor()); Log.d(TAG, "URL is " + feed.getDownload_url()); + FeedPreferences prefs = feed.getPreferences(); imgvCover.post(new Runnable() { @Override @@ -136,7 +144,7 @@ public class FeedInfoActivity extends ActionBarActivity { Iconify.addIcons(txtvUrl); cbxAutoDownload.setEnabled(UserPreferences.isEnableAutodownload()); - cbxAutoDownload.setChecked(feed.getPreferences().getAutoDownload()); + cbxAutoDownload.setChecked(prefs.getAutoDownload()); cbxAutoDownload.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -144,9 +152,38 @@ public class FeedInfoActivity extends ActionBarActivity { feed.savePreferences(FeedInfoActivity.this); } }); + spnAutoDelete.setOnItemSelectedListener(new OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { + FeedPreferences.AutoDeleteAction auto_delete_action; + switch (parent.getSelectedItemPosition()) { + case 0: + auto_delete_action = FeedPreferences.AutoDeleteAction.GLOBAL; + break; + + case 1: + auto_delete_action = FeedPreferences.AutoDeleteAction.YES; + break; + + case 2: + auto_delete_action = FeedPreferences.AutoDeleteAction.NO; + break; + + default: // TODO - add exceptions here + return; + } + feed.getPreferences().setAutoDeleteAction(auto_delete_action);// p + autoDeleteChanged = true; + } + @Override + public void onNothingSelected(AdapterView<?> parent) { + // Another interface callback + } + }); + spnAutoDelete.setSelection(prefs.getAutoDeleteAction().ordinal()); - etxtUsername.setText(feed.getPreferences().getUsername()); - etxtPassword.setText(feed.getPreferences().getPassword()); + etxtUsername.setText(prefs.getUsername()); + etxtPassword.setText(prefs.getPassword()); etxtUsername.addTextChangedListener(authTextWatcher); etxtPassword.addTextChangedListener(authTextWatcher); @@ -184,13 +221,18 @@ public class FeedInfoActivity extends ActionBarActivity { @Override protected void onPause() { super.onPause(); - if (feed != null && authInfoChanged) { - Log.d(TAG, "Auth info changed, saving credentials"); + if (feed != null) { FeedPreferences prefs = feed.getPreferences(); - prefs.setUsername(etxtUsername.getText().toString()); - prefs.setPassword(etxtPassword.getText().toString()); - DBWriter.setFeedPreferences(this, prefs); + if (authInfoChanged) { + Log.d(TAG, "Auth info changed, saving credentials"); + prefs.setUsername(etxtUsername.getText().toString()); + prefs.setPassword(etxtPassword.getText().toString()); + } + if (authInfoChanged || autoDeleteChanged) { + DBWriter.setFeedPreferences(this, prefs); + } authInfoChanged = false; + autoDeleteChanged = false; } } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 2b1b13ae6..3ab384012 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -180,7 +180,7 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity { url = URLChecker.prepareURL(url); feed = new Feed(url, new Date(0)); if (username != null && password != null) { - feed.setPreferences(new FeedPreferences(0, false, username, password)); + feed.setPreferences(new FeedPreferences(0, false, FeedPreferences.AutoDeleteAction.GLOBAL, username, password)); } String fileUrl = new File(getExternalCacheDir(), FileNameGenerator.generateFileName(feed.getDownload_url())).toString(); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index cbf3ffdd7..9a25674b6 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -97,7 +97,7 @@ public class NewEpisodesFragment extends AllEpisodesFragment { long itemId = token.getFeedItemId(); FeedItem item = DBReader.getFeedItem(context, itemId); FeedMedia media = item.getMedia(); - if(media != null && media.hasAlmostEnded() && UserPreferences.isAutoDelete()) { + if(media != null && media.hasAlmostEnded() && item.getFeed().getPreferences().getCurrentAutoDelete()) { DBWriter.deleteFeedMediaOfItem(context, media.getId()); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 282688210..46148a214 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -431,7 +431,7 @@ public class QueueFragment extends Fragment { long itemId = token.getFeedItemId(); FeedItem item = DBReader.getFeedItem(context, itemId); FeedMedia media = item.getMedia(); - if(media != null && media.hasAlmostEnded() && UserPreferences.isAutoDelete()) { + if(media != null && media.hasAlmostEnded() && item.getFeed().getPreferences().getCurrentAutoDelete()) { DBWriter.deleteFeedMediaOfItem(context, media.getId()); } } diff --git a/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java b/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java index 1fe9e2cf9..990b3bd54 100644 --- a/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java +++ b/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java @@ -62,7 +62,7 @@ public class PlayerWidgetService extends Service { DBWriter.markItemRead(this, item, true, false); DBWriter.removeQueueItem(this, item, false); DBWriter.addItemToPlaybackHistory(this, media); - if (UserPreferences.isAutoDelete()) { + if (item.getFeed().getPreferences().getCurrentAutoDelete()) { Log.d(TAG, "Delete " + media.toString()); DBWriter.deleteFeedMediaOfItem(this, media.getId()); } diff --git a/app/src/main/res/layout-v14/authentication_dialog.xml b/app/src/main/res/layout-v14/authentication_dialog.xml index ed05dab1c..00e74c9e1 100644 --- a/app/src/main/res/layout-v14/authentication_dialog.xml +++ b/app/src/main/res/layout-v14/authentication_dialog.xml @@ -15,7 +15,10 @@ android:layout_height="0dp" android:layout_weight="1" android:layout_margin="16dp" - android:hint="@string/username_label"/> + android:hint="@string/username_label" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <EditText android:id="@+id/etxtPassword" @@ -24,7 +27,10 @@ android:layout_weight="1" android:layout_margin="16dp" android:inputType="textPassword" - android:hint="@string/password_label"/> + android:hint="@string/password_label" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <CheckBox android:id="@+id/chkSaveUsernamePassword" diff --git a/app/src/main/res/layout-v14/download_authentication_activity.xml b/app/src/main/res/layout-v14/download_authentication_activity.xml index c1fe55ceb..8d2c7fb17 100644 --- a/app/src/main/res/layout-v14/download_authentication_activity.xml +++ b/app/src/main/res/layout-v14/download_authentication_activity.xml @@ -31,7 +31,10 @@ android:layout_margin="16dp" android:id="@+id/etxtUsername" android:hint="@string/username_label" - android:layout_below="@id/txtvDescription"/> + android:layout_below="@id/txtvDescription" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <EditText android:layout_width="match_parent" @@ -40,7 +43,10 @@ android:id="@+id/etxtPassword" android:hint="@string/password_label" android:inputType="textPassword" - android:layout_below="@id/etxtUsername"/> + android:layout_below="@id/etxtUsername" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <RelativeLayout android:id="@+id/footer" diff --git a/app/src/main/res/layout/addfeed.xml b/app/src/main/res/layout/addfeed.xml index b7babbafa..44ba781c2 100644 --- a/app/src/main/res/layout/addfeed.xml +++ b/app/src/main/res/layout/addfeed.xml @@ -27,7 +27,10 @@ android:layout_height="wrap_content" android:layout_marginTop="4dp" android:hint="@string/etxtFeedurlHint" - android:inputType="textUri"/> + android:inputType="textUri" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <Button android:id="@+id/butConfirm" diff --git a/app/src/main/res/layout/authentication_dialog.xml b/app/src/main/res/layout/authentication_dialog.xml index 82260eb43..e18ab42eb 100644 --- a/app/src/main/res/layout/authentication_dialog.xml +++ b/app/src/main/res/layout/authentication_dialog.xml @@ -16,7 +16,10 @@ android:layout_height="0dp" android:layout_weight="1" android:layout_margin="16dp" - android:hint="@string/username_label"/> + android:hint="@string/username_label" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <EditText android:id="@+id/etxtPassword" @@ -25,7 +28,10 @@ android:layout_weight="1" android:layout_margin="16dp" android:inputType="textPassword" - android:hint="@string/password_label"/> + android:hint="@string/password_label" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <CheckBox android:id="@+id/chkSaveUsernamePassword" diff --git a/app/src/main/res/layout/download_authentication_activity.xml b/app/src/main/res/layout/download_authentication_activity.xml index 69106c9b3..b035f2516 100644 --- a/app/src/main/res/layout/download_authentication_activity.xml +++ b/app/src/main/res/layout/download_authentication_activity.xml @@ -31,7 +31,10 @@ android:layout_margin="16dp" android:id="@+id/etxtUsername" android:hint="@string/username_label" - android:layout_below="@id/txtvDescription"/> + android:layout_below="@id/txtvDescription" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <EditText android:layout_width="match_parent" @@ -40,7 +43,10 @@ android:id="@+id/etxtPassword" android:hint="@string/password_label" android:inputType="textPassword" - android:layout_below="@id/etxtUsername"/> + android:layout_below="@id/etxtUsername" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <LinearLayout android:id="@+id/footer" diff --git a/app/src/main/res/layout/feedinfo.xml b/app/src/main/res/layout/feedinfo.xml index 4dab1e189..edae51847 100644 --- a/app/src/main/res/layout/feedinfo.xml +++ b/app/src/main/res/layout/feedinfo.xml @@ -159,7 +159,38 @@ android:enabled="false" android:textColor="?android:attr/textColorPrimary" tools:background="@android:color/holo_red_light" - android:checked="false"/> + android:checked="false" /> + + <android.support.v7.widget.GridLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:columnCount="2" + app:rowCount="1"> + + <TextView + android:id="@+id/txtvFeedAutoDelete" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/auto_delete_label" + app:layout_row="0" + app:layout_column="0" + app:layout_gravity="center_vertical" + android:layout_marginRight="10dp" /> + + <Spinner + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:id="@+id/spnAutoDelete" + android:entries="@array/spnAutoDeleteItems" + android:layout_marginTop="8dp" + app:layout_row="0" + app:layout_column="1" + android:spinnerMode="dropdown" + app:layout_gravity="center" + android:dropDownWidth="wrap_content" + android:clickable="true" /> + </android.support.v7.widget.GridLayout> <TextView android:id="@+id/txtvAuthentication" @@ -204,7 +235,10 @@ android:layout_height="wrap_content" app:layout_row="0" app:layout_column="1" - android:hint="@string/username_label"/> + android:hint="@string/username_label" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <TextView android:id="@+id/txtvPassword" @@ -215,7 +249,10 @@ app:layout_row="1" app:layout_column="0" android:text="@string/password_label" - android:textColor="?android:attr/textColorPrimary"/> + android:textColor="?android:attr/textColorPrimary" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <EditText android:id="@+id/etxtPassword" diff --git a/app/src/main/res/layout/gpodnetauth_credentials.xml b/app/src/main/res/layout/gpodnetauth_credentials.xml index 8436570fc..13c5977f8 100644 --- a/app/src/main/res/layout/gpodnetauth_credentials.xml +++ b/app/src/main/res/layout/gpodnetauth_credentials.xml @@ -30,7 +30,10 @@ android:layout_height="wrap_content" android:hint="@string/username_label" android:layout_below="@id/txtvDescription" - android:layout_margin="8dp"/> + android:layout_margin="8dp" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <EditText android:id="@+id/etxtPassword" @@ -39,7 +42,10 @@ android:hint="@string/password_label" android:layout_below="@id/etxtUsername" android:inputType="textPassword" - android:layout_margin="8dp"/> + android:layout_margin="8dp" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true"/> <Button android:id="@+id/butLogin" |