show password last letter when typing.
This commit is contained in:
parent
1dc8f0f927
commit
c14e07265e
1 changed files with 24 additions and 1 deletions
|
@ -33,6 +33,8 @@ import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
|
@ -196,7 +198,27 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private class CoolPasswordMethod extends PasswordTransformationMethod{
|
||||||
|
@Override
|
||||||
|
public CharSequence getTransformation(CharSequence source, View view) {
|
||||||
|
return new PasswordCharSequence(source);
|
||||||
|
}
|
||||||
|
private class PasswordCharSequence implements CharSequence {
|
||||||
|
private CharSequence mSource;
|
||||||
|
public PasswordCharSequence(CharSequence source) {
|
||||||
|
mSource = source;
|
||||||
|
}
|
||||||
|
public char charAt(int index) {
|
||||||
|
return index==mSource.length()-1 ? mSource.charAt(index) : '*';
|
||||||
|
}
|
||||||
|
public int length() {
|
||||||
|
return mSource.length();
|
||||||
|
}
|
||||||
|
public CharSequence subSequence(int start, int end) {
|
||||||
|
return mSource.subSequence(start, end); // Return default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private void manageAccountPreferencesFields(PreferenceScreen parent) {
|
private void manageAccountPreferencesFields(PreferenceScreen parent) {
|
||||||
boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == n;
|
boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == n;
|
||||||
|
|
||||||
|
@ -216,6 +238,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
EditTextPreference password = (EditTextPreference) account.getPreference(2);
|
EditTextPreference password = (EditTextPreference) account.getPreference(2);
|
||||||
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
password.setText(mPrefs.getAccountPassword(n));
|
password.setText(mPrefs.getAccountPassword(n));
|
||||||
|
password.getEditText().setTransformationMethod(new CoolPasswordMethod());
|
||||||
password.setOnPreferenceChangeListener(passwordChangedListener);
|
password.setOnPreferenceChangeListener(passwordChangedListener);
|
||||||
|
|
||||||
EditTextPreference domain = (EditTextPreference) account.getPreference(3);
|
EditTextPreference domain = (EditTextPreference) account.getPreference(3);
|
||||||
|
|
Loading…
Reference in a new issue