diff options
author | ByteHamster <info@bytehamster.com> | 2019-12-19 17:50:17 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2019-12-19 17:50:17 +0100 |
commit | ffa8dc10b383a8a37d12e23e541a863ac69fb96a (patch) | |
tree | d3f01402dc9f7f6e1c5dd2bde06b1cfe5c9a77c9 /app | |
parent | 19890afc663d067f70e0286eeaa73cb8cb7acbad (diff) | |
download | AntennaPod-ffa8dc10b383a8a37d12e23e541a863ac69fb96a.zip |
Fixed white on white text in authentication dialog
Diffstat (limited to 'app')
3 files changed, 44 insertions, 123 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 0c6c63e73..a0530fb95 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -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 { diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java index 2c41b8cb8..073f7b550 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java @@ -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 { - - private final int titleRes; - private final boolean enableUsernameField; - private final boolean showSaveCredentialsCheckbox; - private final String usernameInitialValue; - private final String passwordInitialValue; +public abstract class AuthenticationDialog extends AlertDialog.Builder { - 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() { diff --git a/app/src/main/res/layout/authentication_dialog.xml b/app/src/main/res/layout/authentication_dialog.xml index 187045c63..1661eaea1 100644 --- a/app/src/main/res/layout/authentication_dialog.xml +++ b/app/src/main/res/layout/authentication_dialog.xml @@ -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>
\ No newline at end of file |