From 45ea5c356e193a55969b50e1cde901298d16c43b Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 23 May 2019 16:44:51 +0200 Subject: [PATCH] WIP / edit message --- .../room/model/annotation/ReactionService.kt | 10 + .../api/session/room/send/SendService.kt | 1 + .../room/annotation/DefaultReactionService.kt | 20 ++ .../session/room/send/DefaultSendService.kt | 11 + .../room/send/LocalEchoEventFactory.kt | 25 ++ .../riotredesign/core/utils/AnimationUtils.kt | 39 +++ .../riotredesign/features/DebugActivity.kt | 12 + .../home/room/detail/RoomDetailActions.kt | 7 +- .../home/room/detail/RoomDetailFragment.kt | 96 +++++++- .../home/room/detail/RoomDetailViewModel.kt | 231 +++++++++++++----- .../home/room/detail/RoomDetailViewState.kt | 19 +- .../timeline/action/MessageMenuViewModel.kt | 22 +- .../drawable-hdpi/ic_attach_file_white.png | Bin 394 -> 0 bytes .../main/res/drawable-hdpi/ic_send_white.png | Bin 335 -> 0 bytes .../drawable-mdpi/ic_attach_file_white.png | Bin 285 -> 0 bytes .../main/res/drawable-mdpi/ic_send_white.png | Bin 257 -> 0 bytes .../drawable-xhdpi/ic_attach_file_white.png | Bin 507 -> 0 bytes .../main/res/drawable-xhdpi/ic_send_white.png | Bin 423 -> 0 bytes .../drawable-xxhdpi/ic_attach_file_white.png | Bin 809 -> 0 bytes .../res/drawable-xxhdpi/ic_send_white.png | Bin 550 -> 0 bytes .../drawable-xxxhdpi/ic_attach_file_white.png | Bin 1059 -> 0 bytes .../res/drawable-xxxhdpi/ic_send_white.png | Bin 728 -> 0 bytes .../src/main/res/drawable/ic_add_reaction.xml | 54 ++++ .../src/main/res/drawable/ic_attachment.xml | 14 ++ .../src/main/res/drawable/ic_close_round.xml | 20 ++ .../drawable/{ic_smile.xml => ic_delete.xml} | 20 +- vector/src/main/res/drawable/ic_edit.xml | 8 +- vector/src/main/res/drawable/ic_send.xml | 14 ++ .../main/res/layout/adapter_item_action.xml | 8 +- ...constraint_set_composer_layout_compact.xml | 153 ++++++++++++ ...onstraint_set_composer_layout_expanded.xml | 156 ++++++++++++ .../main/res/layout/fragment_room_detail.xml | 55 +---- .../res/layout/include_composer_layout.xml | 123 ++++++++++ vector/src/main/res/values/attrs.xml | 1 + vector/src/main/res/values/colors_riot.xml | 1 + vector/src/main/res/values/theme_black.xml | 1 + vector/src/main/res/values/theme_dark.xml | 1 + vector/src/main/res/values/theme_light.xml | 1 + vector/src/main/res/values/theme_status.xml | 1 + 39 files changed, 978 insertions(+), 146 deletions(-) create mode 100644 vector/src/main/java/im/vector/riotredesign/core/utils/AnimationUtils.kt create mode 100644 vector/src/main/java/im/vector/riotredesign/features/DebugActivity.kt delete mode 100644 vector/src/main/res/drawable-hdpi/ic_attach_file_white.png delete mode 100644 vector/src/main/res/drawable-hdpi/ic_send_white.png delete mode 100644 vector/src/main/res/drawable-mdpi/ic_attach_file_white.png delete mode 100644 vector/src/main/res/drawable-mdpi/ic_send_white.png delete mode 100644 vector/src/main/res/drawable-xhdpi/ic_attach_file_white.png delete mode 100644 vector/src/main/res/drawable-xhdpi/ic_send_white.png delete mode 100644 vector/src/main/res/drawable-xxhdpi/ic_attach_file_white.png delete mode 100644 vector/src/main/res/drawable-xxhdpi/ic_send_white.png delete mode 100644 vector/src/main/res/drawable-xxxhdpi/ic_attach_file_white.png delete mode 100644 vector/src/main/res/drawable-xxxhdpi/ic_send_white.png create mode 100644 vector/src/main/res/drawable/ic_add_reaction.xml create mode 100644 vector/src/main/res/drawable/ic_attachment.xml create mode 100644 vector/src/main/res/drawable/ic_close_round.xml rename vector/src/main/res/drawable/{ic_smile.xml => ic_delete.xml} (51%) create mode 100644 vector/src/main/res/drawable/ic_send.xml create mode 100644 vector/src/main/res/layout/constraint_set_composer_layout_compact.xml create mode 100644 vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml create mode 100644 vector/src/main/res/layout/include_composer_layout.xml diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/annotation/ReactionService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/annotation/ReactionService.kt index ace61159af..3f8fec0017 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/annotation/ReactionService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/annotation/ReactionService.kt @@ -17,6 +17,7 @@ package im.vector.matrix.android.api.session.room.model.annotation import im.vector.matrix.android.api.util.Cancelable +//TODO rename in relationService? interface ReactionService { @@ -49,4 +50,13 @@ interface ReactionService { */ fun updateQuickReaction(reaction: String, oppositeReaction: String, targetEventId: String, myUserId: String) + + /** + * Edit a text message body. Limited to "m.text" contentType + * @param targetEventId The event to edit + * @param newBodyText The edited body + * @param compatibilityBodyText The text that will appear on clients that don't support yet edition + */ + fun editTextMessage(targetEventId: String, newBodyText: String, compatibilityBodyText: String = "* $newBodyText"): Cancelable + } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/SendService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/SendService.kt index 6852931cbb..551ab545a4 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/SendService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/SendService.kt @@ -34,6 +34,7 @@ interface SendService { * @return a [Cancelable] */ fun sendTextMessage(text: String, msgType: String = MessageType.MSGTYPE_TEXT): Cancelable + fun sendFormattedTextMessage(text: String,formattedText: String): Cancelable /** * Method to send a media asynchronously. diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/annotation/DefaultReactionService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/annotation/DefaultReactionService.kt index dbef546166..fdb75a8fdb 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/annotation/DefaultReactionService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/annotation/DefaultReactionService.kt @@ -19,6 +19,7 @@ import androidx.work.* import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.room.model.annotation.ReactionService +import im.vector.matrix.android.api.session.room.model.message.MessageType import im.vector.matrix.android.api.util.Cancelable import im.vector.matrix.android.internal.session.room.send.LocalEchoEventFactory import im.vector.matrix.android.internal.session.room.send.RedactEventWorker @@ -150,4 +151,23 @@ internal class DefaultReactionService(private val roomId: String, .setBackoffCriteria(BackoffPolicy.LINEAR, BACKOFF_DELAY, TimeUnit.MILLISECONDS) .build() } + + override fun editTextMessage(targetEventId: String, newBodyText: String, compatibilityBodyText: String): Cancelable { + val event = eventFactory.createReplaceTextEvent(roomId, targetEventId, newBodyText, MessageType.MSGTYPE_TEXT, compatibilityBodyText) + val sendContentWorkerParams = SendEventWorker.Params(roomId, event) + val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams) + + //TODO use relation API? + val workRequest = OneTimeWorkRequestBuilder() + .setConstraints(WORK_CONSTRAINTS) + .setInputData(sendWorkData) + .setBackoffCriteria(BackoffPolicy.LINEAR, BACKOFF_DELAY, TimeUnit.MILLISECONDS) + .build() + + WorkManager.getInstance() + .beginUniqueWork(buildWorkIdentifier(REACTION_WORK), ExistingWorkPolicy.APPEND, workRequest) + .enqueue() + return CancelableWork(workRequest.id) + + } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt index 28ae63b88c..1d6197a34f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt @@ -60,6 +60,17 @@ internal class DefaultSendService(private val roomId: String, return CancelableWork(sendWork.id) } + override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable { + val event = eventFactory.createFormattedTextEvent(roomId, text, formattedText).also { + saveLocalEcho(it) + } + val sendWork = createSendEventWork(event) + WorkManager.getInstance() + .beginUniqueWork(buildWorkIdentifier(SEND_WORK), ExistingWorkPolicy.APPEND, sendWork) + .enqueue() + return CancelableWork(sendWork.id) + } + override fun sendMedias(attachments: List): Cancelable { val cancelableBag = CancelableBag() attachments.forEach { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt index a2076d3b62..e1cc9c74e0 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt @@ -25,6 +25,7 @@ import im.vector.matrix.android.api.session.events.model.RelationType import im.vector.matrix.android.api.session.events.model.toContent import im.vector.matrix.android.api.session.room.model.annotation.ReactionContent import im.vector.matrix.android.api.session.room.model.annotation.ReactionInfo +import im.vector.matrix.android.api.session.room.model.annotation.RelationDefaultContent import im.vector.matrix.android.api.session.room.model.message.* import im.vector.matrix.android.internal.session.content.ThumbnailExtractor @@ -35,6 +36,30 @@ internal class LocalEchoEventFactory(private val credentials: Credentials) { return createEvent(roomId, content) } + fun createFormattedTextEvent(roomId: String, text: String, formattedText: String): Event { + val content = MessageTextContent( + type = MessageType.MSGTYPE_TEXT, + format = MessageType.FORMAT_MATRIX_HTML, + body = text, + formattedBody = formattedText + ) + return createEvent(roomId, content) + } + + + fun createReplaceTextEvent(roomId: String, targetEventId: String, newBodyText: String, msgType: String, compatibilityText: String): Event { + val content = MessageTextContent( + type = msgType, + body = compatibilityText, + relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId), + newContent = MessageTextContent( + type = MessageType.MSGTYPE_TEXT, + body = newBodyText + ).toContent() + ) + return createEvent(roomId, content) + } + fun createMediaEvent(roomId: String, attachment: ContentAttachmentData): Event { return when (attachment.type) { ContentAttachmentData.Type.IMAGE -> createImageEvent(roomId, attachment) diff --git a/vector/src/main/java/im/vector/riotredesign/core/utils/AnimationUtils.kt b/vector/src/main/java/im/vector/riotredesign/core/utils/AnimationUtils.kt new file mode 100644 index 0000000000..a773991df0 --- /dev/null +++ b/vector/src/main/java/im/vector/riotredesign/core/utils/AnimationUtils.kt @@ -0,0 +1,39 @@ +package im.vector.riotredesign.core.utils + +import android.view.animation.OvershootInterpolator +import androidx.annotation.LayoutRes +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.constraintlayout.widget.ConstraintSet +import androidx.transition.ChangeBounds +import androidx.transition.Transition +import androidx.transition.TransitionManager + + +inline fun ConstraintLayout.updateConstraintSet(@LayoutRes layoutId: Int, rootLayoutForAnimation: ConstraintLayout? = null, noinline onAnimationEnd: (() -> Unit)? = null) { + if (rootLayoutForAnimation != null) { + val transition = ChangeBounds() + transition.interpolator = OvershootInterpolator() + transition.addListener(object : Transition.TransitionListener { + override fun onTransitionResume(transition: Transition) { + } + + override fun onTransitionPause(transition: Transition) { + } + + override fun onTransitionCancel(transition: Transition) { + } + + override fun onTransitionStart(transition: Transition) { + } + + override fun onTransitionEnd(transition: Transition) { + onAnimationEnd?.invoke() + } + }) + TransitionManager.beginDelayedTransition(rootLayoutForAnimation, transition) + } + ConstraintSet().also { + it.clone(this@updateConstraintSet.context, layoutId) + it.applyTo(this@updateConstraintSet) + } +} \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/features/DebugActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/DebugActivity.kt new file mode 100644 index 0000000000..00708d0375 --- /dev/null +++ b/vector/src/main/java/im/vector/riotredesign/features/DebugActivity.kt @@ -0,0 +1,12 @@ +package im.vector.riotredesign.features + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle + +class DebugActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_debug) + } +} diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailActions.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailActions.kt index 7d6ffc04b4..190c37dee4 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailActions.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailActions.kt @@ -31,10 +31,13 @@ sealed class RoomDetailActions { data class SendReaction(val reaction: String, val targetEventId: String) : RoomDetailActions() data class RedactAction(val targetEventId: String, val reason: String? = "") : RoomDetailActions() data class UndoReaction(val targetEventId: String, val key: String, val reason: String? = "") : RoomDetailActions() - data class UpdateQuickReactAction(val targetEventId: String,val selectedReaction: String,val opposite: String) : RoomDetailActions() - data class ShowEditHistoryAction(val event: String,val editAggregatedSummary: EditAggregatedSummary) : RoomDetailActions() + data class UpdateQuickReactAction(val targetEventId: String, val selectedReaction: String, val opposite: String) : RoomDetailActions() + data class ShowEditHistoryAction(val event: String, val editAggregatedSummary: EditAggregatedSummary) : RoomDetailActions() object AcceptInvite : RoomDetailActions() object RejectInvite : RoomDetailActions() + data class EnterEditMode(val eventId: String) : RoomDetailActions() + data class EnterQuoteMode(val eventId: String) : RoomDetailActions() + } \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt index 0278607a8f..0ae0dda55c 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt @@ -32,14 +32,17 @@ import android.view.HapticFeedbackConstants import android.view.LayoutInflater import android.view.View import android.view.inputmethod.InputMethodManager +import android.widget.ImageButton import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AlertDialog +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import butterknife.BindView import com.airbnb.epoxy.EpoxyVisibilityTracker import com.airbnb.mvrx.MvRx import com.airbnb.mvrx.fragmentViewModel @@ -53,6 +56,7 @@ import com.otaliastudios.autocomplete.Autocomplete import com.otaliastudios.autocomplete.AutocompleteCallback import com.otaliastudios.autocomplete.CharPolicy import im.vector.matrix.android.api.session.Session +import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.EditAggregatedSummary import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.android.api.session.room.model.message.* @@ -92,6 +96,7 @@ import im.vector.riotredesign.features.media.VideoMediaViewerActivity import im.vector.riotredesign.features.reactions.EmojiReactionPickerActivity import kotlinx.android.parcel.Parcelize import kotlinx.android.synthetic.main.fragment_room_detail.* +import kotlinx.android.synthetic.main.include_composer_layout.* import org.koin.android.ext.android.inject import org.koin.android.scope.ext.android.bindScope import org.koin.android.scope.ext.android.getOrCreateScope @@ -165,6 +170,15 @@ class RoomDetailFragment : private lateinit var actionViewModel: ActionsHandler + @BindView(R.id.composer_related_message_sender) + lateinit var composerRelatedMessageTitle: TextView + @BindView(R.id.composer_related_message_preview) + lateinit var composerRelatedMessageContent: TextView + @BindView(R.id.composerLayout) + lateinit var composerLayout: ConstraintLayout + @BindView(R.id.rootConstraintLayout) + lateinit var rootConstraintLayout: ConstraintLayout + override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) actionViewModel = ViewModelProviders.of(requireActivity()).get(ActionsHandler::class.java) @@ -187,6 +201,65 @@ class RoomDetailFragment : actionViewModel.actionCommandEvent.observe(this, Observer { handleActions(it) }) + + roomDetailViewModel.selectSubscribe(RoomDetailViewState::sendMode, RoomDetailViewState::selectedEvent, RoomDetailViewState::roomId) { mode, event, roomId -> + when (mode) { + SendMode.REGULAR -> { + val uid = session.sessionParams.credentials.userId + val meMember = session.getRoom(roomId)?.getRoomMember(uid) + AvatarRenderer.render(meMember?.avatarUrl, uid, meMember?.displayName, composer_avatar_view) + composerLayout.updateConstraintSet(R.layout.constraint_set_composer_layout_compact, rootConstraintLayout) { + focusComposerAndShowKeyboard() + } + } + SendMode.EDIT, + SendMode.QUOTE -> { + if (event == null) { + //we should ignore? can this happen? + Timber.e("Enter edit mode with no event selected") + return@selectSubscribe + } + //switch to expanded bar + composerRelatedMessageTitle.text = event.senderName + composerRelatedMessageTitle.setTextColor( + ContextCompat.getColor(requireContext(), AvatarRenderer.getColorFromUserId(event.root.sender + ?: "")) + ) + + val messageContent: MessageContent? = + event.annotations?.editSummary?.aggregatedContent?.toModel() + ?: event.root.content.toModel() + val eventTextBody = messageContent?.body + composerRelatedMessageContent.text = eventTextBody + + + if (mode == SendMode.EDIT) { + composerEditText.setText(eventTextBody) + composer_related_message_action_image.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_edit)) + } else { + composerEditText.setText("") + composer_related_message_action_image.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_quote)) + } + + AvatarRenderer.render(event.senderAvatar, event.root.sender + ?: "", event.senderName, composer_avatar_view) + + composerEditText.setSelection(composerEditText.text.length) + composerLayout.updateConstraintSet(R.layout.constraint_set_composer_layout_expanded, rootConstraintLayout) { + focusComposerAndShowKeyboard() + } + + view?.findViewById(R.id.composer_related_message_close)?.setOnClickListener { + + composerRelatedMessageTitle.text = "" + composerRelatedMessageContent.text = "" + composerEditText.setText("") + roomDetailViewModel.resetSendMode() + } + + } + } + } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @@ -398,6 +471,11 @@ class RoomDetailFragment : if (summary?.membership == Membership.JOIN) { timelineEventController.setTimeline(state.timeline) inviteView.visibility = View.GONE + + val uid = session.sessionParams.credentials.userId + val meMember = session.getRoom(state.roomId)?.getRoomMember(uid) + AvatarRenderer.render(meMember?.avatarUrl, uid, meMember?.displayName, composer_avatar_view) + } else if (summary?.membership == Membership.INVITE && inviter != null) { inviteView.visibility = View.VISIBLE inviteView.render(inviter, VectorInviteView.Mode.LARGE) @@ -601,6 +679,14 @@ class RoomDetailFragment : roomDetailViewModel.process(RoomDetailActions.UpdateQuickReactAction(eventId, clickedOn, opposite)) } } + MessageMenuViewModel.ACTION_EDIT -> { + val eventId = actionData.data.toString() ?: return@let + roomDetailViewModel.process(RoomDetailActions.EnterEditMode(eventId)) + } + MessageMenuViewModel.ACTION_QUOTE -> { + val eventId = actionData.data.toString() ?: return@let + roomDetailViewModel.process(RoomDetailActions.EnterQuoteMode(eventId)) + } else -> { Toast.makeText(context, "Action ${actionData.actionId} not implemented", Toast.LENGTH_LONG).show() } @@ -648,12 +734,16 @@ class RoomDetailFragment : // v.vibrate(100) // } // } - composerEditText.requestFocus() - val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager - imm?.showSoftInput(composerEditText, InputMethodManager.SHOW_FORCED) + focusComposerAndShowKeyboard() } } + private fun focusComposerAndShowKeyboard() { + composerEditText.requestFocus() + val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager + imm?.showSoftInput(composerEditText, InputMethodManager.SHOW_IMPLICIT) + } + fun showSnackWithMessage(message: String, duration: Int = Snackbar.LENGTH_SHORT) { val snack = Snackbar.make(view!!, message, Snackbar.LENGTH_SHORT) snack.view.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.notification_accent_color)) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewModel.kt index 44c2aa8f51..f5664efc87 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewModel.kt @@ -16,6 +16,7 @@ package im.vector.riotredesign.features.home.room.detail +import android.text.TextUtils import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import com.airbnb.mvrx.MvRxViewModelFactory @@ -25,8 +26,11 @@ import com.jakewharton.rxrelay2.BehaviorRelay import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.content.ContentAttachmentData +import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.Membership +import im.vector.matrix.android.api.session.room.model.message.MessageContent import im.vector.matrix.android.api.session.room.model.message.MessageType +import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.rx.rx import im.vector.riotredesign.R import im.vector.riotredesign.core.platform.VectorViewModel @@ -36,11 +40,14 @@ import im.vector.riotredesign.features.command.ParsedCommand import im.vector.riotredesign.features.home.room.VisibleRoomStore import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineDisplayableEvents import io.reactivex.rxkotlin.subscribeBy +import org.commonmark.parser.Parser +import org.commonmark.renderer.html.HtmlRenderer import org.koin.android.ext.android.get import java.text.SimpleDateFormat import java.util.* import java.util.concurrent.TimeUnit + class RoomDetailViewModel(initialState: RoomDetailViewState, private val session: Session, private val visibleRoomHolder: VisibleRoomStore @@ -87,9 +94,28 @@ class RoomDetailViewModel(initialState: RoomDetailViewState, is RoomDetailActions.UndoReaction -> handleUndoReact(action) is RoomDetailActions.UpdateQuickReactAction -> handleUpdateQuickReaction(action) is RoomDetailActions.ShowEditHistoryAction -> handleShowEditHistoryReaction(action) + is RoomDetailActions.EnterEditMode -> handleEditAction(action) + is RoomDetailActions.EnterQuoteMode -> handleQuoteAction(action) } } + fun enterEditMode(event: TimelineEvent) { + setState { + copy( + sendMode = SendMode.EDIT, + selectedEvent = event + ) + } + } + + fun resetSendMode() { + setState { + copy( + sendMode = SendMode.REGULAR, + selectedEvent = null + ) + } + } private val _nonBlockingPopAlert = MutableLiveData>>>() val nonBlockingPopAlert: LiveData>>> @@ -103,71 +129,135 @@ class RoomDetailViewModel(initialState: RoomDetailViewState, // PRIVATE METHODS ***************************************************************************** private fun handleSendMessage(action: RoomDetailActions.SendMessage) { - // Handle slash command - val slashCommandResult = CommandParser.parseSplashCommand(action.text) + withState { state -> + when (state.sendMode) { + SendMode.REGULAR -> { + val slashCommandResult = CommandParser.parseSplashCommand(action.text) - when (slashCommandResult) { - is ParsedCommand.ErrorNotACommand -> { - // Send the text message to the room - room.sendTextMessage(action.text) - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.MessageSent)) - } - is ParsedCommand.ErrorSyntax -> { - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandError(slashCommandResult.command))) - } - is ParsedCommand.ErrorEmptySlashCommand -> { - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandUnknown("/"))) - } - is ParsedCommand.ErrorUnknownSlashCommand -> { - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandUnknown(slashCommandResult.slashCommand))) - } - is ParsedCommand.Invite -> { - handleInviteSlashCommand(slashCommandResult) - } - is ParsedCommand.SetUserPowerLevel -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.ClearScalarToken -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.SetMarkdown -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.UnbanUser -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.BanUser -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.KickUser -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.JoinRoom -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.PartRoom -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) - } - is ParsedCommand.SendEmote -> { - room.sendTextMessage(slashCommandResult.message, msgType = MessageType.MSGTYPE_EMOTE) - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandHandled)) - } - is ParsedCommand.ChangeTopic -> { - handleChangeTopicSlashCommand(slashCommandResult) - } - is ParsedCommand.ChangeDisplayName -> { - // TODO - _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + when (slashCommandResult) { + is ParsedCommand.ErrorNotACommand -> { + // Send the text message to the room + room.sendTextMessage(action.text) + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.MessageSent)) + } + is ParsedCommand.ErrorSyntax -> { + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandError(slashCommandResult.command))) + } + is ParsedCommand.ErrorEmptySlashCommand -> { + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandUnknown("/"))) + } + is ParsedCommand.ErrorUnknownSlashCommand -> { + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandUnknown(slashCommandResult.slashCommand))) + } + is ParsedCommand.Invite -> { + handleInviteSlashCommand(slashCommandResult) + } + is ParsedCommand.SetUserPowerLevel -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.ClearScalarToken -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.SetMarkdown -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.UnbanUser -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.BanUser -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.KickUser -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.JoinRoom -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.PartRoom -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + is ParsedCommand.SendEmote -> { + room.sendTextMessage(slashCommandResult.message, msgType = MessageType.MSGTYPE_EMOTE) + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandHandled)) + } + is ParsedCommand.ChangeTopic -> { + handleChangeTopicSlashCommand(slashCommandResult) + } + is ParsedCommand.ChangeDisplayName -> { + // TODO + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented)) + } + } + } + SendMode.EDIT -> { + room.editTextMessage(state?.selectedEvent?.root?.eventId ?: "", action.text) + setState { + copy( + sendMode = SendMode.REGULAR, + selectedEvent = null + ) + } + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.MessageSent)) + } + SendMode.QUOTE -> { + withState { state -> + val messageContent: MessageContent? = + state.selectedEvent?.annotations?.editSummary?.aggregatedContent?.toModel() + ?: state.selectedEvent?.root?.content.toModel() + val textMsg = messageContent?.body + + val finalText = legacyRiotQuoteText(textMsg, action.text) + + //TODO Refactor this, just temporary for quotes + val parser = Parser.builder().build() + val document = parser.parse(finalText) + val renderer = HtmlRenderer.builder().build() + val htmlText = renderer.render(document) + if (TextUtils.equals(finalText, htmlText)) { + room.sendTextMessage(finalText) + } else { + room.sendFormattedTextMessage(finalText, htmlText) + } + setState { + copy( + sendMode = SendMode.REGULAR, + selectedEvent = null + ) + } + _sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.MessageSent)) + } + + } } } + // Handle slash command + + } + + private fun legacyRiotQuoteText(quotedText: String?, myText: String): String { + val messageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray() + var quotedTextMsg = StringBuilder() + if (messageParagraphs != null) { + for (i in messageParagraphs.indices) { + if (messageParagraphs[i].trim({ it <= ' ' }) != "") { + quotedTextMsg.append("> ").append(messageParagraphs[i]) + } + + if (i + 1 != messageParagraphs.size) { + quotedTextMsg.append("\n\n") + } + } + } + val finalText = "$quotedTextMsg\n\n$myText" + return finalText } private fun handleShowEditHistoryReaction(action: RoomDetailActions.ShowEditHistoryAction) { @@ -271,6 +361,23 @@ class RoomDetailViewModel(initialState: RoomDetailViewState, room.join(object : MatrixCallback {}) } + private fun handleEditAction(action: RoomDetailActions.EnterEditMode) { + room.getTimeLineEvent(action.eventId)?.let { + enterEditMode(it) + } + } + + private fun handleQuoteAction(action: RoomDetailActions.EnterQuoteMode) { + room.getTimeLineEvent(action.eventId)?.let { + setState { + copy( + sendMode = SendMode.QUOTE, + selectedEvent = it + ) + } + } + } + private fun observeEventDisplayedActions() { // We are buffering scroll events for one second diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewState.kt index 43fbe9bd2e..00ce0b4730 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailViewState.kt @@ -22,15 +22,32 @@ import com.airbnb.mvrx.Uninitialized import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.matrix.android.api.session.room.timeline.Timeline import im.vector.matrix.android.api.session.room.timeline.TimelineData +import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.session.user.model.User +/** + * Describes the current send mode: + * REGULAR: sends the text as a regular message + * QUOTE: User is currently quoting a message + * EDIT: User is currently editing an existing message + * + * Depending on the state the bottom toolbar will change (icons/preview/actions...) + */ +enum class SendMode { + REGULAR, + QUOTE, + EDIT +} + data class RoomDetailViewState( val roomId: String, val eventId: String?, val timeline: Timeline? = null, val inviter: Async = Uninitialized, val asyncRoomSummary: Async = Uninitialized, - val asyncTimelineData: Async = Uninitialized + val asyncTimelineData: Async = Uninitialized, + val sendMode: SendMode = SendMode.REGULAR, + val selectedEvent: TimelineEvent? = null ) : MvRxState { constructor(args: RoomDetailArgs) : this(roomId = args.roomId, eventId = args.eventId) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/action/MessageMenuViewModel.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/action/MessageMenuViewModel.kt index c39da48447..4fee2f41e6 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/action/MessageMenuViewModel.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/action/MessageMenuViewModel.kt @@ -59,7 +59,7 @@ class MessageMenuViewModel(initialState: MessageMenuState) : VectorViewModel().apply { - this.add(SimpleAction(ACTION_ADD_REACTION, R.string.message_add_reaction, R.drawable.ic_smile, event.root.eventId)) + this.add(SimpleAction(ACTION_ADD_REACTION, R.string.message_add_reaction, R.drawable.ic_add_reaction, event.root.eventId)) if (canCopy(type)) { //TODO copy images? html? see ClipBoard this.add(SimpleAction(ACTION_COPY, R.string.copy, R.drawable.ic_copy, messageContent.body)) } + if (canEdit(event, currentSession.sessionParams.credentials.userId)) { + this.add(SimpleAction(ACTION_EDIT, R.string.edit, R.drawable.ic_edit, event.root.eventId)) + } + if (canRedact(event, currentSession.sessionParams.credentials.userId)) { - this.add(SimpleAction(ACTION_DELETE, R.string.delete, R.drawable.ic_material_delete, event.root.eventId)) + this.add(SimpleAction(ACTION_DELETE, R.string.delete, R.drawable.ic_delete, event.root.eventId)) } if (canQuote(event, messageContent)) { @@ -159,6 +163,17 @@ class MessageMenuViewModel(initialState: MessageMenuState) : VectorViewModel() + return event.root.sender == myUserId && ( + messageContent?.type == MessageType.MSGTYPE_TEXT + || messageContent?.type == MessageType.MSGTYPE_EMOTE + ) + } + private fun canCopy(type: String): Boolean { return when (type) { @@ -187,6 +202,7 @@ class MessageMenuViewModel(initialState: MessageMenuState) : VectorViewModel5IQ?#}RC|!%)lu~tD_qrI-aTEW6e;_S7 zn$cviB=CU~-+TGUL@+NUgh(mkfI1ie5BT5%G(b8=yXu!qXh!~eKLlZ(C7t2M&Trg&7LMR-kiu?aUyB0n) z&I(x}D`bVNkQK5*R_NS?7JR;x<_etik`Q{~b01t$=9P0#NeGp}e9L8V21-c?g;LLa zMILvibj*Kj6`?f?tK3R6%<**yO<4R!A*aTiZyiEC7H=x#w3yS@Ayj4Y6{s8#f6Z4V z_*qLk=8+5h?2!rtri|_A><6URZ-!^4CGE_cYHKFWbvG^TRMhCi=@T8( oehbc27mTE>CY>q5uE@07*qoM6N<$f}e__;Q#;t diff --git a/vector/src/main/res/drawable-hdpi/ic_send_white.png b/vector/src/main/res/drawable-hdpi/ic_send_white.png deleted file mode 100644 index f133cdbeb2757f5d4f51321c302c7fcd81be52fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 335 zcmV-V0kHmwP)jA}WRMU8oC{kc85)g#pw;5z59ljG-BdP&R(yv#6YTg#Hfm zoUTIVIi*5oIemrHb7~5yx+gicg`VIQ-e3wV*yj+6B|>Sk20TL_MlgpBdJNAf zVcN%%X|KI7{+s0%pN@-Jiu}0d%3{6!aL!`2K@(@u-okok(b(jxX7M=&nPib16iu_- h^-;R~`%wzHas(7`hA~Sk`s4rr002ovPDHLkV1mtQjA#G= diff --git a/vector/src/main/res/drawable-mdpi/ic_attach_file_white.png b/vector/src/main/res/drawable-mdpi/ic_attach_file_white.png deleted file mode 100644 index a819f4034d49512d474d5dd27781f40d6837bd0a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 285 zcmV+&0pk9NP)5&yolhb5=1KtwTyP^0hF9Tv=VP27K)%~8d2A8;S&~#`Pr;p0*~y@ z4)caBb}S);^-t0yH9!DDa03faHzkn8FW>U}-||0v^{6Sb;l>R~h%1 zrzO~fNkYyH>~sZVKFg&a=QgLDuPbmk6E+bNS$xX|DtTsdi(Se>Q_$wMd}7VKLtjz@ jBi{9ce?PACtO9M`=wB&0PW1Bf00000NkvXXu0mjfmu++^ diff --git a/vector/src/main/res/drawable-mdpi/ic_send_white.png b/vector/src/main/res/drawable-mdpi/ic_send_white.png deleted file mode 100644 index 34e49af7ab119a8581624cba15d1874ddb3ee8d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 257 zcmV+c0sj7pP)IG(5t990^tH2frgqR&{1*(Y8sBf1tc7SR!1$0@ii-(STgUK*D%SiQ2mo{ z?QG3}$&cECGd@<$#Ov@pO7 z8ys=h=JS168I;gK4->4g$K_K#$v_!R^fAR62V7GI7O15qs-le{=GfvSNHjvh;vsjC z4gEKLW(fVFy<`Y=RlLpc&1L76L33S;GDto+sto`0O*ZiWxujSd^@pKl00000NkvXX Hu0mjfBSB_$ diff --git a/vector/src/main/res/drawable-xhdpi/ic_attach_file_white.png b/vector/src/main/res/drawable-xhdpi/ic_attach_file_white.png deleted file mode 100644 index c572c35997127449a4b660c4c9f1cd5c70ff7a1e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 507 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(Fdp)BaSW-r^>)^Iufq-k$1ZmV z=4-tQtP-@HdT;e3W|5DYQCpWcl?yt4(0hB(UEsfnyhCl%BKD2j7uh-L=GsW4Cw3hc znv`qi>o%wH{iJi}>h^EAIc2WJzW3Jkk$nt*R&iuCSt;;;<;rT{n!}jpAYNBdqkPB2 zoFVn!Mf3jOOB8dsUzGn73UQk3CA~mfclklq1uG<1w?C1~I=%7$6sN*7oD?OdD&O^L7z{|))m3ZrBRto7dme*i0P5aIwQPtGf)-Ni^)E5 zoq>-VdfqoayOd`*SAh8y>o(J4H*#&#ZAo!J6cZ?V89ZJ6T-G@yGywo`ncEKl diff --git a/vector/src/main/res/drawable-xhdpi/ic_send_white.png b/vector/src/main/res/drawable-xhdpi/ic_send_white.png deleted file mode 100644 index e5f9ba41acdb7d7f9353981e1aa0bcff06353b14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 423 zcmV;Y0a*TtP)prx+ z$_|d)F5m&)eB>qlT-LgJFVHE= z%W~f$arHimd07iA!6xj(DO|!MyjKu7gH_FhR$v3wd;=dyV1##h Rc_07)002ovPDHLkV1lk5y~_Xq diff --git a/vector/src/main/res/drawable-xxhdpi/ic_attach_file_white.png b/vector/src/main/res/drawable-xxhdpi/ic_attach_file_white.png deleted file mode 100644 index a5dc29f0d272d854bf2ad39ead95d01b1d791d47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 809 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@Zgyv2VEW+c;uunK>+PJo-lC2Y?X8RF zHvMAOIw7+9wbJ5xC9N0B_$R*5TQplwh4YfqZY>Qa)jj9!Jhb}6*hJ&R1H;2qYBj=2 zij6#0Zr;oM{$9`fH|H#?)9%jwyZ1vupVjAcXNuF(%Tm8@VR5{`bjE>+<*9#w`bB>q z!OusGjF0cP_Ri5=w1DrC-beio{?KP;7vn@6ZI8TP@GnB8@0Z>ReGj?x8qq7lhA-Y9 zkuW^6;=8@lDfy4S0qqYrL@88thAs4yE}Zj2?aFW0oR6LtWD_Ukcl3&tnhWN){@Pw6 zct!I~827XyC$rCqE8ge5wc~gtZuj>d+ow4KpT7K5$nc7o5G{S;vYO5v{~7_4^}JbY zI}b07 z%mT&htZQS|YBbelrOHVZ*$U-7*KS#G{LmST1ye0m&TQ#i#9^g2CD=$#XnMu7D=kLt z-AW#Jzy7jXp&uu-bP-2T4u9A^ojk6u6;9!|$`|ewO4;qKxlM4rPMTl1OP^!+T)p5X zv8{aZoto?Uq`$`8P&vP1{~xP^*?yYK{)MjHn{|z~_KH=_`9N#M$5GYtoAfe*UVlhG z-t=tCH?2tVlDG)>GOMiY?H8`?T*G}!yQJz!VDw_A=(~~PODfiv{_;QLcZI{cY3ljb zGbWpPr#Ja=&wo?gEqhXIYI;=0pkVOl1Jf%f=A`H2Ys|8 zpRBlX{f*(0j}9k%4=2QZh%DKgeQt~5{SDp!mMePr{!DLk)ZKU>RxJAGiVX_wAE!i2 z4tMP06`XYFhu59wr`x*!Sn17S@hZBu`&IR<^9!ac^KExazH#+TB(J05?@oWtqi1$S zOxUdCv2mJ(>z>uYXL#m6pK|$Cw%EQS8T|3qp+B_tocjN6#i#S4|Ej-dec_Kk%<3rc bWXgYOqoS1K?z8p+vjBsqtDnm{r-UW|NG4=C diff --git a/vector/src/main/res/drawable-xxhdpi/ic_send_white.png b/vector/src/main/res/drawable-xxhdpi/ic_send_white.png deleted file mode 100644 index 0ba718b6e25df33c10d4a2b91af75d08ccf25eff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 550 zcmV+>0@?kEP)2^SE1z*7@_A8XwdQqbbcxxfm#$i0yQJUBhX4kjY*Dg#$+aQ-5}@Qea_zJ ze0ye9>DKIZ|I={JHOO!%fr2QAf+&cBD2Re6=qGnz3rtW@IbHWX9dHC@D5zXee?Gtk zSf-$IL4(uIB|l$5ZXmzIl=G`9sF>eUPJ(*QZ<5MSLQqoqNeW6LzYu~<=NDR#x%__n zF~q3PFSa1{`DqeV%x{{4{?4xzJ3q~W2In4Z#>mf#plJD76BIl@tAc{%mx3VC{8AEB z%&#deXcEkWHLwd#!8LdSpSk4cYjzCGf)%h0j=?2(0Iw% zKaF?Lp||e^91P3P+7mv>?RziF&!V6?unKm-3Ah4};H?Hh=U~x7Vhdm$?13|I1D*vF z+Xqvc4$@LvFzP{i1B}Ny&4=8AN*PIAC~DY(TFz8eZZ$M+flo#vw;EPw4AVNVDL_ripK@?=1FD5h?{9Ic8+W-In07*qoM6N<$f?2ikg8%>k diff --git a/vector/src/main/res/drawable-xxxhdpi/ic_attach_file_white.png b/vector/src/main/res/drawable-xxxhdpi/ic_attach_file_white.png deleted file mode 100644 index 60147bc7a378eb0cb32cfe4cc9ae61b4bcd046de..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1059 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V1DK4;uunK>+RgT-Xeh#?Yae~ zckT3?4kc+`+x7aj(g*ny9~P}S>$7sV6YF~JUB!X<2+ua>mL+ndNLZnCCJu z3NR=vP&wTxmo%fot48(N%*=njf7j3MZ)I@KQF80BJYN0FGe$j1VL{C_LFXg#%l|A{ z*T?N*%km>x`Qs(S>1rJ&EEUPtACDT&w-b(5Jn;7n|Dw;`s!J3XnDENA&Aop_W1?b^ zi|*t{_wzm&<{b{SWzk7FvGnmKm(A@(*MySwQs=fevm_h5q6*jOVn^_FWSA zFkkTO&0Fz~JDFz{wJR!|=Q^vToxPwY(_)tDB!LO{<0j#?qi;39@sYWc?Ks_OFiATFP^6W87wg)m4n2ot|HjTC>=1g)%#1 zQPi5R4h$?H<^bV$@-+yYGcXqLH-5%!yk8N*;KdMyjM6- zzu!Z@9hK>}y)9+18_h4O~B_ z3w#jde*04NmXY`|PQk6-|9X?Z@$QOC3(n8w>)gh&CHvX?<4!rpIeo2fJ<>_w{ODBt zGM{fD?`@f%%ns)dz2cs&uX}gBjlay{x6&QUbxgp`2V%z*}akdsd3vx z%crnt_*p(&?l{}f-M8VLuPF>e5TLF$o2K^ad*bDe-$@2&poQP;DB8m{|v9J z*4^q}hHkMAjj=~^&+4txTe-G3I`Qq>BcTqBZ0}BNKEhm=ViEhrC*tqluK6h|+cm9q oZIe6JHr#0RYhd7D5c|pAuy^9+A9F0;05d;>r>mdKI;Vst01_g}=l}o! diff --git a/vector/src/main/res/drawable-xxxhdpi/ic_send_white.png b/vector/src/main/res/drawable-xxxhdpi/ic_send_white.png deleted file mode 100644 index f02b6453d5c3a05f683d2c49aaa8495033a14b8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 728 zcmV;}0w?{6P)4YaZvw*Q$*X|jJas(hsmet^laJvtPmu(;%u_@GuJROFfQvj;xhT@; z<>_foc`8l7`8?f1K;d~p!0&mQK|n!yLV$6es$6tMTo+5?vDg+b#K)GOmKBkwx_@9& zTorf3L$N6iQ~!;*??Lml*JPgBZd~Nm^G2-H&6DMK;3%u7R-SU+sPeXY26>u~BEa+N zshp>%54&?&J)gzezw%V#%TN}p=jd;FDpkNWu_zviE%97@5IR2x&m@Is-WXJGhPLR$&5Dvz2j;^ zod@ATK + + + + + + + diff --git a/vector/src/main/res/drawable/ic_attachment.xml b/vector/src/main/res/drawable/ic_attachment.xml new file mode 100644 index 0000000000..e54b93025b --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable/ic_close_round.xml b/vector/src/main/res/drawable/ic_close_round.xml new file mode 100644 index 0000000000..413a233b56 --- /dev/null +++ b/vector/src/main/res/drawable/ic_close_round.xml @@ -0,0 +1,20 @@ + + + + diff --git a/vector/src/main/res/drawable/ic_smile.xml b/vector/src/main/res/drawable/ic_delete.xml similarity index 51% rename from vector/src/main/res/drawable/ic_smile.xml rename to vector/src/main/res/drawable/ic_delete.xml index e2f3402e57..b740db3cff 100644 --- a/vector/src/main/res/drawable/ic_smile.xml +++ b/vector/src/main/res/drawable/ic_delete.xml @@ -4,31 +4,19 @@ android:viewportWidth="22" android:viewportHeight="22"> - - diff --git a/vector/src/main/res/drawable/ic_edit.xml b/vector/src/main/res/drawable/ic_edit.xml index ec5cf418ae..1ad914fc99 100644 --- a/vector/src/main/res/drawable/ic_edit.xml +++ b/vector/src/main/res/drawable/ic_edit.xml @@ -4,19 +4,19 @@ android:viewportWidth="21" android:viewportHeight="22"> diff --git a/vector/src/main/res/drawable/ic_send.xml b/vector/src/main/res/drawable/ic_send.xml new file mode 100644 index 0000000000..d79ba7c126 --- /dev/null +++ b/vector/src/main/res/drawable/ic_send.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/layout/adapter_item_action.xml b/vector/src/main/res/layout/adapter_item_action.xml index 5ee60d3259..ce518071a7 100644 --- a/vector/src/main/res/layout/adapter_item_action.xml +++ b/vector/src/main/res/layout/adapter_item_action.xml @@ -3,7 +3,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:layout_height="50dp" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground" @@ -12,7 +11,8 @@ android:paddingLeft="@dimen/layout_horizontal_margin" android:paddingTop="8dp" android:paddingRight="@dimen/layout_horizontal_margin" - android:paddingBottom="8dp"> + android:paddingBottom="8dp" + tools:layout_height="50dp"> + tools:src="@drawable/ic_delete" + android:tint="?android:attr/textColorTertiary" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml b/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml new file mode 100644 index 0000000000..9a354fc267 --- /dev/null +++ b/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/layout/fragment_room_detail.xml b/vector/src/main/res/layout/fragment_room_detail.xml index a5711bce7b..0f631722cc 100644 --- a/vector/src/main/res/layout/fragment_room_detail.xml +++ b/vector/src/main/res/layout/fragment_room_detail.xml @@ -2,6 +2,7 @@ @@ -89,66 +90,18 @@ android:background="?vctr_list_divider_color" app:layout_constraintBottom_toTopOf="@+id/composerLayout" /> - - - - - - - - - + + app:layout_constraintVertical_bias="1.0" + tools:visibility="gone" /> \ No newline at end of file diff --git a/vector/src/main/res/layout/include_composer_layout.xml b/vector/src/main/res/layout/include_composer_layout.xml new file mode 100644 index 0000000000..655691e9b9 --- /dev/null +++ b/vector/src/main/res/layout/include_composer_layout.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/attrs.xml b/vector/src/main/res/values/attrs.xml index 17cb3d7564..04c959ee21 100644 --- a/vector/src/main/res/values/attrs.xml +++ b/vector/src/main/res/values/attrs.xml @@ -4,6 +4,7 @@ + diff --git a/vector/src/main/res/values/colors_riot.xml b/vector/src/main/res/values/colors_riot.xml index f60d4991f3..395ebbcee9 100644 --- a/vector/src/main/res/values/colors_riot.xml +++ b/vector/src/main/res/values/colors_riot.xml @@ -19,6 +19,7 @@ @color/accent_color_light #5EA584 #a6d0e5 + #81bddb diff --git a/vector/src/main/res/values/theme_black.xml b/vector/src/main/res/values/theme_black.xml index f816b9befa..dabd32aeea 100644 --- a/vector/src/main/res/values/theme_black.xml +++ b/vector/src/main/res/values/theme_black.xml @@ -27,6 +27,7 @@ @color/riot_primary_background_color_black @color/primary_color_black + #FFE9EDF1 @drawable/direct_chat_circle_black diff --git a/vector/src/main/res/values/theme_dark.xml b/vector/src/main/res/values/theme_dark.xml index 5c1a506ede..ba78e510d3 100644 --- a/vector/src/main/res/values/theme_dark.xml +++ b/vector/src/main/res/values/theme_dark.xml @@ -21,6 +21,7 @@ @color/riot_primary_background_color_dark @color/primary_color_dark + #FFE9EDF1 #55555555 diff --git a/vector/src/main/res/values/theme_light.xml b/vector/src/main/res/values/theme_light.xml index 68076a4b04..e0b58bf0db 100644 --- a/vector/src/main/res/values/theme_light.xml +++ b/vector/src/main/res/values/theme_light.xml @@ -23,6 +23,7 @@ @color/riot_primary_background_color_light #FFF3F8FD + #FFE9EDF1 @style/Widget.Vector.Button diff --git a/vector/src/main/res/values/theme_status.xml b/vector/src/main/res/values/theme_status.xml index d2874e6935..9a50b88db2 100644 --- a/vector/src/main/res/values/theme_status.xml +++ b/vector/src/main/res/values/theme_status.xml @@ -23,6 +23,7 @@ @color/riot_primary_background_color_status @color/riot_primary_background_color_status + #FFE9EDF1 @style/Widget.Vector.Button