mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Renames package and some other things
This commit is contained in:
parent
25e7bbcd79
commit
4c1d50d554
21 changed files with 99 additions and 94 deletions
|
@ -23,6 +23,7 @@ import dagger.Binds
|
|||
import dagger.Module
|
||||
import dagger.multibindings.IntoMap
|
||||
import im.vector.riotx.features.attachments.preview.AttachmentsPreviewFragment
|
||||
import im.vector.riotx.features.contactsbook.ContactsBookFragment
|
||||
import im.vector.riotx.features.crypto.keysbackup.settings.KeysBackupSettingsFragment
|
||||
import im.vector.riotx.features.crypto.quads.SharedSecuredStorageKeyFragment
|
||||
import im.vector.riotx.features.crypto.quads.SharedSecuredStoragePassphraseFragment
|
||||
|
@ -103,7 +104,6 @@ import im.vector.riotx.features.share.IncomingShareFragment
|
|||
import im.vector.riotx.features.signout.soft.SoftLogoutFragment
|
||||
import im.vector.riotx.features.terms.ReviewTermsFragment
|
||||
import im.vector.riotx.features.userdirectory.KnownUsersFragment
|
||||
import im.vector.riotx.features.phonebook.PhoneBookFragment
|
||||
import im.vector.riotx.features.userdirectory.UserDirectoryFragment
|
||||
import im.vector.riotx.features.widgets.WidgetFragment
|
||||
|
||||
|
@ -532,6 +532,6 @@ interface FragmentModule {
|
|||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FragmentKey(PhoneBookFragment::class)
|
||||
fun bindPhoneBookFragment(fragment: PhoneBookFragment): Fragment
|
||||
@FragmentKey(ContactsBookFragment::class)
|
||||
fun bindPhoneBookFragment(fragment: ContactsBookFragment): Fragment
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import android.widget.TextView
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
|
@ -14,11 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class PhoneBookAction : VectorViewModelAction {
|
||||
data class FilterWith(val filter: String) : PhoneBookAction()
|
||||
data class OnlyBoundContacts(val onlyBoundContacts: Boolean) : PhoneBookAction()
|
||||
sealed class ContactsBookAction : VectorViewModelAction {
|
||||
data class FilterWith(val filter: String) : ContactsBookAction()
|
||||
data class OnlyBoundContacts(val onlyBoundContacts: Boolean) : ContactsBookAction()
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import com.airbnb.epoxy.EpoxyController
|
||||
import com.airbnb.mvrx.Fail
|
||||
|
@ -32,12 +32,12 @@ import im.vector.riotx.core.resources.StringProvider
|
|||
import im.vector.riotx.features.home.AvatarRenderer
|
||||
import javax.inject.Inject
|
||||
|
||||
class PhoneBookController @Inject constructor(
|
||||
class ContactsBookController @Inject constructor(
|
||||
private val stringProvider: StringProvider,
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val errorFormatter: ErrorFormatter) : EpoxyController() {
|
||||
|
||||
private var state: PhoneBookViewState? = null
|
||||
private var state: ContactsBookViewState? = null
|
||||
|
||||
var callback: Callback? = null
|
||||
|
||||
|
@ -45,7 +45,7 @@ class PhoneBookController @Inject constructor(
|
|||
requestModelBuild()
|
||||
}
|
||||
|
||||
fun setData(state: PhoneBookViewState) {
|
||||
fun setData(state: ContactsBookViewState) {
|
||||
this.state = state
|
||||
requestModelBuild()
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class PhoneBookController @Inject constructor(
|
|||
private fun renderLoading() {
|
||||
loadingItem {
|
||||
id("loading")
|
||||
loadingText(stringProvider.getString(R.string.loading_contact_book))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ class PhoneBookController @Inject constructor(
|
|||
if (onlyBoundContacts && it.matrixId == null) return@forEachIndexed
|
||||
|
||||
contactDetailItem {
|
||||
id("${mappedContact.id}-$index-${it.email}")
|
||||
id("${mappedContact.id}-e-$index-${it.email}")
|
||||
threePid(it.email)
|
||||
matrixId(it.matrixId)
|
||||
clickListener {
|
||||
|
@ -113,7 +114,7 @@ class PhoneBookController @Inject constructor(
|
|||
if (onlyBoundContacts && it.matrixId == null) return@forEachIndexed
|
||||
|
||||
contactDetailItem {
|
||||
id("${mappedContact.id}-$index-${it.phoneNumber}")
|
||||
id("${mappedContact.id}-m-$index-${it.phoneNumber}")
|
||||
threePid(it.phoneNumber)
|
||||
matrixId(it.matrixId)
|
||||
clickListener {
|
||||
|
@ -132,7 +133,7 @@ class PhoneBookController @Inject constructor(
|
|||
val noResultRes = if (hasSearch) {
|
||||
R.string.no_result_placeholder
|
||||
} else {
|
||||
R.string.empty_phone_book
|
||||
R.string.empty_contact_book
|
||||
}
|
||||
noResultItem {
|
||||
id("noResult")
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
|
@ -35,20 +35,20 @@ import im.vector.riotx.features.userdirectory.UserDirectoryAction
|
|||
import im.vector.riotx.features.userdirectory.UserDirectorySharedAction
|
||||
import im.vector.riotx.features.userdirectory.UserDirectorySharedActionViewModel
|
||||
import im.vector.riotx.features.userdirectory.UserDirectoryViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_phonebook.*
|
||||
import kotlinx.android.synthetic.main.fragment_contacts_book.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
class PhoneBookFragment @Inject constructor(
|
||||
val phoneBookViewModelFactory: PhoneBookViewModel.Factory,
|
||||
private val phoneBookController: PhoneBookController
|
||||
) : VectorBaseFragment(), PhoneBookController.Callback {
|
||||
class ContactsBookFragment @Inject constructor(
|
||||
val contactsBookViewModelFactory: ContactsBookViewModel.Factory,
|
||||
private val contactsBookController: ContactsBookController
|
||||
) : VectorBaseFragment(), ContactsBookController.Callback {
|
||||
|
||||
override fun getLayoutResId() = R.layout.fragment_phonebook
|
||||
override fun getLayoutResId() = R.layout.fragment_contacts_book
|
||||
private val viewModel: UserDirectoryViewModel by activityViewModel()
|
||||
|
||||
// Use activityViewModel to avoid loading several times the data
|
||||
private val phoneBookViewModel: PhoneBookViewModel by activityViewModel()
|
||||
private val contactsBookViewModel: ContactsBookViewModel by activityViewModel()
|
||||
|
||||
private lateinit var sharedActionViewModel: UserDirectorySharedActionViewModel
|
||||
|
||||
|
@ -64,7 +64,7 @@ class PhoneBookFragment @Inject constructor(
|
|||
private fun setupOnlyBoundContactsView() {
|
||||
phoneBookOnlyBoundContacts.checkedChanges()
|
||||
.subscribe {
|
||||
phoneBookViewModel.handle(PhoneBookAction.OnlyBoundContacts(it))
|
||||
contactsBookViewModel.handle(ContactsBookAction.OnlyBoundContacts(it))
|
||||
}
|
||||
.disposeOnDestroyView()
|
||||
}
|
||||
|
@ -75,20 +75,20 @@ class PhoneBookFragment @Inject constructor(
|
|||
.skipInitialValue()
|
||||
.debounce(300, TimeUnit.MILLISECONDS)
|
||||
.subscribe {
|
||||
phoneBookViewModel.handle(PhoneBookAction.FilterWith(it.toString()))
|
||||
contactsBookViewModel.handle(ContactsBookAction.FilterWith(it.toString()))
|
||||
}
|
||||
.disposeOnDestroyView()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
phoneBookRecyclerView.cleanup()
|
||||
phoneBookController.callback = null
|
||||
contactsBookController.callback = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
phoneBookController.callback = this
|
||||
phoneBookRecyclerView.configureWith(phoneBookController)
|
||||
contactsBookController.callback = this
|
||||
phoneBookRecyclerView.configureWith(contactsBookController)
|
||||
}
|
||||
|
||||
private fun setupCloseView() {
|
||||
|
@ -97,9 +97,9 @@ class PhoneBookFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(phoneBookViewModel) { state ->
|
||||
override fun invalidate() = withState(contactsBookViewModel) { state ->
|
||||
phoneBookOnlyBoundContacts.isVisible = state.isBoundRetrieved
|
||||
phoneBookController.setData(state)
|
||||
contactsBookController.setData(state)
|
||||
}
|
||||
|
||||
override fun onMatrixIdClick(matrixId: String) {
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.viewModelScope
|
||||
|
@ -43,26 +43,26 @@ import timber.log.Timber
|
|||
|
||||
private typealias PhoneBookSearch = String
|
||||
|
||||
class PhoneBookViewModel @AssistedInject constructor(@Assisted
|
||||
initialState: PhoneBookViewState,
|
||||
private val contactsDataSource: ContactsDataSource,
|
||||
private val session: Session)
|
||||
: VectorViewModel<PhoneBookViewState, PhoneBookAction, EmptyViewEvents>(initialState) {
|
||||
class ContactsBookViewModel @AssistedInject constructor(@Assisted
|
||||
initialState: ContactsBookViewState,
|
||||
private val contactsDataSource: ContactsDataSource,
|
||||
private val session: Session)
|
||||
: VectorViewModel<ContactsBookViewState, ContactsBookAction, EmptyViewEvents>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
fun create(initialState: PhoneBookViewState): PhoneBookViewModel
|
||||
fun create(initialState: ContactsBookViewState): ContactsBookViewModel
|
||||
}
|
||||
|
||||
companion object : MvRxViewModelFactory<PhoneBookViewModel, PhoneBookViewState> {
|
||||
companion object : MvRxViewModelFactory<ContactsBookViewModel, ContactsBookViewState> {
|
||||
|
||||
override fun create(viewModelContext: ViewModelContext, state: PhoneBookViewState): PhoneBookViewModel? {
|
||||
override fun create(viewModelContext: ViewModelContext, state: ContactsBookViewState): ContactsBookViewModel? {
|
||||
return when (viewModelContext) {
|
||||
is FragmentViewModelContext -> (viewModelContext.fragment() as PhoneBookFragment).phoneBookViewModelFactory.create(state)
|
||||
is FragmentViewModelContext -> (viewModelContext.fragment() as ContactsBookFragment).contactsBookViewModelFactory.create(state)
|
||||
is ActivityViewModelContext -> {
|
||||
when (viewModelContext.activity<FragmentActivity>()) {
|
||||
is CreateDirectRoomActivity -> viewModelContext.activity<CreateDirectRoomActivity>().phoneBookViewModelFactory.create(state)
|
||||
is InviteUsersToRoomActivity -> viewModelContext.activity<InviteUsersToRoomActivity>().phoneBookViewModelFactory.create(state)
|
||||
is CreateDirectRoomActivity -> viewModelContext.activity<CreateDirectRoomActivity>().contactsBookViewModelFactory.create(state)
|
||||
is InviteUsersToRoomActivity -> viewModelContext.activity<InviteUsersToRoomActivity>().contactsBookViewModelFactory.create(state)
|
||||
else -> error("Wrong activity or fragment")
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class PhoneBookViewModel @AssistedInject constructor(@Assisted
|
|||
init {
|
||||
loadContacts()
|
||||
|
||||
selectSubscribe(PhoneBookViewState::searchTerm, PhoneBookViewState::onlyBoundContacts) { _, _ ->
|
||||
selectSubscribe(ContactsBookViewState::searchTerm, ContactsBookViewState::onlyBoundContacts) { _, _ ->
|
||||
updateFilteredMappedContacts()
|
||||
}
|
||||
}
|
||||
|
@ -163,14 +163,14 @@ class PhoneBookViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
}
|
||||
|
||||
override fun handle(action: PhoneBookAction) {
|
||||
override fun handle(action: ContactsBookAction) {
|
||||
when (action) {
|
||||
is PhoneBookAction.FilterWith -> handleFilterWith(action)
|
||||
is PhoneBookAction.OnlyBoundContacts -> handleOnlyBoundContacts(action)
|
||||
is ContactsBookAction.FilterWith -> handleFilterWith(action)
|
||||
is ContactsBookAction.OnlyBoundContacts -> handleOnlyBoundContacts(action)
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
private fun handleOnlyBoundContacts(action: PhoneBookAction.OnlyBoundContacts) {
|
||||
private fun handleOnlyBoundContacts(action: ContactsBookAction.OnlyBoundContacts) {
|
||||
setState {
|
||||
copy(
|
||||
onlyBoundContacts = action.onlyBoundContacts
|
||||
|
@ -178,7 +178,7 @@ class PhoneBookViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleFilterWith(action: PhoneBookAction.FilterWith) {
|
||||
private fun handleFilterWith(action: ContactsBookAction.FilterWith) {
|
||||
setState {
|
||||
copy(
|
||||
searchTerm = action.filter
|
|
@ -14,14 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.phonebook
|
||||
package im.vector.riotx.features.contactsbook
|
||||
|
||||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.MvRxState
|
||||
import im.vector.riotx.core.contacts.MappedContact
|
||||
|
||||
data class PhoneBookViewState(
|
||||
data class ContactsBookViewState(
|
||||
// All the contacts on the phone
|
||||
val mappedContacts: Async<List<MappedContact>> = Loading(),
|
||||
// Use to filter contacts by display name
|
|
@ -20,5 +20,5 @@ import im.vector.riotx.core.platform.VectorViewModelAction
|
|||
import im.vector.riotx.features.userdirectory.PendingInvitee
|
||||
|
||||
sealed class CreateDirectRoomAction : VectorViewModelAction {
|
||||
data class CreateRoomAndInviteSelectedUsers(val selectedUsers: Set<PendingInvitee>) : CreateDirectRoomAction()
|
||||
data class CreateRoomAndInviteSelectedUsers(val invitees: Set<PendingInvitee>) : CreateDirectRoomAction()
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ import im.vector.riotx.core.utils.PERMISSIONS_FOR_MEMBERS_SEARCH
|
|||
import im.vector.riotx.core.utils.PERMISSION_REQUEST_CODE_READ_CONTACTS
|
||||
import im.vector.riotx.core.utils.allGranted
|
||||
import im.vector.riotx.core.utils.checkPermissions
|
||||
import im.vector.riotx.features.phonebook.PhoneBookFragment
|
||||
import im.vector.riotx.features.phonebook.PhoneBookViewModel
|
||||
import im.vector.riotx.features.contactsbook.ContactsBookFragment
|
||||
import im.vector.riotx.features.contactsbook.ContactsBookViewModel
|
||||
import im.vector.riotx.features.userdirectory.KnownUsersFragment
|
||||
import im.vector.riotx.features.userdirectory.KnownUsersFragmentArgs
|
||||
import im.vector.riotx.features.userdirectory.UserDirectoryFragment
|
||||
|
@ -60,7 +60,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
|||
private lateinit var sharedActionViewModel: UserDirectorySharedActionViewModel
|
||||
@Inject lateinit var userDirectoryViewModelFactory: UserDirectoryViewModel.Factory
|
||||
@Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory
|
||||
@Inject lateinit var phoneBookViewModelFactory: PhoneBookViewModel.Factory
|
||||
@Inject lateinit var contactsBookViewModelFactory: ContactsBookViewModel.Factory
|
||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
|
@ -106,21 +106,21 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
|||
this,
|
||||
PERMISSION_REQUEST_CODE_READ_CONTACTS,
|
||||
0)) {
|
||||
addFragmentToBackstack(R.id.container, PhoneBookFragment::class.java)
|
||||
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||
if (allGranted(grantResults)) {
|
||||
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
|
||||
addFragmentToBackstack(R.id.container, PhoneBookFragment::class.java)
|
||||
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onMenuItemSelected(action: UserDirectorySharedAction.OnMenuItemSelected) {
|
||||
if (action.itemId == R.id.action_create_direct_room) {
|
||||
viewModel.handle(CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers(action.selectedUsers))
|
||||
viewModel.handle(CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers(action.invitees))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,14 +49,14 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
|
|||
|
||||
override fun handle(action: CreateDirectRoomAction) {
|
||||
when (action) {
|
||||
is CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers -> createRoomAndInviteSelectedUsers(action.selectedUsers)
|
||||
is CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers -> createRoomAndInviteSelectedUsers(action.invitees)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createRoomAndInviteSelectedUsers(selectedUsers: Set<PendingInvitee>) {
|
||||
private fun createRoomAndInviteSelectedUsers(invitees: Set<PendingInvitee>) {
|
||||
val roomParams = CreateRoomParamsBuilder()
|
||||
.apply {
|
||||
selectedUsers.forEach {
|
||||
invitees.forEach {
|
||||
when (it) {
|
||||
is PendingInvitee.UserPendingInvitee -> invitedUserIds.add(it.user.userId)
|
||||
is PendingInvitee.ThreePidPendingInvitee -> invite3pids.add(it.threePid)
|
||||
|
|
|
@ -20,5 +20,5 @@ import im.vector.riotx.core.platform.VectorViewModelAction
|
|||
import im.vector.riotx.features.userdirectory.PendingInvitee
|
||||
|
||||
sealed class InviteUsersToRoomAction : VectorViewModelAction {
|
||||
data class InviteSelectedUsers(val selectedUsers: Set<PendingInvitee>) : InviteUsersToRoomAction()
|
||||
data class InviteSelectedUsers(val invitees: Set<PendingInvitee>) : InviteUsersToRoomAction()
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ import im.vector.riotx.core.utils.PERMISSION_REQUEST_CODE_READ_CONTACTS
|
|||
import im.vector.riotx.core.utils.allGranted
|
||||
import im.vector.riotx.core.utils.checkPermissions
|
||||
import im.vector.riotx.core.utils.toast
|
||||
import im.vector.riotx.features.phonebook.PhoneBookFragment
|
||||
import im.vector.riotx.features.phonebook.PhoneBookViewModel
|
||||
import im.vector.riotx.features.contactsbook.ContactsBookFragment
|
||||
import im.vector.riotx.features.contactsbook.ContactsBookViewModel
|
||||
import im.vector.riotx.features.userdirectory.KnownUsersFragment
|
||||
import im.vector.riotx.features.userdirectory.KnownUsersFragmentArgs
|
||||
import im.vector.riotx.features.userdirectory.UserDirectoryFragment
|
||||
|
@ -60,7 +60,7 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() {
|
|||
private lateinit var sharedActionViewModel: UserDirectorySharedActionViewModel
|
||||
@Inject lateinit var userDirectoryViewModelFactory: UserDirectoryViewModel.Factory
|
||||
@Inject lateinit var inviteUsersToRoomViewModelFactory: InviteUsersToRoomViewModel.Factory
|
||||
@Inject lateinit var phoneBookViewModelFactory: PhoneBookViewModel.Factory
|
||||
@Inject lateinit var contactsBookViewModelFactory: ContactsBookViewModel.Factory
|
||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
|
@ -107,21 +107,21 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() {
|
|||
this,
|
||||
PERMISSION_REQUEST_CODE_READ_CONTACTS,
|
||||
0)) {
|
||||
addFragmentToBackstack(R.id.container, PhoneBookFragment::class.java)
|
||||
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||
if (allGranted(grantResults)) {
|
||||
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
|
||||
addFragmentToBackstack(R.id.container, PhoneBookFragment::class.java)
|
||||
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onMenuItemSelected(action: UserDirectorySharedAction.OnMenuItemSelected) {
|
||||
if (action.itemId == R.id.action_invite_users_to_room_invite) {
|
||||
viewModel.handle(InviteUsersToRoomAction.InviteSelectedUsers(action.selectedUsers))
|
||||
viewModel.handle(InviteUsersToRoomAction.InviteSelectedUsers(action.invitees))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,30 +53,30 @@ class InviteUsersToRoomViewModel @AssistedInject constructor(@Assisted
|
|||
|
||||
override fun handle(action: InviteUsersToRoomAction) {
|
||||
when (action) {
|
||||
is InviteUsersToRoomAction.InviteSelectedUsers -> inviteUsersToRoom(action.selectedUsers)
|
||||
is InviteUsersToRoomAction.InviteSelectedUsers -> inviteUsersToRoom(action.invitees)
|
||||
}
|
||||
}
|
||||
|
||||
private fun inviteUsersToRoom(selectedUsers: Set<PendingInvitee>) {
|
||||
private fun inviteUsersToRoom(invitees: Set<PendingInvitee>) {
|
||||
_viewEvents.post(InviteUsersToRoomViewEvents.Loading)
|
||||
|
||||
Observable.fromIterable(selectedUsers).flatMapCompletable { user ->
|
||||
Observable.fromIterable(invitees).flatMapCompletable { user ->
|
||||
when (user) {
|
||||
is PendingInvitee.UserPendingInvitee -> room.rx().invite(user.user.userId, null)
|
||||
is PendingInvitee.ThreePidPendingInvitee -> room.rx().invite3pid(user.threePid)
|
||||
}
|
||||
}.subscribe(
|
||||
{
|
||||
val successMessage = when (selectedUsers.size) {
|
||||
val successMessage = when (invitees.size) {
|
||||
1 -> stringProvider.getString(R.string.invitation_sent_to_one_user,
|
||||
selectedUsers.first().getBestName())
|
||||
invitees.first().getBestName())
|
||||
2 -> stringProvider.getString(R.string.invitations_sent_to_two_users,
|
||||
selectedUsers.first().getBestName(),
|
||||
selectedUsers.last().getBestName())
|
||||
invitees.first().getBestName(),
|
||||
invitees.last().getBestName())
|
||||
else -> stringProvider.getQuantityString(R.plurals.invitations_sent_to_one_and_more_users,
|
||||
selectedUsers.size - 1,
|
||||
selectedUsers.first().getBestName(),
|
||||
selectedUsers.size - 1)
|
||||
invitees.size - 1,
|
||||
invitees.first().getBestName(),
|
||||
invitees.size - 1)
|
||||
}
|
||||
_viewEvents.post(InviteUsersToRoomViewEvents.Success(successMessage))
|
||||
},
|
||||
|
|
|
@ -65,7 +65,7 @@ class KnownUsersFragment @Inject constructor(
|
|||
setupAddByMatrixIdView()
|
||||
setupAddFromPhoneBookView()
|
||||
setupCloseView()
|
||||
viewModel.selectSubscribe(this, UserDirectoryViewState::selectedUsers) {
|
||||
viewModel.selectSubscribe(this, UserDirectoryViewState::pendingInvitees) {
|
||||
renderSelectedUsers(it)
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class KnownUsersFragment @Inject constructor(
|
|||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
withState(viewModel) {
|
||||
val showMenuItem = it.selectedUsers.isNotEmpty()
|
||||
val showMenuItem = it.pendingInvitees.isNotEmpty()
|
||||
menu.forEach { menuItem ->
|
||||
menuItem.isVisible = showMenuItem
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class KnownUsersFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean = withState(viewModel) {
|
||||
sharedActionViewModel.post(UserDirectorySharedAction.OnMenuItemSelected(item.itemId, it.selectedUsers))
|
||||
sharedActionViewModel.post(UserDirectorySharedAction.OnMenuItemSelected(item.itemId, it.pendingInvitees))
|
||||
return@withState true
|
||||
}
|
||||
|
||||
|
@ -139,14 +139,14 @@ class KnownUsersFragment @Inject constructor(
|
|||
knownUsersController.setData(it)
|
||||
}
|
||||
|
||||
private fun renderSelectedUsers(selectedUsers: Set<PendingInvitee>) {
|
||||
private fun renderSelectedUsers(invitees: Set<PendingInvitee>) {
|
||||
invalidateOptionsMenu()
|
||||
|
||||
val currentNumberOfChips = chipGroup.childCount
|
||||
val newNumberOfChips = selectedUsers.size
|
||||
val newNumberOfChips = invitees.size
|
||||
|
||||
chipGroup.removeAllViews()
|
||||
selectedUsers.forEach { addChipToGroup(it) }
|
||||
invitees.forEach { addChipToGroup(it) }
|
||||
|
||||
// Scroll to the bottom when adding chips. When removing chips, do not scroll
|
||||
if (newNumberOfChips >= currentNumberOfChips) {
|
||||
|
|
|
@ -23,5 +23,5 @@ sealed class UserDirectorySharedAction : VectorSharedAction {
|
|||
object OpenPhoneBook : UserDirectorySharedAction()
|
||||
object Close : UserDirectorySharedAction()
|
||||
object GoBack : UserDirectorySharedAction()
|
||||
data class OnMenuItemSelected(val itemId: Int, val selectedUsers: Set<PendingInvitee>) : UserDirectorySharedAction()
|
||||
data class OnMenuItemSelected(val itemId: Int, val invitees: Set<PendingInvitee>) : UserDirectorySharedAction()
|
||||
}
|
||||
|
|
|
@ -86,15 +86,15 @@ class UserDirectoryViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
|
||||
private fun handleRemoveSelectedUser(action: UserDirectoryAction.RemovePendingInvitee) = withState { state ->
|
||||
val selectedUsers = state.selectedUsers.minus(action.pendingInvitee)
|
||||
setState { copy(selectedUsers = selectedUsers) }
|
||||
val selectedUsers = state.pendingInvitees.minus(action.pendingInvitee)
|
||||
setState { copy(pendingInvitees = selectedUsers) }
|
||||
}
|
||||
|
||||
private fun handleSelectUser(action: UserDirectoryAction.SelectPendingInvitee) = withState { state ->
|
||||
// Reset the filter asap
|
||||
directoryUsersSearch.accept("")
|
||||
val selectedUsers = state.selectedUsers.toggle(action.pendingInvitee)
|
||||
setState { copy(selectedUsers = selectedUsers) }
|
||||
val selectedUsers = state.pendingInvitees.toggle(action.pendingInvitee)
|
||||
setState { copy(pendingInvitees = selectedUsers) }
|
||||
}
|
||||
|
||||
private fun observeDirectoryUsers() = withState { state ->
|
||||
|
|
|
@ -27,7 +27,7 @@ data class UserDirectoryViewState(
|
|||
val excludedUserIds: Set<String>? = null,
|
||||
val knownUsers: Async<PagedList<User>> = Uninitialized,
|
||||
val directoryUsers: Async<List<User>> = Uninitialized,
|
||||
val selectedUsers: Set<PendingInvitee> = emptySet(),
|
||||
val pendingInvitees: Set<PendingInvitee> = emptySet(),
|
||||
val createAndInviteState: Async<String> = Uninitialized,
|
||||
val directorySearchTerm: String = "",
|
||||
val filterKnownUsersValue: Option<String> = Option.empty()
|
||||
|
@ -36,7 +36,7 @@ data class UserDirectoryViewState(
|
|||
constructor(args: KnownUsersFragmentArgs) : this(excludedUserIds = args.excludedUserIds)
|
||||
|
||||
fun getSelectedMatrixId(): List<String> {
|
||||
return selectedUsers
|
||||
return pendingInvitees
|
||||
.mapNotNull {
|
||||
when (it) {
|
||||
is PendingInvitee.UserPendingInvitee -> it.user.userId
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
android:layout_marginEnd="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/phone_book_title"
|
||||
android:text="@string/contacts_book_title"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
|
@ -97,7 +97,7 @@
|
|||
android:id="@+id/phoneBookFilterDivider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="?attr/vctr_list_divider_color"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
|
@ -132,7 +132,7 @@
|
|||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:minHeight="@dimen/layout_touch_size"
|
||||
android:text="@string/add_from_phone_book"
|
||||
android:text="@string/search_in_my_contacts"
|
||||
android:visibility="visible"
|
||||
app:icon="@drawable/ic_plus_circle"
|
||||
app:iconPadding="13dp"
|
||||
|
|
|
@ -2545,4 +2545,8 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
|
|||
<string name="add_from_phone_book">Add from my phone book</string>
|
||||
<string name="empty_phone_book">Your phone book is empty</string>
|
||||
<string name="phone_book_title">Phone book</string>
|
||||
<string name="search_in_my_contacts">Search in my contacts</string>
|
||||
<string name="loading_contact_book">Retrieving your contacts…</string>
|
||||
<string name="empty_contact_book">Your contact book is empty</string>
|
||||
<string name="contacts_book_title">Contacts book</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue