diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-03-28 18:52:58 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2021-03-28 20:00:49 +0300 |
commit | 2d3517377e7093daff10b796d3e2c5eabb26e4de (patch) | |
tree | a59c3c154d167e4f85755a21763e63f1d16f1788 /app/src/main/java | |
parent | febf3eed80280e7d7637d82da1b3f02fc056dbb0 (diff) |
#630 Search - Handle soft keyboard state
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 26625038b..9f18c791d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -403,15 +403,8 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener distinctUntilChanged(map(filterViewModel.getFilterInformation(), FilterInformation::hasActiveFilter)) .observe(this, (hasActiveFilter) -> binding.filterIndicator.setVisibility(hasActiveFilter ? View.VISIBLE : View.GONE)); // binding.archivedCards.setOnClickListener((v) -> startActivity(ArchivedCardsActvitiy.createIntent(this, mainViewModel.getCurrentAccount(), mainViewModel.getCurrentBoardLocalId(), mainViewModel.currentBoardHasEditPermission()))); - binding.enableSearch.setOnClickListener((v) -> { - binding.toolbar.setVisibility(View.GONE); - binding.searchToolbar.setVisibility(View.VISIBLE); - binding.searchToolbar.setNavigationOnClickListener(v1 -> onBackPressed()); - binding.enableSearch.setVisibility(View.GONE); - binding.filterText.requestFocus(); - final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(binding.filterText, InputMethodManager.SHOW_IMPLICIT); - }); + binding.enableSearch.setOnClickListener((v) -> showFilterTextToolbar()); + binding.toolbar.setOnClickListener((v) -> showFilterTextToolbar()); binding.swipeRefreshLayout.setOnRefreshListener(() -> { @@ -945,15 +938,31 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) { binding.drawerLayout.closeDrawer(GravityCompat.START); } else if (binding.searchToolbar.getVisibility() == View.VISIBLE) { - binding.filterText.setText(null); - binding.searchToolbar.setVisibility(View.GONE); - binding.enableSearch.setVisibility(View.VISIBLE); - binding.toolbar.setVisibility(View.VISIBLE); + hideFilterTextToolbar(); } else { super.onBackPressed(); } } + private void showFilterTextToolbar() { + binding.toolbar.setVisibility(View.GONE); + binding.searchToolbar.setVisibility(View.VISIBLE); + binding.searchToolbar.setNavigationOnClickListener(v1 -> onBackPressed()); + binding.enableSearch.setVisibility(View.GONE); + binding.filterText.requestFocus(); + final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(binding.filterText, InputMethodManager.SHOW_IMPLICIT); + } + + private void hideFilterTextToolbar() { + binding.filterText.setText(null); + final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + binding.searchToolbar.setVisibility(View.GONE); + binding.enableSearch.setVisibility(View.VISIBLE); + binding.toolbar.setVisibility(View.VISIBLE); + } + private void registerAutoSyncOnNetworkAvailable() { final ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkRequest.Builder builder = new NetworkRequest.Builder(); |