diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-11-26 16:57:25 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-11-26 16:57:25 +0300 |
commit | 7aaffb043b6c3f8ca45498c1b1a0f2d92db64dd1 (patch) | |
tree | 244d643601c53401e3fff1b68840fceaae832f84 /app/src/main | |
parent | 56d03fe68be4fb6e7fa1743d66d0a01d0dc30a9f (diff) |
Provide edit and preview mode for card description
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main')
5 files changed, 77 insertions, 6 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/assignee/CardAssigneeDialog.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/assignee/CardAssigneeDialog.java index 34d2eb3f3..b18f35de0 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/assignee/CardAssigneeDialog.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/assignee/CardAssigneeDialog.java @@ -24,10 +24,13 @@ import it.niedermann.nextcloud.deck.model.User; import it.niedermann.nextcloud.deck.ui.branding.BrandedDeleteAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; import it.niedermann.nextcloud.deck.ui.card.EditCardViewModel; +import it.niedermann.nextcloud.deck.ui.card.attachments.previewdialog.PreviewDialog; import static it.niedermann.nextcloud.deck.DeckApplication.isDarkTheme; -@Deprecated +/** + * TODO maybe this can be merged with {@link PreviewDialog} + */ public class CardAssigneeDialog extends BrandedDialogFragment { private static final String KEY_USER = "user"; 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 1422620a7..0ad30eb87 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 @@ -69,6 +69,7 @@ public class CardDetailsFragment extends BrandedFragment implements OnDateSetLis private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM); private final DateTimeFormatter timeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT); private AppCompatActivity activity; + boolean editorActive = true; @Override public void onAttach(@NonNull Context context) { @@ -138,9 +139,23 @@ public class CardDetailsFragment extends BrandedFragment implements OnDateSetLis } private void setupDescription() { - binding.description.setMarkdownString(viewModel.getFullCard().getCard().getDescription()); if (viewModel.canEdit()) { - binding.description.getMarkdownString().observe(getViewLifecycleOwner(), (newText) -> { + binding.descriptionToggle.setVisibility(VISIBLE); + binding.descriptionToggle.setOnClickListener((v) -> { + editorActive = !editorActive; + if (editorActive) { + binding.descriptionEditor.setVisibility(VISIBLE); + binding.descriptionViewer.setVisibility(GONE); + binding.descriptionToggle.setImageResource(R.drawable.ic_baseline_eye_24); + } else { + binding.descriptionEditor.setVisibility(GONE); + binding.descriptionViewer.setVisibility(VISIBLE); + binding.descriptionViewer.setMarkdownString(viewModel.getFullCard().getCard().getDescription()); + binding.descriptionToggle.setImageResource(R.drawable.ic_edit_grey600_24dp); + } + }); + binding.descriptionEditor.setMarkdownString(viewModel.getFullCard().getCard().getDescription()); + binding.descriptionEditor.getMarkdownString().observe(getViewLifecycleOwner(), (newText) -> { if (viewModel.getFullCard() != null) { viewModel.getFullCard().getCard().setDescription(newText == null ? "" : newText.toString()); } else { @@ -148,7 +163,11 @@ public class CardDetailsFragment extends BrandedFragment implements OnDateSetLis } }); } else { - binding.description.setEnabled(false); + binding.descriptionEditor.setEnabled(false); + binding.descriptionEditor.setVisibility(VISIBLE); + binding.descriptionViewer.setEnabled(false); + binding.descriptionViewer.setVisibility(GONE); + binding.descriptionViewer.setMarkdownString(viewModel.getFullCard().getCard().getDescription()); } } diff --git a/app/src/main/res/drawable/ic_baseline_eye_24.xml b/app/src/main/res/drawable/ic_baseline_eye_24.xml new file mode 100644 index 000000000..c8acf29a8 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_eye_24.xml @@ -0,0 +1,5 @@ +<vector android:height="24dp" android:tint="#757575" + android:viewportHeight="24" android:viewportWidth="24" + android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/> +</vector> diff --git a/app/src/main/res/layout/fragment_card_edit_tab_details.xml b/app/src/main/res/layout/fragment_card_edit_tab_details.xml index 8aaabf475..f06a95978 100644 --- a/app/src/main/res/layout/fragment_card_edit_tab_details.xml +++ b/app/src/main/res/layout/fragment_card_edit_tab_details.xml @@ -130,10 +130,53 @@ app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@tools:sample/avatars" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <ImageView + android:layout_width="@dimen/icon_size_details" + android:layout_height="match_parent" + android:layout_marginEnd="@dimen/spacer_2x" + android:contentDescription="@null" + app:srcCompat="@drawable/ic_baseline_subject_24" /> + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="end" + android:orientation="horizontal"> + + <ImageView + android:id="@+id/descriptionToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackgroundBorderless" + android:contentDescription="@string/edit_description" + android:paddingStart="@dimen/spacer_1x" + android:paddingEnd="@dimen/spacer_1x" + android:visibility="gone" + app:srcCompat="@drawable/ic_baseline_eye_24" + tools:visibility="visible" /> + </LinearLayout> + </LinearLayout> + <it.niedermann.android.markdown.MarkdownEditorImpl - android:id="@+id/description" + android:id="@+id/descriptionEditor" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacer_1x" + android:textColor="?attr/colorAccent" /> + + <it.niedermann.android.markdown.MarkdownViewerImpl + android:id="@+id/descriptionViewer" android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacer_2x" + android:textColor="?attr/colorAccent" + android:textSize="18sp" /> </LinearLayout> <TextView diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b2b4efcb..8c29e67cd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -320,4 +320,5 @@ <string name="gallery">Gallery</string> <string name="simple_attach">attach</string> <string name="add_stack_widget">Add list widget</string> + <string name="edit_description">Edit description</string> </resources> |