diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-05-26 18:47:43 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2021-05-26 18:47:43 +0300 |
commit | 3977c1336c68d9960079907645b09fb66db865c5 (patch) | |
tree | 1bae2b46b77a8eaf65ca5c65a3810684c569b868 /app/src/main/java/it/niedermann/nextcloud/deck/ui/card | |
parent | 93c5018c5cb926755dea7524a621ed4b9d4d7ae7 (diff) |
#971 Automatically toggle to edit mode when content is empty
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/card')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java index d827ba9ac..8a51967bd 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java @@ -133,10 +133,13 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, binding.descriptionViewer.setMovementMethod(LinkMovementMethod.getInstance()); viewModel.descriptionIsPreviewMode().observe(getViewLifecycleOwner(), (isPreview) -> { if (isPreview) { - toggleEditorView(isPreview, binding.descriptionViewer, binding.descriptionEditorWrapper, binding.descriptionViewer); + if (TextUtils.isEmpty(viewModel.getFullCard().getCard().getDescription())) { + binding.getRoot().post(() -> viewModel.toggleDescriptionPreviewMode()); + } + toggleEditorView(binding.descriptionViewer, binding.descriptionEditorWrapper, binding.descriptionViewer); binding.descriptionToggle.setImageResource(R.drawable.ic_edit_grey600_24dp); } else { - toggleEditorView(isPreview, binding.descriptionEditorWrapper, binding.descriptionViewer, binding.descriptionEditor); + toggleEditorView(binding.descriptionEditorWrapper, binding.descriptionViewer, binding.descriptionEditor); binding.descriptionToggle.setImageResource(R.drawable.ic_baseline_eye_24); } }); @@ -150,7 +153,7 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, } } - private void toggleEditorView(boolean isPreview, @NonNull View viewToShow, @NonNull View viewToHide, @NonNull MarkdownEditor editorToShow) { + private void toggleEditorView(@NonNull View viewToShow, @NonNull View viewToHide, @NonNull MarkdownEditor editorToShow) { editorToShow.setMarkdownString(viewModel.getFullCard().getCard().getDescription()); if (!editorToShow.getMarkdownString().hasActiveObservers()) { editorToShow.getMarkdownString().observe(getViewLifecycleOwner(), (description) -> { @@ -159,7 +162,7 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, } else { ExceptionDialogFragment.newInstance(new IllegalStateException(FullCard.class.getSimpleName() + " was empty when trying to setup description"), viewModel.getAccount()).show(getChildFragmentManager(), ExceptionDialogFragment.class.getSimpleName()); } - binding.descriptionToggle.setVisibility(TextUtils.isEmpty(description) && !isPreview ? INVISIBLE : VISIBLE); + binding.descriptionToggle.setVisibility(TextUtils.isEmpty(description) ? INVISIBLE : VISIBLE); }); } viewToHide.setVisibility(GONE); |