Invite Space/Room chooser
This commit is contained in:
parent
55745655db
commit
8754f7772b
|
@ -77,6 +77,7 @@ import im.vector.app.features.settings.VectorSettingsActivity
|
||||||
import im.vector.app.features.settings.devices.DeviceVerificationInfoBottomSheet
|
import im.vector.app.features.settings.devices.DeviceVerificationInfoBottomSheet
|
||||||
import im.vector.app.features.share.IncomingShareActivity
|
import im.vector.app.features.share.IncomingShareActivity
|
||||||
import im.vector.app.features.signout.soft.SoftLogoutActivity
|
import im.vector.app.features.signout.soft.SoftLogoutActivity
|
||||||
|
import im.vector.app.features.spaces.InviteRoomSpaceChooserBottomSheet
|
||||||
import im.vector.app.features.spaces.ShareSpaceBottomSheet
|
import im.vector.app.features.spaces.ShareSpaceBottomSheet
|
||||||
import im.vector.app.features.spaces.SpaceCreationActivity
|
import im.vector.app.features.spaces.SpaceCreationActivity
|
||||||
import im.vector.app.features.spaces.SpaceExploreActivity
|
import im.vector.app.features.spaces.SpaceExploreActivity
|
||||||
|
@ -181,6 +182,7 @@ interface ScreenComponent {
|
||||||
fun inject(bottomSheet: MatrixToBottomSheet)
|
fun inject(bottomSheet: MatrixToBottomSheet)
|
||||||
fun inject(bottomSheet: ShareSpaceBottomSheet)
|
fun inject(bottomSheet: ShareSpaceBottomSheet)
|
||||||
fun inject(bottomSheet: SpaceSettingsMenuBottomSheet)
|
fun inject(bottomSheet: SpaceSettingsMenuBottomSheet)
|
||||||
|
fun inject(bottomSheet: InviteRoomSpaceChooserBottomSheet)
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* Others
|
* Others
|
||||||
|
|
|
@ -71,6 +71,7 @@ import im.vector.app.features.roomprofile.RoomProfileActivity
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
import im.vector.app.features.settings.VectorSettingsActivity
|
import im.vector.app.features.settings.VectorSettingsActivity
|
||||||
import im.vector.app.features.share.SharedData
|
import im.vector.app.features.share.SharedData
|
||||||
|
import im.vector.app.features.spaces.InviteRoomSpaceChooserBottomSheet
|
||||||
import im.vector.app.features.spaces.SpaceExploreActivity
|
import im.vector.app.features.spaces.SpaceExploreActivity
|
||||||
import im.vector.app.features.spaces.SpacePreviewActivity
|
import im.vector.app.features.spaces.SpacePreviewActivity
|
||||||
import im.vector.app.features.terms.ReviewTermsActivity
|
import im.vector.app.features.terms.ReviewTermsActivity
|
||||||
|
@ -275,8 +276,32 @@ class DefaultNavigator @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openInviteUsersToRoom(context: Context, roomId: String) {
|
override fun openInviteUsersToRoom(context: Context, roomId: String) {
|
||||||
val intent = InviteUsersToRoomActivity.getIntent(context, roomId)
|
val selectedSpace = selectedSpaceDataSource.currentValue?.orNull()?.let {
|
||||||
context.startActivity(intent)
|
sessionHolder.getSafeActiveSession()?.getRoomSummary(it.roomId)
|
||||||
|
}
|
||||||
|
if (vectorPreferences.labSpaces() && selectedSpace != null) {
|
||||||
|
// let user decides if he does it from space or room
|
||||||
|
(context as? AppCompatActivity)?.supportFragmentManager?.let { fm ->
|
||||||
|
InviteRoomSpaceChooserBottomSheet.newInstance(
|
||||||
|
selectedSpace.roomId,
|
||||||
|
roomId,
|
||||||
|
object : InviteRoomSpaceChooserBottomSheet.InteractionListener {
|
||||||
|
override fun inviteToSpace(spaceId: String) {
|
||||||
|
val intent = InviteUsersToRoomActivity.getIntent(context, spaceId)
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun inviteToRoom(roomId: String) {
|
||||||
|
val intent = InviteUsersToRoomActivity.getIntent(context, roomId)
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).show(fm, InviteRoomSpaceChooserBottomSheet::class.java.name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intent = InviteUsersToRoomActivity.getIntent(context, roomId)
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openRoomsFiltering(context: Context) {
|
override fun openRoomsFiltering(context: Context) {
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.spaces
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.Parcelable
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.airbnb.mvrx.args
|
||||||
|
import im.vector.app.R
|
||||||
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
|
import im.vector.app.core.di.ScreenComponent
|
||||||
|
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||||
|
import im.vector.app.databinding.BottomSheetSpaceInviteChooserBinding
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InviteRoomSpaceChooserBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetSpaceInviteChooserBinding>() {
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class Args(
|
||||||
|
val spaceId: String,
|
||||||
|
val roomId: String
|
||||||
|
) : Parcelable
|
||||||
|
|
||||||
|
override val showExpanded = true
|
||||||
|
|
||||||
|
private val inviteArgs: Args by args()
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
|
|
||||||
|
interface InteractionListener {
|
||||||
|
fun inviteToSpace(spaceId: String)
|
||||||
|
fun inviteToRoom(roomId: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
var interactionListener: InteractionListener? = null
|
||||||
|
|
||||||
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
|
injector.inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetSpaceInviteChooserBinding {
|
||||||
|
return BottomSheetSpaceInviteChooserBinding.inflate(inflater, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
// Not going for full view model for now, as it may change
|
||||||
|
|
||||||
|
val summary = activeSessionHolder.getSafeActiveSession()?.spaceService()?.getSpace(inviteArgs.spaceId)?.spaceSummary()
|
||||||
|
|
||||||
|
val spaceName = summary?.name
|
||||||
|
|
||||||
|
views.inviteToSpaceButton.isVisible = true
|
||||||
|
views.inviteToSpaceButton.title = getString(R.string.invite_to_space_with_name, spaceName)
|
||||||
|
views.inviteToSpaceButton.subTitle = getString(R.string.invite_to_space_with_name_desc, spaceName)
|
||||||
|
views.inviteToSpaceButton.debouncedClicks {
|
||||||
|
dismiss()
|
||||||
|
interactionListener?.inviteToSpace(inviteArgs.spaceId)
|
||||||
|
}
|
||||||
|
|
||||||
|
views.inviteToRoomOnly.isVisible = true
|
||||||
|
views.inviteToRoomOnly.title = getString(R.string.invite_just_to_this_room)
|
||||||
|
views.inviteToRoomOnly.subTitle = getString(R.string.invite_just_to_this_room_desc, spaceName)
|
||||||
|
views.inviteToRoomOnly.debouncedClicks {
|
||||||
|
dismiss()
|
||||||
|
interactionListener?.inviteToRoom(inviteArgs.roomId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance(spaceId: String, roomId: String, interactionListener: InteractionListener)
|
||||||
|
: InviteRoomSpaceChooserBottomSheet {
|
||||||
|
return InviteRoomSpaceChooserBottomSheet().apply {
|
||||||
|
this.interactionListener = interactionListener
|
||||||
|
setArguments(Args(spaceId, roomId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/callControlsWrapper"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?riotx_bottom_sheet_background"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/headerText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/invite_people_menu"
|
||||||
|
android:textColor="?riotx_text_primary"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
<im.vector.app.features.spaces.create.WizardButtonView
|
||||||
|
android:id="@+id/inviteToSpaceButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:icon="@drawable/ic_public_room"
|
||||||
|
app:title="@string/invite_to_space_with_name"
|
||||||
|
app:subTitle="@string/invite_to_space_with_name_desc"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="16dp" />
|
||||||
|
|
||||||
|
<im.vector.app.features.spaces.create.WizardButtonView
|
||||||
|
android:id="@+id/inviteToRoomOnly"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:icon="@drawable/ic_lock"
|
||||||
|
app:iconTint="?riotx_text_secondary"
|
||||||
|
app:title="@string/invite_just_to_this_room"
|
||||||
|
app:subTitle="@string/invite_just_to_this_room_desc"/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="16dp" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -3288,6 +3288,10 @@
|
||||||
<string name="invite_by_email">Invite by email</string>
|
<string name="invite_by_email">Invite by email</string>
|
||||||
<string name="invite_by_mxid">Invite by username</string>
|
<string name="invite_by_mxid">Invite by username</string>
|
||||||
<string name="invite_by_link">Share link</string>
|
<string name="invite_by_link">Share link</string>
|
||||||
|
<string name="invite_to_space_with_name">Invite to %s</string>
|
||||||
|
<string name="invite_to_space_with_name_desc">"They’ll be able to explore %s"</string>
|
||||||
|
<string name="invite_just_to_this_room">Just to this room</string>
|
||||||
|
<string name="invite_just_to_this_room_desc">"They won’t be a part of %s"</string>
|
||||||
<!-- First one is the space name, and the second one is the matrix.to link -->
|
<!-- First one is the space name, and the second one is the matrix.to link -->
|
||||||
<string name="share_space_link_message">Join my space %1$s %2$s</string>
|
<string name="share_space_link_message">Join my space %1$s %2$s</string>
|
||||||
<string name="skip_for_now">Skip for now</string>
|
<string name="skip_for_now">Skip for now</string>
|
||||||
|
|
Loading…
Reference in New Issue