Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions app/src/main/java/com/beemdevelopment/aegis/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@ public void migratePreferences() {

_prefs.edit().remove(prefCopyOnTapKey).apply();
}

String prefCopyBehaviorKey = "pref_current_copy_behavior";
if (_prefs.contains(prefCopyBehaviorKey)
&& !_prefs.contains("pref_single_tap_action")
&& !_prefs.contains("pref_double_tap_action")) {
CopyBehavior copyBehavior = getCopyBehavior();

switch (copyBehavior) {
case SINGLETAP:
setSingleTapAction(TapAction.COPY);
setDoubleTapAction(TapAction.NONE);
break;

case DOUBLETAP:
setSingleTapAction(TapAction.NONE);
setDoubleTapAction(TapAction.COPY);
break;

case NEVER:
default:
setSingleTapAction(TapAction.NONE);
setDoubleTapAction(TapAction.NONE);
break;
}

_prefs.edit().remove(prefCopyBehaviorKey).apply();
}
}

public boolean isTapToRevealEnabled() {
Expand Down Expand Up @@ -580,6 +607,28 @@ public void setCopyBehavior(CopyBehavior copyBehavior) {
_prefs.edit().putInt("pref_current_copy_behavior", copyBehavior.ordinal()).apply();
}

public TapAction getSingleTapAction() {
int def = TapAction.COPY.ordinal();
return TapAction.fromInteger(_prefs.getInt("pref_single_tap_action", def));
}

public void setSingleTapAction(TapAction tapAction) {
_prefs.edit().putInt("pref_single_tap_action", tapAction.ordinal()).apply();
}

public TapAction getDoubleTapAction() {
int def = TapAction.NONE.ordinal();
return TapAction.fromInteger(_prefs.getInt("pref_double_tap_action", def));
}

public void setDoubleTapAction(TapAction tapAction) {
_prefs.edit().putInt("pref_double_tap_action", tapAction.ordinal()).apply();
}

public boolean isReserveFirstTapEnabled() {
return _prefs.getBoolean("pref_reserve_first_tap", false);
}

public boolean isMinimizeOnCopyEnabled() {
return _prefs.getBoolean("pref_minimize_on_copy", false);
}
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/beemdevelopment/aegis/TapAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.beemdevelopment.aegis;

public enum TapAction {
COPY,
EDIT,
NONE;

private static TapAction[] _values;

static {
_values = values();
}

public static TapAction fromInteger(int x) {
if (x < 0 || x >= _values.length) {
return NONE;
}

return _values[x];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,14 @@ protected void onCreate(Bundle savedInstanceState) {
_entryListView.setShowNextCode(_prefs.getShowNextCode());
_entryListView.setOnlyShowNecessaryAccountNames(_prefs.onlyShowNecessaryAccountNames());
_entryListView.setHighlightEntry(_prefs.isEntryHighlightEnabled());
_entryListView.setSingleTapAction(_prefs.getSingleTapAction());
_entryListView.setDoubleTapAction(_prefs.getDoubleTapAction());
_entryListView.setReserveFirstTap(_prefs.isReserveFirstTapEnabled());
_entryListView.setPauseFocused(_prefs.isPauseFocusedEnabled());
_entryListView.setTapToReveal(_prefs.isTapToRevealEnabled());
_entryListView.setTapToRevealTime(_prefs.getTapToRevealTime());
_entryListView.setViewMode(_prefs.getCurrentViewMode());
_entryListView.setSortCategory(_prefs.getCurrentSortCategory(), false);
_entryListView.setCopyBehavior(_prefs.getCopyBehavior());
_entryListView.setSearchBehaviorMask(_prefs.getSearchBehaviorMask());
_prefGroupFilter = _prefs.getGroupFilter();

Expand Down Expand Up @@ -1222,6 +1224,11 @@ public void onEntryClick(VaultEntry entry) {
}
}

@Override
public void onEntryEdit(VaultEntry entry) {
startEditEntryActivity(entry);
}

@Override
public void onSelect(VaultEntry entry) {
_selectedEntries.add(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;

import com.beemdevelopment.aegis.CopyBehavior;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
Expand Down Expand Up @@ -63,26 +62,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
return true;
});

int currentCopyBehavior = _prefs.getCopyBehavior().ordinal();
Preference copyBehaviorPreference = requirePreference("pref_copy_behavior");
copyBehaviorPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.copy_behavior_titles)[currentCopyBehavior]));
copyBehaviorPreference.setOnPreferenceClickListener(preference -> {
int currentCopyBehavior1 = _prefs.getCopyBehavior().ordinal();

Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.choose_copy_behavior))
.setSingleChoiceItems(R.array.copy_behavior_titles, currentCopyBehavior1, (dialog, which) -> {
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
_prefs.setCopyBehavior(CopyBehavior.fromInteger(i));
copyBehaviorPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.copy_behavior_titles)[i]));
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
.create());

return true;
});

Preference entryPausePreference = requirePreference("pref_pause_entry");
entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || _prefs.isEntryHighlightEnabled());

Expand All @@ -91,6 +70,18 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || (boolean) newValue);
return true;
});

Preference tapActions = findPreference("pref_tap_actions");
if (tapActions != null) {
tapActions.setOnPreferenceClickListener(preference -> {
getParentFragmentManager()
.beginTransaction()
.replace(R.id.content, new TapActionsPreferencesFragment())
.addToBackStack(null)
.commit();
return true;
});
}
}

private String getSearchBehaviorSummary() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.beemdevelopment.aegis.ui.fragments.preferences;


import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.SwitchPreferenceCompat;

import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.TapAction;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

public class TapActionsPreferencesFragment extends PreferencesFragment {

@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
setPreferencesFromResource(R.xml.preferences_tap_actions, rootKey);

boolean isTapToRevealEnabled = _prefs.isTapToRevealEnabled();
SwitchPreferenceCompat reserveFirstTap = requirePreference("pref_reserve_first_tap");
Preference tapActionsHint = requirePreference("pref_tap_actions_hint");
reserveFirstTap.setEnabled(isTapToRevealEnabled);
tapActionsHint.setVisible(isTapToRevealEnabled);

Preference singleTapAction = requirePreference("pref_single_tap_action");
singleTapAction.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.pref_tap_action_entries)[_prefs.getSingleTapAction().ordinal()]));
singleTapAction.setOnPreferenceClickListener(preference -> {
int currentSingleTapAction = _prefs.getSingleTapAction().ordinal();
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.choose_single_tap_action))
.setSingleChoiceItems(R.array.pref_tap_action_entries, currentSingleTapAction, (dialog, which) -> {
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
singleTapAction.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.pref_tap_action_entries)[i]));

_prefs.setSingleTapAction(TapAction.fromInteger(i));
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
.create());

return true;
});

Preference doubleTapAction = requirePreference("pref_double_tap_action");
doubleTapAction.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.pref_tap_action_entries)[_prefs.getDoubleTapAction().ordinal()]));
doubleTapAction.setOnPreferenceClickListener(preference -> {
int currentDoubleTapAction = _prefs.getDoubleTapAction().ordinal();

Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.choose_double_tap_action))
.setSingleChoiceItems(R.array.pref_tap_action_entries, currentDoubleTapAction, (dialog, which) -> {
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
doubleTapAction.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.pref_tap_action_entries)[i]));

_prefs.setDoubleTapAction(TapAction.fromInteger(i));
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
.create());

return true;
});
}
}
Loading
Loading