Allow showing passwords when biometric / PIN authentication is enabled only

pull/175/head
M66B 5 years ago
parent 4ccf83e742
commit 7708165e8e

@ -74,6 +74,8 @@ import java.util.Objects;
import javax.mail.Folder;
import static android.app.Activity.RESULT_OK;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_NONE;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_PASSWORD_TOGGLE;
public class FragmentAccount extends FragmentBase {
private ViewGroup view;
@ -330,7 +332,8 @@ public class FragmentAccount extends FragmentBase {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
if (TextUtils.isEmpty(s))
tilPassword.setEndIconMode(END_ICON_PASSWORD_TOGGLE);
}
@Override
@ -494,6 +497,7 @@ public class FragmentAccount extends FragmentBase {
rgEncryption.setVisibility(View.GONE);
cbInsecure.setVisibility(View.GONE);
tilPassword.setEndIconMode(id < 0 || Helper.isSecure(getContext()) ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
tvCharacters.setVisibility(View.GONE);
btnAdvanced.setVisibility(View.GONE);

@ -69,6 +69,8 @@ import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import static android.app.Activity.RESULT_OK;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_NONE;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_PASSWORD_TOGGLE;
public class FragmentIdentity extends FragmentBase {
private ViewGroup view;
@ -267,6 +269,7 @@ public class FragmentIdentity extends FragmentBase {
etEmail.setText(account.user);
etUser.setText(account.user);
tilPassword.getEditText().setText(account.password);
tilPassword.setEndIconMode(Helper.isSecure(getContext()) ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
certificate = account.certificate_alias;
tvCertificate.setText(certificate == null ? getString(R.string.title_optional) : certificate);
etRealm.setText(account.realm);
@ -306,7 +309,8 @@ public class FragmentIdentity extends FragmentBase {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
if (TextUtils.isEmpty(s))
tilPassword.setEndIconMode(END_ICON_PASSWORD_TOGGLE);
}
@Override
@ -477,6 +481,7 @@ public class FragmentIdentity extends FragmentBase {
btnAutoConfig.setEnabled(false);
pbAutoConfig.setVisibility(View.GONE);
cbInsecure.setVisibility(View.GONE);
tilPassword.setEndIconMode(Helper.isSecure(getContext()) ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
tvCharacters.setVisibility(View.GONE);
btnAdvanced.setVisibility(View.GONE);

@ -56,6 +56,8 @@ import java.util.Date;
import java.util.Objects;
import static android.app.Activity.RESULT_OK;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_NONE;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_PASSWORD_TOGGLE;
public class FragmentPop extends FragmentBase {
private ViewGroup view;
@ -151,7 +153,8 @@ public class FragmentPop extends FragmentBase {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
if (TextUtils.isEmpty(s))
tilPassword.setEndIconMode(END_ICON_PASSWORD_TOGGLE);
}
@Override
@ -209,6 +212,7 @@ public class FragmentPop extends FragmentBase {
// Initialize
Helper.setViewsEnabled(view, false);
tilPassword.setEndIconMode(id < 0 || Helper.isSecure(getContext()) ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
tvCharacters.setVisibility(View.GONE);
pbSave.setVisibility(View.GONE);
grpError.setVisibility(View.GONE);

@ -378,6 +378,13 @@ public class Helper {
return BuildConfig.PLAY_STORE_RELEASE;
}
static boolean isSecure(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean biometrics = prefs.getBoolean("biometrics", false);
String pin = prefs.getString("pin", null);
return (biometrics || !TextUtils.isEmpty(pin));
}
// View
static Intent getChooser(Context context, Intent intent) {

Loading…
Cancel
Save