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 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;
@ -317,7 +317,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);
@ -343,19 +343,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());
@ -1096,7 +1093,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();
@ -1594,7 +1591,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());

View File

@ -349,8 +349,13 @@
android:tooltipText="@string/post_visibility"
android:src="@drawable/ic_fluent_earth_24_regular"/>
<Space
android:layout_width="0px"
android:layout_height="1px"
android:layout_weight="1"/>
<ImageButton
android:id="@+id/btn_schedule"
android:id="@+id/btn_more"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="24dp"
@ -358,14 +363,9 @@
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/sk_draft_or_schedule"
android:tooltipText="@string/sk_draft_or_schedule"
android:src="@drawable/ic_fluent_clock_24_selector"/>
<Space
android:layout_width="0px"
android:layout_height="1px"
android:layout_weight="1"/>
android:contentDescription="@string/more_options"
android:tooltipText="@string/more_options"
android:src="@drawable/ic_fluent_more_vertical_24_regular"/>
<TextView
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_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_save_draft">Save draft?</string>
<string name="sk_save_changes">Save changes?</string>
<string name="sk_confirm_save_draft">Save draft?</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>