schedule/draft in overflow menu

This commit is contained in:
sk 2022-12-29 20:24:37 +01:00 committed by LucasGGamerM
parent 245b91bebd
commit fe3052a359
5 changed files with 29 additions and 30 deletions

View File

@ -168,8 +168,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private int charCount, charLimit, trimmedCharCount; private int charCount, charLimit, trimmedCharCount;
private Button publishButton, languageButton, scheduleTimeBtn; private Button publishButton, languageButton, scheduleTimeBtn;
private PopupMenu languagePopup, visibilityPopup, scheduleDraftPopup; private PopupMenu languagePopup, visibilityPopup, moreOptionsPopup;
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, scheduleBtn, scheduleDraftDismiss; private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, moreBtn, scheduleDraftDismiss;
private ImageView sensitiveIcon; private ImageView sensitiveIcon;
private ComposeMediaLayout attachmentsView; private ComposeMediaLayout attachmentsView;
private TextView replyText; private TextView replyText;
@ -317,7 +317,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
emojiBtn=view.findViewById(R.id.btn_emoji); emojiBtn=view.findViewById(R.id.btn_emoji);
spoilerBtn=view.findViewById(R.id.btn_spoiler); spoilerBtn=view.findViewById(R.id.btn_spoiler);
visibilityBtn=view.findViewById(R.id.btn_visibility); 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); scheduleDraftView=view.findViewById(R.id.schedule_draft_view);
scheduleDraftText=view.findViewById(R.id.schedule_draft_text); scheduleDraftText=view.findViewById(R.id.schedule_draft_text);
scheduleDraftDismiss=view.findViewById(R.id.schedule_draft_dismiss); scheduleDraftDismiss=view.findViewById(R.id.schedule_draft_dismiss);
@ -343,19 +343,16 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
visibilityBtn.setOnClickListener(v->visibilityPopup.show()); visibilityBtn.setOnClickListener(v->visibilityPopup.show());
visibilityBtn.setOnTouchListener(visibilityPopup.getDragToOpenListener()); visibilityBtn.setOnTouchListener(visibilityPopup.getDragToOpenListener());
scheduleDraftPopup=new PopupMenu(getContext(), scheduleBtn); moreOptionsPopup =new PopupMenu(getContext(), moreBtn);
scheduleDraftPopup.inflate(R.menu.schedule_draft); moreOptionsPopup.inflate(R.menu.compose_more);
scheduleDraftPopup.setOnMenuItemClickListener(item->{ moreOptionsPopup.setOnMenuItemClickListener(item->{
if (item.getItemId() == R.id.draft) updateScheduledAt(getDraftInstant()); if (item.getItemId() == R.id.draft) updateScheduledAt(getDraftInstant());
else pickScheduledDateTime(); else pickScheduledDateTime();
return true; return true;
}); });
UiUtils.enablePopupMenuIcons(getContext(), scheduleDraftPopup); UiUtils.enablePopupMenuIcons(getContext(), moreOptionsPopup);
scheduleBtn.setOnClickListener(v->{ moreBtn.setOnClickListener(v->moreOptionsPopup.show());
if (scheduledAt != null) updateScheduledAt(null); moreBtn.setOnTouchListener(moreOptionsPopup.getDragToOpenListener());
else scheduleDraftPopup.show();
});
scheduleBtn.setOnTouchListener(scheduleDraftPopup.getDragToOpenListener());
scheduleDraftDismiss.setOnClickListener(v->updateScheduledAt(null)); scheduleDraftDismiss.setOnClickListener(v->updateScheduledAt(null));
scheduleTimeBtn.setOnClickListener(v->pickScheduledDateTime()); scheduleTimeBtn.setOnClickListener(v->pickScheduledDateTime());
@ -1096,7 +1093,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private void confirmDiscardDraftAndFinish(){ private void confirmDiscardDraftAndFinish(){
new M3AlertDialogBuilder(getActivity()) 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) -> { .setPositiveButton(R.string.save, (d, w) -> {
updateScheduledAt(scheduledAt == null ? getDraftInstant() : scheduledAt); updateScheduledAt(scheduledAt == null ? getDraftInstant() : scheduledAt);
publish(); publish();
@ -1594,7 +1591,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private void updateScheduledAt(Instant scheduledAt) { private void updateScheduledAt(Instant scheduledAt) {
this.scheduledAt = scheduledAt; this.scheduledAt = scheduledAt;
scheduleDraftView.setVisibility(scheduledAt == null ? View.GONE : View.VISIBLE); scheduleDraftView.setVisibility(scheduledAt == null ? View.GONE : View.VISIBLE);
scheduleBtn.setSelected(scheduledAt != null); moreBtn.setSelected(scheduledAt != null);
updatePublishButtonState(); updatePublishButtonState();
if (scheduledAt != null) { if (scheduledAt != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault());

View File

@ -349,8 +349,13 @@
android:tooltipText="@string/post_visibility" android:tooltipText="@string/post_visibility"
android:src="@drawable/ic_fluent_earth_24_regular"/> android:src="@drawable/ic_fluent_earth_24_regular"/>
<Space
android:layout_width="0px"
android:layout_height="1px"
android:layout_weight="1"/>
<ImageButton <ImageButton
android:id="@+id/btn_schedule" android:id="@+id/btn_more"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
@ -358,14 +363,9 @@
android:padding="0px" android:padding="0px"
android:tint="@color/compose_button" android:tint="@color/compose_button"
android:tintMode="src_in" android:tintMode="src_in"
android:contentDescription="@string/sk_draft_or_schedule" android:contentDescription="@string/more_options"
android:tooltipText="@string/sk_draft_or_schedule" android:tooltipText="@string/more_options"
android:src="@drawable/ic_fluent_clock_24_selector"/> android:src="@drawable/ic_fluent_more_vertical_24_regular"/>
<Space
android:layout_width="0px"
android:layout_height="1px"
android:layout_weight="1"/>
<TextView <TextView
android:id="@+id/char_counter" android:id="@+id/char_counter"

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/schedule" android:title="@string/sk_schedule_post" android:icon="@drawable/ic_fluent_clock_24_regular" />
<item android:id="@+id/draft" android:title="@string/sk_mark_as_draft" android:icon="@drawable/ic_fluent_drafts_24_regular" />
</menu>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/schedule" android:title="@string/sk_schedule" android:icon="@drawable/ic_fluent_clock_24_regular" />
<item android:id="@+id/draft" android:title="@string/sk_draft" android:icon="@drawable/ic_fluent_drafts_24_regular" />
</menu>

View File

@ -122,6 +122,8 @@
<string name="sk_post_scheduled">Post scheduled</string> <string name="sk_post_scheduled">Post scheduled</string>
<string name="sk_scheduled_too_soon_title">Scheduled time is too soon</string> <string name="sk_scheduled_too_soon_title">Scheduled time is too soon</string>
<string name="sk_scheduled_too_soon">Post must be scheduled at least 10 minutes in the future.</string> <string name="sk_scheduled_too_soon">Post must be scheduled at least 10 minutes in the future.</string>
<string name="sk_save_draft">Save draft?</string> <string name="sk_confirm_save_draft">Save draft?</string>
<string name="sk_save_changes">Save changes?</string> <string name="sk_confirm_save_changes">Save changes?</string>
<string name="sk_mark_as_draft">Mark as draft</string>
<string name="sk_schedule_post">Schedule post</string>
</resources> </resources>