Split feed info and settings

This commit is contained in:
ByteHamster 2018-04-13 15:39:51 +02:00
parent 4e63bfb11c
commit c9fdc05784
8 changed files with 644 additions and 406 deletions

View File

@ -105,7 +105,12 @@
android:value="de.danoeh.antennapod.activity.MainActivity"/> android:value="de.danoeh.antennapod.activity.MainActivity"/>
</activity> </activity>
<activity android:name=".activity.FeedInfoActivity"> <activity android:name=".activity.FeedInfoActivity"
android:label="@string/feed_info_label">
</activity>
<activity android:name=".activity.FeedSettingsActivity"
android:label="@string/feed_settings_label">
</activity> </activity>
<service <service

View File

@ -2,51 +2,35 @@ package de.danoeh.antennapod.activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.Iconify;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedFilter;
import de.danoeh.antennapod.core.feed.FeedPreferences;
import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.core.util.LangUtils; import de.danoeh.antennapod.core.util.LangUtils;
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
import de.danoeh.antennapod.menuhandler.FeedMenuHandler; import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import rx.Observable; import rx.Observable;
import rx.Subscription; import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers; import rx.android.schedulers.AndroidSchedulers;
@ -59,7 +43,6 @@ public class FeedInfoActivity extends AppCompatActivity {
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId"; public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
private static final String TAG = "FeedInfoActivity"; private static final String TAG = "FeedInfoActivity";
private boolean autoDeleteChanged = false;
private Feed feed; private Feed feed;
private ImageView imgvCover; private ImageView imgvCover;
@ -70,15 +53,6 @@ public class FeedInfoActivity extends AppCompatActivity {
private TextView lblAuthor; private TextView lblAuthor;
private TextView txtvAuthor; private TextView txtvAuthor;
private TextView txtvUrl; private TextView txtvUrl;
private EditText etxtUsername;
private EditText etxtPassword;
private EditText etxtFilterText;
private RadioButton rdoFilterInclude;
private RadioButton rdoFilterExclude;
private CheckBox cbxAutoDownload;
private CheckBox cbxKeepUpdated;
private Spinner spnAutoDelete;
private boolean filterInclude = true;
private Subscription subscription; private Subscription subscription;
@ -98,40 +72,6 @@ public class FeedInfoActivity extends AppCompatActivity {
} }
}; };
private boolean authInfoChanged = false;
private final TextWatcher authTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
authInfoChanged = true;
}
};
private boolean filterTextChanged = false;
private final TextWatcher filterTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
filterTextChanged = true;
}
};
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme()); setTheme(UserPreferences.getTheme());
@ -148,22 +88,7 @@ public class FeedInfoActivity extends AppCompatActivity {
lblAuthor = (TextView) findViewById(R.id.lblAuthor); lblAuthor = (TextView) findViewById(R.id.lblAuthor);
txtvAuthor = (TextView) findViewById(R.id.txtvAuthor); txtvAuthor = (TextView) findViewById(R.id.txtvAuthor);
txtvUrl = (TextView) findViewById(R.id.txtvUrl); txtvUrl = (TextView) findViewById(R.id.txtvUrl);
cbxAutoDownload = (CheckBox) findViewById(R.id.cbxAutoDownload);
cbxKeepUpdated = (CheckBox) findViewById(R.id.cbxKeepUpdated);
spnAutoDelete = (Spinner) findViewById(R.id.spnAutoDelete);
etxtUsername = (EditText) findViewById(R.id.etxtUsername);
etxtPassword = (EditText) findViewById(R.id.etxtPassword);
etxtFilterText = (EditText) findViewById(R.id.etxtEpisodeFilterText);
rdoFilterInclude = (RadioButton) findViewById(R.id.radio_filter_include);
rdoFilterInclude.setOnClickListener(v -> {
filterInclude = true;
filterTextChanged = true;
});
rdoFilterExclude = (RadioButton) findViewById(R.id.radio_filter_exclude);
rdoFilterExclude.setOnClickListener(v -> {
filterInclude = false;
filterTextChanged = true;
});
txtvUrl.setOnClickListener(copyUrlToClipboard); txtvUrl.setOnClickListener(copyUrlToClipboard);
@ -179,7 +104,6 @@ public class FeedInfoActivity extends AppCompatActivity {
Log.d(TAG, "Language is " + feed.getLanguage()); Log.d(TAG, "Language is " + feed.getLanguage());
Log.d(TAG, "Author is " + feed.getAuthor()); Log.d(TAG, "Author is " + feed.getAuthor());
Log.d(TAG, "URL is " + feed.getDownload_url()); Log.d(TAG, "URL is " + feed.getDownload_url());
FeedPreferences prefs = feed.getPreferences();
Glide.with(FeedInfoActivity.this) Glide.with(FeedInfoActivity.this)
.load(feed.getImageLocation()) .load(feed.getImageLocation())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
@ -218,113 +142,13 @@ public class FeedInfoActivity extends AppCompatActivity {
txtvUrl.setText(feed.getDownload_url() + " {fa-paperclip}"); txtvUrl.setText(feed.getDownload_url() + " {fa-paperclip}");
Iconify.addIcons(txtvUrl); Iconify.addIcons(txtvUrl);
cbxAutoDownload.setEnabled(UserPreferences.isEnableAutodownload());
cbxAutoDownload.setChecked(prefs.getAutoDownload());
cbxAutoDownload.setOnCheckedChangeListener((compoundButton, checked) -> {
feed.getPreferences().setAutoDownload(checked);
feed.savePreferences();
updateAutoDownloadSettings();
ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(FeedInfoActivity.this,
feed, checked);
dialog.createNewDialog().show();
});
cbxKeepUpdated.setChecked(prefs.getKeepUpdated());
cbxKeepUpdated.setOnCheckedChangeListener((compoundButton, checked) -> {
feed.getPreferences().setKeepUpdated(checked);
feed.savePreferences();
});
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(prefs.getUsername());
etxtPassword.setText(prefs.getPassword());
etxtUsername.addTextChangedListener(authTextWatcher);
etxtPassword.addTextChangedListener(authTextWatcher);
FeedFilter filter = prefs.getFilter();
if (filter.includeOnly()) {
etxtFilterText.setText(filter.getIncludeFilter());
rdoFilterInclude.setChecked(true);
rdoFilterExclude.setChecked(false);
filterInclude = true;
} else if (filter.excludeOnly()) {
etxtFilterText.setText(filter.getExcludeFilter());
rdoFilterInclude.setChecked(false);
rdoFilterExclude.setChecked(true);
filterInclude = false;
} else {
Log.d(TAG, "No filter set");
rdoFilterInclude.setChecked(false);
rdoFilterExclude.setChecked(false);
etxtFilterText.setText("");
}
etxtFilterText.addTextChangedListener(filterTextWatcher);
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
updateAutoDownloadSettings();
}, error -> { }, error -> {
Log.d(TAG, Log.getStackTraceString(error)); Log.d(TAG, Log.getStackTraceString(error));
finish(); finish();
}); });
} }
@Override
protected void onPause() {
super.onPause();
if (feed != null) {
FeedPreferences prefs = feed.getPreferences();
if (authInfoChanged) {
Log.d(TAG, "Auth info changed, saving credentials");
prefs.setUsername(etxtUsername.getText().toString());
prefs.setPassword(etxtPassword.getText().toString());
}
if (filterTextChanged) {
Log.d(TAG, "Filter info changed, saving...");
String filterText = etxtFilterText.getText().toString();
String includeString = "";
String excludeString = "";
if (filterInclude) {
includeString = filterText;
} else {
excludeString = filterText;
}
prefs.setFilter(new FeedFilter(includeString, excludeString));
}
if (authInfoChanged || autoDeleteChanged || filterTextChanged) {
DBWriter.setFeedPreferences(prefs);
}
authInfoChanged = false;
autoDeleteChanged = false;
filterTextChanged = false;
}
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -369,34 +193,4 @@ public class FeedInfoActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
} }
private void updateAutoDownloadSettings() {
if (feed != null && feed.getPreferences() != null) {
boolean enabled = feed.getPreferences().getAutoDownload() && UserPreferences.isEnableAutodownload();
rdoFilterInclude.setEnabled(enabled);
rdoFilterExclude.setEnabled(enabled);
etxtFilterText.setEnabled(enabled);
}
}
private static class ApplyToEpisodesDialog extends ConfirmationDialog {
private final Feed feed;
private final boolean autoDownload;
ApplyToEpisodesDialog(Context context, Feed feed, boolean autoDownload) {
super(context, R.string.auto_download_apply_to_items_title,
R.string.auto_download_apply_to_items_message);
this.feed = feed;
this.autoDownload = autoDownload;
setPositiveText(R.string.yes);
setNegativeText(R.string.no);
}
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
DBWriter.setFeedsItemsAutoDownload(feed, autoDownload);
}
}
} }

