From e91b09ca44525854fdab46e058390344f1f60dff Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 10 Jun 2021 14:30:53 +0200 Subject: [PATCH 01/19] Restore Onuray's code: do not allow to send blank text --- .../features/home/room/detail/RoomDetailFragment.kt | 2 +- .../home/room/detail/composer/ComposerEditText.kt | 10 +++++----- .../home/room/detail/composer/TextComposerView.kt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index 9ed4feebc41..0d4fcc31b51 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -1189,7 +1189,7 @@ class RoomDetailFragment @Inject constructor( return sendUri(contentUri) } - override fun onTextEmptyStateChanged(isEmpty: Boolean) { + override fun onTextBlankStateChanged(isBlank: Boolean) { // No op } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/ComposerEditText.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/ComposerEditText.kt index 2a2ae56c4cf..79ff7be4411 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/ComposerEditText.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/ComposerEditText.kt @@ -37,11 +37,11 @@ class ComposerEditText @JvmOverloads constructor(context: Context, attrs: Attrib interface Callback { fun onRichContentSelected(contentUri: Uri): Boolean - fun onTextEmptyStateChanged(isEmpty: Boolean) + fun onTextBlankStateChanged(isBlank: Boolean) } var callback: Callback? = null - private var isEmptyText = true + private var isBlankText = true override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection? { val ic = super.onCreateInputConnection(editorInfo) ?: return null @@ -96,9 +96,9 @@ class ComposerEditText @JvmOverloads constructor(context: Context, attrs: Attrib spanToRemove = null } // Report blank status of EditText to be able to arrange other elements of the composer - if (s.isEmpty() != isEmptyText) { - isEmptyText = !isEmptyText - callback?.onTextEmptyStateChanged(isEmptyText) + if (s.isBlank() != isBlankText) { + isBlankText = !isBlankText + callback?.onTextBlankStateChanged(isBlankText) } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt index d5e24dbb6b4..96d592fe4bf 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt @@ -70,8 +70,8 @@ class TextComposerView @JvmOverloads constructor( return callback?.onRichContentSelected(contentUri) ?: false } - override fun onTextEmptyStateChanged(isEmpty: Boolean) { - views.sendButton.isVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isEmpty + override fun onTextBlankStateChanged(isBlank: Boolean) { + views.sendButton.isVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isBlank } } views.composerRelatedMessageCloseButton.setOnClickListener { From 3f4e80992b7323ac8363563c627dab88c83335a0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 10 Jun 2021 14:55:17 +0200 Subject: [PATCH 02/19] Animate the transition (faster than default), and ensure the callback is called, even if it's a no-op --- .../home/room/detail/composer/TextComposerView.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt index 96d592fe4bf..fa5e736c1c0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/TextComposerView.kt @@ -25,6 +25,7 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.core.text.toSpannable import androidx.core.view.isVisible +import androidx.transition.AutoTransition import androidx.transition.ChangeBounds import androidx.transition.Fade import androidx.transition.Transition @@ -35,7 +36,6 @@ import im.vector.app.databinding.ComposerLayoutBinding /** * Encapsulate the timeline composer UX. - * */ class TextComposerView @JvmOverloads constructor( context: Context, @@ -71,7 +71,15 @@ class TextComposerView @JvmOverloads constructor( } override fun onTextBlankStateChanged(isBlank: Boolean) { - views.sendButton.isVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isBlank + callback?.onTextBlankStateChanged(isBlank) + val shouldBeVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isBlank + if (views.sendButton.isVisible != shouldBeVisible) { + TransitionManager.beginDelayedTransition( + this@TextComposerView, + AutoTransition().also { it.duration = 150 } + ) + views.sendButton.isVisible = shouldBeVisible + } } } views.composerRelatedMessageCloseButton.setOnClickListener { From 0ccd8ba071c15656cafcebdd9788ddf39bcbb40c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 10 Jun 2021 15:36:26 +0200 Subject: [PATCH 03/19] Configure the toolbar in the debug activity --- .../debug/DebugMaterialThemeActivity.kt | 6 + .../layout/activity_test_material_theme.xml | 743 +++++++++--------- 2 files changed, 383 insertions(+), 366 deletions(-) diff --git a/vector/src/debug/java/im/vector/app/features/debug/DebugMaterialThemeActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/DebugMaterialThemeActivity.kt index de6b981c02d..3378740eea0 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/DebugMaterialThemeActivity.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/DebugMaterialThemeActivity.kt @@ -33,6 +33,12 @@ abstract class DebugMaterialThemeActivity : AppCompatActivity() { val views = ActivityTestMaterialThemeBinding.inflate(layoutInflater) setContentView(views.root) + setSupportActionBar(views.debugToolbar) + supportActionBar?.let { + it.setDisplayShowHomeEnabled(true) + it.setDisplayHomeAsUpEnabled(true) + } + views.debugShowSnackbar.setOnClickListener { Snackbar.make(views.coordinatorLayout, "Snackbar!", Snackbar.LENGTH_SHORT) .setAction("Action") { } diff --git a/vector/src/debug/res/layout/activity_test_material_theme.xml b/vector/src/debug/res/layout/activity_test_material_theme.xml index 2ec23a4b31f..c2baded7f2e 100644 --- a/vector/src/debug/res/layout/activity_test_material_theme.xml +++ b/vector/src/debug/res/layout/activity_test_material_theme.xml @@ -8,437 +8,448 @@ tools:context=".features.debug.DebugMaterialThemeActivity" tools:ignore="HardcodedText"> - - + app:layout_constraintTop_toTopOf="parent" + app:subtitle="Toolbar Subtitle" + app:title="Toolbar Title" /> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + android:hint="OutlinedBox"> - - - - - + - - - - - - - - - - - - - - - - - - - + - - - - - - - - + android:hint="OutlinedBox.Dense"> - + - + - + android:hint="FilledBox"> - + + - - - + android:hint="FilledBox.Dense"> - + - + - + android:text="Buttons" /> - +