Close keyboard when opening emoji picker + improved EmojiCompat init
This commit is contained in:
parent
22d4a8baf1
commit
e395cff106
3 changed files with 18 additions and 3 deletions
|
@ -330,6 +330,14 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chatSendingViewModel.requestKeyboardHidingEvent.observe(
|
||||||
|
viewLifecycleOwner
|
||||||
|
) {
|
||||||
|
it.consume {
|
||||||
|
(requireActivity() as MainActivity).hideKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
listViewModel.events.observe(
|
listViewModel.events.observe(
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) { events ->
|
) { events ->
|
||||||
|
|
|
@ -107,6 +107,10 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
|
||||||
|
|
||||||
val isEmojiPickerVisible = MutableLiveData<Boolean>()
|
val isEmojiPickerVisible = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val requestKeyboardHidingEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||||
|
MutableLiveData<Event<Boolean>>()
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var recorder: Recorder
|
private lateinit var recorder: Recorder
|
||||||
|
|
||||||
private var voiceRecordAudioFocusRequest: AudioFocusRequestCompat? = null
|
private var voiceRecordAudioFocusRequest: AudioFocusRequestCompat? = null
|
||||||
|
@ -216,6 +220,9 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
|
||||||
|
|
||||||
fun toggleEmojiPicker() {
|
fun toggleEmojiPicker() {
|
||||||
isEmojiPickerOpen.value = isEmojiPickerOpen.value == false
|
isEmojiPickerOpen.value = isEmojiPickerOpen.value == false
|
||||||
|
if (isEmojiPickerOpen.value == true) {
|
||||||
|
requestKeyboardHidingEvent.value = Event(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendMessage() {
|
fun sendMessage() {
|
||||||
|
|
|
@ -45,15 +45,15 @@ import org.linphone.core.tools.Log
|
||||||
*/
|
*/
|
||||||
class AppUtils {
|
class AppUtils {
|
||||||
companion object {
|
companion object {
|
||||||
var emojiCompat: EmojiCompat? = null
|
private val emojiCompat: EmojiCompat?
|
||||||
get() = initEmojiCompat()
|
get() = initEmojiCompat()
|
||||||
|
|
||||||
private fun initEmojiCompat(): EmojiCompat? {
|
private fun initEmojiCompat(): EmojiCompat? {
|
||||||
return try {
|
return try {
|
||||||
EmojiCompat.get()
|
EmojiCompat.get()
|
||||||
} catch (ise: IllegalStateException) {
|
} catch (ise: IllegalStateException) {
|
||||||
Log.e("[App Utils] Can't get EmojiCompat: $ise")
|
Log.w("[App Utils] EmojiCompat.get() triggered IllegalStateException [$ise], trying manual init")
|
||||||
null
|
EmojiCompat.init(coreContext.context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue