Skip to content

Commit

Permalink
Merge pull request #7054 from vector-im/feature/bma/fix_invite_to_roo…
Browse files Browse the repository at this point in the history
…m_in_space

Fix invite to room in space
  • Loading branch information
bmarty authored Sep 7, 2022
2 parents 9b5d8c2 + 8c32b08 commit c408621
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 111 deletions.
1 change: 1 addition & 0 deletions changelog.d/7054.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix invite to room when in a space buttons not working.
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class HomeActivity :

lifecycleScope.launch {
val isHandled = permalinkHandler.launch(
context = this@HomeActivity,
fragmentActivity = this@HomeActivity,
deepLink = resolvedLink,
navigationInterceptor = this@HomeActivity,
buildTask = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ class HomeDetailFragment :
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)
?.navigator
?.requestSessionVerification(requireContext(), newest.deviceId ?: "")
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let { vectorBaseActivity ->
vectorBaseActivity.navigator
.requestSessionVerification(vectorBaseActivity, newest.deviceId ?: "")
}
unknownDeviceDetectorSharedViewModel.handle(
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@ class NewHomeDetailFragment :
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)
?.navigator
?.requestSessionVerification(requireContext(), newest.deviceId ?: "")
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let { vectorBaseActivity ->
vectorBaseActivity.navigator
.requestSessionVerification(vectorBaseActivity, newest.deviceId ?: "")
}
unknownDeviceDetectorSharedViewModel.handle(
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(newest.deviceId?.let { listOf(it) }.orEmpty())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class TimelineFragment :
RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView()
is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(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.OpenRoomSettings -> handleOpenRoomSettings(RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS)
RoomDetailViewEvents.OpenRoomProfile -> handleOpenRoomSettings()
Expand Down Expand Up @@ -2190,7 +2190,7 @@ class TimelineFragment :
override fun onRoomCreateLinkClicked(url: String) {
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
permalinkHandler
.launch(requireContext(), url, object : NavigationInterceptor {
.launch(requireActivity(), url, object : NavigationInterceptor {
override fun navToRoom(roomId: String?, eventId: String?, deepLink: Uri?, rootThreadEventId: String?): Boolean {
requireActivity().finish()
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class RoomListFragment :
}

private fun handleShowMxToLink(link: String) {
navigator.openMatrixToBottomSheet(requireContext(), link, OriginOfMatrixTo.ROOM_LIST)
navigator.openMatrixToBottomSheet(requireActivity(), link, OriginOfMatrixTo.ROOM_LIST)
}

override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import android.view.View
import android.view.Window
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityOptionsCompat
import androidx.core.app.TaskStackBuilder
import androidx.core.util.Pair
import androidx.core.view.ViewCompat
import androidx.fragment.app.FragmentActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import im.vector.app.R
import im.vector.app.SpaceStateHandler
Expand Down Expand Up @@ -224,73 +224,63 @@ class DefaultNavigator @Inject constructor(
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 tx = session.cryptoService().verificationService().getExistingTransaction(otherUserId, sasTransactionId)
?: return
(tx as? IncomingSasVerificationTransaction)?.performAccept()
if (context is AppCompatActivity) {
VerificationBottomSheet.withArgs(
roomId = null,
otherUserId = otherUserId,
transactionId = sasTransactionId
).show(context.supportFragmentManager, "REQPOP")
}
VerificationBottomSheet.withArgs(
roomId = null,
otherUserId = otherUserId,
transactionId = sasTransactionId
).show(fragmentActivity.supportFragmentManager, "REQPOP")
}

override fun requestSessionVerification(context: Context, otherSessionId: String) {
override fun requestSessionVerification(fragmentActivity: FragmentActivity, otherSessionId: String) {
val session = sessionHolder.getSafeActiveSession() ?: return
val pr = session.cryptoService().verificationService().requestKeyVerification(
supportedVerificationMethodsProvider.provide(),
session.myUserId,
listOf(otherSessionId)
)
if (context is AppCompatActivity) {
VerificationBottomSheet.withArgs(
roomId = null,
otherUserId = session.myUserId,
transactionId = pr.transactionId
).show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
}
VerificationBottomSheet.withArgs(
roomId = null,
otherUserId = session.myUserId,
transactionId = pr.transactionId
).show(fragmentActivity.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
}

override fun requestSelfSessionVerification(context: Context) {
override fun requestSelfSessionVerification(fragmentActivity: FragmentActivity) {
val session = sessionHolder.getSafeActiveSession() ?: return
val otherSessions = session.cryptoService()
.getCryptoDeviceInfo(session.myUserId)
.filter { it.deviceId != session.sessionParams.deviceId }
.map { it.deviceId }
if (context is AppCompatActivity) {
if (otherSessions.isNotEmpty()) {
val pr = session.cryptoService().verificationService().requestKeyVerification(
supportedVerificationMethodsProvider.provide(),
session.myUserId,
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)
}
if (otherSessions.isNotEmpty()) {
val pr = session.cryptoService().verificationService().requestKeyVerification(
supportedVerificationMethodsProvider.provide(),
session.myUserId,
otherSessions
)
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(context: Context) {
override fun waitSessionVerification(fragmentActivity: FragmentActivity) {
val session = sessionHolder.getSafeActiveSession() ?: return
if (context is AppCompatActivity) {
VerificationBottomSheet.forSelfVerification(session)
.show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
}
VerificationBottomSheet.forSelfVerification(session)
.show(fragmentActivity.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
)
}
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) {
Expand All @@ -316,16 +306,14 @@ class DefaultNavigator @Inject constructor(
context.startActivity(intent)
}

override fun openMatrixToBottomSheet(context: Context, link: String, origin: OriginOfMatrixTo) {
if (context is AppCompatActivity) {
if (context !is MatrixToBottomSheet.InteractionListener) {
fatalError("Caller context should implement MatrixToBottomSheet.InteractionListener", vectorPreferences.failFast())
return
}
// TODO check if there is already one??
MatrixToBottomSheet.withLink(link, origin)
.show(context.supportFragmentManager, "HA#MatrixToBottomSheet")
override fun openMatrixToBottomSheet(fragmentActivity: FragmentActivity, link: String, origin: OriginOfMatrixTo) {
if (fragmentActivity !is MatrixToBottomSheet.InteractionListener) {
fatalError("Caller context should implement MatrixToBottomSheet.InteractionListener", vectorPreferences.failFast())
return
}
// TODO check if there is already one??
MatrixToBottomSheet.withLink(link, origin)
.show(fragmentActivity.supportFragmentManager, "HA#MatrixToBottomSheet")
}

override fun openRoomDirectory(context: Context, initialFilter: String) {
Expand All @@ -347,18 +335,16 @@ class DefaultNavigator @Inject constructor(
}.start(context)
}

override fun openInviteUsersToRoom(context: Context, roomId: String) {
override fun openInviteUsersToRoom(fragmentActivity: FragmentActivity, roomId: String) {
when (val currentSpace = spaceStateHandler.getCurrentSpace()) {
null -> InviteUsersToRoomActivity.getIntent(context, roomId).start(context)
else -> showInviteToDialog(context, currentSpace, roomId)
null -> InviteUsersToRoomActivity.getIntent(fragmentActivity, roomId).start(fragmentActivity)
else -> showInviteToDialog(fragmentActivity, currentSpace, roomId)
}
}

private fun showInviteToDialog(context: Context, currentSpace: RoomSummary, roomId: String) {
(context as? AppCompatActivity)?.supportFragmentManager?.let { fragmentManager ->
InviteRoomSpaceChooserBottomSheet.showInstance(fragmentManager, currentSpace.roomId, roomId) { itemId ->
InviteUsersToRoomActivity.getIntent(context, itemId).start(context)
}
private fun showInviteToDialog(fragmentActivity: FragmentActivity, currentSpace: RoomSummary, roomId: String) {
InviteRoomSpaceChooserBottomSheet.showInstance(fragmentActivity.supportFragmentManager, currentSpace.roomId, roomId) { itemId ->
InviteUsersToRoomActivity.getIntent(fragmentActivity, itemId).start(fragmentActivity)
}
}

Expand All @@ -381,24 +367,20 @@ class DefaultNavigator @Inject constructor(
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
sessionHolder.getSafeActiveSession()?.let { session ->
if (session.cryptoService().crossSigningService().getMyCrossSigningKeys() == null ||
session.cryptoService().crossSigningService().canCrossSign()) {
(context as? AppCompatActivity)?.let {
BootstrapBottomSheet.show(it.supportFragmentManager, SetupMode.NORMAL)
}
BootstrapBottomSheet.show(fragmentActivity.supportFragmentManager, SetupMode.NORMAL)
} else {
context.startActivity(KeysBackupSetupActivity.intent(context, showManualExport))
fragmentActivity.startActivity(KeysBackupSetupActivity.intent(fragmentActivity, showManualExport))
}
}
}

override fun open4SSetup(context: Context, setupMode: SetupMode) {
if (context is AppCompatActivity) {
BootstrapBottomSheet.show(context.supportFragmentManager, setupMode)
}
override fun open4SSetup(fragmentActivity: FragmentActivity, setupMode: SetupMode) {
BootstrapBottomSheet.show(fragmentActivity.supportFragmentManager, setupMode)
}

override fun openKeysBackupManager(context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.net.Uri
import android.view.View
import androidx.activity.result.ActivityResultLauncher
import androidx.core.util.Pair
import androidx.fragment.app.FragmentActivity
import im.vector.app.features.analytics.plan.ViewRoom
import im.vector.app.features.crypto.recover.SetupMode
import im.vector.app.features.displayname.getBestName
Expand Down Expand Up @@ -76,29 +77,29 @@ interface Navigator {

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 openRoomPreview(context: Context, publicRoom: PublicRoom, roomDirectoryData: RoomDirectoryData)

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 openCreateDirectRoom(context: Context)

fun openInviteUsersToRoom(context: Context, roomId: String)
fun openInviteUsersToRoom(fragmentActivity: FragmentActivity, roomId: String)

fun openRoomDirectory(context: Context, initialFilter: String = "")

Expand All @@ -110,9 +111,9 @@ interface Navigator {

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)

Expand Down
Loading

0 comments on commit c408621

Please sign in to comment.