ComposeActivity refactor (#1541)

* Convert ComposeActivity to Kotlin

* More ComposeActivity cleanups

* Move ComposeActivity to it's own package

* Remove ComposeActivity.IntentBuilder

* Re-do part of the media downsizing/uploading

* Add sending of status to ViewModel, draft media descriptions

* Allow uploading video, update description after uploading

* Enable camera, enable upload cancelling

* Cleanup of ComposeActivity

* Extract CaptionDialog, extract ComposeActivity methods

* Fix handling of redrafted media

* Add initial state and media uploading out of Activity

* Change ComposeOptions.mentionedUsernames to be Set rather than List

We probably don't want repeated usernames when we are writing a post
and Set provides such guarantee for free plus it tells it to the
callers. The only disadvantage is lack of order but it shouldn't be a
problem.

* Add combineOptionalLiveData. Add docs.

It it useful for nullable LiveData's. I think we cannot differentiate
between value not being set and value being null so I just added the
variant without null check.

* Add poll support to Compose.

* cleanup code

* move more classes into compose package

* cleanup code

* fix button behavior

* add error handling for media upload

* add caching for instance data again

* merge develop

* fix scheduled toots

* delete unused string

* cleanup ComposeActivity

* fix restoring media from drafts

* make media upload code a little bit clearer

* cleanup autocomplete search code

* avoid duplicate object creation in SavedTootActivity

* perf: avoid unnecessary work when initializing ComposeActivity

* add license header to new files

* use small toot button on bigger displays

* fix ComposeActivityTest

* fix bad merge

* use Singles.zip instead of Single.zip
This commit is contained in:
Ivan Kupalov 2019-12-19 19:09:40 +01:00 committed by Konrad Pozniak
commit 8770fbe986
68 changed files with 3162 additions and 2666 deletions

View file

@ -2,7 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
android:id="@+id/activity_compose"
android:id="@+id/activityCompose"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -30,10 +30,9 @@
android:layout_gravity="end"
android:padding="8dp"
android:text="@string/at_symbol"
android:textStyle="bold"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_large"
/>
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/hashButton"
@ -43,10 +42,9 @@
android:layout_gravity="end"
android:padding="8dp"
android:text="@string/hash_symbol"
android:textStyle="bold"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_large"
/>
android:textStyle="bold" />
</androidx.appcompat.widget.Toolbar>
<androidx.core.widget.NestedScrollView
@ -119,7 +117,7 @@
</LinearLayout>
<com.keylesspalace.tusky.view.EditTextTyped
<com.keylesspalace.tusky.components.compose.view.EditTextTyped
android:id="@+id/composeEditField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -136,25 +134,19 @@
android:textColorHint="?android:attr/textColorTertiary"
android:textSize="?attr/status_text_large" />
<HorizontalScrollView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/composeMediaPreviewBar"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:paddingLeft="16dp"
android:paddingRight="16dp">
<!--This is filled at runtime with ImageView's for each preview in the upload queue.-->
</LinearLayout>
</HorizontalScrollView>
android:scrollbars="none" />
<com.keylesspalace.tusky.components.compose.view.PollPreviewView
android:id="@+id/pollPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
@ -174,7 +166,7 @@
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView
android:id="@+id/action_photo_take"
android:id="@+id/actionPhotoTake"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="8dp"
@ -183,7 +175,7 @@
android:textSize="?attr/status_text_medium" />
<TextView
android:id="@+id/action_photo_pick"
android:id="@+id/actionPhotoPick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="8dp"
@ -192,7 +184,7 @@
android:textSize="?attr/status_text_medium" />
<TextView
android:id="@+id/action_add_poll"
android:id="@+id/addPollTextActionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="8dp"
@ -217,7 +209,7 @@
app:behavior_peekHeight="0dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
<com.keylesspalace.tusky.view.ComposeOptionsView
<com.keylesspalace.tusky.components.compose.view.ComposeOptionsView
android:id="@+id/composeOptionsBottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -231,7 +223,7 @@
app:behavior_peekHeight="0dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
<com.keylesspalace.tusky.view.ComposeScheduleView
<com.keylesspalace.tusky.components.compose.view.ComposeScheduleView
android:id="@+id/composeScheduleView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -300,7 +292,7 @@
android:contentDescription="@string/action_content_warning"
android:padding="4dp"
android:tooltipText="@string/action_content_warning"
app:srcCompat="@drawable/ic_cw_24dp"/>
app:srcCompat="@drawable/ic_cw_24dp" />
<ImageButton
android:id="@+id/composeEmojiButton"
@ -337,7 +329,7 @@
android:textSize="?attr/status_text_medium"
tools:text="500" />
<com.keylesspalace.tusky.view.TootButton
<com.keylesspalace.tusky.components.compose.view.TootButton
android:id="@+id/composeTootButton"
style="@style/TuskyButton"
android:layout_width="@dimen/toot_button_width"

View file

@ -5,27 +5,28 @@
<Button
android:id="@+id/resetScheduleButton"
style="@style/TuskyButton.Outlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_marginEnd="16dp"
android:text="@string/action_reset_schedule"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/scheduledDateTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:paddingEnd="16dp"
android:drawablePadding="4dp"
android:paddingStart="4dp"
android:paddingTop="4dp"
android:paddingBottom="16dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
android:drawablePadding="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/resetScheduleButton"
tools:text="2020/01/01 00:00:00" />
</merge>