Fix some remaining issues with the Intro

Closes #486
This commit is contained in:
Jakob Nixdorf 2020-05-04 07:42:34 +02:00
parent fcb8aaa415
commit 6a8511a26f
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -261,6 +261,8 @@ public class IntroScreenActivity extends IntroActivity {
if (desc != null) { if (desc != null) {
if (encryptionType == Constants.EncryptionType.KEYSTORE) { if (encryptionType == Constants.EncryptionType.KEYSTORE) {
desc.setText(R.string.intro_slide3_desc_keystore); desc.setText(R.string.intro_slide3_desc_keystore);
selection.setSelection(selectionMapping.indexOfValue(Constants.AuthMethod.NONE));
} else if (encryptionType == Constants.EncryptionType.PASSWORD) { } else if (encryptionType == Constants.EncryptionType.PASSWORD) {
desc.setText(R.string.intro_slide3_desc_password); desc.setText(R.string.intro_slide3_desc_password);
@ -279,21 +281,24 @@ public class IntroScreenActivity extends IntroActivity {
selectionMapping.put(i, authValues[i]); selectionMapping.put(i, authValues[i]);
} }
private void displayWarning(int resId) { private void updateWarning(int resId) {
displayWarning(getString(resId)); updateWarning(getString(resId));
} }
private void displayWarning(String warning) { private void updateWarning(String warning) {
authWarnings.setVisibility(View.VISIBLE);
authWarnings.setText(warning); authWarnings.setText(warning);
} }
private void hideWarning() { private void hideWarning() {
authWarnings.setVisibility(View.GONE); authWarnings.setVisibility(View.GONE);
authWarnings.setText(null);
} }
public void flashWarning() { public void flashWarning() {
if (authWarnings.getVisibility() == View.VISIBLE) { if (authWarnings.getText().toString().isEmpty()) {
authWarnings.setVisibility(View.GONE);
} else {
authWarnings.setVisibility(View.VISIBLE);
ObjectAnimator animator = ObjectAnimator.ofInt(authWarnings, "backgroundColor", ObjectAnimator animator = ObjectAnimator.ofInt(authWarnings, "backgroundColor",
Color.TRANSPARENT, getResources().getColor(R.color.colorAccent), Color.TRANSPARENT); Color.TRANSPARENT, getResources().getColor(R.color.colorAccent), Color.TRANSPARENT);
animator.setDuration(500); animator.setDuration(500);
@ -405,6 +410,11 @@ public class IntroScreenActivity extends IntroActivity {
UIHelper.hideKeyboard(getIntroActivity(), root); UIHelper.hideKeyboard(getIntroActivity(), root);
} }
passwordInput.setText(null);
passwordConfirm.setText(null);
authWarnings.setVisibility(View.GONE);
updateNavigation(); updateNavigation();
} }
@ -446,38 +456,36 @@ public class IntroScreenActivity extends IntroActivity {
if (! password.isEmpty()) { if (! password.isEmpty()) {
if (password.length() < minLength) { if (password.length() < minLength) {
displayWarning(lengthWarning); updateWarning(lengthWarning);
return false; return false;
} else { } else {
if (! confirm.isEmpty() && confirm.equals(password)) { if (! confirm.isEmpty() && confirm.equals(password)) {
hideWarning(); hideWarning();
return true; return true;
} else { } else {
displayWarning(confirmPasswordWarning); updateWarning(confirmPasswordWarning);
return false; return false;
} }
} }
} else { } else {
displayWarning(noPasswordWarning); updateWarning(noPasswordWarning);
return false; return false;
} }
} else if (authMethod == Constants.AuthMethod.DEVICE) { } else if (authMethod == Constants.AuthMethod.DEVICE) {
KeyguardManager km = (KeyguardManager) getContext().getSystemService(KEYGUARD_SERVICE); KeyguardManager km = (KeyguardManager) getContext().getSystemService(KEYGUARD_SERVICE);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
displayWarning(R.string.settings_toast_auth_device_pre_lollipop); updateWarning(R.string.settings_toast_auth_device_pre_lollipop);
return false; return false;
} else if (! km.isKeyguardSecure()) { } else if (! km.isKeyguardSecure()) {
displayWarning(R.string.settings_toast_auth_device_not_secure); updateWarning(R.string.settings_toast_auth_device_not_secure);
return false; return false;
} }
hideWarning(); hideWarning();
return true; return true;
} else { } else {
hideWarning(); hideWarning();
return true; return true;
} }
} }