move and refine scheduling and drafting

This commit is contained in:
sk
2022-12-30 21:48:59 +01:00
parent 676e166459
commit 3e0e0c1484
11 changed files with 62 additions and 50 deletions

View File

@@ -22,7 +22,6 @@ import android.graphics.PixelFormat;
import android.graphics.RenderEffect;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.icu.text.BreakIterator;
import android.media.MediaMetadataRetriever;
@@ -39,7 +38,6 @@ import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.format.DateFormat;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -170,8 +168,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private int charCount, charLimit, trimmedCharCount;
private Button publishButton, languageButton, scheduleTimeBtn, draftsBtn;
private PopupMenu languagePopup, visibilityPopup, moreOptionsPopup;
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, moreBtn, scheduleDraftDismiss;
private PopupMenu languagePopup, visibilityPopup, draftOptionsPopup;
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, scheduleDraftDismiss;
private ImageView sensitiveIcon;
private ComposeMediaLayout attachmentsView;
private TextView replyText;
@@ -184,6 +182,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private TextView scheduleDraftText;
private CheckBox pollAllowMultipleCheckbox;
private TextView pollDurationView;
private MenuItem draftMenuItem, undraftMenuItem, scheduleMenuItem, unscheduleMenuItem;
private ArrayList<DraftPollOption> pollOptions=new ArrayList<>();
@@ -317,7 +316,6 @@ 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);
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);
@@ -334,16 +332,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
visibilityBtn.setOnClickListener(v->visibilityPopup.show());
visibilityBtn.setOnTouchListener(visibilityPopup.getDragToOpenListener());
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(), moreOptionsPopup);
moreBtn.setOnClickListener(v->moreOptionsPopup.show());
moreBtn.setOnTouchListener(moreOptionsPopup.getDragToOpenListener());
scheduleDraftDismiss.setOnClickListener(v->updateScheduledAt(null));
scheduleTimeBtn.setOnClickListener(v->pickScheduledDateTime());
@@ -671,7 +659,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
}
updateSensitive();
updateScheduledAt(scheduledAt != null ? scheduledAt : scheduledStatus != null ? scheduledStatus.scheduledAt : null);
if(editingStatus!=null){
updateCharCounter();
@@ -687,19 +674,36 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
item.setActionView(wrap);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
publishButton = wrap.findViewById(R.id.publish_btn);
draftsBtn = wrap.findViewById(R.id.drafts_btn);
draftOptionsPopup = new PopupMenu(getContext(), draftsBtn);
draftOptionsPopup.inflate(R.menu.compose_more);
draftMenuItem = draftOptionsPopup.getMenu().findItem(R.id.draft);
undraftMenuItem = draftOptionsPopup.getMenu().findItem(R.id.undraft);
scheduleMenuItem = draftOptionsPopup.getMenu().findItem(R.id.schedule);
unscheduleMenuItem = draftOptionsPopup.getMenu().findItem(R.id.unschedule);
draftOptionsPopup.setOnMenuItemClickListener(i->{
int id = i.getItemId();
if (id == R.id.draft) updateScheduledAt(getDraftInstant());
else if (id == R.id.schedule) pickScheduledDateTime();
else if (id == R.id.unschedule || id == R.id.undraft) updateScheduledAt(null);
else navigateToUnsentPosts();
return true;
});
UiUtils.enablePopupMenuIcons(getContext(), draftOptionsPopup);
publishButton = wrap.findViewById(R.id.publish_btn);
languageButton = wrap.findViewById(R.id.language_btn);
sendProgress = wrap.findViewById(R.id.send_progress);
sendError = wrap.findViewById(R.id.send_error);
publishButton.setOnClickListener(this::onPublishClick);
draftsBtn.setOnClickListener(this::onDraftsClick);
updatePublishButtonState();
draftsBtn.setOnClickListener(v-> draftOptionsPopup.show());
draftsBtn.setOnTouchListener(draftOptionsPopup.getDragToOpenListener());
updateScheduledAt(scheduledAt != null ? scheduledAt : scheduledStatus != null ? scheduledStatus.scheduledAt : null);
buildLanguageSelector(languageButton);
}
private void onDraftsClick(View v) {
private void navigateToUnsentPosts() {
Bundle args=new Bundle();
args.putString("account", accountID);
InputMethodManager imm=getActivity().getSystemService(InputMethodManager.class);
@@ -1538,27 +1542,39 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private void updateScheduledAt(Instant scheduledAt) {
this.scheduledAt = scheduledAt;
scheduleDraftView.setVisibility(scheduledAt == null ? View.GONE : View.VISIBLE);
moreBtn.setSelected(scheduledAt != null);
updatePublishButtonState();
scheduleDraftView.setVisibility(scheduledAt == null ? View.GONE : View.VISIBLE);
draftMenuItem.setVisible(true);
scheduleMenuItem.setVisible(true);
undraftMenuItem.setVisible(false);
unscheduleMenuItem.setVisible(false);
if (scheduledAt != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault());
if (scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)) {
draftMenuItem.setVisible(false);
undraftMenuItem.setVisible(true);
scheduleTimeBtn.setVisibility(View.GONE);
scheduleDraftText.setText(R.string.sk_compose_draft);
scheduleDraftText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_drafts_20_regular, 0, 0, 0);
scheduleDraftDismiss.setContentDescription(getString(R.string.sk_compose_no_draft));
draftsBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_drafts_20_filled, 0, 0, 0);
publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)
? R.string.save : R.string.sk_draft);
} else {
scheduleMenuItem.setVisible(false);
unscheduleMenuItem.setVisible(true);
String at = scheduledAt.atZone(ZoneId.systemDefault()).format(formatter);
scheduleTimeBtn.setVisibility(View.VISIBLE);
scheduleTimeBtn.setText(at);
scheduleDraftText.setText(R.string.sk_compose_scheduled);
scheduleDraftText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
scheduleDraftDismiss.setContentDescription(getString(R.string.sk_compose_no_schedule));
draftsBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_clock_20_filled, 0, 0, 0);
publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.equals(scheduledAt)
? R.string.save : R.string.sk_schedule);
}
} else {
draftsBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_clock_20_regular, 0, 0, 0);
resetPublishButtonText();
}
}

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="20dp" android:height="20dp" android:viewportWidth="20" android:viewportHeight="20">
<path android:pathData="M10 2c4.418 0 8 3.582 8 8s-3.582 8-8 8-8-3.582-8-8 3.582-8 8-8zM9.5 5C9.224 5 9 5.224 9 5.5v5l0.008 0.09C9.05 10.823 9.255 11 9.5 11h3l0.09-0.008C12.823 10.95 13 10.745 13 10.5c0-0.276-0.224-0.5-0.5-0.5H10V5.5L9.992 5.41C9.95 5.177 9.745 5 9.5 5z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--~ Copyright (c) 2022. ~ Microsoft Corporation. All rights reserved.-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_fluent_clock_24_filled" android:state_activated="true"/>
<item android:drawable="@drawable/ic_fluent_clock_24_filled" android:state_checked="true"/>
<item android:drawable="@drawable/ic_fluent_clock_24_filled" android:state_selected="true"/>
<item android:drawable="@drawable/ic_fluent_clock_24_regular"/>
</selector>

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="20dp" android:height="20dp" android:viewportWidth="20" android:viewportHeight="20">
<path android:pathData="M15.613 8.32l-3.936-3.936-8.038 8.039-0.117 0.128c-0.185 0.22-0.322 0.48-0.398 0.76l-1.106 4.055-0.015 0.08c-0.038 0.34 0.282 0.628 0.63 0.534l4.054-1.106 0.165-0.053c0.271-0.1 0.518-0.257 0.723-0.462l8.038-8.039zm1.568-5.503c-1.087-1.087-2.849-1.087-3.936 0l-0.861 0.86 3.936 3.936 0.86-0.86 0.131-0.14c0.955-1.093 0.911-2.754-0.13-3.796zM11.648 3H2.5C2.224 3 2 3.224 2 3.5S2.224 4 2.5 4h8.148l1-1zm-3 3H2.5C2.224 6 2 6.223 2 6.5 2 6.776 2.224 7 2.5 7h5.148l1-1zm-3 3l-1 1H2.5C2.224 10 2 9.776 2 9.5 2 9.223 2.224 9 2.5 9h3.148z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M13.94 5l5.061 5.06L9.063 20c-0.277 0.277-0.621 0.477-1 0.58l-5.115 1.395c-0.56 0.153-1.073-0.361-0.92-0.921l1.394-5.116c0.103-0.377 0.303-0.722 0.58-0.999L13.94 5zm-7.414 6l-1.5 1.5H2.75C2.337 12.5 2 12.165 2 11.75 2 11.336 2.337 11 2.75 11h3.775zm14.352-8.174l0.153 0.144 0.145 0.153c1.25 1.405 1.203 3.56-0.145 4.908L20.061 9 15 3.94l0.97-0.97c1.348-1.348 3.503-1.396 4.908-0.144zM10.526 7l-1.5 1.5H2.75C2.337 8.5 2 8.165 2 7.75 2 7.336 2.337 7 2.75 7h7.775zm4-4l-1.5 1.5H2.75C2.337 4.5 2 4.165 2 3.75 2 3.336 2.337 3 2.75 3h11.775z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M20 9.502V8.75c0-1.243-1.007-2.25-2.25-2.25h-5.725l-2.38-1.98C9.24 4.184 8.73 4 8.204 4H4.25C3.008 4 2 5.007 2 6.25l-0.004 11.5c0 1.242 1.007 2.25 2.25 2.25H18.47c0.803 0 1.503-0.546 1.698-1.325l1.75-6.998c0.276-1.105-0.56-2.175-1.698-2.175H20zM4.25 5.5h3.956c0.175 0 0.344 0.061 0.48 0.173l2.588 2.154C11.41 7.939 11.58 8 11.755 8h5.996c0.415 0 0.75 0.336 0.75 0.75v0.752H6.424c-1.032 0-1.932 0.703-2.183 1.704l-0.744 2.978L3.5 6.25c0-0.414 0.336-0.75 0.75-0.75zm1.447 6.07c0.083-0.334 0.383-0.568 0.727-0.568H20.22c0.162 0 0.282 0.153 0.242 0.31l-1.75 6.999c-0.027 0.111-0.128 0.189-0.242 0.189H4.285c-0.163 0-0.282-0.153-0.243-0.31l1.655-6.62z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@@ -31,7 +31,6 @@
android:id="@+id/language_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingHorizontal="8dp"
android:drawableStart="@drawable/ic_fluent_local_language_16_regular"
android:drawablePadding="8dp"
@@ -45,12 +44,12 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingHorizontal="8dp"
android:drawableStart="@drawable/ic_fluent_drafts_20_regular"
android:drawableStart="@drawable/ic_fluent_clock_20_regular"
android:drawableTint="?android:textColorSecondary"
android:textColor="?android:textColorSecondary"
android:background="@drawable/bg_text_button"
android:contentDescription="@string/sk_unsent_posts"
android:tooltipText="@string/sk_unsent_posts" />
android:contentDescription="@string/sk_schedule_or_draft"
android:tooltipText="@string/sk_schedule_or_draft" />
<Button
android:id="@+id/publish_btn"

View File

@@ -235,7 +235,7 @@
android:elevation="2dp"
android:outlineProvider="bounds"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingRight="12dp"
android:layoutDirection="locale">
<LinearLayout
android:id="@+id/schedule_draft_view"
@@ -280,9 +280,9 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="-4dp"
android:src="@drawable/ic_fluent_dismiss_20_filled"
android:background="?android:selectableItemBackgroundBorderless"
android:contentDescription="@string/sk_compose_no_schedule"
android:padding="4dp"/>
</LinearLayout>
@@ -357,19 +357,6 @@
android:tooltipText="@string/post_visibility"
android:src="@drawable/ic_fluent_earth_24_regular"/>
<ImageButton
android:id="@+id/btn_more"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/more_options"
android:tooltipText="@string/more_options"
android:src="@drawable/ic_fluent_more_vertical_24_regular"/>
<Space
android:layout_width="0px"
android:layout_height="1px"

View File

@@ -1,5 +1,8 @@
<?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/unschedule" android:title="@string/sk_schedule_post" android:icon="@drawable/ic_fluent_clock_24_filled" android:contentDescription="@string/sk_compose_no_schedule" />
<item android:id="@+id/draft" android:title="@string/sk_mark_as_draft" android:icon="@drawable/ic_fluent_drafts_24_regular" />
<item android:id="@+id/undraft" android:title="@string/sk_mark_as_draft" android:icon="@drawable/ic_fluent_drafts_24_filled" android:contentDescription="@string/sk_compose_no_draft" />
<item android:id="@+id/drafts" android:title="@string/sk_unsent_posts" android:icon="@drawable/ic_fluent_folder_open_24_regular" />
</menu>

View File

@@ -3,6 +3,6 @@
<item android:id="@+id/followed_hashtags" android:title="@string/sk_hashtags_you_follow" android:icon="@drawable/ic_fluent_number_symbol_24_regular" android:showAsAction="always"/>
<item android:id="@+id/bookmarks" android:title="@string/bookmarks" android:icon="@drawable/ic_fluent_bookmark_multiple_24_regular" android:showAsAction="always"/>
<item android:id="@+id/favorites" android:title="@string/your_favorites" android:icon="@drawable/ic_fluent_star_24_regular"/>
<item android:id="@+id/scheduled" android:title="@string/sk_unsent_posts" android:icon="@drawable/ic_fluent_drafts_24_regular"/>
<item android:id="@+id/scheduled" android:title="@string/sk_unsent_posts" android:icon="@drawable/ic_fluent_folder_open_24_regular"/>
<item android:id="@+id/share" android:title="@string/share_user" android:icon="@drawable/ic_fluent_share_24_regular"/>
</menu>

View File

@@ -121,4 +121,7 @@
<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>
<string name="sk_schedule_or_draft">Schedule or draft</string>
<string name="sk_compose_no_schedule">Dont schedule</string>
<string name="sk_compose_no_draft">Dont draft</string>
</resources>