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) { } else if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
if (!isFinishing() && !isPaused) { if (!isFinishing() && !isPaused) {
dialog = new FeedViewAuthenticationDialog(OnlineFeedViewActivity.this, dialog = new FeedViewAuthenticationDialog(OnlineFeedViewActivity.this,
R.string.authentication_notification_title, downloader.getDownloadRequest().getSource()); R.string.authentication_notification_title,
downloader.getDownloadRequest().getSource()).create();
dialog.show(); dialog.show();
} }
} else { } else {

View File

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

View File

@ -4,11 +4,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText <EditText
android:id="@+id/etxtUsername" android:id="@+id/etxtUsername"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -39,53 +34,3 @@
android:layout_margin="16dp" android:layout_margin="16dp"
android:text="@string/save_username_password_label"/> android:text="@string/save_username_password_label"/>
</LinearLayout> </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>
</LinearLayout>