diff options
author | stefan-niedermann <info@niedermann.it> | 2019-10-16 20:17:18 +0300 |
---|---|---|
committer | stefan-niedermann <info@niedermann.it> | 2019-10-16 20:17:18 +0300 |
commit | 99f0120f0056d144a7702b013ede44f30b206890 (patch) | |
tree | b27a6639b68cee79a57984a3cacd17d856b3cbef | |
parent | 90626c935751c8bc7b3e5fb9ad4f0529802e558e (diff) |
Fix #182 "Delete column"-menu disappears in some cases
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java | 26 | ||||
-rw-r--r-- | fastlane/metadata/android/en-US/changelogs/13.txt | 3 |
2 files changed, 17 insertions, 12 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 082ff21a8..4fa43865a 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 @@ -55,6 +55,7 @@ import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.NO_LOCAL_ID; import static it.niedermann.nextcloud.deck.ui.stack.EditStackDialogFragment.NO_STACK_ID; public class MainActivity extends DrawerActivity { + @BindView(R.id.fab) FloatingActionButton fab; @BindView(R.id.navigationView) @@ -67,14 +68,14 @@ public class MainActivity extends DrawerActivity { RelativeLayout noStacks; private StackAdapter stackAdapter; - - private MenuItem addColumnMenuItem; - private List<Board> boardsList; private LiveData<List<Board>> boardsLiveData; private Observer<List<Board>> boardsLiveDataObserver; + private long currentBoardId = 0; private boolean currentBoardHasEditPermission = false; + private boolean currentBoardHasStacks = false; + private TabLayoutHelper mTabLayoutHelper; @Override @@ -340,26 +341,23 @@ public class MainActivity extends DrawerActivity { currentBoardHasEditPermission = board.isPermissionEdit(); if (currentBoardHasEditPermission) { fab.show(); - invalidateOptionsMenu(); - onCreateOptionsMenu(toolbar.getMenu()); } else { fab.hide(); - toolbar.getMenu().clear(); } syncManager.getStacksForBoard(account.getId(), board.getLocalId()).observe(MainActivity.this, (List<FullStack> fullStacks) -> { if (fullStacks == null) { noStacks.setVisibility(View.VISIBLE); - addColumnMenuItem.setVisible(false); + currentBoardHasStacks = false; } else { long savedStackId = sharedPreferences.getLong(getString(R.string.shared_preference_last_stack_for_account_and_board) + account.getId() + "_" + this.currentBoardId, NO_STACKS); DeckLog.log("--- Read: shared_preference_last_stack_for_account_and_board" + account.getId() + "_" + this.currentBoardId + " | " + savedStackId); if (fullStacks.size() == 0) { noStacks.setVisibility(View.VISIBLE); - addColumnMenuItem.setVisible(false); + currentBoardHasStacks = false; } else { noStacks.setVisibility(View.GONE); - addColumnMenuItem.setVisible(true); + currentBoardHasStacks = true; } StackAdapter newStackAdapter = new StackAdapter(getSupportFragmentManager()); @@ -381,14 +379,20 @@ public class MainActivity extends DrawerActivity { stackLayout.setupWithViewPager(viewPager); }); } + invalidateOptionsMenu(); }); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.card_list_menu, menu); - addColumnMenuItem = menu.findItem(R.id.action_card_list_delete_column); + if(currentBoardHasEditPermission) { + inflater.inflate(R.menu.card_list_menu, menu); + menu.findItem(R.id.action_card_list_rename_column).setVisible(currentBoardHasStacks); + menu.findItem(R.id.action_card_list_delete_column).setVisible(currentBoardHasStacks); + } else { + menu.clear(); + } return super.onCreateOptionsMenu(menu); } diff --git a/fastlane/metadata/android/en-US/changelogs/13.txt b/fastlane/metadata/android/en-US/changelogs/13.txt index c3b0b76e7..9b38995f8 100644 --- a/fastlane/metadata/android/en-US/changelogs/13.txt +++ b/fastlane/metadata/android/en-US/changelogs/13.txt @@ -1,4 +1,5 @@ - Fix Double-clicking card opens EditActivity twice (#159) - Fix crash when hitting enter on a label or user search input - SyncOnWifiOnly causes OfflineException on opening about activity (#165) -- Move card title to toolbar when opening a card
\ No newline at end of file +- Move card title to toolbar when opening a card +- Fix "Delete column"-menu disappears in some cases (#182)
\ No newline at end of file |