Fixed UI issues when sharing file(s) from third party using shortcut API

This commit is contained in:
Sylvain Berfini 2021-10-27 17:31:50 +02:00
parent 23211f49ea
commit 9874b04d9c
8 changed files with 17 additions and 17 deletions

View file

@ -454,6 +454,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
findNavController(R.id.nav_host_fragment).navigate(Uri.parse(deepLink))
} else {
Log.e("[Main Activity] Failed to parse shortcut/locus id: $id")
findNavController(R.id.nav_host_fragment).navigate(R.id.action_global_masterChatRoomsFragment)
}
}

View file

@ -318,6 +318,8 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
if (sharedViewModel.isSlidingPaneSlideable.value == true) {
Log.i("[Chat Room] Forwarding message, going to chat rooms list")
sharedViewModel.closeSlidingPaneEvent.value = Event(true)
} else {
navigateToEmptyChatRoom()
}
}
}

View file

@ -148,11 +148,7 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
binding.slidingPane.addPanelSlideListener(object : SlidingPaneLayout.PanelSlideListener {
override fun onPanelSlide(panel: View, slideOffset: Float) { }
override fun onPanelOpened(panel: View) {
/* if (binding.slidingPane.isSlideable) {
(requireActivity() as MainActivity).hideTabsFragment()
} */
}
override fun onPanelOpened(panel: View) { }
override fun onPanelClosed(panel: View) {
if (binding.slidingPane.isSlideable) {
@ -326,6 +322,7 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
// val activity = requireActivity() as MainActivity
// activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
listViewModel.textSharingPending.value = true
clearDisplayedChatRoom()
} else {
if (sharedViewModel.filesToShare.value.isNullOrEmpty()) {
listViewModel.textSharingPending.value = false
@ -341,6 +338,7 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
// val activity = requireActivity() as MainActivity
// activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
listViewModel.fileSharingPending.value = true
clearDisplayedChatRoom()
} else {
if (sharedViewModel.textToShare.value.isNullOrEmpty()) {
listViewModel.fileSharingPending.value = false

View file

@ -86,9 +86,7 @@ class Api29Compatibility {
fun setLocusIdInContentCaptureSession(root: View, chatRoom: ChatRoom) {
val session: ContentCaptureSession? = root.contentCaptureSession
if (session != null) {
val localAddress = chatRoom.localAddress.asStringUriOnly()
val peerAddress = chatRoom.peerAddress.asStringUriOnly()
val id = LinphoneUtils.getChatRoomId(localAddress, peerAddress)
val id = LinphoneUtils.getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
session.contentCaptureContext = ContentCaptureContext.forLocusId(id)
}
}

View file

@ -46,11 +46,8 @@ class Api30Compatibility {
}
fun removeChatRoomShortcut(context: Context, chatRoom: ChatRoom) {
val peerAddress = chatRoom.peerAddress.asStringUriOnly()
val localAddress = chatRoom.localAddress.asStringUriOnly()
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
val id = LinphoneUtils.getChatRoomId(localAddress, peerAddress)
val id = LinphoneUtils.getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
val shortcutsToRemoveList = arrayListOf(id)
shortcutManager.removeLongLivedShortcuts(shortcutsToRemoveList)
}

View file

@ -636,7 +636,7 @@ class NotificationsManager(private val context: Context) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
val id = LinphoneUtils.getChatRoomId(localAddress, peerAddress)
val id = LinphoneUtils.getChatRoomId(room.localAddress, room.peerAddress)
val notification = createMessageNotification(notifiable, pendingIntent, bubbleIntent, id)
notify(notifiable.notificationId, notification)
}

View file

@ -162,8 +162,12 @@ class LinphoneUtils {
)
}
fun getChatRoomId(localAddress: String, remoteAddress: String): String {
return "$localAddress~$remoteAddress"
fun getChatRoomId(localAddress: Address, remoteAddress: Address): String {
val localSipUri = localAddress.clone()
localSipUri.clean()
val remoteSipUri = remoteAddress.clone()
remoteSipUri.clean()
return "${localSipUri.asStringUriOnly()}~${remoteSipUri.asStringUriOnly()}"
}
}
}

View file

@ -151,9 +151,9 @@ class ShortcutsHelper(val context: Context) {
}
private fun createChatRoomShortcut(context: Context, chatRoom: ChatRoom): ShortcutInfo? {
val peerAddress = chatRoom.peerAddress.asStringUriOnly()
val localAddress = chatRoom.localAddress.asStringUriOnly()
val id = LinphoneUtils.getChatRoomId(localAddress, peerAddress)
val peerAddress = chatRoom.peerAddress.asStringUriOnly()
val id = LinphoneUtils.getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
try {
val categories: ArraySet<String> = ArraySet()