View File

@ -0,0 +1,348 @@
package de.danoeh.antennapod.activity;
import android.content.ClipData;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedFilter;
import de.danoeh.antennapod.core.feed.FeedPreferences;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Displays information about a feed.
*/
public class FeedSettingsActivity extends AppCompatActivity {
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
private static final String TAG = "FeedSettingsActivity";
private boolean autoDeleteChanged = false;
private Feed feed;
private ImageView imgvCover;
private TextView txtvTitle;
private EditText etxtUsername;
private EditText etxtPassword;
private EditText etxtFilterText;
private RadioButton rdoFilterInclude;
private RadioButton rdoFilterExclude;
private CheckBox cbxAutoDownload;
private CheckBox cbxKeepUpdated;
private Spinner spnAutoDelete;
private boolean filterInclude = true;
private Subscription subscription;
private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() {
@Override
public void onClick(View v) {
if(feed != null && feed.getDownload_url() != null) {
String url = feed.getDownload_url();
ClipData clipData = ClipData.newPlainText(url, url);
android.content.ClipboardManager cm = (android.content.ClipboardManager) FeedSettingsActivity.this
.getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(clipData);
Toast t = Toast.makeText(FeedSettingsActivity.this, R.string.copied_url_msg, Toast.LENGTH_SHORT);
t.show();
}
}
};
private boolean authInfoChanged = false;
private final TextWatcher authTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
authInfoChanged = true;
}
};
private boolean filterTextChanged = false;
private final TextWatcher filterTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
filterTextChanged = true;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
super.onCreate(savedInstanceState);
setContentView(R.layout.feedsettings);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
long feedId = getIntent().getLongExtra(EXTRA_FEED_ID, -1);
imgvCover = (ImageView) findViewById(R.id.imgvCover);
txtvTitle = (TextView) findViewById(R.id.txtvTitle);
cbxAutoDownload = (CheckBox) findViewById(R.id.cbxAutoDownload);
cbxKeepUpdated = (CheckBox) findViewById(R.id.cbxKeepUpdated);
spnAutoDelete = (Spinner) findViewById(R.id.spnAutoDelete);
etxtUsername = (EditText) findViewById(R.id.etxtUsername);
etxtPassword = (EditText) findViewById(R.id.etxtPassword);
etxtFilterText = (EditText) findViewById(R.id.etxtEpisodeFilterText);
rdoFilterInclude = (RadioButton) findViewById(R.id.radio_filter_include);
rdoFilterInclude.setOnClickListener(v -> {
filterInclude = true;
filterTextChanged = true;
});
rdoFilterExclude = (RadioButton) findViewById(R.id.radio_filter_exclude);
rdoFilterExclude.setOnClickListener(v -> {
filterInclude = false;
filterTextChanged = true;
});
subscription = Observable.fromCallable(()-> DBReader.getFeed(feedId))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if (result == null) {
Log.e(TAG, "Activity was started with invalid arguments");
finish();
}
feed = result;
FeedPreferences prefs = feed.getPreferences();
Glide.with(FeedSettingsActivity.this)
.load(feed.getImageLocation())
.placeholder(R.color.light_gray)
.error(R.color.light_gray)
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter()
.dontAnimate()
.into(imgvCover);
txtvTitle.setText(feed.getTitle());
cbxAutoDownload.setEnabled(UserPreferences.isEnableAutodownload());
cbxAutoDownload.setChecked(prefs.getAutoDownload());
cbxAutoDownload.setOnCheckedChangeListener((compoundButton, checked) -> {
feed.getPreferences().setAutoDownload(checked);
feed.savePreferences();
updateAutoDownloadSettings();
ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(FeedSettingsActivity.this,
feed, checked);
dialog.createNewDialog().show();
});
cbxKeepUpdated.setChecked(prefs.getKeepUpdated());
cbxKeepUpdated.setOnCheckedChangeListener((compoundButton, checked) -> {
feed.getPreferences().setKeepUpdated(checked);
feed.savePreferences();
});
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(prefs.getUsername());
etxtPassword.setText(prefs.getPassword());
etxtUsername.addTextChangedListener(authTextWatcher);
etxtPassword.addTextChangedListener(authTextWatcher);
FeedFilter filter = prefs.getFilter();
if (filter.includeOnly()) {
etxtFilterText.setText(filter.getIncludeFilter());
rdoFilterInclude.setChecked(true);
rdoFilterExclude.setChecked(false);
filterInclude = true;
} else if (filter.excludeOnly()) {
etxtFilterText.setText(filter.getExcludeFilter());
rdoFilterInclude.setChecked(false);
rdoFilterExclude.setChecked(true);
filterInclude = false;
} else {
Log.d(TAG, "No filter set");
rdoFilterInclude.setChecked(false);
rdoFilterExclude.setChecked(false);
etxtFilterText.setText("");
}
etxtFilterText.addTextChangedListener(filterTextWatcher);
supportInvalidateOptionsMenu();
updateAutoDownloadSettings();
}, error -> {
Log.d(TAG, Log.getStackTraceString(error));
finish();
});
}
@Override
protected void onPause() {
super.onPause();
if (feed != null) {
FeedPreferences prefs = feed.getPreferences();
if (authInfoChanged) {
Log.d(TAG, "Auth info changed, saving credentials");
prefs.setUsername(etxtUsername.getText().toString());
prefs.setPassword(etxtPassword.getText().toString());
}
if (filterTextChanged) {
Log.d(TAG, "Filter info changed, saving...");
String filterText = etxtFilterText.getText().toString();
String includeString = "";
String excludeString = "";
if (filterInclude) {
includeString = filterText;
} else {
excludeString = filterText;
}
prefs.setFilter(new FeedFilter(includeString, excludeString));
}
if (authInfoChanged || autoDeleteChanged || filterTextChanged) {
DBWriter.setFeedPreferences(prefs);
}
authInfoChanged = false;
autoDeleteChanged = false;
filterTextChanged = false;
}
}
@Override
public void onDestroy() {
super.onDestroy();
if(subscription != null) {
subscription.unsubscribe();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.feedinfo, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.findItem(R.id.support_item).setVisible(
feed != null && feed.getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(feed != null && feed.getLink() != null);
menu.findItem(R.id.visit_website_item).setVisible(feed != null && feed.getLink() != null &&
IntentUtils.isCallable(this, new Intent(Intent.ACTION_VIEW, Uri.parse(feed.getLink()))));
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
try {
return FeedMenuHandler.onOptionsItemClicked(this, item, feed);
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
e.getMessage());
}
return super.onOptionsItemSelected(item);
}
}
private void updateAutoDownloadSettings() {
if (feed != null && feed.getPreferences() != null) {
boolean enabled = feed.getPreferences().getAutoDownload() && UserPreferences.isEnableAutodownload();
rdoFilterInclude.setEnabled(enabled);
rdoFilterExclude.setEnabled(enabled);
etxtFilterText.setEnabled(enabled);
}
}
private static class ApplyToEpisodesDialog extends ConfirmationDialog {
private final Feed feed;
private final boolean autoDownload;
ApplyToEpisodesDialog(Context context, Feed feed, boolean autoDownload) {
super(context, R.string.auto_download_apply_to_items_title,
R.string.auto_download_apply_to_items_message);
this.feed = feed;
this.autoDownload = autoDownload;
setPositiveText(R.string.yes);
setNegativeText(R.string.no);
}
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
DBWriter.setFeedsItemsAutoDownload(feed, autoDownload);
}
}
}

