Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ freeline_project_description.json
**/fastlane/test_output
/fastlane/vendor/
/.bundle/
/.artifacts/
/fastlane/.bundle

# python
**/__pycache__/

/gradle/verification-keyring.gpg
/.claude/settings.local.json
/.claude/settings.local.json
10 changes: 3 additions & 7 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ class ChatActivity :
)
}

public override fun onDestroy() {
override fun onDestroy() {
super.onDestroy()
logConversationInfos("onDestroy")

Expand Down Expand Up @@ -4029,15 +4029,11 @@ class ChatActivity :
}

fun cancelReply() {
messageInputViewModel.reply(null)
chatViewModel.messageDraft.quotedMessageText = null
chatViewModel.messageDraft.quotedDisplayName = null
chatViewModel.messageDraft.quotedImageUrl = null
chatViewModel.messageDraft.quotedJsonId = null
messageInputViewModel.cancelReply()
}

fun cancelCreateThread() {
chatViewModel.clearThreadTitle()
messageInputViewModel.cancelCreateThread()
}

companion object {
Expand Down
268 changes: 184 additions & 84 deletions app/src/main/java/com/nextcloud/talk/chat/MessageInputFragment.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import com.nextcloud.talk.chat.data.io.AudioRecorderManager
import com.nextcloud.talk.chat.data.io.MediaPlayerManager
import com.nextcloud.talk.chat.data.model.ChatMessage
import com.nextcloud.talk.chat.data.network.ChatNetworkDataSource
import com.nextcloud.talk.models.MessageDraft
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
import com.nextcloud.talk.models.json.chat.ChatUtils
import com.nextcloud.talk.utils.message.SendMessageUtils
import io.reactivex.disposables.Disposable
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -38,6 +41,18 @@ class MessageInputViewModel :
ViewModel(),
DefaultLifecycleObserver {

data class MessageInputState(
val messageText: String = "",
val messageCursor: Int = 0,
val quotedJsonId: Int? = null,
val quotedDisplayName: String? = null,
val quotedMessageText: String? = null,
val quotedImageUrl: String? = null,
val threadTitle: String? = null,
val editMessage: ChatMessage? = null,
val isThreadCreationInProgress: Boolean = false
)

enum class LifeCycleFlag {
PAUSED,
RESUMED,
Expand Down Expand Up @@ -234,14 +249,95 @@ class MessageInputViewModel :
}
}

private val _inputState = MutableStateFlow(MessageInputState())
val inputState: StateFlow<MessageInputState> = _inputState

fun updateMessageText(text: String) {
_inputState.update { it.copy(messageText = text) }
}

fun updateMessageCursor(cursor: Int) {
_inputState.update { it.copy(messageCursor = cursor) }
}

fun updateThreadTitle(title: String) {
_inputState.update { it.copy(threadTitle = title) }
}

fun initFromDraft(draft: MessageDraft) {
_inputState.update {
it.copy(
messageText = draft.messageText,
messageCursor = draft.messageCursor,
quotedJsonId = draft.quotedJsonId,
quotedDisplayName = draft.quotedDisplayName,
quotedMessageText = draft.quotedMessageText,
quotedImageUrl = draft.quotedImageUrl,
threadTitle = draft.threadTitle,
isThreadCreationInProgress = false
)
}
}

fun toDraft(): MessageDraft =
MessageDraft(
messageText = _inputState.value.messageText,
messageCursor = _inputState.value.messageCursor,
quotedJsonId = _inputState.value.quotedJsonId,
quotedDisplayName = _inputState.value.quotedDisplayName,
quotedMessageText = _inputState.value.quotedMessageText,
quotedImageUrl = _inputState.value.quotedImageUrl,
threadTitle = _inputState.value.threadTitle
)

fun reply(message: ChatMessage?) {
_inputState.update {
it.copy(
quotedJsonId = message?.jsonMessageId,
quotedDisplayName = message?.actorDisplayName,
quotedMessageText = message?.getRichText(),
quotedImageUrl = "" // TODO
)
}
_getReplyChatMessage.postValue(message)
}

fun cancelReply() {
_inputState.update {
it.copy(
quotedJsonId = null,
quotedDisplayName = null,
quotedMessageText = null,
quotedImageUrl = null
)
}
_getReplyChatMessage.postValue(null)
}

fun edit(message: ChatMessage?) {
val text = message?.let {
ChatUtils.getParsedMessage(it.message, it.messageParameters)
} ?: ""
_inputState.update {
it.copy(
editMessage = message,
messageText = text,
messageCursor = text.length
)
}
_getEditChatMessage.value = message
}

fun cancelEdit() {
_inputState.update { it.copy(editMessage = null) }
_getEditChatMessage.value = null
}

fun cancelCreateThread() {
_inputState.update { it.copy(threadTitle = "") }
stopThreadCreation()
}

fun startMicInput(context: Context) {
audioFocusRequestManager.audioFocusRequest(true) {
audioRecorderManager.start(context)
Expand Down Expand Up @@ -284,10 +380,12 @@ class MessageInputViewModel :
}

fun startThreadCreation() {
_inputState.update { it.copy(isThreadCreationInProgress = true) }
_createThreadViewState.postValue(CreateThreadEditState())
}

fun stopThreadCreation() {
_inputState.update { it.copy(isThreadCreationInProgress = false) }
_createThreadViewState.postValue(CreateThreadStartState)
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/nextcloud/talk/ui/MessageInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MessageInput : FrameLayout {
lateinit var slideToCancelDescription: TextView
lateinit var microphoneEnabledInfo: ImageView
lateinit var microphoneEnabledInfoBackground: ImageView
lateinit var smileyButton: ImageButton
lateinit var deleteVoiceRecording: ImageView
lateinit var sendVoiceRecording: ImageView
lateinit var micInputCloud: MicInputCloud
Expand Down Expand Up @@ -70,6 +71,7 @@ class MessageInput : FrameLayout {
slideToCancelDescription = findViewById(R.id.slideToCancelDescription)
microphoneEnabledInfo = findViewById(R.id.microphoneEnabledInfo)
microphoneEnabledInfoBackground = findViewById(R.id.microphoneEnabledInfoBackground)
smileyButton = findViewById(R.id.smileyButton)
deleteVoiceRecording = findViewById(R.id.deleteVoiceRecording)
sendVoiceRecording = findViewById(R.id.sendVoiceRecording)
micInputCloud = findViewById(R.id.micInputCloud)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.ColorUtils
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.ViewCompat
import androidx.emoji2.emojipicker.EmojiPickerView
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.chip.Chip
Expand Down Expand Up @@ -492,6 +493,18 @@ class TalkSpecificViewThemeUtils @Inject constructor(
}
}

fun themeEmojiPicker(emojiPickerView: EmojiPickerView) {
withScheme(emojiPickerView.context) { scheme ->
emojiPickerView.setBackgroundColor(dynamicColor.surfaceContainerLow().getArgb(scheme))
themeEmojiPickerCategoryTabs(
emojiPickerView,
dynamicColor.primary().getArgb(scheme),
dynamicColor.onSurfaceVariant().getArgb(scheme)
)
protectEmojiPickerScrollGesture(emojiPickerView)
}
}

companion object {
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
R.drawable.ic_mimetype_package_x_generic,
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/create_thread_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:id="@+id/createThreadView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">

<LinearLayout
android:layout_width="0dp"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/fragment_message_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
android:animateLayoutChanges="true"
android:inputType="textLongMessage|textAutoComplete"
android:maxLength="1000" />

<androidx.emoji2.emojipicker.EmojiPickerView
android:id="@+id/emoji_picker"
android:layout_width="match_parent"
android:layout_height="250dp"
android:visibility="gone" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
17 changes: 15 additions & 2 deletions app/src/main/res/layout/view_message_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,25 @@
android:src="@drawable/ic_baseline_attach_file_24"
app:tint="?attr/colorControlNormal" />

<ImageButton
android:id="@+id/smileyButton"
android:layout_width="@dimen/min_size_clickable_area"
android:layout_height="@dimen/min_size_clickable_area"
android:layout_alignBottom="@id/messageInput"
android:layout_toEndOf="@id/attachmentButton"
android:background="@color/transparent"
android:contentDescription="@string/nc_add_emojis"
android:gravity="bottom"
android:src="@drawable/ic_insert_emoticon_black_24dp"
app:tint="?attr/colorControlNormal" />

<com.nextcloud.talk.utils.ImageEmojiEditText
android:id="@+id/messageInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginEnd="48dp"
android:layout_toEndOf="@id/attachmentButton"
android:layout_toEndOf="@id/smileyButton"
android:background="@null"
android:imeOptions="actionDone"
android:inputType="textAutoCorrect|textMultiLine|textCapSentences"
Expand Down Expand Up @@ -237,7 +249,8 @@
android:background="@color/transparent"
android:contentDescription="@string/start_thread"
android:src="@drawable/outline_forum_24"
app:tint="?attr/colorControlNormal" />
app:tint="?attr/colorControlNormal"
android:visibility="gone" />

<ImageButton
android:id="@+id/editMessageButton"
Expand Down
Loading