Merge pull request #7054 from vector-im/feature/bma/fix_invite_to_room_in_space
Fix invite to room in space
This commit is contained in:
commit
c408621bd5
|
@ -0,0 +1 @@
|
||||||
|
Fix invite to room when in a space buttons not working.
|
|
@ -377,7 +377,7 @@ class HomeActivity :
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val isHandled = permalinkHandler.launch(
|
val isHandled = permalinkHandler.launch(
|
||||||
context = this@HomeActivity,
|
fragmentActivity = this@HomeActivity,
|
||||||
deepLink = resolvedLink,
|
deepLink = resolvedLink,
|
||||||
navigationInterceptor = this@HomeActivity,
|
navigationInterceptor = this@HomeActivity,
|
||||||
buildTask = true
|
buildTask = true
|
||||||
|
|
|
@ -232,9 +232,10 @@ class HomeDetailFragment :
|
||||||
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
|
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
|
||||||
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
|
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
|
||||||
contentAction = Runnable {
|
contentAction = Runnable {
|
||||||
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)
|
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let { vectorBaseActivity ->
|
||||||
?.navigator
|
vectorBaseActivity.navigator
|
||||||
?.requestSessionVerification(requireContext(), newest.deviceId ?: "")
|
.requestSessionVerification(vectorBaseActivity, newest.deviceId ?: "")
|
||||||
|
}
|
||||||
unknownDeviceDetectorSharedViewModel.handle(
|
unknownDeviceDetectorSharedViewModel.handle(
|
||||||
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty())
|
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty())
|
||||||
)
|
)
|
||||||
|
|
|
@ -250,9 +250,10 @@ class NewHomeDetailFragment :
|
||||||
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
|
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
|
||||||
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
|
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
|
||||||
contentAction = Runnable {
|
contentAction = Runnable {
|
||||||
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)
|
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let { vectorBaseActivity ->
|
||||||
?.navigator
|
vectorBaseActivity.navigator
|
||||||
?.requestSessionVerification(requireContext(), newest.deviceId ?: "")
|
.requestSessionVerification(vectorBaseActivity, newest.deviceId ?: "")
|
||||||
|
}
|
||||||
unknownDeviceDetectorSharedViewModel.handle(
|
unknownDeviceDetectorSharedViewModel.handle(
|
||||||
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty())
|
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty())
|
||||||
)
|
)
|
||||||
|
|
|
@ -497,7 +497,7 @@ class TimelineFragment :
|
||||||
RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView()
|
RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView()
|
||||||
is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it)
|
is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it)
|
||||||
is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it)
|
is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it)
|
||||||
RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), timelineArgs.roomId)
|
RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireActivity(), timelineArgs.roomId)
|
||||||
RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show()
|
RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show()
|
||||||
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings(RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS)
|
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings(RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS)
|
||||||
RoomDetailViewEvents.OpenRoomProfile -> handleOpenRoomSettings()
|
RoomDetailViewEvents.OpenRoomProfile -> handleOpenRoomSettings()
|
||||||
|
@ -2190,7 +2190,7 @@ class TimelineFragment :
|
||||||
override fun onRoomCreateLinkClicked(url: String) {
|
override fun onRoomCreateLinkClicked(url: String) {
|
||||||
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
|
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
|
||||||
permalinkHandler
|
permalinkHandler
|
||||||
.launch(requireContext(), url, object : NavigationInterceptor {
|
.launch(requireActivity(), url, object : NavigationInterceptor {
|
||||||
override fun navToRoom(roomId: String?, eventId: String?, deepLink: Uri?, rootThreadEventId: String?): Boolean {
|
override fun navToRoom(roomId: String?, eventId: String?, deepLink: Uri?, rootThreadEventId: String?): Boolean {
|
||||||
requireActivity().finish()
|
requireActivity().finish()
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -188,7 +188,7 @@ class RoomListFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleShowMxToLink(link: String) {
|
private fun handleShowMxToLink(link: String) {
|
||||||
navigator.openMatrixToBottomSheet(requireContext(), link, OriginOfMatrixTo.ROOM_LIST)
|
navigator.openMatrixToBottomSheet(requireActivity(), link, OriginOfMatrixTo.ROOM_LIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|
|
@ -25,11 +25,11 @@ import android.view.View
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.core.app.ActivityOptionsCompat
|
import androidx.core.app.ActivityOptionsCompat
|
||||||
import androidx.core.app.TaskStackBuilder
|
import androidx.core.app.TaskStackBuilder
|
||||||
import androidx.core.util.Pair
|
import androidx.core.util.Pair
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.SpaceStateHandler
|
import im.vector.app.SpaceStateHandler
|
||||||
|
@ -224,75 +224,65 @@ class DefaultNavigator @Inject constructor(
|
||||||
startActivity(context, SpacePreviewActivity.newIntent(context, spaceId), false)
|
startActivity(context, SpacePreviewActivity.newIntent(context, spaceId), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun performDeviceVerification(context: Context, otherUserId: String, sasTransactionId: String) {
|
override fun performDeviceVerification(fragmentActivity: FragmentActivity, otherUserId: String, sasTransactionId: String) {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
val tx = session.cryptoService().verificationService().getExistingTransaction(otherUserId, sasTransactionId)
|
val tx = session.cryptoService().verificationService().getExistingTransaction(otherUserId, sasTransactionId)
|
||||||
?: return
|
?: return
|
||||||
(tx as? IncomingSasVerificationTransaction)?.performAccept()
|
(tx as? IncomingSasVerificationTransaction)?.performAccept()
|
||||||
if (context is AppCompatActivity) {
|
VerificationBottomSheet.withArgs(
|
||||||
VerificationBottomSheet.withArgs(
|
roomId = null,
|
||||||
roomId = null,
|
otherUserId = otherUserId,
|
||||||
otherUserId = otherUserId,
|
transactionId = sasTransactionId
|
||||||
transactionId = sasTransactionId
|
).show(fragmentActivity.supportFragmentManager, "REQPOP")
|
||||||
).show(context.supportFragmentManager, "REQPOP")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun requestSessionVerification(context: Context, otherSessionId: String) {
|
override fun requestSessionVerification(fragmentActivity: FragmentActivity, otherSessionId: String) {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
val pr = session.cryptoService().verificationService().requestKeyVerification(
|
val pr = session.cryptoService().verificationService().requestKeyVerification(
|
||||||
supportedVerificationMethodsProvider.provide(),
|
supportedVerificationMethodsProvider.provide(),
|
||||||
session.myUserId,
|
session.myUserId,
|
||||||
listOf(otherSessionId)
|
listOf(otherSessionId)
|
||||||
)
|
)
|
||||||
if (context is AppCompatActivity) {
|
VerificationBottomSheet.withArgs(
|
||||||
VerificationBottomSheet.withArgs(
|
roomId = null,
|
||||||
roomId = null,
|
otherUserId = session.myUserId,
|
||||||
otherUserId = session.myUserId,
|
transactionId = pr.transactionId
|
||||||
transactionId = pr.transactionId
|
).show(fragmentActivity.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
||||||
).show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun requestSelfSessionVerification(context: Context) {
|
override fun requestSelfSessionVerification(fragmentActivity: FragmentActivity) {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
val otherSessions = session.cryptoService()
|
val otherSessions = session.cryptoService()
|
||||||
.getCryptoDeviceInfo(session.myUserId)
|
.getCryptoDeviceInfo(session.myUserId)
|
||||||
.filter { it.deviceId != session.sessionParams.deviceId }
|
.filter { it.deviceId != session.sessionParams.deviceId }
|
||||||
.map { it.deviceId }
|
.map { it.deviceId }
|
||||||
if (context is AppCompatActivity) {
|
if (otherSessions.isNotEmpty()) {
|
||||||
if (otherSessions.isNotEmpty()) {
|
val pr = session.cryptoService().verificationService().requestKeyVerification(
|
||||||
val pr = session.cryptoService().verificationService().requestKeyVerification(
|
supportedVerificationMethodsProvider.provide(),
|
||||||
supportedVerificationMethodsProvider.provide(),
|
session.myUserId,
|
||||||
session.myUserId,
|
otherSessions
|
||||||
otherSessions
|
|
||||||
)
|
|
||||||
VerificationBottomSheet.forSelfVerification(session, pr.transactionId ?: pr.localId)
|
|
||||||
.show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
|
||||||
} else {
|
|
||||||
VerificationBottomSheet.forSelfVerification(session)
|
|
||||||
.show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun waitSessionVerification(context: Context) {
|
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
|
||||||
if (context is AppCompatActivity) {
|
|
||||||
VerificationBottomSheet.forSelfVerification(session)
|
|
||||||
.show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun upgradeSessionSecurity(context: Context, initCrossSigningOnly: Boolean) {
|
|
||||||
if (context is AppCompatActivity) {
|
|
||||||
BootstrapBottomSheet.show(
|
|
||||||
context.supportFragmentManager,
|
|
||||||
if (initCrossSigningOnly) SetupMode.CROSS_SIGNING_ONLY else SetupMode.NORMAL
|
|
||||||
)
|
)
|
||||||
|
VerificationBottomSheet.forSelfVerification(session, pr.transactionId ?: pr.localId)
|
||||||
|
.show(fragmentActivity.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
||||||
|
} else {
|
||||||
|
VerificationBottomSheet.forSelfVerification(session)
|
||||||
|
.show(fragmentActivity.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun waitSessionVerification(fragmentActivity: FragmentActivity) {
|
||||||
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
|
VerificationBottomSheet.forSelfVerification(session)
|
||||||
|
.show(fragmentActivity.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun upgradeSessionSecurity(fragmentActivity: FragmentActivity, initCrossSigningOnly: Boolean) {
|
||||||
|
BootstrapBottomSheet.show(
|
||||||
|
fragmentActivity.supportFragmentManager,
|
||||||
|
if (initCrossSigningOnly) SetupMode.CROSS_SIGNING_ONLY else SetupMode.NORMAL
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean) {
|
override fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean) {
|
||||||
val args = RoomMemberProfileArgs(userId = userId, roomId = roomId)
|
val args = RoomMemberProfileArgs(userId = userId, roomId = roomId)
|
||||||
val intent = RoomMemberProfileActivity.newIntent(context, args)
|
val intent = RoomMemberProfileActivity.newIntent(context, args)
|
||||||
|
@ -316,16 +306,14 @@ class DefaultNavigator @Inject constructor(
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openMatrixToBottomSheet(context: Context, link: String, origin: OriginOfMatrixTo) {
|
override fun openMatrixToBottomSheet(fragmentActivity: FragmentActivity, link: String, origin: OriginOfMatrixTo) {
|
||||||
if (context is AppCompatActivity) {
|
if (fragmentActivity !is MatrixToBottomSheet.InteractionListener) {
|
||||||
if (context !is MatrixToBottomSheet.InteractionListener) {
|
fatalError("Caller context should implement MatrixToBottomSheet.InteractionListener", vectorPreferences.failFast())
|
||||||
fatalError("Caller context should implement MatrixToBottomSheet.InteractionListener", vectorPreferences.failFast())
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
// TODO check if there is already one??
|
|
||||||
MatrixToBottomSheet.withLink(link, origin)
|
|
||||||
.show(context.supportFragmentManager, "HA#MatrixToBottomSheet")
|
|
||||||
}
|
}
|
||||||
|
// TODO check if there is already one??
|
||||||
|
MatrixToBottomSheet.withLink(link, origin)
|
||||||
|
.show(fragmentActivity.supportFragmentManager, "HA#MatrixToBottomSheet")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openRoomDirectory(context: Context, initialFilter: String) {
|
override fun openRoomDirectory(context: Context, initialFilter: String) {
|
||||||
|
@ -347,18 +335,16 @@ class DefaultNavigator @Inject constructor(
|
||||||
}.start(context)
|
}.start(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openInviteUsersToRoom(context: Context, roomId: String) {
|
override fun openInviteUsersToRoom(fragmentActivity: FragmentActivity, roomId: String) {
|
||||||
when (val currentSpace = spaceStateHandler.getCurrentSpace()) {
|
when (val currentSpace = spaceStateHandler.getCurrentSpace()) {
|
||||||
null -> InviteUsersToRoomActivity.getIntent(context, roomId).start(context)
|
null -> InviteUsersToRoomActivity.getIntent(fragmentActivity, roomId).start(fragmentActivity)
|
||||||
else -> showInviteToDialog(context, currentSpace, roomId)
|
else -> showInviteToDialog(fragmentActivity, currentSpace, roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showInviteToDialog(context: Context, currentSpace: RoomSummary, roomId: String) {
|
private fun showInviteToDialog(fragmentActivity: FragmentActivity, currentSpace: RoomSummary, roomId: String) {
|
||||||
(context as? AppCompatActivity)?.supportFragmentManager?.let { fragmentManager ->
|
InviteRoomSpaceChooserBottomSheet.showInstance(fragmentActivity.supportFragmentManager, currentSpace.roomId, roomId) { itemId ->
|
||||||
InviteRoomSpaceChooserBottomSheet.showInstance(fragmentManager, currentSpace.roomId, roomId) { itemId ->
|
InviteUsersToRoomActivity.getIntent(fragmentActivity, itemId).start(fragmentActivity)
|
||||||
InviteUsersToRoomActivity.getIntent(context, itemId).start(context)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,24 +367,20 @@ class DefaultNavigator @Inject constructor(
|
||||||
debugNavigator.openDebugMenu(context)
|
debugNavigator.openDebugMenu(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openKeysBackupSetup(context: Context, showManualExport: Boolean) {
|
override fun openKeysBackupSetup(fragmentActivity: FragmentActivity, showManualExport: Boolean) {
|
||||||
// if cross signing is enabled and trusted or not set up at all we should propose full 4S
|
// if cross signing is enabled and trusted or not set up at all we should propose full 4S
|
||||||
sessionHolder.getSafeActiveSession()?.let { session ->
|
sessionHolder.getSafeActiveSession()?.let { session ->
|
||||||
if (session.cryptoService().crossSigningService().getMyCrossSigningKeys() == null ||
|
if (session.cryptoService().crossSigningService().getMyCrossSigningKeys() == null ||
|
||||||
session.cryptoService().crossSigningService().canCrossSign()) {
|
session.cryptoService().crossSigningService().canCrossSign()) {
|
||||||
(context as? AppCompatActivity)?.let {
|
BootstrapBottomSheet.show(fragmentActivity.supportFragmentManager, SetupMode.NORMAL)
|
||||||
BootstrapBottomSheet.show(it.supportFragmentManager, SetupMode.NORMAL)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
context.startActivity(KeysBackupSetupActivity.intent(context, showManualExport))
|
fragmentActivity.startActivity(KeysBackupSetupActivity.intent(fragmentActivity, showManualExport))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun open4SSetup(context: Context, setupMode: SetupMode) {
|
override fun open4SSetup(fragmentActivity: FragmentActivity, setupMode: SetupMode) {
|
||||||
if (context is AppCompatActivity) {
|
BootstrapBottomSheet.show(fragmentActivity.supportFragmentManager, setupMode)
|
||||||
BootstrapBottomSheet.show(context.supportFragmentManager, setupMode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openKeysBackupManager(context: Context) {
|
override fun openKeysBackupManager(context: Context) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.net.Uri
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.core.util.Pair
|
import androidx.core.util.Pair
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import im.vector.app.features.analytics.plan.ViewRoom
|
import im.vector.app.features.analytics.plan.ViewRoom
|
||||||
import im.vector.app.features.crypto.recover.SetupMode
|
import im.vector.app.features.crypto.recover.SetupMode
|
||||||
import im.vector.app.features.displayname.getBestName
|
import im.vector.app.features.displayname.getBestName
|
||||||
|
@ -76,15 +77,15 @@ interface Navigator {
|
||||||
|
|
||||||
fun openSpacePreview(context: Context, spaceId: String)
|
fun openSpacePreview(context: Context, spaceId: String)
|
||||||
|
|
||||||
fun performDeviceVerification(context: Context, otherUserId: String, sasTransactionId: String)
|
fun performDeviceVerification(fragmentActivity: FragmentActivity, otherUserId: String, sasTransactionId: String)
|
||||||
|
|
||||||
fun requestSessionVerification(context: Context, otherSessionId: String)
|
fun requestSessionVerification(fragmentActivity: FragmentActivity, otherSessionId: String)
|
||||||
|
|
||||||
fun requestSelfSessionVerification(context: Context)
|
fun requestSelfSessionVerification(fragmentActivity: FragmentActivity)
|
||||||
|
|
||||||
fun waitSessionVerification(context: Context)
|
fun waitSessionVerification(fragmentActivity: FragmentActivity)
|
||||||
|
|
||||||
fun upgradeSessionSecurity(context: Context, initCrossSigningOnly: Boolean)
|
fun upgradeSessionSecurity(fragmentActivity: FragmentActivity, initCrossSigningOnly: Boolean)
|
||||||
|
|
||||||
fun openRoomForSharingAndFinish(activity: Activity, roomId: String, sharedData: SharedData)
|
fun openRoomForSharingAndFinish(activity: Activity, roomId: String, sharedData: SharedData)
|
||||||
|
|
||||||
|
@ -92,13 +93,13 @@ interface Navigator {
|
||||||
|
|
||||||
fun openRoomPreview(context: Context, roomPreviewData: RoomPreviewData, fromEmailInviteLink: PermalinkData.RoomEmailInviteLink? = null)
|
fun openRoomPreview(context: Context, roomPreviewData: RoomPreviewData, fromEmailInviteLink: PermalinkData.RoomEmailInviteLink? = null)
|
||||||
|
|
||||||
fun openMatrixToBottomSheet(context: Context, link: String, origin: OriginOfMatrixTo)
|
fun openMatrixToBottomSheet(fragmentActivity: FragmentActivity, link: String, origin: OriginOfMatrixTo)
|
||||||
|
|
||||||
fun openCreateRoom(context: Context, initialName: String = "", openAfterCreate: Boolean = true)
|
fun openCreateRoom(context: Context, initialName: String = "", openAfterCreate: Boolean = true)
|
||||||
|
|
||||||
fun openCreateDirectRoom(context: Context)
|
fun openCreateDirectRoom(context: Context)
|
||||||
|
|
||||||
fun openInviteUsersToRoom(context: Context, roomId: String)
|
fun openInviteUsersToRoom(fragmentActivity: FragmentActivity, roomId: String)
|
||||||
|
|
||||||
fun openRoomDirectory(context: Context, initialFilter: String = "")
|
fun openRoomDirectory(context: Context, initialFilter: String = "")
|
||||||
|
|
||||||
|
@ -110,9 +111,9 @@ interface Navigator {
|
||||||
|
|
||||||
fun openDebug(context: Context)
|
fun openDebug(context: Context)
|
||||||
|
|
||||||
fun openKeysBackupSetup(context: Context, showManualExport: Boolean)
|
fun openKeysBackupSetup(fragmentActivity: FragmentActivity, showManualExport: Boolean)
|
||||||
|
|
||||||
fun open4SSetup(context: Context, setupMode: SetupMode)
|
fun open4SSetup(fragmentActivity: FragmentActivity, setupMode: SetupMode)
|
||||||
|
|
||||||
fun openKeysBackupManager(context: Context)
|
fun openKeysBackupManager(context: Context)
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.permalink
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.extensions.isIgnored
|
import im.vector.app.core.extensions.isIgnored
|
||||||
|
@ -52,17 +53,17 @@ class PermalinkHandler @Inject constructor(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun launch(
|
suspend fun launch(
|
||||||
context: Context,
|
fragmentActivity: FragmentActivity,
|
||||||
deepLink: String?,
|
deepLink: String?,
|
||||||
navigationInterceptor: NavigationInterceptor? = null,
|
navigationInterceptor: NavigationInterceptor? = null,
|
||||||
buildTask: Boolean = false
|
buildTask: Boolean = false
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val uri = deepLink?.let { Uri.parse(it) }
|
val uri = deepLink?.let { Uri.parse(it) }
|
||||||
return launch(context, uri, navigationInterceptor, buildTask)
|
return launch(fragmentActivity, uri, navigationInterceptor, buildTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun launch(
|
suspend fun launch(
|
||||||
context: Context,
|
fragmentActivity: FragmentActivity,
|
||||||
deepLink: Uri?,
|
deepLink: Uri?,
|
||||||
navigationInterceptor: NavigationInterceptor? = null,
|
navigationInterceptor: NavigationInterceptor? = null,
|
||||||
buildTask: Boolean = false
|
buildTask: Boolean = false
|
||||||
|
@ -70,12 +71,12 @@ class PermalinkHandler @Inject constructor(
|
||||||
return when {
|
return when {
|
||||||
deepLink == null -> false
|
deepLink == null -> false
|
||||||
deepLink.isIgnored() -> true
|
deepLink.isIgnored() -> true
|
||||||
!isPermalinkSupported(context, deepLink.toString()) -> false
|
!isPermalinkSupported(fragmentActivity, deepLink.toString()) -> false
|
||||||
else -> {
|
else -> {
|
||||||
tryOrNull {
|
tryOrNull {
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
val permalinkData = PermalinkParser.parse(deepLink)
|
val permalinkData = PermalinkParser.parse(deepLink)
|
||||||
handlePermalink(permalinkData, deepLink, context, navigationInterceptor, buildTask)
|
handlePermalink(permalinkData, deepLink, fragmentActivity, navigationInterceptor, buildTask)
|
||||||
}
|
}
|
||||||
} ?: false
|
} ?: false
|
||||||
}
|
}
|
||||||
|
@ -85,22 +86,22 @@ class PermalinkHandler @Inject constructor(
|
||||||
private suspend fun handlePermalink(
|
private suspend fun handlePermalink(
|
||||||
permalinkData: PermalinkData,
|
permalinkData: PermalinkData,
|
||||||
rawLink: Uri,
|
rawLink: Uri,
|
||||||
context: Context,
|
fragmentActivity: FragmentActivity,
|
||||||
navigationInterceptor: NavigationInterceptor?,
|
navigationInterceptor: NavigationInterceptor?,
|
||||||
buildTask: Boolean
|
buildTask: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return when (permalinkData) {
|
return when (permalinkData) {
|
||||||
is PermalinkData.RoomLink -> handleRoomLink(permalinkData, rawLink, context, navigationInterceptor, buildTask)
|
is PermalinkData.RoomLink -> handleRoomLink(permalinkData, rawLink, fragmentActivity, navigationInterceptor, buildTask)
|
||||||
is PermalinkData.UserLink -> handleUserLink(permalinkData, rawLink, context, navigationInterceptor, buildTask)
|
is PermalinkData.UserLink -> handleUserLink(permalinkData, rawLink, fragmentActivity, navigationInterceptor, buildTask)
|
||||||
is PermalinkData.FallbackLink -> handleFallbackLink(permalinkData, context)
|
is PermalinkData.FallbackLink -> handleFallbackLink(permalinkData, fragmentActivity)
|
||||||
is PermalinkData.RoomEmailInviteLink -> handleRoomInviteLink(permalinkData, context)
|
is PermalinkData.RoomEmailInviteLink -> handleRoomInviteLink(permalinkData, fragmentActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun handleRoomLink(
|
private suspend fun handleRoomLink(
|
||||||
permalinkData: PermalinkData.RoomLink,
|
permalinkData: PermalinkData.RoomLink,
|
||||||
rawLink: Uri,
|
rawLink: Uri,
|
||||||
context: Context,
|
fragmentActivity: FragmentActivity,
|
||||||
navigationInterceptor: NavigationInterceptor?,
|
navigationInterceptor: NavigationInterceptor?,
|
||||||
buildTask: Boolean
|
buildTask: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
@ -119,7 +120,7 @@ class PermalinkHandler @Inject constructor(
|
||||||
}
|
}
|
||||||
openRoom(
|
openRoom(
|
||||||
navigationInterceptor,
|
navigationInterceptor,
|
||||||
context = context,
|
fragmentActivity = fragmentActivity,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
permalinkData = permalinkData,
|
permalinkData = permalinkData,
|
||||||
rawLink = rawLink,
|
rawLink = rawLink,
|
||||||
|
@ -200,7 +201,7 @@ class PermalinkHandler @Inject constructor(
|
||||||
*/
|
*/
|
||||||
private fun openRoom(
|
private fun openRoom(
|
||||||
navigationInterceptor: NavigationInterceptor?,
|
navigationInterceptor: NavigationInterceptor?,
|
||||||
context: Context,
|
fragmentActivity: FragmentActivity,
|
||||||
roomId: String?,
|
roomId: String?,
|
||||||
permalinkData: PermalinkData.RoomLink,
|
permalinkData: PermalinkData.RoomLink,
|
||||||
rawLink: Uri,
|
rawLink: Uri,
|
||||||
|
@ -209,7 +210,7 @@ class PermalinkHandler @Inject constructor(
|
||||||
) {
|
) {
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
if (roomId == null) {
|
if (roomId == null) {
|
||||||
context.toast(R.string.room_error_not_found)
|
fragmentActivity.toast(R.string.room_error_not_found)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val roomSummary = session.getRoomSummary(roomId)
|
val roomSummary = session.getRoomSummary(roomId)
|
||||||
|
@ -218,19 +219,19 @@ class PermalinkHandler @Inject constructor(
|
||||||
// val roomAlias = permalinkData.getRoomAliasOrNull()
|
// val roomAlias = permalinkData.getRoomAliasOrNull()
|
||||||
val isSpace = roomSummary?.roomType == RoomType.SPACE
|
val isSpace = roomSummary?.roomType == RoomType.SPACE
|
||||||
return when {
|
return when {
|
||||||
membership == Membership.BAN -> context.toast(R.string.error_opening_banned_room)
|
membership == Membership.BAN -> fragmentActivity.toast(R.string.error_opening_banned_room)
|
||||||
membership?.isActive().orFalse() -> {
|
membership?.isActive().orFalse() -> {
|
||||||
if (!isSpace && membership == Membership.JOIN) {
|
if (!isSpace && membership == Membership.JOIN) {
|
||||||
// If it's a room you're in, let's just open it, you can tap back if needed
|
// If it's a room you're in, let's just open it, you can tap back if needed
|
||||||
navigationInterceptor.openJoinedRoomScreen(buildTask, roomId, eventId, rawLink, context, rootThreadEventId, roomSummary)
|
navigationInterceptor.openJoinedRoomScreen(buildTask, roomId, eventId, rawLink, fragmentActivity, rootThreadEventId, roomSummary)
|
||||||
} else {
|
} else {
|
||||||
// maybe open space preview navigator.openSpacePreview(context, roomId)? if already joined?
|
// maybe open space preview navigator.openSpacePreview(fragmentActivity, roomId)? if already joined?
|
||||||
navigator.openMatrixToBottomSheet(context, rawLink.toString(), OriginOfMatrixTo.LINK)
|
navigator.openMatrixToBottomSheet(fragmentActivity, rawLink.toString(), OriginOfMatrixTo.LINK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// XXX this could trigger another server load
|
// XXX this could trigger another server load
|
||||||
navigator.openMatrixToBottomSheet(context, rawLink.toString(), OriginOfMatrixTo.LINK)
|
navigator.openMatrixToBottomSheet(fragmentActivity, rawLink.toString(), OriginOfMatrixTo.LINK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ class PublicRoomsFragment :
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
val permalink = session.permalinkService().createPermalink(roomIdOrAlias)
|
val permalink = session.permalinkService().createPermalink(roomIdOrAlias)
|
||||||
val isHandled = permalinkHandler
|
val isHandled = permalinkHandler
|
||||||
.launch(requireContext(), permalink, object : NavigationInterceptor {
|
.launch(requireActivity(), permalink, object : NavigationInterceptor {
|
||||||
override fun navToRoom(roomId: String?, eventId: String?, deepLink: Uri?, rootThreadEventId: String?): Boolean {
|
override fun navToRoom(roomId: String?, eventId: String?, deepLink: Uri?, rootThreadEventId: String?): Boolean {
|
||||||
requireActivity().finish()
|
requireActivity().finish()
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -76,7 +76,7 @@ class RoomMemberListFragment :
|
||||||
|
|
||||||
private fun setupInviteUsersButton() {
|
private fun setupInviteUsersButton() {
|
||||||
views.inviteUsersButton.debouncedClicks {
|
views.inviteUsersButton.debouncedClicks {
|
||||||
navigator.openInviteUsersToRoom(requireContext(), roomProfileArgs.roomId)
|
navigator.openInviteUsersToRoom(requireActivity(), roomProfileArgs.roomId)
|
||||||
}
|
}
|
||||||
// Hide FAB when list is scrolling
|
// Hide FAB when list is scrolling
|
||||||
views.roomSettingGeneric.roomSettingsRecyclerView.addOnScrollListener(
|
views.roomSettingGeneric.roomSettingsRecyclerView.addOnScrollListener(
|
||||||
|
|
|
@ -94,7 +94,7 @@ class VectorSettingsDevicesFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is DevicesViewEvents.PromptResetSecrets -> {
|
is DevicesViewEvents.PromptResetSecrets -> {
|
||||||
navigator.open4SSetup(requireContext(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET)
|
navigator.open4SSetup(requireActivity(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class VectorSettingsDevicesFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is DevicesViewEvents.PromptResetSecrets -> {
|
is DevicesViewEvents.PromptResetSecrets -> {
|
||||||
navigator.open4SSetup(requireContext(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET)
|
navigator.open4SSetup(requireActivity(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue