From f0a704b93b172125cb83b184b671cb0d8251af98 Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 29 Dec 2022 20:24:37 +0100 Subject: [PATCH] schedule/draft in overflow menu --- .../android/fragments/ComposeFragment.java | 25 ++++++++----------- .../src/main/res/layout/fragment_compose.xml | 18 ++++++------- mastodon/src/main/res/menu/compose_more.xml | 5 ++++ mastodon/src/main/res/menu/schedule_draft.xml | 5 ---- mastodon/src/main/res/values/strings_sk.xml | 6 +++-- 5 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 mastodon/src/main/res/menu/compose_more.xml delete mode 100644 mastodon/src/main/res/menu/schedule_draft.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index b71098954..0795306d4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -168,8 +168,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr private int charCount, charLimit, trimmedCharCount; private Button publishButton, languageButton, scheduleTimeBtn; - private PopupMenu languagePopup, visibilityPopup, scheduleDraftPopup; - private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, scheduleBtn, scheduleDraftDismiss; + private PopupMenu languagePopup, visibilityPopup, moreOptionsPopup; + private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, moreBtn, scheduleDraftDismiss; private ImageView sensitiveIcon; private ComposeMediaLayout attachmentsView; private TextView replyText; @@ -315,7 +315,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr emojiBtn=view.findViewById(R.id.btn_emoji); spoilerBtn=view.findViewById(R.id.btn_spoiler); visibilityBtn=view.findViewById(R.id.btn_visibility); - scheduleBtn=view.findViewById(R.id.btn_schedule); + moreBtn=view.findViewById(R.id.btn_more); scheduleDraftView=view.findViewById(R.id.schedule_draft_view); scheduleDraftText=view.findViewById(R.id.schedule_draft_text); scheduleDraftDismiss=view.findViewById(R.id.schedule_draft_dismiss); @@ -332,19 +332,16 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr visibilityBtn.setOnClickListener(v->visibilityPopup.show()); visibilityBtn.setOnTouchListener(visibilityPopup.getDragToOpenListener()); - scheduleDraftPopup=new PopupMenu(getContext(), scheduleBtn); - scheduleDraftPopup.inflate(R.menu.schedule_draft); - scheduleDraftPopup.setOnMenuItemClickListener(item->{ + moreOptionsPopup =new PopupMenu(getContext(), moreBtn); + moreOptionsPopup.inflate(R.menu.compose_more); + moreOptionsPopup.setOnMenuItemClickListener(item->{ if (item.getItemId() == R.id.draft) updateScheduledAt(getDraftInstant()); else pickScheduledDateTime(); return true; }); - UiUtils.enablePopupMenuIcons(getContext(), scheduleDraftPopup); - scheduleBtn.setOnClickListener(v->{ - if (scheduledAt != null) updateScheduledAt(null); - else scheduleDraftPopup.show(); - }); - scheduleBtn.setOnTouchListener(scheduleDraftPopup.getDragToOpenListener()); + UiUtils.enablePopupMenuIcons(getContext(), moreOptionsPopup); + moreBtn.setOnClickListener(v->moreOptionsPopup.show()); + moreBtn.setOnTouchListener(moreOptionsPopup.getDragToOpenListener()); scheduleDraftDismiss.setOnClickListener(v->updateScheduledAt(null)); scheduleTimeBtn.setOnClickListener(v->pickScheduledDateTime()); @@ -1079,7 +1076,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr private void confirmDiscardDraftAndFinish(){ new M3AlertDialogBuilder(getActivity()) - .setTitle(editingStatus != null ? R.string.sk_save_changes : R.string.sk_save_draft) + .setTitle(editingStatus != null ? R.string.sk_confirm_save_changes : R.string.sk_confirm_save_draft) .setPositiveButton(R.string.save, (d, w) -> { updateScheduledAt(scheduledAt == null ? getDraftInstant() : scheduledAt); publish(); @@ -1577,7 +1574,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr private void updateScheduledAt(Instant scheduledAt) { this.scheduledAt = scheduledAt; scheduleDraftView.setVisibility(scheduledAt == null ? View.GONE : View.VISIBLE); - scheduleBtn.setSelected(scheduledAt != null); + moreBtn.setSelected(scheduledAt != null); updatePublishButtonState(); if (scheduledAt != null) { DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()); diff --git a/mastodon/src/main/res/layout/fragment_compose.xml b/mastodon/src/main/res/layout/fragment_compose.xml index 40c28a96f..bd862ea83 100644 --- a/mastodon/src/main/res/layout/fragment_compose.xml +++ b/mastodon/src/main/res/layout/fragment_compose.xml @@ -349,8 +349,13 @@ android:tooltipText="@string/post_visibility" android:src="@drawable/ic_fluent_earth_24_regular"/> + + - - + android:contentDescription="@string/more_options" + android:tooltipText="@string/more_options" + android:src="@drawable/ic_fluent_more_vertical_24_regular"/> + + + + diff --git a/mastodon/src/main/res/menu/schedule_draft.xml b/mastodon/src/main/res/menu/schedule_draft.xml deleted file mode 100644 index 5c14ae5b8..000000000 --- a/mastodon/src/main/res/menu/schedule_draft.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 6c6a0e136..1ba6d14fc 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -117,6 +117,8 @@ Post scheduled Scheduled time is too soon Post must be scheduled at least 10 minutes in the future. - Save draft? - Save changes? + Save draft? + Save changes? + Mark as draft + Schedule post \ No newline at end of file