mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Merge pull request #904 from CristianAUnisa/dont-hide-fab-on-keydown
Don't hide "Add entry" button when a DPad key is pressed
This commit is contained in:
commit
b0e8d041d0
2 changed files with 29 additions and 1 deletions
|
@ -10,9 +10,11 @@ import android.graphics.BitmapFactory;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -74,6 +76,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
private boolean _loaded;
|
||||
private boolean _searchSubmitted;
|
||||
private boolean _isRecreated;
|
||||
private boolean _isDPadPressed;
|
||||
|
||||
private List<VaultEntry> _selectedEntries;
|
||||
private ActionMode _actionMode;
|
||||
|
@ -94,6 +97,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
setContentView(R.layout.activity_main);
|
||||
setSupportActionBar(findViewById(R.id.toolbar));
|
||||
_loaded = false;
|
||||
_isDPadPressed = false;
|
||||
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
_isRecreated = true;
|
||||
|
@ -208,6 +213,21 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
_isDPadPressed = isDPadKey(keyCode);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private static boolean isDPadKey(int keyCode) {
|
||||
return keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntryListTouch() {
|
||||
_isDPadPressed = false;
|
||||
}
|
||||
|
||||
private void onPreferencesResult(Intent data) {
|
||||
// refresh the entire entry list if needed
|
||||
if (_loaded) {
|
||||
|
@ -721,7 +741,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
@Override
|
||||
public void onScroll(int dx, int dy) {
|
||||
_fabScrollHelper.onScroll(dx, dy);
|
||||
if (!_isDPadPressed) {
|
||||
_fabScrollHelper.onScroll(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,6 +101,11 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
}
|
||||
});
|
||||
|
||||
_recyclerView.setOnTouchListener((v, event) -> {
|
||||
_listener.onEntryListTouch();
|
||||
return false;
|
||||
});
|
||||
|
||||
// set up icon preloading
|
||||
_preloadSizeProvider = new ViewPreloadSizeProvider<>();
|
||||
IconPreloadProvider modelProvider = new IconPreloadProvider();
|
||||
|
@ -510,6 +515,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
void onDeselect(VaultEntry entry);
|
||||
void onListChange();
|
||||
void onSaveGroupFilter(List<String> groupFilter);
|
||||
void onEntryListTouch();
|
||||
}
|
||||
|
||||
private class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue