From 48530e6169ded70679d429aa3edbd4ae95f264e9 Mon Sep 17 00:00:00 2001 From: Taras Smakula <tarassmakula@gmail.com> Date: Tue, 28 Nov 2023 14:07:34 +0200 Subject: [PATCH] Cleanup composer --- .../futo/circles/view/MessageComposerView.kt | 7 - .../circles/view/RichTextComposerLayout.kt | 427 +----------------- .../res/drawable/ic_composer_collapse.xml | 9 - .../res/drawable/ic_composer_full_screen.xml | 9 - .../drawable/ic_composer_rich_mic_pressed.xml | 17 - .../ic_composer_rich_text_editor_close.xml | 9 - .../ic_composer_rich_text_editor_edit.xml | 12 - .../drawable/ic_composer_rich_text_save.xml | 16 - app/src/main/res/drawable/ic_quote.xml | 14 - .../res/drawable/ic_rich_composer_add.xml | 15 - .../res/drawable/ic_rich_composer_send.xml | 12 - .../res/layout/composer_rich_text_layout.xml | 170 +------ app/src/main/res/layout/view_preview_post.xml | 3 +- app/src/main/res/values/colors.xml | 1 - app/src/main/res/values/dimens.xml | 1 - app/src/main/res/values/strings.xml | 12 - 16 files changed, 23 insertions(+), 711 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_composer_collapse.xml delete mode 100644 app/src/main/res/drawable/ic_composer_full_screen.xml delete mode 100644 app/src/main/res/drawable/ic_composer_rich_mic_pressed.xml delete mode 100644 app/src/main/res/drawable/ic_composer_rich_text_editor_close.xml delete mode 100644 app/src/main/res/drawable/ic_composer_rich_text_editor_edit.xml delete mode 100644 app/src/main/res/drawable/ic_composer_rich_text_save.xml delete mode 100644 app/src/main/res/drawable/ic_quote.xml delete mode 100644 app/src/main/res/drawable/ic_rich_composer_add.xml delete mode 100644 app/src/main/res/drawable/ic_rich_composer_send.xml diff --git a/app/src/main/java/org/futo/circles/view/MessageComposerView.kt b/app/src/main/java/org/futo/circles/view/MessageComposerView.kt index e81441dfc..70c6a953e 100644 --- a/app/src/main/java/org/futo/circles/view/MessageComposerView.kt +++ b/app/src/main/java/org/futo/circles/view/MessageComposerView.kt @@ -22,20 +22,13 @@ import android.widget.ImageButton interface MessageComposerView { - companion object { - const val MAX_LINES_WHEN_COLLAPSED = 10 - } - val text: Editable? val formattedText: String? val editText: EditText val emojiButton: ImageButton? - val sendButton: ImageButton - val attachmentButton: ImageButton var callback: Callback? fun setTextIfDifferent(text: CharSequence?): Boolean - fun renderComposerMode(mode: MessageComposerMode) } diff --git a/app/src/main/java/org/futo/circles/view/RichTextComposerLayout.kt b/app/src/main/java/org/futo/circles/view/RichTextComposerLayout.kt index d14371955..a630af30e 100644 --- a/app/src/main/java/org/futo/circles/view/RichTextComposerLayout.kt +++ b/app/src/main/java/org/futo/circles/view/RichTextComposerLayout.kt @@ -1,59 +1,30 @@ package org.futo.circles.view -/* - * Copyright (c) 2022 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import android.annotation.SuppressLint import android.content.Context -import android.content.res.ColorStateList -import android.content.res.Configuration -import android.graphics.Color import android.text.Editable -import android.text.TextWatcher import android.util.AttributeSet -import android.util.TypedValue import android.view.LayoutInflater import android.view.MotionEvent import android.view.View -import android.view.ViewGroup import android.widget.EditText import android.widget.ImageButton import android.widget.LinearLayout import androidx.annotation.DrawableRes import androidx.annotation.StringRes -import androidx.constraintlayout.widget.ConstraintSet -import androidx.core.text.toSpannable -import androidx.core.view.ViewCompat -import androidx.core.view.isGone -import androidx.core.view.isInvisible import androidx.core.view.isVisible -import androidx.core.view.updateLayoutParams -import com.google.android.material.shape.MaterialShapeDrawable +import androidx.core.widget.doOnTextChanged import io.element.android.wysiwyg.EditorEditText import io.element.android.wysiwyg.display.KeywordDisplayHandler import io.element.android.wysiwyg.display.LinkDisplayHandler import io.element.android.wysiwyg.display.TextDisplay -import io.element.android.wysiwyg.utils.RustErrorCollector import io.element.android.wysiwyg.view.models.InlineFormat import io.element.android.wysiwyg.view.models.LinkAction import org.futo.circles.R import org.futo.circles.databinding.ComposerRichTextLayoutBinding import org.futo.circles.databinding.ViewRichTextMenuButtonBinding import org.futo.circles.extensions.setTextIfDifferent -import org.futo.circles.extensions.showKeyboard import uniffi.wysiwyg_composer.ActionState import uniffi.wysiwyg_composer.ComposerAction @@ -67,130 +38,18 @@ internal class RichTextComposerLayout @JvmOverloads constructor( override var callback: Callback? = null - // There is no need to persist these values since they're always updated by the parent fragment - private var isFullScreen = false - private var hasRelatedMessage = false - private var composerMode: MessageComposerMode? = null - - var isTextFormattingEnabled = true - set(value) { - if (field == value) return - syncEditTexts() - field = value - updateTextFieldBorder(isFullScreen) - updateEditTextVisibility() - updateFullScreenButtonVisibility() - // If formatting is no longer enabled and it's in full screen, minimise the editor - if (!value && isFullScreen) { - callback?.onFullScreenModeChanged() - } - } - override val text: Editable? get() = editText.text override val formattedText: String? get() = (editText as? EditorEditText)?.getContentAsMessageHtml() override val editText: EditText - get() = if (isTextFormattingEnabled) { - views.richTextComposerEditText - } else { - views.plainTextComposerEditText - } + get() = views.richTextComposerEditText + override val emojiButton: ImageButton? get() = null - override val sendButton: ImageButton - get() = views.sendButton - override val attachmentButton: ImageButton - get() = views.attachmentButton - - val richTextEditText: EditText - get() = - views.richTextComposerEditText - val plainTextEditText: EditText - get() = - views.plainTextComposerEditText var pillDisplayHandler: PillDisplayHandler? = null - // Border of the EditText - private val borderShapeDrawable: MaterialShapeDrawable by lazy { - MaterialShapeDrawable().apply { - val typedData = TypedValue() - val lineColor = context.theme.obtainStyledAttributes( - typedData.data, - intArrayOf(R.attr.vctr_content_quaternary) - ) - .getColor(0, 0) - strokeColor = ColorStateList.valueOf(lineColor) - strokeWidth = 1 * resources.displayMetrics.scaledDensity - fillColor = ColorStateList.valueOf(Color.TRANSPARENT) - val cornerSize = - resources.getDimensionPixelSize(R.dimen.rich_text_composer_corner_radius_single_line) - setCornerSize(cornerSize.toFloat()) - } - } - - private val dimensionConverter = DimensionConverter(resources) - - fun setFullScreen(isFullScreen: Boolean, animated: Boolean) { - if (!animated && views.composerLayout.layoutParams != null) { - views.composerLayout.updateLayoutParams<ViewGroup.LayoutParams> { - height = - if (isFullScreen) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT - } - } - editText.updateLayoutParams<ViewGroup.LayoutParams> { - height = - if (isFullScreen) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT - } - - updateTextFieldBorder(isFullScreen) - updateEditTextVisibility() - - updateEditTextFullScreenState(views.richTextComposerEditText, isFullScreen) - updateEditTextFullScreenState(views.plainTextComposerEditText, isFullScreen) - - views.composerFullScreenButton.setImageResource( - if (isFullScreen) R.drawable.ic_composer_collapse else R.drawable.ic_composer_full_screen - ) - - views.bottomSheetHandle.isVisible = isFullScreen - if (isFullScreen) { - editText.showKeyboard(true) - } - this.isFullScreen = isFullScreen - } - - fun notifyIsBeingDragged(percentage: Float) { - // Calculate a new shape for the border according to the position in screen - val isSingleLine = editText.lineCount == 1 - val cornerSize = if (!isSingleLine || hasRelatedMessage) { - resources.getDimensionPixelSize(R.dimen.rich_text_composer_corner_radius_expanded) - .toFloat() - } else { - val multilineCornerSize = - resources.getDimensionPixelSize(R.dimen.rich_text_composer_corner_radius_expanded) - val singleLineCornerSize = - resources.getDimensionPixelSize(R.dimen.rich_text_composer_corner_radius_single_line) - val diff = singleLineCornerSize - multilineCornerSize - multilineCornerSize + diff * (1 - percentage) - } - if (cornerSize != borderShapeDrawable.bottomLeftCornerResolvedSize) { - borderShapeDrawable.setCornerSize(cornerSize) - } - - // Change maxLines while dragging, this should improve the smoothness of animations - val maxLines = if (percentage > 0.25f) { - Int.MAX_VALUE - } else { - MessageComposerView.MAX_LINES_WHEN_COLLAPSED - } - views.richTextComposerEditText.maxLines = maxLines - views.plainTextComposerEditText.maxLines = maxLines - - views.bottomSheetHandle.isVisible = true - } - init { inflate(context, R.layout.composer_rich_text_layout, this) views = ComposerRichTextLayoutBinding.bind(this) @@ -203,60 +62,12 @@ internal class RichTextComposerLayout @JvmOverloads constructor( 0f, 0 ) - views.plainTextComposerEditText.setShadowLayer( - views.richTextComposerEditText.paddingBottom.toFloat(), - 0f, - 0f, - 0 - ) - - renderComposerMode(MessageComposerMode.Normal(null)) - - views.richTextComposerEditText.addTextChangedListener( - TextChangeListener( - { callback?.onTextChanged(it) }, - { updateTextFieldBorder(isFullScreen) }) - ) - views.plainTextComposerEditText.addTextChangedListener( - TextChangeListener( - { callback?.onTextChanged(it) }, - { updateTextFieldBorder(isFullScreen) }) - ) - ViewCompat.setOnReceiveContentListener( - views.richTextComposerEditText, - arrayOf("image/*"), - UriContentListener { callback?.onRichContentSelected(it) } - ) - ViewCompat.setOnReceiveContentListener( - views.plainTextComposerEditText, - arrayOf("image/*"), - UriContentListener { callback?.onRichContentSelected(it) } - ) - - disallowParentInterceptTouchEvent(views.richTextComposerEditText) - disallowParentInterceptTouchEvent(views.plainTextComposerEditText) - - views.composerModeCloseView.setOnClickListener { - callback?.onCloseRelatedMessage() - } - - views.sendButton.setOnClickListener { - val textMessage = text?.toSpannable() ?: "" - callback?.onSendMessage(textMessage) - } - views.attachmentButton.setOnClickListener { - callback?.onAddAttachment() + views.richTextComposerEditText.doOnTextChanged { s, _, _, _ -> + callback?.onTextChanged(s ?: "") } - views.composerFullScreenButton.apply { - updateFullScreenButtonVisibility() - setOnClickListener { - callback?.onFullScreenModeChanged() - } - } - - views.composerEditTextOuterBorder.background = borderShapeDrawable + disallowParentInterceptTouchEvent(views.richTextComposerEditText) setupRichTextMenu() views.richTextComposerEditText.linkDisplayHandler = LinkDisplayHandler { text, url -> @@ -269,8 +80,6 @@ internal class RichTextComposerLayout @JvmOverloads constructor( override fun resolveKeywordDisplay(text: String): TextDisplay = pillDisplayHandler?.resolveKeywordDisplay(text) ?: TextDisplay.Plain } - - updateTextFieldBorder(isFullScreen) } private fun setupRichTextMenu() { @@ -381,7 +190,6 @@ internal class RichTextComposerLayout @JvmOverloads constructor( fun removeLink() = views.richTextComposerEditText.removeLink() - // Update the API to insertMention when available fun insertMention(url: String, displayText: String) = views.richTextComposerEditText.insertLink(url, displayText) @@ -409,109 +217,8 @@ internal class RichTextComposerLayout @JvmOverloads constructor( updateMenuStateFor(action, state) } } - updateEditTextVisibility() - } - - fun setOnErrorListener(onError: (e: RichTextEditorException) -> Unit) { - views.richTextComposerEditText.rustErrorCollector = RustErrorCollector { - onError(RichTextEditorException(it)) - } - } - - private fun updateEditTextVisibility() { - views.richTextComposerEditText.isVisible = isTextFormattingEnabled - views.richTextMenuScrollView.isVisible = isTextFormattingEnabled - views.plainTextComposerEditText.isVisible = !isTextFormattingEnabled - - // The layouts for formatted text mode and plain text mode are different, so we need to update the constraints - val dpToPx = { dp: Int -> dimensionConverter.dpToPx(dp) } - ConstraintSet().apply { - clone(views.composerLayoutContent) - clear(R.id.composerEditTextOuterBorder, ConstraintSet.TOP) - clear(R.id.composerEditTextOuterBorder, ConstraintSet.BOTTOM) - clear(R.id.composerEditTextOuterBorder, ConstraintSet.START) - clear(R.id.composerEditTextOuterBorder, ConstraintSet.END) - if (isTextFormattingEnabled) { - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.TOP, - R.id.composerLayoutContent, - ConstraintSet.TOP, - dpToPx(8) - ) - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.BOTTOM, - R.id.sendButton, - ConstraintSet.TOP, - 0 - ) - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.START, - R.id.composerLayoutContent, - ConstraintSet.START, - dpToPx(12) - ) - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.END, - R.id.composerLayoutContent, - ConstraintSet.END, - dpToPx(12) - ) - } else { - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.TOP, - R.id.composerLayoutContent, - ConstraintSet.TOP, - dpToPx(8) - ) - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.BOTTOM, - R.id.composerLayoutContent, - ConstraintSet.BOTTOM, - dpToPx(8) - ) - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.START, - R.id.attachmentButton, - ConstraintSet.END, - 0 - ) - connect( - R.id.composerEditTextOuterBorder, - ConstraintSet.END, - R.id.sendButton, - ConstraintSet.START, - 0 - ) - } - applyTo(views.composerLayoutContent) - } - } - - private fun updateFullScreenButtonVisibility() { - val isLargeScreenDevice = - resources.configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE) - val isLandscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE - // There's no point in having full screen in landscape since there's almost no vertical space - views.composerFullScreenButton.isInvisible = - !isTextFormattingEnabled || (isLandscape && !isLargeScreenDevice) } - /** - * Updates the non-active input with the contents of the active input. - */ - private fun syncEditTexts() = - if (isTextFormattingEnabled) { - views.plainTextComposerEditText.setText(views.richTextComposerEditText.getMarkdown()) - } else { - views.richTextComposerEditText.setMarkdown(views.plainTextComposerEditText.text.toString()) - } private fun addRichTextMenuItem( @DrawableRes iconId: Int, @@ -548,128 +255,8 @@ internal class RichTextComposerLayout @JvmOverloads constructor( } } - fun estimateCollapsedHeight(): Int { - val editText = this.editText - val originalLines = editText.maxLines - val originalParamsHeight = editText.layoutParams.height - editText.maxLines = MessageComposerView.MAX_LINES_WHEN_COLLAPSED - editText.layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT - measure( - MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), - MeasureSpec.UNSPECIFIED, - ) - val result = measuredHeight - editText.layoutParams.height = originalParamsHeight - editText.maxLines = originalLines - return result - } - - private fun updateTextFieldBorder(isFullScreen: Boolean) { - val isMultiline = - editText.editableText.lines().count() > 1 || isFullScreen || hasRelatedMessage - val cornerSize = if (isMultiline) { - resources.getDimensionPixelSize(R.dimen.rich_text_composer_corner_radius_expanded) - } else { - resources.getDimensionPixelSize(R.dimen.rich_text_composer_corner_radius_single_line) - }.toFloat() - borderShapeDrawable.setCornerSize(cornerSize) - } - - private fun replaceFormattedContent(text: CharSequence) { - views.richTextComposerEditText.setHtml(text.toString()) - updateTextFieldBorder(isFullScreen) - } - override fun setTextIfDifferent(text: CharSequence?): Boolean { - val result = editText.setTextIfDifferent(text) - updateTextFieldBorder(isFullScreen) - return result - } - - private fun updateEditTextFullScreenState(editText: EditText, isFullScreen: Boolean) { - if (isFullScreen) { - editText.maxLines = Int.MAX_VALUE - } else { - editText.maxLines = MessageComposerView.MAX_LINES_WHEN_COLLAPSED - } + return editText.setTextIfDifferent(text) } - override fun renderComposerMode(mode: MessageComposerMode) { - if (mode is MessageComposerMode.Special) { - views.composerModeGroup.isVisible = true - if (isTextFormattingEnabled) { - replaceFormattedContent(mode.defaultContent) - } else { - views.plainTextComposerEditText.setText(mode.defaultContent) - } - hasRelatedMessage = true - editText.showKeyboard(andRequestFocus = true) - } else { - views.composerModeGroup.isGone = true - (mode as? MessageComposerMode.Normal)?.content?.let { text -> - if (isTextFormattingEnabled) { - replaceFormattedContent(text) - } else { - views.plainTextComposerEditText.setText(text) - } - } - hasRelatedMessage = false - } - - updateTextFieldBorder(isFullScreen) - - if (this.composerMode == mode) return - this.composerMode = mode - - views.sendButton.apply { - if (mode is MessageComposerMode.Edit) { - contentDescription = resources.getString(R.string.action_save) - setImageResource(R.drawable.ic_composer_rich_text_save) - } else { - contentDescription = resources.getString(R.string.action_send) - setImageResource(R.drawable.ic_rich_composer_send) - } - } - - when (mode) { - is MessageComposerMode.Edit -> { - views.composerModeTitleView.setText(R.string.editing) - views.composerModeIconView.setImageResource(R.drawable.ic_composer_rich_text_editor_edit) - } - - is MessageComposerMode.Quote -> { - views.composerModeTitleView.setText(R.string.quoting) - views.composerModeIconView.setImageResource(R.drawable.ic_quote) - } - - is MessageComposerMode.Reply -> { - val senderInfo = mode.event.senderInfo - val userName = senderInfo.displayName ?: senderInfo.disambiguatedDisplayName - views.composerModeTitleView.text = - resources.getString(R.string.replying_to, userName) - views.composerModeIconView.setImageResource(R.drawable.ic_reply) - } - - else -> Unit - } - } - - private class TextChangeListener( - private val onTextChanged: (s: Editable) -> Unit, - private val onExpandedChanged: (isExpanded: Boolean) -> Unit, - ) : TextWatcher { - private var previousTextWasExpanded = false - - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} - override fun afterTextChanged(s: Editable) { - onTextChanged.invoke(s) - - val isExpanded = s.lines().count() > 1 - if (previousTextWasExpanded != isExpanded) { - onExpandedChanged(isExpanded) - } - previousTextWasExpanded = isExpanded - } - } } diff --git a/app/src/main/res/drawable/ic_composer_collapse.xml b/app/src/main/res/drawable/ic_composer_collapse.xml deleted file mode 100644 index d123caac5..000000000 --- a/app/src/main/res/drawable/ic_composer_collapse.xml +++ /dev/null @@ -1,9 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="20dp" - android:height="20dp" - android:viewportWidth="20" - android:viewportHeight="20"> - <path - android:fillColor="?vctr_content_quaternary" - android:pathData="M10.708,10Q10.438,10 10.219,9.781Q10,9.562 10,9.292V4.542Q10,4.354 10.146,4.219Q10.292,4.083 10.458,4.083Q10.646,4.083 10.781,4.219Q10.917,4.354 10.917,4.542V8.438L16.375,3Q16.5,2.854 16.688,2.854Q16.875,2.854 17,3Q17.146,3.125 17.146,3.312Q17.146,3.5 17,3.625L11.562,9.083H15.458Q15.646,9.083 15.781,9.229Q15.917,9.375 15.917,9.542Q15.917,9.729 15.781,9.865Q15.646,10 15.458,10ZM3,17Q2.854,16.875 2.854,16.688Q2.854,16.5 3,16.375L8.438,10.917H4.542Q4.354,10.917 4.219,10.771Q4.083,10.625 4.083,10.458Q4.083,10.271 4.219,10.135Q4.354,10 4.542,10H9.292Q9.562,10 9.781,10.219Q10,10.438 10,10.708V15.458Q10,15.646 9.854,15.781Q9.708,15.917 9.542,15.917Q9.354,15.917 9.219,15.781Q9.083,15.646 9.083,15.458V11.562L3.625,17Q3.5,17.146 3.312,17.146Q3.125,17.146 3,17Z" /> -</vector> diff --git a/app/src/main/res/drawable/ic_composer_full_screen.xml b/app/src/main/res/drawable/ic_composer_full_screen.xml deleted file mode 100644 index 6c7d7d673..000000000 --- a/app/src/main/res/drawable/ic_composer_full_screen.xml +++ /dev/null @@ -1,9 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="20dp" - android:height="20dp" - android:viewportWidth="20" - android:viewportHeight="20"> - <path - android:fillColor="?vctr_content_quaternary" - android:pathData="M3.625,17.083Q3.354,17.083 3.135,16.865Q2.917,16.646 2.917,16.375V11.625Q2.917,11.438 3.062,11.302Q3.208,11.167 3.375,11.167Q3.562,11.167 3.698,11.302Q3.833,11.438 3.833,11.625V15.5L15.5,3.833H11.625Q11.438,3.833 11.302,3.688Q11.167,3.542 11.167,3.375Q11.167,3.188 11.302,3.052Q11.438,2.917 11.625,2.917H16.375Q16.646,2.917 16.865,3.135Q17.083,3.354 17.083,3.625V8.375Q17.083,8.562 16.938,8.698Q16.792,8.833 16.625,8.833Q16.438,8.833 16.302,8.698Q16.167,8.562 16.167,8.375V4.5L4.5,16.167H8.375Q8.562,16.167 8.698,16.312Q8.833,16.458 8.833,16.625Q8.833,16.812 8.698,16.948Q8.562,17.083 8.375,17.083Z" /> -</vector> diff --git a/app/src/main/res/drawable/ic_composer_rich_mic_pressed.xml b/app/src/main/res/drawable/ic_composer_rich_mic_pressed.xml deleted file mode 100644 index e9dbe610e..000000000 --- a/app/src/main/res/drawable/ic_composer_rich_mic_pressed.xml +++ /dev/null @@ -1,17 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="52dp" - android:height="52dp" - android:viewportWidth="52" - android:viewportHeight="52"> - <path - android:pathData="M26.173,26.169m-22.763,0a22.763,22.763 0,1 1,45.526 0a22.763,22.763 0,1 1,-45.526 0" - android:fillColor="#0DBD8B"/> - <path - android:pathData="M26,26m-26,0a26,26 0,1 1,52 0a26,26 0,1 1,-52 0" - android:strokeAlpha="0.2" - android:fillColor="#0DBD8B" - android:fillAlpha="0.2"/> - <path - android:pathData="M26,29.5C27.937,29.5 29.488,27.937 29.488,26L29.5,19C29.5,17.063 27.937,15.5 26,15.5C24.063,15.5 22.5,17.063 22.5,19V26C22.5,27.937 24.063,29.5 26,29.5ZM33.093,26C32.603,26 32.195,26.35 32.125,26.828C31.693,29.873 28.952,31.95 26,31.95C23.048,31.95 20.307,29.885 19.875,26.828C19.805,26.35 19.385,26 18.907,26C18.3,26 17.833,26.537 17.915,27.132C18.452,30.597 21.368,33.315 24.833,33.84V36.5C24.833,37.142 25.358,37.667 26,37.667C26.642,37.667 27.167,37.142 27.167,36.5V33.84C30.62,33.338 33.548,30.597 34.085,27.132C34.167,26.537 33.7,26 33.093,26Z" - android:fillColor="#ffffff"/> -</vector> diff --git a/app/src/main/res/drawable/ic_composer_rich_text_editor_close.xml b/app/src/main/res/drawable/ic_composer_rich_text_editor_close.xml deleted file mode 100644 index cb80a6587..000000000 --- a/app/src/main/res/drawable/ic_composer_rich_text_editor_close.xml +++ /dev/null @@ -1,9 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="12dp" - android:height="12dp" - android:viewportWidth="12" - android:viewportHeight="12"> - <path - android:pathData="M10.403,2.53C10.696,2.237 10.696,1.763 10.403,1.47C10.111,1.177 9.636,1.177 9.343,1.47L5.946,4.867L2.549,1.47C2.256,1.177 1.781,1.177 1.488,1.47C1.195,1.763 1.195,2.237 1.488,2.53L4.885,5.927L1.343,9.47C1.05,9.763 1.05,10.237 1.343,10.53C1.636,10.823 2.11,10.823 2.403,10.53L5.946,6.988L9.488,10.53C9.781,10.823 10.256,10.823 10.549,10.53C10.842,10.237 10.842,9.763 10.549,9.47L7.006,5.927L10.403,2.53Z" - android:fillColor="@color/blue" /> -</vector> diff --git a/app/src/main/res/drawable/ic_composer_rich_text_editor_edit.xml b/app/src/main/res/drawable/ic_composer_rich_text_editor_edit.xml deleted file mode 100644 index 1c3ddde54..000000000 --- a/app/src/main/res/drawable/ic_composer_rich_text_editor_edit.xml +++ /dev/null @@ -1,12 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="12dp" - android:height="12dp" - android:viewportWidth="12" - android:viewportHeight="12"> - <path - android:pathData="M2.649,7.355C2.655,7.316 2.672,7.28 2.699,7.251L8.404,1.064C8.479,0.983 8.605,0.978 8.686,1.053L9.863,2.138C9.944,2.213 9.949,2.339 9.874,2.42L4.169,8.607C4.143,8.636 4.108,8.656 4.069,8.665L2.668,9.005C2.529,9.039 2.401,8.92 2.423,8.779L2.649,7.355Z" - android:fillColor="@color/blue" /> - <path - android:pathData="M1.75,9.443C1.336,9.443 1,9.779 1,10.193C1,10.608 1.336,10.943 1.75,10.943L10.75,10.943C11.164,10.943 11.5,10.608 11.5,10.193C11.5,9.779 11.164,9.443 10.75,9.443L1.75,9.443Z" - android:fillColor="@color/blue" /> -</vector> diff --git a/app/src/main/res/drawable/ic_composer_rich_text_save.xml b/app/src/main/res/drawable/ic_composer_rich_text_save.xml deleted file mode 100644 index 63eb8d2c4..000000000 --- a/app/src/main/res/drawable/ic_composer_rich_text_save.xml +++ /dev/null @@ -1,16 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="36dp" - android:height="36dp" - android:viewportWidth="36" - android:viewportHeight="36"> - <path - android:pathData="M18,18m-18,0a18,18 0,1 1,36 0a18,18 0,1 1,-36 0" - android:fillColor="?colorPrimary"/> - <path - android:pathData="M9.818,18.787L14.705,23.818L26.182,12" - android:strokeLineJoin="round" - android:strokeWidth="2.5" - android:fillColor="#00000000" - android:strokeColor="?colorOnPrimary" - android:strokeLineCap="round"/> -</vector> diff --git a/app/src/main/res/drawable/ic_quote.xml b/app/src/main/res/drawable/ic_quote.xml deleted file mode 100644 index 0689651f1..000000000 --- a/app/src/main/res/drawable/ic_quote.xml +++ /dev/null @@ -1,14 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="20dp" - android:height="14dp" - android:viewportWidth="20" - android:viewportHeight="14"> - <path - android:pathData="M19,5H1M19,1H1M10,9H1M10,13H1" - android:strokeLineJoin="round" - android:strokeWidth="2" - android:fillColor="#00000000" - android:fillType="evenOdd" - android:strokeColor="#9E9E9E" - android:strokeLineCap="round"/> -</vector> diff --git a/app/src/main/res/drawable/ic_rich_composer_add.xml b/app/src/main/res/drawable/ic_rich_composer_add.xml deleted file mode 100644 index a5961c498..000000000 --- a/app/src/main/res/drawable/ic_rich_composer_add.xml +++ /dev/null @@ -1,15 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="36dp" - android:height="36dp" - android:viewportWidth="36" - android:viewportHeight="36"> - <path - android:pathData="M18,18m-18,0a18,18 0,1 1,36 0a18,18 0,1 1,-36 0" - android:fillColor="@color/blue"/> - <path - android:pathData="M11.251,18H24.751M18.001,11.25V24.75" - android:strokeWidth="2" - android:fillColor="#00000000" - android:strokeColor="@color/blue" - android:strokeLineCap="round"/> -</vector> diff --git a/app/src/main/res/drawable/ic_rich_composer_send.xml b/app/src/main/res/drawable/ic_rich_composer_send.xml deleted file mode 100644 index b3df6e92d..000000000 --- a/app/src/main/res/drawable/ic_rich_composer_send.xml +++ /dev/null @@ -1,12 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="36dp" - android:height="36dp" - android:viewportWidth="36" - android:viewportHeight="36"> - <path - android:pathData="M18,18m-18,0a18,18 0,1 1,36 0a18,18 0,1 1,-36 0" - android:fillColor="?colorPrimary"/> - <path - android:pathData="M27.83,19.085L12.26,26.867C11.21,27.391 10.119,26.266 10.632,25.24C10.632,25.24 12.561,21.343 13.092,20.322C13.623,19.301 14.231,19.124 19.874,18.395C20.083,18.368 20.253,18.21 20.253,18C20.253,17.79 20.083,17.632 19.874,17.605C14.231,16.876 13.623,16.699 13.092,15.678C12.561,14.658 10.632,10.76 10.632,10.76C10.119,9.734 11.21,8.609 12.26,9.133L27.83,16.915C28.725,17.362 28.725,18.638 27.83,19.085Z" - android:fillColor="?colorOnPrimary"/> -</vector> diff --git a/app/src/main/res/layout/composer_rich_text_layout.xml b/app/src/main/res/layout/composer_rich_text_layout.xml index a8f0b4baa..bcfd40c54 100644 --- a/app/src/main/res/layout/composer_rich_text_layout.xml +++ b/app/src/main/res/layout/composer_rich_text_layout.xml @@ -7,188 +7,48 @@ android:layout_height="match_parent" android:orientation="vertical"> - <FrameLayout - android:id="@+id/bottomSheetHandle" - android:layout_width="match_parent" - android:layout_height="wrap_content" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent"> - - <View - android:layout_width="36dp" - android:layout_height="5dp" - android:layout_gravity="center_horizontal" - android:layout_marginTop="8dp" - /> - - </FrameLayout> - <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/composerLayoutContent" android:layout_width="match_parent" android:layout_height="match_parent"> - <ImageButton - android:id="@+id/attachmentButton" - android:layout_width="60dp" - android:layout_height="56dp" - android:background="?android:attr/selectableItemBackgroundBorderless" - android:contentDescription="Send Files" - android:src="@drawable/ic_rich_composer_add" - app:layout_constraintVertical_bias="1" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:layout_goneMarginBottom="56dp" - tools:ignore="MissingPrefix,RtlSymmetry" /> - - <!-- Constraints are updated programmatically --> - <FrameLayout - android:id="@+id/composerEditTextOuterBorder" - android:layout_width="0dp" - android:layout_height="0dp" - android:minHeight="40dp" - android:layout_marginTop="8dp" - android:layout_marginBottom="8dp" - android:layout_marginHorizontal="12dp" - app:layout_constraintVertical_bias="0" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toTopOf="@id/sendButton" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" /> - - <androidx.appcompat.widget.AppCompatImageView - android:id="@+id/composerModeIconView" - android:layout_width="11dp" - android:layout_height="11dp" - tools:src="@drawable/ic_quote" - android:layout_marginStart="12dp" - app:layout_constraintTop_toTopOf="@id/composerModeTitleView" - app:layout_constraintBottom_toBottomOf="@id/composerModeTitleView" - app:layout_constraintStart_toStartOf="@id/composerEditTextOuterBorder" - app:tint="@color/blue" /> - - <TextView android:id="@+id/composerModeTitleView" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="6dp" - android:layout_marginTop="8dp" - android:paddingBottom="2dp" - android:fontFamily="sans-serif-medium" - tools:text="Editing" - app:layout_constraintTop_toTopOf="@id/composerEditTextOuterBorder" - app:layout_constraintStart_toEndOf="@id/composerModeIconView" /> - - <ImageButton android:id="@+id/composerModeCloseView" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@drawable/ic_composer_rich_text_editor_close" - android:background="?android:selectableItemBackground" - android:layout_marginEnd="12dp" - app:layout_constraintTop_toTopOf="@id/composerModeIconView" - app:layout_constraintEnd_toEndOf="@id/composerEditTextOuterBorder" /> - - <androidx.constraintlayout.widget.Barrier - android:id="@+id/composerModeBarrier" - android:layout_width="0dp" - android:layout_height="0dp" - app:barrierDirection="bottom" - app:constraint_referenced_ids="composerModeIconView,composerModeTitleView,composerModeCloseView" /> - - <androidx.constraintlayout.widget.Group - android:id="@+id/composerModeGroup" - android:layout_width="0dp" - android:layout_height="0dp" - android:visibility="gone" - tools:visibility="visible" - app:constraint_referenced_ids="composerModeIconView,composerModeTitleView,composerModeCloseView" /> - <io.element.android.wysiwyg.EditorEditText android:id="@+id/richTextComposerEditText" android:layout_width="0dp" android:layout_height="0dp" - app:layout_constraintHeight_default="wrap" + android:layout_marginStart="12dp" android:gravity="top" android:hint="Room message placeholder" + android:imeOptions="flagNoExtractUi" android:nextFocusLeft="@id/richTextComposerEditText" android:nextFocusUp="@id/richTextComposerEditText" - android:layout_marginStart="12dp" - android:imeOptions="flagNoExtractUi" - app:layout_constraintVertical_bias="0" - app:layout_constraintBottom_toBottomOf="@id/composerEditTextOuterBorder" - app:layout_constraintEnd_toStartOf="@id/composerFullScreenButton" - app:layout_constraintStart_toStartOf="@id/composerEditTextOuterBorder" - app:layout_constraintTop_toBottomOf="@id/composerModeBarrier" - app:bulletRadius="4sp" app:bulletGap="8sp" + app:bulletRadius="4sp" app:codeBlockBackgroundDrawable="@drawable/bg_code_block" - app:inlineCodeSingleLineBg="@drawable/bg_inline_code_single_line" app:inlineCodeMultiLineBgLeft="@drawable/bg_inline_code_multi_line_left" app:inlineCodeMultiLineBgMid="@drawable/bg_inline_code_multi_line_mid" app:inlineCodeMultiLineBgRight="@drawable/bg_inline_code_multi_line_right" - tools:text="@tools:sample/lorem/random" /> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/plainTextComposerEditText" - android:layout_width="0dp" - android:layout_height="0dp" + app:inlineCodeSingleLineBg="@drawable/bg_inline_code_single_line" + app:layout_constraintBottom_toTopOf="@id/richTextMenuScrollView" + app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_default="wrap" - android:visibility="gone" - android:hint="Room placeholder" - android:nextFocusLeft="@id/plainTextComposerEditText" - android:nextFocusUp="@id/plainTextComposerEditText" - android:layout_marginStart="12dp" - android:gravity="top" - android:imeOptions="flagNoExtractUi" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0" - app:layout_constraintBottom_toBottomOf="@id/composerEditTextOuterBorder" - app:layout_constraintEnd_toStartOf="@id/composerFullScreenButton" - app:layout_constraintStart_toStartOf="@id/composerEditTextOuterBorder" - app:layout_constraintTop_toBottomOf="@id/composerModeBarrier" tools:text="@tools:sample/lorem/random" /> - <ImageButton - android:id="@+id/composerFullScreenButton" - android:layout_width="40dp" - android:layout_height="40dp" - android:layout_marginEnd="4dp" - app:layout_constraintEnd_toEndOf="@id/composerEditTextOuterBorder" - app:layout_constraintTop_toBottomOf="@id/composerModeBarrier" - app:layout_constraintBottom_toBottomOf="@id/composerEditTextOuterBorder" - app:layout_constraintVertical_bias="0" - android:src="@drawable/ic_composer_full_screen" - android:background="?android:attr/selectableItemBackgroundBorderless" - android:contentDescription="@string/rich_text_editor_full_screen_toggle" /> - - <ImageButton - android:id="@+id/sendButton" - android:layout_width="56dp" - android:layout_height="56dp" - android:paddingEnd="4dp" - android:contentDescription="@string/action_send" - android:scaleType="center" - android:src="@drawable/ic_rich_composer_send" - android:visibility="invisible" - android:background="?android:attr/selectableItemBackgroundBorderless" - app:layout_constraintTop_toBottomOf="@id/composerEditTextOuterBorder" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintVertical_bias="1" - tools:ignore="MissingPrefix,RtlSymmetry" - tools:visibility="visible" /> - - <HorizontalScrollView android:id="@+id/richTextMenuScrollView" + <HorizontalScrollView + android:id="@+id/richTextMenuScrollView" android:layout_width="0dp" android:layout_height="wrap_content" + android:fadingEdgeLength="28dp" + android:fillViewport="true" android:minHeight="52dp" android:requiresFadingEdge="horizontal" - android:fadingEdgeLength="28dp" - app:layout_constraintTop_toBottomOf="@id/composerEditTextOuterBorder" - app:layout_constraintStart_toEndOf="@id/attachmentButton" - app:layout_constraintEnd_toStartOf="@id/sendButton" app:layout_constraintBottom_toBottomOf="parent" - android:fillViewport="true"> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/richTextComposerEditText"> <LinearLayout android:id="@+id/richTextMenu" diff --git a/app/src/main/res/layout/view_preview_post.xml b/app/src/main/res/layout/view_preview_post.xml index 8f3a8baa7..d516d10c3 100644 --- a/app/src/main/res/layout/view_preview_post.xml +++ b/app/src/main/res/layout/view_preview_post.xml @@ -60,8 +60,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_default="wrap" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - tools:visibility="visible" /> + app:layout_constraintTop_toTopOf="parent" /> <!-- <io.element.android.wysiwyg.EditorEditText--> <!-- android:id="@+id/etTextPost"--> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a56cca454..ed95017c7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -19,6 +19,5 @@ <color name="close_background">#80000000</color> <color name="highlight_color">#4D0E7AFE</color> <color name="launcher_background_color">#00008b</color> - <color name="transparent">#00000000</color> </resources> \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index b92aaf03d..4671e2397 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,7 +6,6 @@ <dimen name="circle_icon_size">100dp</dimen> <dimen name="profile_avatar_size">50dp</dimen> - <dimen name="rich_text_composer_corner_radius_single_line">28dp</dimen> <dimen name="rich_text_composer_corner_radius_expanded">14dp</dimen> <dimen name="rich_text_composer_menu_item_size">44dp</dimen> </resources> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa73109f6..5e0890b1c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -25,7 +25,6 @@ <string name="invites">Invites</string> <string name="create_new_group">Create new group</string> <string name="create_new_circle">Create new circle</string> - <string name="circles_created">Circles created</string> <string name="private_circles">Private Circles</string> <string name="log_out">Log out</string> <string name="others">Others</string> @@ -74,7 +73,6 @@ <string name="severity_formatter">Severity: %d</string> <string name="add_reaction">Add reaction</string> <string name="unfollow">Unfollow</string> - <string name="requested_to_follow_format">%s requested to follow</string> <string name="request_to_join">Request to join</string> <string name="request_to_follow">Request to follow</string> <string name="select_circles_in_which_you_want_to_follow_this_timeline">Select circles in which you want to follow this timeline</string> @@ -184,9 +182,6 @@ <string name="unifiedpush_distributor_background_sync">Background synchronization</string> <string name="no_valid_google_play_services_apk">No valid Google Play Services APK found. Notifications may not work properly.</string> <string name="unable_to_register_receiver">Unable to register the receiver</string> - <string name="scan_profile">Scan profile</string> - <string name="mute_notifications">Mute notifications</string> - <string name="unmute_notifications">Unmute notifications</string> <string name="shortcut_disabled">Shortcut disabled</string> <string name="shared_circles_space_not_found">Shared Circles space not found</string> <string name="notification_method">Notification method</string> @@ -202,7 +197,6 @@ <string name="request_to_become_member_room">Request to join to become a member of this room</string> <string name="you_have_pending_invitation_user">You have a pending invitation to follow this user. Check your invite notifications</string> <string name="you_are_already_following_user">You are already following this user</string> - <string name="you_are_banned_user">You are banned</string> <string name="send_request_to_follow_user">Send request to follow this user</string> <string name="unable_to_parse_url">Unable to parse url</string> <string name="developer_mode_enabled">Developer mode is enabled</string> @@ -229,12 +223,6 @@ <string name="rich_text_editor_quote">Toggle quote</string> <string name="rich_text_editor_inline_code">Apply inline code format</string> <string name="rich_text_editor_code_block">Toggle code block</string> - <string name="rich_text_editor_full_screen_toggle">Toggle full screen mode</string> - <string name="action_save">Save</string> - <string name="action_send">Send</string> - <string name="editing">Editing</string> - <string name="quoting">Quoting</string> - <string name="replying_to">Replying to %s</string> <string-array name="report_categories"> <item>@string/crude_language</item> -- GitLab