View File

@ -31,6 +31,7 @@ import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeIcons; import com.joanzapata.iconify.fonts.FontAwesomeIcons;
import com.joanzapata.iconify.widget.IconTextView; import com.joanzapata.iconify.widget.IconTextView;
import de.danoeh.antennapod.activity.FeedSettingsActivity;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import java.util.List; import java.util.List;
@ -497,6 +498,7 @@ public class ItemlistFragment extends ListFragment {
imgvBackground = (ImageView) header.findViewById(R.id.imgvBackground); imgvBackground = (ImageView) header.findViewById(R.id.imgvBackground);
imgvCover = (ImageView) header.findViewById(R.id.imgvCover); imgvCover = (ImageView) header.findViewById(R.id.imgvCover);
ImageButton butShowInfo = (ImageButton) header.findViewById(R.id.butShowInfo); ImageButton butShowInfo = (ImageButton) header.findViewById(R.id.butShowInfo);
ImageButton butShowSettings = (ImageButton) header.findViewById(R.id.butShowSettings);
txtvInformation = (TextView) header.findViewById(R.id.txtvInformation); txtvInformation = (TextView) header.findViewById(R.id.txtvInformation);
txtvFailure = (IconTextView) header.findViewById(R.id.txtvFailure); txtvFailure = (IconTextView) header.findViewById(R.id.txtvFailure);
@ -509,15 +511,26 @@ public class ItemlistFragment extends ListFragment {
loadFeedImage(); loadFeedImage();
butShowInfo.setOnClickListener(v -> { butShowInfo.setOnClickListener(v -> showFeedInfo());
imgvCover.setOnClickListener(v -> showFeedInfo());
butShowSettings.setOnClickListener(v -> {
if (viewsCreated && itemsLoaded) {
Intent startIntent = new Intent(getActivity(), FeedSettingsActivity.class);
startIntent.putExtra(FeedSettingsActivity.EXTRA_FEED_ID,
feed.getId());
startActivity(startIntent);
}
});
headerCreated = true;
}
private void showFeedInfo() {
if (viewsCreated && itemsLoaded) { if (viewsCreated && itemsLoaded) {
Intent startIntent = new Intent(getActivity(), FeedInfoActivity.class); Intent startIntent = new Intent(getActivity(), FeedInfoActivity.class);
startIntent.putExtra(FeedInfoActivity.EXTRA_FEED_ID, startIntent.putExtra(FeedInfoActivity.EXTRA_FEED_ID,
feed.getId()); feed.getId());
startActivity(startIntent); startActivity(startIntent);
} }
});
headerCreated = true;
} }
private void loadFeedImage() { private void loadFeedImage() {

View File

@ -142,198 +142,6 @@
</android.support.v7.widget.GridLayout> </android.support.v7.widget.GridLayout>
<TextView
android:id="@+id/txtvSettings"
style="@style/AntennaPod.TextView.Heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/podcast_settings_label"
android:layout_marginTop="8dp"/>
<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>
<CheckBox
android:id="@+id/cbxKeepUpdated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/keep_updated"
android:enabled="true"
android:textColor="?android:attr/textColorPrimary"
tools:background="@android:color/holo_red_light"
android:checked="true" />
<TextView
android:id="@+id/txtvAuthentication"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/authentication_label"
android:textSize="@dimen/text_size_medium"
android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/txtvAuthenticationDescr"
android:text="@string/authentication_descr"
android:textSize="@dimen/text_size_small"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:columnCount="2"
app:rowCount="3"
android:layout_gravity="center_horizontal">
<TextView
android:id="@+id/txtvUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_row="0"
app:layout_column="0"
android:text="@string/username_label"
android:textColor="?android:attr/textColorPrimary"/>
<EditText
android:id="@+id/etxtUsername"
android:layout_width="140sp"
android:layout_height="wrap_content"
app:layout_row="0"
app:layout_column="1"
android:hint="@string/username_label"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<TextView
android:id="@+id/txtvPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_row="1"
app:layout_column="0"
android:text="@string/password_label"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/etxtPassword"
android:layout_width="140sp"
android:layout_height="wrap_content"
app:layout_row="1"
app:layout_column="1"
android:hint="@string/password_label"
android:inputType="textPassword"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
</android.support.v7.widget.GridLayout>
<TextView
android:id="@+id/txtvAutoDownloadSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/auto_download_settings_label"
android:textSize="@dimen/text_size_medium"
android:textColor="?android:attr/textColorPrimary"/>
<CheckBox
android:id="@+id/cbxAutoDownload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/auto_download_label"
android:enabled="false"
android:textColor="?android:attr/textColorPrimary"
tools:background="@android:color/holo_red_light"
android:checked="false" />
<TextView
android:id="@+id/txtvEpisodeFilters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/episode_filters_label"
android:textSize="@dimen/text_size_medium"
android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/txtvEpisodeFiltersDescription"
android:text="@string/episode_filters_description"
android:textSize="@dimen/text_size_small"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/radio_filter_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<RadioButton android:id="@+id/radio_filter_include"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/episode_filters_include" />
<RadioButton android:id="@+id/radio_filter_exclude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/episode_filters_exclude" />
</RadioGroup>
<EditText
android:id="@+id/etxtEpisodeFilterText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:lines="8"
android:minLines="1"
android:maxLines="20"
android:scrollbars="vertical"
android:hint="@string/episode_filters_hint"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<TextView <TextView
style="@style/AntennaPod.TextView.Heading" style="@style/AntennaPod.TextView.Heading"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -42,6 +42,18 @@
android:src="@drawable/ic_info_white_24dp" android:src="@drawable/ic_info_white_24dp"
tools:background="@android:color/holo_green_dark"/> tools:background="@android:color/holo_green_dark"/>
<ImageButton
android:id="@+id/butShowSettings"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/show_feed_settings_label"
android:src="@drawable/ic_settings_white_24dp"
tools:background="@android:color/holo_green_dark"
android:layout_below="@+id/butShowInfo"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<TextView <TextView
android:id="@+id/txtvTitle" android:id="@+id/txtvTitle"
style="@style/AntennaPod.TextView.Heading" style="@style/AntennaPod.TextView.Heading"

View File

@ -0,0 +1,255 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/header"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<ImageView
android:id="@+id/imgvCover"
android:contentDescription="@string/cover_label"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
tools:src="@drawable/ic_stat_antenna_default"
tools:background="@android:color/holo_green_dark"/>
<TextView
android:id="@+id/txtvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:layout_alignTop="@id/imgvCover"
android:layout_toRightOf="@id/imgvCover"
android:layout_alignBottom="@id/imgvCover"
style="@style/AntennaPod.TextView.Heading"
tools:text="Feed title"
tools:background="@android:color/holo_green_dark"/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/imgvCover"
android:layout_marginTop="8dp"
android:background="@color/holo_blue_light"/>
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbarStyle="outsideOverlay"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<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>
<CheckBox
android:id="@+id/cbxKeepUpdated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/keep_updated"
android:enabled="true"
android:textColor="?android:attr/textColorPrimary"
tools:background="@android:color/holo_red_light"
android:checked="true" />
<TextView
android:id="@+id/txtvAuthentication"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/authentication_label"
android:textSize="@dimen/text_size_medium"
android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/txtvAuthenticationDescr"
android:text="@string/authentication_descr"
android:textSize="@dimen/text_size_small"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:columnCount="2"
app:rowCount="3"
android:layout_gravity="center_horizontal">
<TextView
android:id="@+id/txtvUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_row="0"
app:layout_column="0"
android:text="@string/username_label"
android:textColor="?android:attr/textColorPrimary"/>
<EditText
android:id="@+id/etxtUsername"
android:layout_width="140sp"
android:layout_height="wrap_content"
app:layout_row="0"
app:layout_column="1"
android:hint="@string/username_label"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<TextView
android:id="@+id/txtvPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_row="1"
app:layout_column="0"
android:text="@string/password_label"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/etxtPassword"
android:layout_width="140sp"
android:layout_height="wrap_content"
app:layout_row="1"
app:layout_column="1"
android:hint="@string/password_label"
android:inputType="textPassword"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
</android.support.v7.widget.GridLayout>
<TextView
android:id="@+id/txtvAutoDownloadSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/auto_download_settings_label"
android:textSize="@dimen/text_size_medium"
android:textColor="?android:attr/textColorPrimary"/>
<CheckBox
android:id="@+id/cbxAutoDownload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/auto_download_label"
android:enabled="false"
android:textColor="?android:attr/textColorPrimary"
tools:background="@android:color/holo_red_light"
android:checked="false" />
<TextView
android:id="@+id/txtvEpisodeFilters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/episode_filters_label"
android:textSize="@dimen/text_size_medium"
android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/txtvEpisodeFiltersDescription"
android:text="@string/episode_filters_description"
android:textSize="@dimen/text_size_small"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/radio_filter_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<RadioButton android:id="@+id/radio_filter_include"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/episode_filters_include" />
<RadioButton android:id="@+id/radio_filter_exclude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/episode_filters_exclude" />
</RadioGroup>
<EditText
android:id="@+id/etxtEpisodeFilterText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:lines="8"
android:minLines="1"
android:maxLines="20"
android:scrollbars="vertical"
android:hint="@string/episode_filters_hint"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -122,6 +122,9 @@
<string name="mark_all_seen_msg">Marked all Episodes as seen</string> <string name="mark_all_seen_msg">Marked all Episodes as seen</string>
<string name="mark_all_seen_confirmation_msg">Please confirm that you want to mark all episodes as seen.</string> <string name="mark_all_seen_confirmation_msg">Please confirm that you want to mark all episodes as seen.</string>
<string name="show_info_label">Show information</string> <string name="show_info_label">Show information</string>
<string name="show_feed_settings_label">Show feed settings</string>
<string name="feed_info_label">Feed info</string>
<string name="feed_settings_label">Feed settings</string>
<string name="rename_feed_label">Rename Podcast</string> <string name="rename_feed_label">Rename Podcast</string>
<string name="remove_feed_label">Remove Podcast</string> <string name="remove_feed_label">Remove Podcast</string>
<string name="share_label">Share&#8230;</string> <string name="share_label">Share&#8230;</string>