diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-05-09 18:08:17 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-05-09 18:08:17 +0300 |
commit | d4a25e9ef04bbebda8324bb8d059a3b7717f6989 (patch) | |
tree | f773ee243042d62e3dfa1388a39f46f9e2d36f15 /app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards | |
parent | 11f7cbe73274e6bbfda2a05c12e9a735b31707d2 (diff) |
#423 Handle too old server version
- ArchivedBoardsActivity
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards')
3 files changed, 44 insertions, 37 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardViewHolder.java index 03d125f6b..5ab94b4f6 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardViewHolder.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardViewHolder.java @@ -28,47 +28,52 @@ public class ArchivedBoardViewHolder extends RecyclerView.ViewHolder { this.binding = binding; } - void bind(Board board, FragmentManager fragmentManager, Consumer<Board> dearchiveBoardListener) { + void bind(boolean isSupportedVersion, Board board, FragmentManager fragmentManager, Consumer<Board> dearchiveBoardListener) { final Context context = itemView.getContext(); binding.boardIcon.setImageDrawable(ViewUtil.getTintedImageView(binding.boardIcon.getContext(), R.drawable.circle_grey600_36dp, "#" + board.getColor())); binding.boardMenu.setVisibility(View.GONE); binding.boardTitle.setText(board.getTitle()); - if (board.isPermissionManage()) { - binding.boardMenu.setVisibility(View.VISIBLE); - binding.boardMenu.setImageDrawable(ViewUtil.getTintedImageView(context, R.drawable.ic_menu, R.color.grey600)); + if (isSupportedVersion) { + if (board.isPermissionManage()) { + binding.boardMenu.setVisibility(View.VISIBLE); + binding.boardMenu.setImageDrawable(ViewUtil.getTintedImageView(context, R.drawable.ic_menu, R.color.grey600)); - binding.boardMenu.setOnClickListener((v) -> { - PopupMenu popup = new PopupMenu(context, binding.boardMenu); - popup.getMenuInflater().inflate(R.menu.archived_board_menu, popup.getMenu()); - final int SHARE_BOARD_ID = -1; - if (board.isPermissionShare()) { - popup.getMenu().add(Menu.NONE, SHARE_BOARD_ID, 5, R.string.share_board); - } - popup.setOnMenuItemClickListener((MenuItem item) -> { - final String editBoard = context.getString(R.string.edit_board); - switch (item.getItemId()) { - case SHARE_BOARD_ID: - AccessControlDialogFragment.newInstance(board.getLocalId()).show(fragmentManager, AccessControlDialogFragment.class.getSimpleName()); - return true; - case R.id.edit_board: - EditBoardDialogFragment.newInstance(board.getLocalId()).show(fragmentManager, editBoard); - return true; - case R.id.dearchive_board: - dearchiveBoardListener.accept(board); - return true; - case R.id.delete_board: - DeleteBoardDialogFragment.newInstance(board).show(fragmentManager, DeleteBoardDialogFragment.class.getSimpleName()); - return true; - default: - return false; + binding.boardMenu.setOnClickListener((v) -> { + PopupMenu popup = new PopupMenu(context, binding.boardMenu); + popup.getMenuInflater().inflate(R.menu.archived_board_menu, popup.getMenu()); + final int SHARE_BOARD_ID = -1; + if (board.isPermissionShare()) { + popup.getMenu().add(Menu.NONE, SHARE_BOARD_ID, 5, R.string.share_board); } + popup.setOnMenuItemClickListener((MenuItem item) -> { + final String editBoard = context.getString(R.string.edit_board); + switch (item.getItemId()) { + case SHARE_BOARD_ID: + AccessControlDialogFragment.newInstance(board.getLocalId()).show(fragmentManager, AccessControlDialogFragment.class.getSimpleName()); + return true; + case R.id.edit_board: + EditBoardDialogFragment.newInstance(board.getLocalId()).show(fragmentManager, editBoard); + return true; + case R.id.dearchive_board: + dearchiveBoardListener.accept(board); + return true; + case R.id.delete_board: + DeleteBoardDialogFragment.newInstance(board).show(fragmentManager, DeleteBoardDialogFragment.class.getSimpleName()); + return true; + default: + return false; + } + }); + popup.show(); }); - popup.show(); - }); - } else if (board.isPermissionShare()) { + } else if (board.isPermissionShare()) { + binding.boardMenu.setVisibility(View.VISIBLE); + binding.boardMenu.setImageDrawable(ViewUtil.getTintedImageView(context, R.drawable.ic_share_grey600_18dp, R.color.grey600)); + binding.boardMenu.setOnClickListener((v) -> AccessControlDialogFragment.newInstance(board.getLocalId()).show(fragmentManager, AccessControlDialogFragment.class.getSimpleName())); + } binding.boardMenu.setVisibility(View.VISIBLE); - binding.boardMenu.setImageDrawable(ViewUtil.getTintedImageView(context, R.drawable.ic_share_grey600_18dp, R.color.grey600)); - binding.boardMenu.setOnClickListener((v) -> AccessControlDialogFragment.newInstance(board.getLocalId()).show(fragmentManager, AccessControlDialogFragment.class.getSimpleName())); + } else { + binding.boardMenu.setVisibility(View.GONE); } } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActvitiy.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActvitiy.java index 79aba8d34..07ca40661 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActvitiy.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActvitiy.java @@ -53,10 +53,10 @@ public class ArchivedBoardsActvitiy extends BrandedActivity implements DeleteBoa setSupportActionBar(binding.toolbar); viewModel = new ViewModelProvider(this).get(MainViewModel.class); - viewModel.setCurrentAccount(account); + viewModel.setCurrentAccount(account, account.getServerDeckVersionAsObject().isSupported(this)); syncManager = new SyncManager(this); - adapter = new ArchivedBoardsAdapter(getSupportFragmentManager(), (board) -> syncManager.dearchiveBoard(board)); + adapter = new ArchivedBoardsAdapter(viewModel.isCurrentAccountIsSupportedVersion(), getSupportFragmentManager(), (board) -> syncManager.dearchiveBoard(board)); binding.recyclerView.setAdapter(adapter); syncManager.getBoards(account.getId(), true).observe(this, (boards) -> { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsAdapter.java index 86a194319..7bf82314c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsAdapter.java @@ -16,6 +16,7 @@ import it.niedermann.nextcloud.deck.model.Board; public class ArchivedBoardsAdapter extends RecyclerView.Adapter<ArchivedBoardViewHolder> { + private final boolean isSupportedVersion; @NonNull private final Consumer<Board> onDearchiveListener; @NonNull @@ -24,7 +25,8 @@ public class ArchivedBoardsAdapter extends RecyclerView.Adapter<ArchivedBoardVie private List<Board> boards = new ArrayList<>(); @SuppressWarnings("WeakerAccess") - public ArchivedBoardsAdapter(@NonNull FragmentManager fragmentManager, @NonNull Consumer<Board> onDearchiveListener) { + public ArchivedBoardsAdapter(boolean isSupportedVersion, @NonNull FragmentManager fragmentManager, @NonNull Consumer<Board> onDearchiveListener) { + this.isSupportedVersion = isSupportedVersion; this.fragmentManager = fragmentManager; this.onDearchiveListener = onDearchiveListener; setHasStableIds(true); @@ -43,7 +45,7 @@ public class ArchivedBoardsAdapter extends RecyclerView.Adapter<ArchivedBoardVie @Override public void onBindViewHolder(@NonNull ArchivedBoardViewHolder holder, int position) { - holder.bind(boards.get(position), fragmentManager, onDearchiveListener); + holder.bind(isSupportedVersion, boards.get(position), fragmentManager, onDearchiveListener); } @Override |