Skip to content

Commit

Permalink
Replaced EmojiPicker in ChatActivity
Browse files Browse the repository at this point in the history
Signed-off-by: Smarshal21 <[email protected]>
  • Loading branch information
Smarshal21 committed Nov 8, 2023
1 parent ed3117b commit d6ff39a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
40 changes: 13 additions & 27 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import androidx.core.content.PermissionChecker.PERMISSION_GRANTED
import androidx.core.graphics.drawable.toBitmap
import androidx.core.text.bold
import androidx.core.widget.doAfterTextChanged
import androidx.emoji2.emojipicker.EmojiPickerView
import androidx.emoji2.text.EmojiCompat
import androidx.emoji2.widget.EmojiTextView
import androidx.fragment.app.DialogFragment
Expand Down Expand Up @@ -237,7 +238,6 @@ import com.stfalcon.chatkit.messages.MessageHolders
import com.stfalcon.chatkit.messages.MessageHolders.ContentChecker
import com.stfalcon.chatkit.messages.MessagesListAdapter
import com.stfalcon.chatkit.utils.DateFormatter
import com.vanniktech.emoji.EmojiPopup
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
Expand Down Expand Up @@ -322,7 +322,6 @@ class ChatActivity :
lateinit var roomId: String
var voiceOnly: Boolean = true
var isFirstMessagesProcessing = true
private var emojiPopup: EmojiPopup? = null
private lateinit var path: String

var myFirstMessage: CharSequence? = null
Expand Down Expand Up @@ -351,6 +350,7 @@ class ChatActivity :
private var voicePreviewObjectAnimator: ObjectAnimator? = null
var mediaPlayer: MediaPlayer? = null
lateinit var mediaPlayerHandler: Handler
private var isEmojiPickerVisible = false
private var currentlyPlayedVoiceMessage: ChatMessage? = null
private lateinit var micInputAudioRecorder: AudioRecord
private var micInputAudioRecordThread: Thread? = null
Expand Down Expand Up @@ -452,7 +452,6 @@ class ChatActivity :
binding.progressBar.visibility = View.VISIBLE

onBackPressedDispatcher.addCallback(this, onBackPressedCallback)

initObservers()
}

Expand Down Expand Up @@ -644,7 +643,6 @@ class ChatActivity :
logConversationInfos("onResume")

pullChatMessagesPending = false

setupWebsocket()
webSocketInstance?.getSignalingMessageReceiver()?.addListener(localParticipantMessageListener)
webSocketInstance?.getSignalingMessageReceiver()?.addListener(conversationMessageListener)
Expand Down Expand Up @@ -1429,30 +1427,18 @@ class ChatActivity :
private fun initSmileyKeyboardToggler() {
val smileyButton = binding.messageInputView.findViewById<ImageButton>(R.id.smileyButton)

emojiPopup = binding.messageInputView.inputEditText?.let {
EmojiPopup(
rootView = binding.root,
editText = it,
onEmojiPopupShownListener = {
if (resources != null) {
smileyButton?.setImageDrawable(
ContextCompat.getDrawable(context, R.drawable.ic_baseline_keyboard_24)
)
}
},
onEmojiPopupDismissListener = {
smileyButton?.setImageDrawable(
ContextCompat.getDrawable(context, R.drawable.ic_insert_emoticon_black_24dp)
)
},
onEmojiClickListener = {
binding.messageInputView.inputEditText?.editableText?.append(" ")
}
)
}

smileyButton?.setOnClickListener {
emojiPopup?.toggle()

if (!isEmojiPickerVisible) {
binding.messageInputView.findViewById<FrameLayout>(R.id.emoji_picker).visibility = View.VISIBLE
isEmojiPickerVisible = true
} else {
binding.messageInputView.findViewById<EmojiPickerView>(R.id.emoji_picker).visibility = View.GONE
isEmojiPickerVisible = false
}
binding.messageInputView.findViewById<EmojiPickerView>(R.id.emoji_picker).setOnEmojiPickedListener() {
binding.messageInputView.inputEditText.editableText?.append(it.emoji)
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/layout/view_message_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,16 @@
android:lineSpacingMultiplier="1.2"
android:minHeight="48dp"
android:textAlignment="viewStart"
android:layoutDirection="locale"
tools:hint="@string/nc_hint_enter_a_message" />

<androidx.emoji2.emojipicker.EmojiPickerView
android:id="@+id/emoji_picker"
android:layout_width="match_parent"
android:layout_below="@id/messageInput"
android:visibility="gone"
android:layout_height="350dp"
app:emojiGridColumns="9" />

<TextView
android:id="@+id/slideToCancelDescription"
android:layout_width="wrap_content"
Expand Down

0 comments on commit d6ff39a

Please sign in to comment.