Drafts and scheduled posts (#217)
closes #100 closes #59 * enable saving as draft (scheduled) * add scheduled posts list * fix NoSuchMethodError * editable drafts/scheduled posts * ui for drafts * use instants between 9999-01-01 and 9999-12-31 * use save and draft strings * map scheduled status params to status * implement scheduling posts * improve save/discard draft dialog * persist scheduled date in state * add unsent posts button to toolbar * clean up imports
This commit is contained in:
@@ -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-8zm0 1c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zM9.5 5c0.245 0 0.45 0.177 0.492 0.41L10 5.5V10h2.5c0.276 0 0.5 0.224 0.5 0.5 0 0.245-0.177 0.45-0.41 0.492L12.5 11h-3c-0.245 0-0.45-0.177-0.492-0.41L9 10.5v-5C9 5.224 9.224 5 9.5 5z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||
</vector>
|
||||
@@ -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="M15.25 13.5h-4c-0.414 0-0.75-0.336-0.75-0.75v-6C10.5 6.336 10.836 6 11.25 6S12 6.336 12 6.75V12h3.25c0.414 0 0.75 0.336 0.75 0.75s-0.336 0.75-0.75 0.75zM12 2C6.478 2 2 6.478 2 12s4.478 10 10 10 10-4.478 10-10S17.522 2 12 2z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||
</vector>
|
||||
@@ -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="M12 2c5.523 0 10 4.478 10 10s-4.477 10-10 10S2 17.522 2 12 6.477 2 12 2zm0 1.667c-4.595 0-8.333 3.738-8.333 8.333 0 4.595 3.738 8.333 8.333 8.333 4.595 0 8.333-3.738 8.333-8.333 0-4.595-3.738-8.333-8.333-8.333zM11.25 6c0.38 0 0.694 0.282 0.743 0.648L12 6.75V12h3.25c0.414 0 0.75 0.336 0.75 0.75 0 0.38-0.282 0.694-0.648 0.743L15.25 13.5h-4c-0.38 0-0.694-0.282-0.743-0.648L10.5 12.75v-6C10.5 6.336 10.836 6 11.25 6z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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>
|
||||
@@ -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="M13.245 2.817L3.64 12.423 3.522 12.55c-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.462l9.606-9.606 0.13-0.14c0.955-1.093 0.911-2.754-0.13-3.796-1.087-1.087-2.849-1.087-3.936 0zM4.346 13.13l8.039-8.038 2.521 2.52-8.038 8.04-0.098 0.085-0.107 0.072c-0.075 0.044-0.155 0.077-0.239 0.1l-3.212 0.876 0.877-3.211 0.042-0.123c0.05-0.12 0.123-0.229 0.215-0.321zm12.128-9.606l0.11 0.12c0.584 0.7 0.547 1.744-0.11 2.402l-0.861 0.86-2.521-2.521 0.86-0.86 0.12-0.11c0.7-0.585 1.744-0.548 2.402 0.11zM11.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-4 4l1-1H2.5C2.224 9 2 9.223 2 9.5 2 9.776 2.224 10 2.5 10h2.148z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||
</vector>
|
||||
@@ -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.878 2.826l0.153 0.144 0.145 0.153c1.25 1.405 1.203 3.56-0.145 4.908L9.063 19.999c-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.999L15.97 2.97c1.348-1.348 3.503-1.396 4.908-0.144zM15.001 6.06l-9.938 9.938c-0.092 0.092-0.16 0.207-0.193 0.333l-1.05 3.85 3.85-1.05c0.125-0.035 0.24-0.101 0.332-0.194L17.94 9l-2.939-2.94zM6.526 11l-1.5 1.5H2.75C2.337 12.5 2 12.165 2 11.75 2 11.336 2.337 11 2.75 11h3.775zm4-4l-1.5 1.5H2.75C2.337 8.5 2 8.165 2 7.75 2 7.336 2.337 7 2.75 7h7.775zm6.505-2.97L16.061 5 19 7.94l0.97-0.97c0.812-0.812 0.812-2.128 0-2.94-0.811-0.811-2.127-0.811-2.939 0zM14.526 3l-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>
|
||||
@@ -229,94 +229,153 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="?colorBackgroundLightest"
|
||||
android:elevation="2dp"
|
||||
android:outlineProvider="bounds"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:layoutDirection="locale">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_media"
|
||||
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/add_media"
|
||||
android:tooltipText="@string/add_media"
|
||||
android:src="@drawable/ic_fluent_image_24_regular"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_poll"
|
||||
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/add_poll"
|
||||
android:tooltipText="@string/add_poll"
|
||||
android:src="@drawable/ic_fluent_poll_24_selector"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_emoji"
|
||||
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/emoji"
|
||||
android:tooltipText="@string/emoji"
|
||||
android:src="@drawable/ic_fluent_emoji_24_selector"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_spoiler"
|
||||
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/content_warning"
|
||||
android:tooltipText="@string/content_warning"
|
||||
android:src="@drawable/ic_fluent_chat_warning_24_selector"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_visibility"
|
||||
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/post_visibility"
|
||||
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"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/char_counter"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/schedule_draft_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:text="500"/>
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="48dp"
|
||||
android:paddingTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/schedule_draft_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/sk_compose_draft" />
|
||||
<Button
|
||||
android:id="@+id/scheduled_time_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:gravity="center"
|
||||
android:padding="8dp"
|
||||
android:textSize="14sp"
|
||||
android:minHeight="48dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:background="@drawable/bg_text_button"
|
||||
android:fontFamily="sans-serif"
|
||||
android:drawableStart="@drawable/ic_fluent_clock_20_regular"
|
||||
android:drawablePadding="8dp"
|
||||
android:drawableTint="?android:textColorSecondary"
|
||||
tools:text="Dec 12, 2021, 12:42 PM"/>
|
||||
<ImageButton
|
||||
android:id="@+id/schedule_draft_dismiss"
|
||||
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:padding="4dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_media"
|
||||
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/add_media"
|
||||
android:tooltipText="@string/add_media"
|
||||
android:src="@drawable/ic_fluent_image_24_regular"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_poll"
|
||||
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/add_poll"
|
||||
android:tooltipText="@string/add_poll"
|
||||
android:src="@drawable/ic_fluent_poll_24_selector"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_emoji"
|
||||
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/emoji"
|
||||
android:tooltipText="@string/emoji"
|
||||
android:src="@drawable/ic_fluent_emoji_24_selector"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_spoiler"
|
||||
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/content_warning"
|
||||
android:tooltipText="@string/content_warning"
|
||||
android:src="@drawable/ic_fluent_chat_warning_24_selector"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_visibility"
|
||||
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/post_visibility"
|
||||
android:tooltipText="@string/post_visibility"
|
||||
android:src="@drawable/ic_fluent_earth_24_regular"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_schedule"
|
||||
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/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"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/char_counter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:text="500"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</org.joinmastodon.android.ui.views.SizeListenerLinearLayout>
|
||||
@@ -3,5 +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/share" android:title="@string/share_user" android:icon="@drawable/ic_fluent_share_24_regular"/>
|
||||
</menu>
|
||||
5
mastodon/src/main/res/menu/schedule_draft.xml
Normal file
5
mastodon/src/main/res/menu/schedule_draft.xml
Normal 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" 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>
|
||||
@@ -103,4 +103,20 @@
|
||||
<string name="sk_reply_as">Reply with other account</string>
|
||||
<string name="sk_settings_uniform_icon_for_notifications">Uniform icon for all notifications</string>
|
||||
<string name="sk_forward_report_to">Forward to %s</string>
|
||||
<string name="sk_unsent_posts">Unsent posts</string>
|
||||
<string name="sk_draft">Draft</string>
|
||||
<string name="sk_schedule">Schedule</string>
|
||||
<string name="sk_confirm_delete_draft_title">Delete draft</string>
|
||||
<string name="sk_confirm_delete_draft">Are you sure you want to delete this drafted post?</string>
|
||||
<string name="sk_confirm_delete_scheduled_post_title">Delete scheduled post</string>
|
||||
<string name="sk_confirm_delete_scheduled_post">Are you sure you want to delete this scheduled post?</string>
|
||||
<string name="sk_draft_or_schedule">Draft or schedule</string>
|
||||
<string name="sk_compose_draft">Post will be saved as a draft.</string>
|
||||
<string name="sk_compose_scheduled">Scheduled for</string>
|
||||
<string name="sk_draft_saved">Draft saved</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">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>
|
||||
</resources>
|
||||
@@ -29,6 +29,8 @@
|
||||
<item name="android:navigationBarColor">?android:statusBarColor</item>
|
||||
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar</item>
|
||||
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert</item>
|
||||
<item name="android:datePickerDialogTheme">@style/Theme.Mastodon.Dialog.Alert</item>
|
||||
<item name="android:timePickerDialogTheme">@style/Theme.Mastodon.Dialog.Alert</item>
|
||||
<item name="colorPollMostVoted">?colorPrimary500</item>
|
||||
<item name="colorPollVoted">?colorGray300</item>
|
||||
<item name="colorAccentLight">?colorPrimary600</item>
|
||||
@@ -123,6 +125,8 @@
|
||||
<item name="android:navigationBarColor">?android:statusBarColor</item>
|
||||
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar.Dark</item>
|
||||
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert.Dark</item>
|
||||
<item name="android:datePickerDialogTheme">@style/Theme.Mastodon.Dialog.Alert.Dark</item>
|
||||
<item name="android:timePickerDialogTheme">@style/Theme.Mastodon.Dialog.Alert.Dark</item>
|
||||
<item name="colorPollMostVoted">?colorPrimary700</item>
|
||||
<item name="colorPollVoted">?colorGray600</item>
|
||||
<item name="colorAccentLight">?colorPrimary600</item>
|
||||
@@ -318,6 +322,8 @@
|
||||
<item name="android:dialogPreferredPadding">24dp</item>
|
||||
<item name="android:windowBackground">@drawable/bg_alert</item>
|
||||
<item name="android:buttonBarButtonStyle">@style/Widget.Mastodon.ButtonBarButton</item>
|
||||
<item name="android:datePickerStyle">@style/Widget.Mastodon.DatePicker.Dark</item>
|
||||
<item name="android:timePickerStyle">@style/Widget.Mastodon.TimePicker.Dark</item>
|
||||
|
||||
<!-- colors -->
|
||||
<item name="android:colorAccent">?colorPrimary600</item>
|
||||
@@ -327,6 +333,15 @@
|
||||
<item name="android:textColorSecondary">?colorGray400</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Mastodon.DatePicker.Dark" parent="@android:style/Widget.Material.DatePicker">
|
||||
<item name="android:headerBackground">?colorGray700</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Mastodon.TimePicker.Dark" parent="@android:style/Widget.Material.TimePicker">
|
||||
<item name="android:headerBackground">?colorGray700</item>
|
||||
<item name="android:numbersBackgroundColor">?colorGray700</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Mastodon.ButtonBarButton" parent="android:Widget.Material.Button.Borderless">
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:layout_marginEnd">8dp</item>
|
||||
|
||||
Reference in New Issue
Block a user