mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-06-07 23:27:50 +00:00
Merge pull request #439 from alexbakker/copy-on-tap-option
Add an option to copy tokens on tap (and disable it by default)
This commit is contained in:
commit
00b0c8deaf
7 changed files with 45 additions and 3 deletions
|
@ -167,4 +167,8 @@ public class Preferences {
|
||||||
public void setIsTimeSyncWarningEnabled(boolean enabled) {
|
public void setIsTimeSyncWarningEnabled(boolean enabled) {
|
||||||
_prefs.edit().putBoolean("pref_warn_time_sync", enabled).apply();
|
_prefs.edit().putBoolean("pref_warn_time_sync", enabled).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCopyOnTapEnabled() {
|
||||||
|
return _prefs.getBoolean("pref_copy_on_tap", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
_entryListView.setTapToRevealTime(getPreferences().getTapToRevealTime());
|
_entryListView.setTapToRevealTime(getPreferences().getTapToRevealTime());
|
||||||
_entryListView.setSortCategory(getPreferences().getCurrentSortCategory(), false);
|
_entryListView.setSortCategory(getPreferences().getCurrentSortCategory(), false);
|
||||||
_entryListView.setViewMode(getPreferences().getCurrentViewMode());
|
_entryListView.setViewMode(getPreferences().getCurrentViewMode());
|
||||||
|
_entryListView.setIsCopyOnTapEnabled(getPreferences().isCopyOnTapEnabled());
|
||||||
|
|
||||||
// set up the floating action button
|
// set up the floating action button
|
||||||
_fabMenu = findViewById(R.id.fab);
|
_fabMenu = findViewById(R.id.fab);
|
||||||
|
@ -226,6 +227,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
boolean tapToReveal = getPreferences().isTapToRevealEnabled();
|
boolean tapToReveal = getPreferences().isTapToRevealEnabled();
|
||||||
int tapToRevealTime = getPreferences().getTapToRevealTime();
|
int tapToRevealTime = getPreferences().getTapToRevealTime();
|
||||||
ViewMode viewMode = getPreferences().getCurrentViewMode();
|
ViewMode viewMode = getPreferences().getCurrentViewMode();
|
||||||
|
boolean copyOnTap = getPreferences().isCopyOnTapEnabled();
|
||||||
_entryListView.setShowAccountName(showAccountName);
|
_entryListView.setShowAccountName(showAccountName);
|
||||||
_entryListView.setCodeGroupSize(codeGroupSize);
|
_entryListView.setCodeGroupSize(codeGroupSize);
|
||||||
_entryListView.setSearchAccountName(searchAccountName);
|
_entryListView.setSearchAccountName(searchAccountName);
|
||||||
|
@ -233,6 +235,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
_entryListView.setTapToReveal(tapToReveal);
|
_entryListView.setTapToReveal(tapToReveal);
|
||||||
_entryListView.setTapToRevealTime(tapToRevealTime);
|
_entryListView.setTapToRevealTime(tapToRevealTime);
|
||||||
_entryListView.setViewMode(viewMode);
|
_entryListView.setViewMode(viewMode);
|
||||||
|
_entryListView.setIsCopyOnTapEnabled(copyOnTap);
|
||||||
_entryListView.refresh(true);
|
_entryListView.refresh(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,8 +658,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyEntryCode(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -701,6 +702,10 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
saveVault();
|
saveVault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEntryCopy(VaultEntry entry) {
|
||||||
|
copyEntryCode(entry);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScroll(int dx, int dy) {
|
public void onScroll(int dx, int dy) {
|
||||||
_fabScrollHelper.onScroll(dx, dy);
|
_fabScrollHelper.onScroll(dx, dy);
|
||||||
|
|
|
@ -228,6 +228,12 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Preference copyOnTapPreference = findPreference("pref_copy_on_tap");
|
||||||
|
copyOnTapPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
_result.putExtra("needsRefresh", true);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
Preference entryHighlightPreference = findPreference("pref_highlight_entry");
|
Preference entryHighlightPreference = findPreference("pref_highlight_entry");
|
||||||
entryHighlightPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
entryHighlightPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
_result.putExtra("needsRefresh", true);
|
_result.putExtra("needsRefresh", true);
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
private boolean _highlightEntry;
|
private boolean _highlightEntry;
|
||||||
private boolean _tapToReveal;
|
private boolean _tapToReveal;
|
||||||
private int _tapToRevealTime;
|
private int _tapToRevealTime;
|
||||||
|
private boolean _copyOnTap;
|
||||||
private String _groupFilter;
|
private String _groupFilter;
|
||||||
private SortCategory _sortCategory;
|
private SortCategory _sortCategory;
|
||||||
private ViewMode _viewMode;
|
private ViewMode _viewMode;
|
||||||
|
@ -89,6 +90,10 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
_highlightEntry = highlightEntry;
|
_highlightEntry = highlightEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsCopyOnTapEnabled(boolean enabled) {
|
||||||
|
_copyOnTap = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public VaultEntry getEntryAt(int position) {
|
public VaultEntry getEntryAt(int position) {
|
||||||
return _shownEntries.get(position);
|
return _shownEntries.get(position);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +348,10 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
|
|
||||||
if (_selectedEntries.isEmpty()) {
|
if (_selectedEntries.isEmpty()) {
|
||||||
|
if (_copyOnTap) {
|
||||||
|
_view.onEntryCopy(entry);
|
||||||
holder.animateCopyText();
|
holder.animateCopyText();
|
||||||
|
}
|
||||||
|
|
||||||
if (_highlightEntry || _tapToReveal) {
|
if (_highlightEntry || _tapToReveal) {
|
||||||
if (_focusedEntry == entry) {
|
if (_focusedEntry == entry) {
|
||||||
|
@ -548,6 +556,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
void onEntryMove(VaultEntry entry1, VaultEntry entry2);
|
void onEntryMove(VaultEntry entry1, VaultEntry entry2);
|
||||||
void onEntryDrop(VaultEntry entry);
|
void onEntryDrop(VaultEntry entry);
|
||||||
void onEntryChange(VaultEntry entry);
|
void onEntryChange(VaultEntry entry);
|
||||||
|
void onEntryCopy(VaultEntry entry);
|
||||||
void onPeriodUniformityChanged(boolean uniform, int period);
|
void onPeriodUniformityChanged(boolean uniform, int period);
|
||||||
void onSelect(VaultEntry entry);
|
void onSelect(VaultEntry entry);
|
||||||
void onDeselect(VaultEntry entry);
|
void onDeselect(VaultEntry entry);
|
||||||
|
|
|
@ -138,6 +138,10 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
_touchCallback.setIsLongPressDragEnabled(enabled);
|
_touchCallback.setIsLongPressDragEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsCopyOnTapEnabled(boolean enabled) {
|
||||||
|
_adapter.setIsCopyOnTapEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
public void setActionModeState(boolean enabled, VaultEntry entry) {
|
public void setActionModeState(boolean enabled, VaultEntry entry) {
|
||||||
_touchCallback.setSelectedEntry(entry);
|
_touchCallback.setSelectedEntry(entry);
|
||||||
_touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed());
|
_touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed());
|
||||||
|
@ -205,6 +209,11 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
_listener.onEntryChange(entry);
|
_listener.onEntryChange(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntryCopy(VaultEntry entry) {
|
||||||
|
_listener.onEntryCopy(entry);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(VaultEntry entry) { _listener.onSelect(entry); }
|
public void onSelect(VaultEntry entry) { _listener.onSelect(entry); }
|
||||||
|
|
||||||
|
@ -323,6 +332,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
void onEntryMove(VaultEntry entry1, VaultEntry entry2);
|
void onEntryMove(VaultEntry entry1, VaultEntry entry2);
|
||||||
void onEntryDrop(VaultEntry entry);
|
void onEntryDrop(VaultEntry entry);
|
||||||
void onEntryChange(VaultEntry entry);
|
void onEntryChange(VaultEntry entry);
|
||||||
|
void onEntryCopy(VaultEntry entry);
|
||||||
void onLongEntryClick(VaultEntry entry);
|
void onLongEntryClick(VaultEntry entry);
|
||||||
void onScroll(int dx, int dy);
|
void onScroll(int dx, int dy);
|
||||||
void onSelect(VaultEntry entry);
|
void onSelect(VaultEntry entry);
|
||||||
|
|
|
@ -195,6 +195,8 @@
|
||||||
<string name="pref_search_name_summary">Include account name matches in the search results</string>
|
<string name="pref_search_name_summary">Include account name matches in the search results</string>
|
||||||
<string name="pref_highlight_entry_title">Highlight tokens when tapped</string>
|
<string name="pref_highlight_entry_title">Highlight tokens when tapped</string>
|
||||||
<string name="pref_highlight_entry_summary">Make tokens easier to distinguish from each other by temporarily highlighting them when tapped</string>
|
<string name="pref_highlight_entry_summary">Make tokens easier to distinguish from each other by temporarily highlighting them when tapped</string>
|
||||||
|
<string name="pref_copy_on_tap_title">Copy tokens when tapped</string>
|
||||||
|
<string name="pref_copy_on_tap_summary">Copy tokens to the clipboard by tapping them</string>
|
||||||
<string name="tap_to_reveal">Hidden</string>
|
<string name="tap_to_reveal">Hidden</string>
|
||||||
<string name="selected">Selected</string>
|
<string name="selected">Selected</string>
|
||||||
<string name="dark_theme_title">Dark theme</string>
|
<string name="dark_theme_title">Dark theme</string>
|
||||||
|
|
|
@ -58,6 +58,12 @@
|
||||||
android:title="@string/pref_search_name_title"
|
android:title="@string/pref_search_name_title"
|
||||||
android:summary="@string/pref_search_name_summary"
|
android:summary="@string/pref_search_name_summary"
|
||||||
app:iconSpaceReserved="false"/>
|
app:iconSpaceReserved="false"/>
|
||||||
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="pref_copy_on_tap"
|
||||||
|
android:title="@string/pref_copy_on_tap_title"
|
||||||
|
android:summary="@string/pref_copy_on_tap_summary"
|
||||||
|
app:iconSpaceReserved="false"/>
|
||||||
<androidx.preference.SwitchPreferenceCompat
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_highlight_entry"
|
android:key="pref_highlight_entry"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue