Added password length check while creating backups #770
This commit is contained in:
parent
dfc788cd29
commit
0fb27f3a5c
2 changed files with 30 additions and 10 deletions
|
@ -13,9 +13,11 @@ import android.text.TextWatcher;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.shadowice.flocke.andotp.R;
|
import org.shadowice.flocke.andotp.R;
|
||||||
import org.shadowice.flocke.andotp.Utilities.ConfirmedPasswordTransformationHelper;
|
import org.shadowice.flocke.andotp.Utilities.ConfirmedPasswordTransformationHelper;
|
||||||
|
import org.shadowice.flocke.andotp.Utilities.Constants;
|
||||||
import org.shadowice.flocke.andotp.Utilities.Tools;
|
import org.shadowice.flocke.andotp.Utilities.Tools;
|
||||||
|
|
||||||
public class PasswordEntryDialog extends AppCompatDialog
|
public class PasswordEntryDialog extends AppCompatDialog
|
||||||
|
@ -27,12 +29,13 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
void onPasswordEntered(String newPassword);
|
void onPasswordEntered(String newPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mode dialogMode;
|
private final Mode dialogMode;
|
||||||
private PasswordEnteredCallback callback;
|
private final PasswordEnteredCallback callback;
|
||||||
|
|
||||||
private TextInputEditText passwordInput;
|
private final TextInputEditText passwordInput;
|
||||||
private EditText passwordConfirm;
|
private final EditText passwordConfirm;
|
||||||
private Button okButton;
|
private final Button okButton;
|
||||||
|
private final TextView toShortWarning;
|
||||||
|
|
||||||
public PasswordEntryDialog(Context context, Mode newMode, boolean blockAccessibility, boolean blockAutofill, PasswordEnteredCallback newCallback) {
|
public PasswordEntryDialog(Context context, Mode newMode, boolean blockAccessibility, boolean blockAutofill, PasswordEnteredCallback newCallback) {
|
||||||
super(context, Tools.getThemeResource(context, R.attr.dialogTheme));
|
super(context, Tools.getThemeResource(context, R.attr.dialogTheme));
|
||||||
|
@ -43,6 +46,8 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
TextInputLayout passwordLayout = findViewById(R.id.passwordInputLayout);
|
TextInputLayout passwordLayout = findViewById(R.id.passwordInputLayout);
|
||||||
passwordInput = findViewById(R.id.passwordInput);
|
passwordInput = findViewById(R.id.passwordInput);
|
||||||
passwordConfirm = findViewById(R.id.passwordConfirm);
|
passwordConfirm = findViewById(R.id.passwordConfirm);
|
||||||
|
toShortWarning = findViewById(R.id.toShortWarning);
|
||||||
|
toShortWarning.setText(getContext().getString(R.string.settings_label_short_password, Constants.AUTH_MIN_PASSWORD_LENGTH));
|
||||||
ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm);
|
ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm);
|
||||||
|
|
||||||
if (blockAccessibility) {
|
if (blockAccessibility) {
|
||||||
|
@ -56,9 +61,10 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
okButton = findViewById(R.id.buttonOk);
|
okButton = findViewById(R.id.buttonOk);
|
||||||
Button cancelButton = findViewById(R.id.buttonCancel);
|
|
||||||
|
|
||||||
okButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
|
okButton.setEnabled(false);
|
||||||
|
|
||||||
|
Button cancelButton = findViewById(R.id.buttonCancel);
|
||||||
cancelButton.setOnClickListener(this);
|
cancelButton.setOnClickListener(this);
|
||||||
|
|
||||||
this.callback = newCallback;
|
this.callback = newCallback;
|
||||||
|
@ -76,11 +82,16 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
|
|
||||||
// TextWatcher
|
// TextWatcher
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
if (passwordInput.getEditableText().length() >= Constants.AUTH_MIN_PASSWORD_LENGTH) {
|
||||||
|
toShortWarning.setVisibility(View.GONE);
|
||||||
if (TextUtils.equals(passwordInput.getEditableText(), passwordConfirm.getEditableText()))
|
if (TextUtils.equals(passwordInput.getEditableText(), passwordConfirm.getEditableText()))
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
toShortWarning.setVisibility(View.VISIBLE);
|
||||||
okButton.setEnabled(false);
|
okButton.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {}
|
public void afterTextChanged(Editable s) {}
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
|
|
@ -33,6 +33,15 @@
|
||||||
android:hint="@string/dialog_label_confirm_password"
|
android:hint="@string/dialog_label_confirm_password"
|
||||||
android:inputType="textPassword" />
|
android:inputType="textPassword" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toShortWarning"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/settings_label_short_password" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue