mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-01 03:06:48 +01:00
Allow modification of feed username and password, propagate credentials to episodes. fixes #395
This commit is contained in:
parent
a0ef9f5a87
commit
c881b7982c
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/header"
|
android:id="@+id/header"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
@ -118,6 +120,72 @@
|
|||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvAuthentication"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:text="@string/authentication_label"
|
||||||
|
android:textSize="@dimen/text_size_medium"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginTop="24dp"/>
|
||||||
|
|
||||||
|
<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_margin="8dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvUsername"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:text="@string/username_label"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etxtUsername"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/username_label"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvPassword"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:text="@string/password_label"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etxtPassword"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/password_label"
|
||||||
|
android:inputType="textPassword"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -357,6 +357,10 @@
|
|||||||
<string name="new_episodes_count_label">Number of new episodes</string>
|
<string name="new_episodes_count_label">Number of new episodes</string>
|
||||||
<string name="in_progress_episodes_count_label">Number of episodes you have started listening to</string>
|
<string name="in_progress_episodes_count_label">Number of episodes you have started listening to</string>
|
||||||
|
|
||||||
|
<!-- Feed information screen -->
|
||||||
|
<string name="authentication_label">Authentication</string>
|
||||||
|
<string name="authentication_descr">Change your username and password for this podcast and its episodes.</string>
|
||||||
|
|
||||||
<!-- OPML backup -->
|
<!-- OPML backup -->
|
||||||
<string name="backup_restored">"Restored feed subscriptions from backup"</string>
|
<string name="backup_restored">"Restored feed subscriptions from backup"</string>
|
||||||
|
|
||||||
|
@ -3,21 +3,22 @@ package de.danoeh.antennapod.activity;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.text.Editable;
|
||||||
|
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.widget.CheckBox;
|
import android.widget.*;
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import de.danoeh.antennapod.BuildConfig;
|
import de.danoeh.antennapod.BuildConfig;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.asynctask.ImageLoader;
|
import de.danoeh.antennapod.asynctask.ImageLoader;
|
||||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||||
import de.danoeh.antennapod.feed.Feed;
|
import de.danoeh.antennapod.feed.Feed;
|
||||||
|
import de.danoeh.antennapod.feed.FeedPreferences;
|
||||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.storage.DBReader;
|
import de.danoeh.antennapod.storage.DBReader;
|
||||||
|
import de.danoeh.antennapod.storage.DBWriter;
|
||||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||||
import de.danoeh.antennapod.util.LangUtils;
|
import de.danoeh.antennapod.util.LangUtils;
|
||||||
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
||||||
@ -37,6 +38,8 @@ public class FeedInfoActivity extends ActionBarActivity {
|
|||||||
private TextView txtvDescription;
|
private TextView txtvDescription;
|
||||||
private TextView txtvLanguage;
|
private TextView txtvLanguage;
|
||||||
private TextView txtvAuthor;
|
private TextView txtvAuthor;
|
||||||
|
private EditText etxtUsername;
|
||||||
|
private EditText etxtPassword;
|
||||||
private CheckBox cbxAutoDownload;
|
private CheckBox cbxAutoDownload;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,6 +56,8 @@ public class FeedInfoActivity extends ActionBarActivity {
|
|||||||
txtvLanguage = (TextView) findViewById(R.id.txtvLanguage);
|
txtvLanguage = (TextView) findViewById(R.id.txtvLanguage);
|
||||||
txtvAuthor = (TextView) findViewById(R.id.txtvAuthor);
|
txtvAuthor = (TextView) findViewById(R.id.txtvAuthor);
|
||||||
cbxAutoDownload = (CheckBox) findViewById(R.id.cbxAutoDownload);
|
cbxAutoDownload = (CheckBox) findViewById(R.id.cbxAutoDownload);
|
||||||
|
etxtUsername = (EditText) findViewById(R.id.etxtUsername);
|
||||||
|
etxtPassword = (EditText) findViewById(R.id.etxtPassword);
|
||||||
|
|
||||||
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
||||||
|
|
||||||
@ -98,6 +103,12 @@ public class FeedInfoActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
etxtUsername.setText(feed.getPreferences().getUsername());
|
||||||
|
etxtPassword.setText(feed.getPreferences().getPassword());
|
||||||
|
|
||||||
|
etxtUsername.addTextChangedListener(authTextWatcher);
|
||||||
|
etxtPassword.addTextChangedListener(authTextWatcher);
|
||||||
|
|
||||||
supportInvalidateOptionsMenu();
|
supportInvalidateOptionsMenu();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -108,6 +119,39 @@ public class FeedInfoActivity extends ActionBarActivity {
|
|||||||
loadTask.execute(feedId);
|
loadTask.execute(feedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean authInfoChanged = false;
|
||||||
|
|
||||||
|
private 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (feed != null && authInfoChanged) {
|
||||||
|
Log.d(TAG, "Auth info changed, saving credentials");
|
||||||
|
FeedPreferences prefs = feed.getPreferences();
|
||||||
|
prefs.setUsername(etxtUsername.getText().toString());
|
||||||
|
prefs.setPassword(etxtPassword.getText().toString());
|
||||||
|
DBWriter.setFeedPreferences(this, prefs);
|
||||||
|
authInfoChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
@ -837,6 +837,7 @@ public class DBWriter {
|
|||||||
adapter.open();
|
adapter.open();
|
||||||
adapter.setFeedPreferences(preferences);
|
adapter.setFeedPreferences(preferences);
|
||||||
adapter.close();
|
adapter.close();
|
||||||
|
EventDistributor.getInstance().sendFeedUpdateBroadcast();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -164,9 +164,19 @@ public class DownloadRequester {
|
|||||||
public void downloadMedia(Context context, FeedMedia feedmedia)
|
public void downloadMedia(Context context, FeedMedia feedmedia)
|
||||||
throws DownloadRequestException {
|
throws DownloadRequestException {
|
||||||
if (feedFileValid(feedmedia)) {
|
if (feedFileValid(feedmedia)) {
|
||||||
|
Feed feed = feedmedia.getItem().getFeed();
|
||||||
|
String username;
|
||||||
|
String password;
|
||||||
|
if (feed != null && feed.getPreferences() != null) {
|
||||||
|
username = feed.getPreferences().getUsername();
|
||||||
|
password = feed.getPreferences().getPassword();
|
||||||
|
} else {
|
||||||
|
username = null;
|
||||||
|
password = null;
|
||||||
|
}
|
||||||
download(context, feedmedia,
|
download(context, feedmedia,
|
||||||
new File(getMediafilePath(context, feedmedia),
|
new File(getMediafilePath(context, feedmedia),
|
||||||
getMediafilename(feedmedia)), false, null, null
|
getMediafilename(feedmedia)), false, username, password
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user