mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-22 06:49:12 +00:00
Add setting to change from 3 digit group size to 2 digit group size
This commit is contained in:
parent
09065c705b
commit
00e2e90aa7
8 changed files with 45 additions and 5 deletions
|
@ -61,6 +61,14 @@ public class Preferences {
|
||||||
return _prefs.getBoolean("pref_account_name", true);
|
return _prefs.getBoolean("pref_account_name", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCodeGroupSize() {
|
||||||
|
if (_prefs.getBoolean("pref_code_group_size", false)) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isIntroDone() {
|
public boolean isIntroDone() {
|
||||||
return _prefs.getBoolean("pref_intro", false);
|
return _prefs.getBoolean("pref_intro", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
// set up the entry view
|
// set up the entry view
|
||||||
_entryListView = (EntryListView) getSupportFragmentManager().findFragmentById(R.id.key_profiles);
|
_entryListView = (EntryListView) getSupportFragmentManager().findFragmentById(R.id.key_profiles);
|
||||||
_entryListView.setListener(this);
|
_entryListView.setListener(this);
|
||||||
|
_entryListView.setCodeGroupSize(getPreferences().getCodeGroupSize());
|
||||||
_entryListView.setShowAccountName(getPreferences().isAccountNameVisible());
|
_entryListView.setShowAccountName(getPreferences().isAccountNameVisible());
|
||||||
_entryListView.setSearchAccountName(getPreferences().isSearchAccountNameEnabled());
|
_entryListView.setSearchAccountName(getPreferences().isSearchAccountNameEnabled());
|
||||||
_entryListView.setHighlightEntry(getPreferences().isEntryHighlightEnabled());
|
_entryListView.setHighlightEntry(getPreferences().isEntryHighlightEnabled());
|
||||||
|
@ -220,12 +221,14 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
recreate();
|
recreate();
|
||||||
} else if (data.getBooleanExtra("needsRefresh", false)) {
|
} else if (data.getBooleanExtra("needsRefresh", false)) {
|
||||||
boolean showAccountName = getPreferences().isAccountNameVisible();
|
boolean showAccountName = getPreferences().isAccountNameVisible();
|
||||||
|
int codeGroupSize = getPreferences().getCodeGroupSize();
|
||||||
boolean searchAccountName = getPreferences().isSearchAccountNameEnabled();
|
boolean searchAccountName = getPreferences().isSearchAccountNameEnabled();
|
||||||
boolean highlightEntry = getPreferences().isEntryHighlightEnabled();
|
boolean highlightEntry = getPreferences().isEntryHighlightEnabled();
|
||||||
boolean tapToReveal = getPreferences().isTapToRevealEnabled();
|
boolean tapToReveal = getPreferences().isTapToRevealEnabled();
|
||||||
int tapToRevealTime = getPreferences().getTapToRevealTime();
|
int tapToRevealTime = getPreferences().getTapToRevealTime();
|
||||||
ViewMode viewMode = getPreferences().getCurrentViewMode();
|
ViewMode viewMode = getPreferences().getCurrentViewMode();
|
||||||
_entryListView.setShowAccountName(showAccountName);
|
_entryListView.setShowAccountName(showAccountName);
|
||||||
|
_entryListView.setCodeGroupSize(codeGroupSize);
|
||||||
_entryListView.setSearchAccountName(searchAccountName);
|
_entryListView.setSearchAccountName(searchAccountName);
|
||||||
_entryListView.setHighlightEntry(highlightEntry);
|
_entryListView.setHighlightEntry(highlightEntry);
|
||||||
_entryListView.setTapToReveal(tapToReveal);
|
_entryListView.setTapToReveal(tapToReveal);
|
||||||
|
|
|
@ -206,6 +206,12 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
});
|
});
|
||||||
timeoutPreference.getOnPreferenceChangeListener().onPreferenceChange(timeoutPreference, timeoutPreference.getText());*/
|
timeoutPreference.getOnPreferenceChangeListener().onPreferenceChange(timeoutPreference, timeoutPreference.getText());*/
|
||||||
|
|
||||||
|
Preference codeDigitGroupingPreference = findPreference("pref_code_group_size");
|
||||||
|
codeDigitGroupingPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
_result.putExtra("needsRefresh", true);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
Preference issuerPreference = findPreference("pref_account_name");
|
Preference issuerPreference = findPreference("pref_account_name");
|
||||||
issuerPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
issuerPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,8 +4,6 @@ import android.os.Handler;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
@ -30,6 +28,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
private List<VaultEntry> _shownEntries;
|
private List<VaultEntry> _shownEntries;
|
||||||
private List<VaultEntry> _selectedEntries;
|
private List<VaultEntry> _selectedEntries;
|
||||||
private VaultEntry _focusedEntry;
|
private VaultEntry _focusedEntry;
|
||||||
|
private int _codeGroupSize;
|
||||||
private boolean _showAccountName;
|
private boolean _showAccountName;
|
||||||
private boolean _searchAccountName;
|
private boolean _searchAccountName;
|
||||||
private boolean _highlightEntry;
|
private boolean _highlightEntry;
|
||||||
|
@ -62,6 +61,10 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
_view = null;
|
_view = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCodeGroupSize(int codeGroupeSize) {
|
||||||
|
_codeGroupSize = codeGroupeSize;
|
||||||
|
}
|
||||||
|
|
||||||
public void setShowAccountName(boolean showAccountName) {
|
public void setShowAccountName(boolean showAccountName) {
|
||||||
_showAccountName = showAccountName;
|
_showAccountName = showAccountName;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +313,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
boolean hidden = _tapToReveal && entry != _focusedEntry;
|
boolean hidden = _tapToReveal && entry != _focusedEntry;
|
||||||
boolean dimmed = _highlightEntry && _focusedEntry != null && _focusedEntry != entry;
|
boolean dimmed = _highlightEntry && _focusedEntry != null && _focusedEntry != entry;
|
||||||
boolean showProgress = !isPeriodUniform() && entry.getInfo() instanceof TotpInfo;
|
boolean showProgress = !isPeriodUniform() && entry.getInfo() instanceof TotpInfo;
|
||||||
holder.setData(entry, _showAccountName, showProgress, hidden, dimmed);
|
holder.setData(entry, _codeGroupSize, _showAccountName, showProgress, hidden, dimmed);
|
||||||
holder.setFocused(_selectedEntries.contains(entry));
|
holder.setFocused(_selectedEntries.contains(entry));
|
||||||
holder.loadIcon(_view);
|
holder.loadIcon(_view);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
private final ImageView _selected;
|
private final ImageView _selected;
|
||||||
private final Handler _selectedHandler;
|
private final Handler _selectedHandler;
|
||||||
|
|
||||||
|
private int _codeGroupSize = 6;
|
||||||
|
|
||||||
private boolean _hidden;
|
private boolean _hidden;
|
||||||
|
|
||||||
private PeriodProgressBar _progressBar;
|
private PeriodProgressBar _progressBar;
|
||||||
|
@ -92,10 +94,15 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(VaultEntry entry, boolean showAccountName, boolean showProgress, boolean hidden, boolean dimmed) {
|
public void setData(VaultEntry entry, int codeGroupSize, boolean showAccountName, boolean showProgress, boolean hidden, boolean dimmed) {
|
||||||
_entry = entry;
|
_entry = entry;
|
||||||
_hidden = hidden;
|
_hidden = hidden;
|
||||||
|
|
||||||
|
if (codeGroupSize <= 0)
|
||||||
|
throw new IllegalArgumentException("Code group size cannot be zero or negative");
|
||||||
|
|
||||||
|
_codeGroupSize = codeGroupSize;
|
||||||
|
|
||||||
_selected.clearAnimation();
|
_selected.clearAnimation();
|
||||||
_selected.setVisibility(View.GONE);
|
_selected.setVisibility(View.GONE);
|
||||||
_selectedHandler.removeCallbacksAndMessages(null);
|
_selectedHandler.removeCallbacksAndMessages(null);
|
||||||
|
@ -207,7 +214,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
if (!(info instanceof SteamInfo)) {
|
if (!(info instanceof SteamInfo)) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < otp.length(); i++) {
|
for (int i = 0; i < otp.length(); i++) {
|
||||||
if (i != 0 && i % 3 == 0) {
|
if (i != 0 && i % _codeGroupSize == 0) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
sb.append(otp.charAt(i));
|
sb.append(otp.charAt(i));
|
||||||
|
|
|
@ -223,6 +223,10 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCodeGroupSize(int codeGrouping) {
|
||||||
|
_adapter.setCodeGroupSize(codeGrouping);
|
||||||
|
}
|
||||||
|
|
||||||
public void setShowAccountName(boolean showAccountName) {
|
public void setShowAccountName(boolean showAccountName) {
|
||||||
_adapter.setShowAccountName(showAccountName);
|
_adapter.setShowAccountName(showAccountName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
<string name="pref_select_theme_title">Theme</string>
|
<string name="pref_select_theme_title">Theme</string>
|
||||||
<string name="pref_view_mode_title">View mode</string>
|
<string name="pref_view_mode_title">View mode</string>
|
||||||
<string name="pref_lang_title">Language</string>
|
<string name="pref_lang_title">Language</string>
|
||||||
|
<string name="pref_code_group_size_title">Code digit grouping</string>
|
||||||
|
<string name="pref_code_group_size_summary">Show code in 2-digit grouping instead of 3-digit grouping</string>
|
||||||
<string name="pref_account_name_title">Show the account name</string>
|
<string name="pref_account_name_title">Show the account name</string>
|
||||||
<string name="pref_account_name_summary">Enable this to show the account name next to the issuer</string>
|
<string name="pref_account_name_summary">Enable this to show the account name next to the issuer</string>
|
||||||
<string name="pref_timeout_title">Timeout</string>
|
<string name="pref_timeout_title">Timeout</string>
|
||||||
|
|
|
@ -28,6 +28,13 @@
|
||||||
android:defaultValue="system"
|
android:defaultValue="system"
|
||||||
app:iconSpaceReserved="false"/>
|
app:iconSpaceReserved="false"/>
|
||||||
|
|
||||||
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="pref_code_group_size"
|
||||||
|
android:title="@string/pref_code_group_size_title"
|
||||||
|
android:summary="@string/pref_code_group_size_summary"
|
||||||
|
app:iconSpaceReserved="false"/>
|
||||||
|
|
||||||
<androidx.preference.SwitchPreferenceCompat
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="pref_account_name"
|
android:key="pref_account_name"
|
||||||
|
|
Loading…
Add table
Reference in a new issue