ComposeActivity improvements (#548)

* do not add media urls to status text

* add scrolling to content

* add arrow icon and animation to replying-to toggle

* remove unnecessary compose_button_colors.xml

* improve toot button

* improve bottom bar, add bottom sheet for compose options, dedicated cw button

* fix crash on Android < API 21

* move media picking from dialog to bottom sheet

* add small style tootbutton

* fix colors/button background for light theme

* add icons to media chose bottom sheet

* improve hide media button, delete unused styles

* fix crash on dev build when taking photo

* consolidate drawables

* consolidate strings and ids, add tooltips to buttons

* allow media only toots

* change error message to show max size of upload correctly

* fix button color

* add emoji

* code cleanup

* Merge branch 'master' into compose_activity_refactoring

# Conflicts:
#	app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java

* fix hidden snackbar

* improve hint text color

* add SendTootService

* fix timeline refreshing

* toot saving and error handling for sendtootservice

* restructure some code

* convert EditTextTyped to Kotlin

* fixed pick media button disabled color

* force sensitive media when content warning is shown

* add db cache for emojis & fix tests

* reorder buttons to match mastodon web

* add possibility to cancel sending of toot

* correctly delete sent toots

* refresh SavedTootActivity after toot was sent

* remove unused resources

* correct params for toot saving in SendTootService

* consolidate strings

* bugfix

* remove unused resources

* fix notifications on old android for SendTootService

* fix crash
This commit is contained in:
Konrad Pozniak 2018-04-13 22:37:21 +02:00 committed by GitHub
commit 27eefbf65a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 1815 additions and 1234 deletions

View file

@ -6,115 +6,122 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="8dp"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/composeAvatar"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="end"
android:padding="8dp"
tools:ignore="ContentDescription" />
<!--content description will be set in code -->
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="8dp"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/composeAvatar"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="right|end"
android:padding="8dp"
tools:ignore="ContentDescription" />
<!--content description will be set in code -->
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/reply_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textSize="?attr/status_text_small"
android:textStyle="bold"
android:visibility="gone"
tools:text="Reply to @username"
tools:visibility="visible" />
<TextView
android:id="@+id/reply_content_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:background="?attr/compose_reply_content_background"
android:paddingBottom="4dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="4dp"
android:textSize="?attr/status_text_small"
android:visibility="gone"
tools:text="Post content which may be preeettyy long, so please, make sure there's enough room for everything, okay? Not kidding. I wish Eugen answered me more often, sigh."
tools:visibility="visible" />
android:layout_marginBottom="52dp"
android:layout_marginTop="?attr/actionBarSize">
<LinearLayout
android:id="@+id/compose_content_warning_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<EditText
android:id="@+id/field_content_warning"
<TextView
android:id="@+id/composeReplyView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:drawablePadding="6dp"
android:textSize="?attr/status_text_small"
android:textStyle="bold"
android:visibility="gone"
tools:text="Reply to @username"
tools:visibility="visible" />
<TextView
android:id="@+id/composeReplyContentView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:ems="10"
android:hint="@string/hint_content_warning"
android:inputType="text|textCapSentences"
android:maxLines="1"
android:layout_marginBottom="2dp"
android:background="?attr/compose_reply_content_background"
android:lineSpacingMultiplier="1.1"
android:paddingBottom="4dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textSize="?attr/status_text_medium" />
android:paddingTop="4dp"
android:textSize="?attr/status_text_small"
android:visibility="gone"
tools:text="Post content which may be preeettyy long, so please, make sure there's enough room for everything, okay? Not kidding. I wish Eugen answered me more often, sigh."
tools:visibility="visible" />
<View
<LinearLayout
android:id="@+id/composeContentWarningBar"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<EditText
android:id="@+id/composeContentWarningField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@android:color/transparent"
android:hint="@string/hint_content_warning"
android:inputType="text|textCapSentences"
android:lineSpacingMultiplier="1.1"
android:maxLines="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColorHint="?android:attr/textColorTertiary"
android:textSize="?attr/status_text_medium" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingBottom="4dp"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
</LinearLayout>
<com.keylesspalace.tusky.view.EditTextTyped
android:id="@+id/compose_edit_field"
android:id="@+id/composeEditField"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:layout_height="wrap_content"
android:background="@null"
android:completionThreshold="2"
android:dropDownWidth="wrap_content"
android:ems="10"
android:gravity="start|top"
android:hint="@string/hint_compose"
android:inputType="text|textMultiLine|textCapSentences"
android:lineSpacingMultiplier="1.1"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:textColorHint="?android:attr/textColorTertiary"
android:textSize="?attr/status_text_large" />
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
android:scrollbars="none">
<LinearLayout
android:id="@+id/compose_media_preview_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<!--This is filled at runtime with ImageView's for each preview in the upload queue.-->
@ -122,104 +129,162 @@
</HorizontalScrollView>
<ProgressBar
android:id="@+id/postProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingBottom="8dp"
android:paddingEnd="16dp"
android:paddingStart="8dp"
android:paddingTop="4dp">
<ImageButton
android:id="@+id/compose_photo_pick"
style="?attr/image_button_style"
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@string/action_photo_pick"
android:paddingBottom="4dp"
android:paddingEnd="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingStart="4dp"
android:paddingTop="4dp"
app:srcCompat="@drawable/ic_attach_file_24dp" />
<ImageButton
android:id="@+id/action_toggle_visibility"
style="?attr/image_button_style"
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@string/action_compose_options"
android:paddingBottom="4dp"
android:paddingEnd="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingStart="4dp"
android:paddingTop="4dp"
app:srcCompat="@drawable/ic_public_24dp" />
<ImageButton
android:id="@+id/compose_save_draft"
style="?attr/image_button_style"
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@string/action_save"
android:paddingBottom="4dp"
android:paddingEnd="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingStart="4dp"
android:paddingTop="4dp"
app:srcCompat="@drawable/ic_save_24dp" />
<ImageButton
android:id="@+id/action_hide_media"
style="?attr/image_button_style"
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@string/action_hide_media"
android:paddingBottom="4dp"
android:paddingEnd="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingStart="4dp"
android:paddingTop="4dp"
android:visibility="gone"
app:srcCompat="@drawable/ic_hide_media_24dp" />
<android.support.v4.widget.Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/characters_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_medium" />
<Button
android:id="@+id/floating_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:background="@drawable/compose_button_colors"
android:text="@string/action_send"
android:textColor="@android:color/white"
android:textSize="?attr/status_text_medium" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<LinearLayout
android:id="@+id/addMediaBottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:elevation="12dp"
android:orientation="vertical"
android:paddingBottom="52dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<TextView
android:id="@+id/action_photo_take"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="8dp"
android:padding="8dp"
android:text="@string/action_photo_take"
android:textSize="?attr/status_text_medium" />
<TextView
android:id="@+id/action_photo_pick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="8dp"
android:padding="8dp"
android:text="@string/action_add_media"
android:textSize="?attr/status_text_medium" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/emojiView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:clipToPadding="false"
android:elevation="12dp"
android:orientation="horizontal"
android:paddingBottom="60dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior" />
<com.keylesspalace.tusky.view.ComposeOptionsView
android:id="@+id/composeOptionsBottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:elevation="12dp"
android:paddingBottom="52dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:colorBackground"
android:elevation="12dp"
android:gravity="center_vertical"
android:paddingBottom="4dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:paddingTop="4dp">
<ImageButton
android:id="@+id/composeAddMediaButton"
style="?attr/image_button_style"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="4dp"
android:contentDescription="@string/action_add_media"
android:padding="4dp"
android:tooltipText="@string/action_add_media"
app:srcCompat="@drawable/ic_attach_file_24dp" />
<ImageButton
android:id="@+id/composeToggleVisibilityButton"
style="?attr/image_button_style"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="4dp"
android:contentDescription="@string/action_toggle_visibility"
android:padding="4dp"
android:tooltipText="@string/action_toggle_visibility"
tools:src="@drawable/ic_public_24dp" />
<ImageButton
android:id="@+id/composeHideMediaButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="4dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_hide_media"
android:padding="4dp"
android:tooltipText="@string/action_hide_media"
android:visibility="gone"
tools:src="@drawable/ic_eye_24dp" />
<Button
android:id="@+id/composeContentWarningButton"
style="?attr/image_button_style"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="4dp"
android:contentDescription="@string/action_content_warning"
android:padding="4dp"
android:text="CW"
android:textColor="?android:textColorTertiary"
android:tooltipText="@string/action_content_warning" />
<ImageButton
android:id="@+id/composeEmojiButton"
style="?attr/image_button_style"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="4dp"
android:contentDescription="@string/action_emoji_keyboard"
android:padding="4dp"
android:tooltipText="@string/action_emoji_keyboard"
app:srcCompat="@drawable/ic_emoji_24dp" />
<android.support.v4.widget.Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/composeCharactersLeftView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium" />
<com.keylesspalace.tusky.view.TootButton
android:id="@+id/composeTootButton"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="@dimen/toot_button_width"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:textColor="@android:color/white"
android:textSize="?attr/status_text_medium" />
</LinearLayout>

View file

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:padding="16dp"
android:layout_height="match_parent">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/radio_visibility"
android:checkedButton="@+id/radio_public"
android:layout_margin="@dimen/compose_options_margin">
<RadioButton
android:text="@string/visibility_public"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/radio_public"
android:layout_marginBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="0dp"
android:layout_weight="1" />
<RadioButton
android:text="@string/visibility_unlisted"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/radio_unlisted"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="0dp"
android:layout_weight="1" />
<RadioButton
android:text="@string/visibility_private"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/radio_private"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="0dp"
android:layout_weight="1" />
<RadioButton
android:text="@string/visibility_direct"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/radio_direct"
android:layout_marginTop="5dp"
android:paddingStart="10dp"
android:paddingEnd="0dp"
android:layout_weight="1" />
</RadioGroup>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/compose_options_margin"
android:id="@+id/compose_hide_text"
android:text="@string/action_hide_text" />
</LinearLayout>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/composeEmojiButton"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="4dp"
android:padding="4dp"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ContentDescription" />

View file

@ -244,7 +244,7 @@
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="@+id/status_media_preview_container"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_container"
app:srcCompat="@drawable/ic_remove_red_eye_black_24dp" />
app:srcCompat="@drawable/ic_eye_24dp" />
<TextView
android:id="@+id/status_sensitive_media_warning"

View file

@ -264,7 +264,7 @@
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="@+id/status_media_preview_container"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_container"
app:srcCompat="@drawable/ic_remove_red_eye_black_24dp" />
app:srcCompat="@drawable/ic_eye_24dp" />
<TextView
android:id="@+id/status_sensitive_media_warning"

View file

@ -0,0 +1,69 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:parentTag="android.widget.LinearLayout">
<RadioGroup
android:id="@+id/visibilityRadioGroup"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/compose_options_margin"
android:layout_marginLeft="@dimen/compose_options_margin"
android:layout_marginRight="@dimen/compose_options_margin"
android:layout_marginTop="6dp"
android:checkedButton="@+id/radio_public"
android:orientation="vertical">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/publicRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_weight="1"
android:paddingEnd="0dp"
android:paddingStart="10dp"
android:text="@string/visibility_public"
android:textColor="?android:textColorTertiary"
app:buttonTint="?attr/compound_button_color" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/unlistedRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:paddingEnd="0dp"
android:paddingStart="10dp"
android:text="@string/visibility_unlisted"
android:textColor="?android:textColorTertiary"
app:buttonTint="?attr/compound_button_color" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/privateRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:paddingEnd="0dp"
android:paddingStart="10dp"
android:text="@string/visibility_private"
android:textColor="?android:textColorTertiary"
app:buttonTint="?attr/compound_button_color" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/directRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:paddingEnd="0dp"
android:paddingStart="10dp"
android:text="@string/visibility_direct"
android:textColor="?android:textColorTertiary"
app:buttonTint="?attr/compound_button_color" />
</RadioGroup>
</merge>