Fixed scroll when sending messages + added default RLS SIP URI
This commit is contained in:
parent
70ea703f13
commit
87e1ae3500
5 changed files with 10 additions and 19 deletions
|
@ -51,7 +51,7 @@ class ChatBubbleActivity : GenericActivity() {
|
|||
|
||||
private val observer = object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||
if (positionStart == adapter.itemCount - 1) {
|
||||
if (positionStart == adapter.itemCount - itemCount) {
|
||||
adapter.notifyItemChanged(positionStart - 1) // For grouping purposes
|
||||
scrollToBottom()
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
|
@ -72,6 +71,10 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
private val observer = object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||
adapter.notifyItemChanged(positionStart - 1) // For grouping purposes
|
||||
|
||||
if (positionStart == adapter.itemCount - itemCount) {
|
||||
scrollToBottom()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,15 +186,6 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
})
|
||||
|
||||
listViewModel.scrollToBottomOnMessageReceivedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
delay(100)
|
||||
scrollToBottom()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
listViewModel.requestWriteExternalStoragePermissionEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
requestPermissions(arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
|
||||
|
|
|
@ -54,10 +54,6 @@ class ChatMessagesListViewModel(private val chatRoom: ChatRoom) : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val scrollToBottomOnMessageReceivedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
private val chatRoomListener: ChatRoomListenerStub = object : ChatRoomListenerStub() {
|
||||
override fun onChatMessageReceived(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||
chatRoom.markAsRead()
|
||||
|
@ -211,8 +207,6 @@ class ChatMessagesListViewModel(private val chatRoom: ChatRoom) : ViewModel() {
|
|||
list.add(eventLog)
|
||||
}
|
||||
events.value = list
|
||||
|
||||
scrollToBottomOnMessageReceivedEvent.value = Event(true)
|
||||
}
|
||||
|
||||
private fun getEvents(): ArrayList<EventLog> {
|
||||
|
|
|
@ -238,8 +238,8 @@ class AsyncContactsLoader(private val context: Context) :
|
|||
for (list in core.friendsLists) {
|
||||
if (list.rlsAddress == null) {
|
||||
Log.w("[Contacts Loader] Friend list subscription enabled but RLS URI not set!")
|
||||
val defaultRlsUri = core.config.getString("sip", "rls_uri", null)
|
||||
if (defaultRlsUri != null) {
|
||||
val defaultRlsUri = corePreferences.defaultRlsUri
|
||||
if (defaultRlsUri.isNotEmpty()) {
|
||||
val rlsAddress = core.interpretUrl(defaultRlsUri)
|
||||
if (rlsAddress != null) {
|
||||
Log.i("[Contacts Loader] Using new RLS URI: ${rlsAddress.asStringUriOnly()}")
|
||||
|
|
|
@ -389,6 +389,9 @@ class CorePreferences constructor(private val context: Context) {
|
|||
val defaultDomain: String
|
||||
get() = config.getString("app", "default_domain", "sip.linphone.org")!!
|
||||
|
||||
val defaultRlsUri: String
|
||||
get() = config.getString("sip", "rls_uri", "sips:rls@sip.linphone.org")!!
|
||||
|
||||
val debugPopupCode: String
|
||||
get() = config.getString("app", "debug_popup_magic", "#1234#")!!
|
||||
|
||||
|
|
Loading…
Reference in a new issue