Merge pull request #3696 from ByteHamster/white-on-white

Fixed white on white text in authentication dialog
This commit is contained in:
H. Lehmann 2019-12-20 00:15:36 +01:00 committed by GitHub
commit 46731178b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 123 deletions

View File

@ -256,7 +256,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
} else if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
if (!isFinishing() && !isPaused) {
dialog = new FeedViewAuthenticationDialog(OnlineFeedViewActivity.this,
R.string.authentication_notification_title, downloader.getDownloadRequest().getSource());
R.string.authentication_notification_title,
downloader.getDownloadRequest().getSource()).create();
dialog.show();
}
} else {

View File

@ -1,51 +1,29 @@
package de.danoeh.antennapod.dialog;
import android.app.Dialog;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import de.danoeh.antennapod.R;
/**
* Displays a dialog with a username and password text field and an optional checkbox to save username and preferences.
*/
public abstract class AuthenticationDialog extends Dialog {
public abstract class AuthenticationDialog extends AlertDialog.Builder {
private final int titleRes;
private final boolean enableUsernameField;
private final boolean showSaveCredentialsCheckbox;
private final String usernameInitialValue;
private final String passwordInitialValue;
public AuthenticationDialog(Context context, int titleRes, boolean enableUsernameField, boolean showSaveCredentialsCheckbox, String usernameInitialValue, String passwordInitialValue) {
public AuthenticationDialog(Context context, int titleRes, boolean enableUsernameField,
boolean showSaveCredentialsCheckbox, String usernameInitialValue,
String passwordInitialValue) {
super(context);
this.titleRes = titleRes;
this.enableUsernameField = enableUsernameField;
this.showSaveCredentialsCheckbox = showSaveCredentialsCheckbox;
this.usernameInitialValue = usernameInitialValue;
this.passwordInitialValue = passwordInitialValue;
}
setTitle(titleRes);
View rootView = View.inflate(context, R.layout.authentication_dialog, null);
setView(rootView);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.authentication_dialog);
final EditText etxtUsername = findViewById(R.id.etxtUsername);
final EditText etxtPassword = findViewById(R.id.etxtPassword);
final CheckBox saveUsernamePassword = findViewById(R.id.chkSaveUsernamePassword);
final Button butConfirm = findViewById(R.id.butConfirm);
final Button butCancel = findViewById(R.id.butCancel);
final EditText etxtUsername = rootView.findViewById(R.id.etxtUsername);
final EditText etxtPassword = rootView.findViewById(R.id.etxtPassword);
final CheckBox saveUsernamePassword = rootView.findViewById(R.id.chkSaveUsernamePassword);
if (titleRes != 0) {
setTitle(titleRes);
} else {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
etxtUsername.setEnabled(enableUsernameField);
if (showSaveCredentialsCheckbox) {
saveUsernamePassword.setVisibility(View.VISIBLE);
@ -59,13 +37,10 @@ public abstract class AuthenticationDialog extends Dialog {
etxtPassword.setText(passwordInitialValue);
}
setOnCancelListener(dialog -> onCancelled());
butCancel.setOnClickListener(v -> cancel());
butConfirm.setOnClickListener(v -> {
onConfirmed(etxtUsername.getText().toString(),
etxtPassword.getText().toString(),
showSaveCredentialsCheckbox && saveUsernamePassword.isChecked());
dismiss();
});
setNegativeButton(R.string.cancel_label, null);
setPositiveButton(R.string.confirm_label, (dialog, which)
-> onConfirmed(etxtUsername.getText().toString(), etxtPassword.getText().toString(),
showSaveCredentialsCheckbox && saveUsernamePassword.isChecked()));
}
protected void onCancelled() {

View File

@ -4,88 +4,33 @@
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
<EditText
android:id="@+id/etxtUsername"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="16dp"
android:hint="@string/username_label"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<EditText
android:id="@+id/etxtPassword"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="16dp"
android:inputType="textPassword"
android:hint="@string/password_label"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<CheckBox
android:id="@+id/chkSaveUsernamePassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/etxtUsername"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="16dp"
android:hint="@string/username_label"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<EditText
android:id="@+id/etxtPassword"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="16dp"
android:inputType="textPassword"
android:hint="@string/password_label"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<CheckBox
android:id="@+id/chkSaveUsernamePassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/save_username_password_label"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="48dp" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_alignParentTop="true"
android:background="?android:attr/dividerVertical" />
<View
android:id="@+id/horizontal_divider"
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="?android:attr/dividerVertical" />
<Button
android:id="@+id/butCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/horizontal_divider"
android:layout_toStartOf="@id/horizontal_divider"
android:background="?android:attr/selectableItemBackground"
android:text="@string/cancel_label" />
<Button
android:id="@+id/butConfirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/horizontal_divider"
android:layout_toEndOf="@id/horizontal_divider"
android:background="?android:attr/selectableItemBackground"
android:text="@string/confirm_label" />
</RelativeLayout>
android:layout_margin="16dp"
android:text="@string/save_username_password_label"/>
</LinearLayout>