This commit is contained in:
Martin Fietz 2018-01-10 23:35:18 +01:00
parent 648b6c9529
commit 7257a6c76e
1 changed files with 22 additions and 25 deletions

View File

@ -3,15 +3,14 @@ package de.danoeh.antennapod.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.apache.commons.lang3.Validate;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
@ -23,7 +22,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequester;
* Other arguments are optional.
* The activity's result will be the same DownloadRequest with the entered username and password.
*/
public class DownloadAuthenticationActivity extends ActionBarActivity {
public class DownloadAuthenticationActivity extends AppCompatActivity {
/**
* The download request object that contains information about the resource that requires a username and a password
@ -35,47 +34,39 @@ public class DownloadAuthenticationActivity extends ActionBarActivity {
*/
public static final String ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL = "send_to_downloadrequester";
public static final String RESULT_REQUEST = "request";
private static final String RESULT_REQUEST = "request";
private EditText etxtUsername;
private EditText etxtPassword;
private Button butConfirm;
private Button butCancel;
private TextView txtvDescription;
private DownloadRequest request;
private boolean sendToDownloadRequester;
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.download_authentication_activity);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.hide();
}
setContentView(R.layout.download_authentication_activity);
TextView txtvDescription = (TextView) findViewById(R.id.txtvDescription);
etxtUsername = (EditText) findViewById(R.id.etxtUsername);
etxtPassword = (EditText) findViewById(R.id.etxtPassword);
butConfirm = (Button) findViewById(R.id.butConfirm);
butCancel = (Button) findViewById(R.id.butCancel);
txtvDescription = (TextView) findViewById(R.id.txtvDescription);
Button butConfirm = (Button) findViewById(R.id.butConfirm);
Button butCancel = (Button) findViewById(R.id.butCancel);
Validate.isTrue(getIntent().hasExtra(ARG_DOWNLOAD_REQUEST), "Download request missing");
DownloadRequest request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST);
boolean sendToDownloadRequester = getIntent().getBooleanExtra(ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, false);
request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST);
sendToDownloadRequester = getIntent().getBooleanExtra(ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, false);
String newDescription = txtvDescription.getText() + ":\n\n" + request.getTitle();
txtvDescription.setText(newDescription);
if (savedInstanceState != null) {
etxtUsername.setText(savedInstanceState.getString("username"));
etxtPassword.setText(savedInstanceState.getString("password"));
}
txtvDescription.setText(txtvDescription.getText() + ":\n\n" + request.getTitle());
butCancel.setOnClickListener(v -> {
setResult(Activity.RESULT_CANCELED);
finish();
});
butConfirm.setOnClickListener(v -> {
String username = etxtUsername.getText().toString();
String password = etxtPassword.getText().toString();
@ -90,6 +81,12 @@ public class DownloadAuthenticationActivity extends ActionBarActivity {
}
finish();
});
butCancel.setOnClickListener(v -> {
setResult(Activity.RESULT_CANCELED);
finish();
});
}
@Override