mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Address comments.
This commit is contained in:
parent
de5b2ad460
commit
fe800a56e2
9 changed files with 49 additions and 67 deletions
|
@ -113,8 +113,8 @@ class RoomProfileActivity :
|
|||
RoomProfileSharedAction.OpenRoomAliasesSettings -> openRoomAlias()
|
||||
RoomProfileSharedAction.OpenRoomPermissionsSettings -> openRoomPermissions()
|
||||
RoomProfileSharedAction.OpenRoomUploads -> openRoomUploads()
|
||||
RoomProfileSharedAction.OpenBannedRoomMembers -> openBannedRoomMembers()
|
||||
RoomProfileSharedAction.OpenRoomNotificaitonSettings -> openRoomNotificationSettings()
|
||||
RoomProfileSharedAction.OpenBannedRoomMembers -> openBannedRoomMembers()
|
||||
RoomProfileSharedAction.OpenRoomNotificationSettings -> openRoomNotificationSettings()
|
||||
}.exhaustive
|
||||
}
|
||||
.disposeOnDestroy()
|
||||
|
|
|
@ -255,7 +255,7 @@ class RoomProfileFragment @Inject constructor(
|
|||
|
||||
override fun onNotificationsClicked() {
|
||||
if (BuildConfig.USE_NOTIFICATION_SETTINGS_V2) {
|
||||
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomNotificaitonSettings)
|
||||
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomNotificationSettings)
|
||||
} else {
|
||||
RoomListQuickActionsBottomSheet
|
||||
.newInstance(roomProfileArgs.roomId, RoomListActionsArgs.Mode.NOTIFICATIONS)
|
||||
|
|
|
@ -28,5 +28,5 @@ sealed class RoomProfileSharedAction : VectorSharedAction {
|
|||
object OpenRoomUploads : RoomProfileSharedAction()
|
||||
object OpenRoomMembers : RoomProfileSharedAction()
|
||||
object OpenBannedRoomMembers : RoomProfileSharedAction()
|
||||
object OpenRoomNotificaitonSettings : RoomProfileSharedAction()
|
||||
object OpenRoomNotificationSettings : RoomProfileSharedAction()
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
|
|||
}
|
||||
notificationSettingsFooterItem {
|
||||
id("roomNotificationSettingsFooter")
|
||||
encrypted(data.roomEncrypted)
|
||||
encrypted(data.roomSummary()?.isEncrypted == true)
|
||||
clickListener {
|
||||
host.callback?.didSelectAccountSettingsLink()
|
||||
}
|
||||
|
|
|
@ -24,10 +24,12 @@ import androidx.core.view.isVisible
|
|||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.cleanup
|
||||
import im.vector.app.core.extensions.configureWith
|
||||
import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.databinding.FragmentRoomSettingGenericBinding
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import javax.inject.Inject
|
||||
|
@ -53,6 +55,13 @@ class RoomNotificationSettingsFragment @Inject constructor(
|
|||
setupWaitingView()
|
||||
observeViewEvents()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
views.roomSettingsRecyclerView.cleanup()
|
||||
roomNotificationSettingsController.callback = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
private fun setupWaitingView() {
|
||||
views.waitingView.waitingStatusText.setText(R.string.please_wait)
|
||||
views.waitingView.waitingStatusText.isVisible = true
|
||||
|
@ -77,7 +86,7 @@ class RoomNotificationSettingsFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun didSelectAccountSettingsLink() {
|
||||
navigator.openSettings(requireContext())
|
||||
navigator.openSettings(requireContext(), VectorSettingsActivity.EXTRA_DIRECT_ACCESS_NOTIFICATIONS)
|
||||
}
|
||||
|
||||
private fun renderRoomSummary(state: RoomNotificationSettingsViewState) {
|
||||
|
|
|
@ -59,17 +59,10 @@ class RoomNotificationSettingsViewModel @AssistedInject constructor(
|
|||
private val room = session.getRoom(initialState.roomId)!!
|
||||
|
||||
init {
|
||||
initEncrypted()
|
||||
observeSummary()
|
||||
observeNotificationState()
|
||||
}
|
||||
|
||||
private fun initEncrypted() {
|
||||
setState {
|
||||
copy(roomEncrypted = room.isEncrypted())
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeSummary() {
|
||||
room.rx().liveRoomSummary()
|
||||
.unwrap()
|
||||
|
@ -96,10 +89,19 @@ class RoomNotificationSettingsViewModel @AssistedInject constructor(
|
|||
setState { copy(isLoading = true) }
|
||||
viewModelScope.launch {
|
||||
runCatching { room.setRoomNotificationState(action.notificationState) }
|
||||
.onFailure { _viewEvents.post(RoomNotificationSettingsViewEvents.Failure(it)) }
|
||||
setState {
|
||||
copy(isLoading = false, notificationState = Success(action.notificationState))
|
||||
}
|
||||
.fold(
|
||||
{
|
||||
setState {
|
||||
copy(isLoading = false, notificationState = Success(action.notificationState))
|
||||
}
|
||||
},
|
||||
{
|
||||
setState {
|
||||
copy(isLoading = false)
|
||||
}
|
||||
_viewEvents.post(RoomNotificationSettingsViewEvents.Failure(it))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,24 +29,18 @@ data class RoomNotificationSettingsViewState(
|
|||
val roomId: String,
|
||||
val roomSummary: Async<RoomSummary> = Uninitialized,
|
||||
val isLoading: Boolean = false,
|
||||
val roomEncrypted: Boolean = false,
|
||||
val notificationState: Async<RoomNotificationState> = Uninitialized
|
||||
) : MvRxState {
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
constructor(args: RoomListActionsArgs) : this(roomId = args.roomId)
|
||||
}
|
||||
|
||||
data class AvatarData(
|
||||
val displayName: String,
|
||||
val avatarUrl: String
|
||||
)
|
||||
|
||||
/**
|
||||
* Used to map this old room notification settings to the new options in v2.
|
||||
*/
|
||||
val RoomNotificationSettingsViewState.notificationStateMapped: Async<RoomNotificationState>
|
||||
get() {
|
||||
if ((roomEncrypted && notificationState() == RoomNotificationState.MENTIONS_ONLY) || notificationState() == RoomNotificationState.ALL_MESSAGES) {
|
||||
if ((roomSummary()?.isEncrypted == true && notificationState() == RoomNotificationState.MENTIONS_ONLY) || notificationState() == RoomNotificationState.ALL_MESSAGES) {
|
||||
/** if in an encrypted room, mentions notifications are not supported so show "All Messages" as selected.
|
||||
* Also in the new settings there is no notion of notifications without sound so it maps to noisy also
|
||||
*/
|
||||
|
@ -59,7 +53,7 @@ val RoomNotificationSettingsViewState.notificationStateMapped: Async<RoomNotific
|
|||
*/
|
||||
val RoomNotificationSettingsViewState.notificationOptions: List<RoomNotificationState>
|
||||
get() {
|
||||
return if (roomEncrypted) {
|
||||
return if (roomSummary()?.isEncrypted == true) {
|
||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
|
||||
} else {
|
||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/Widget.Vector.TextView.Body"
|
||||
android:id="@+id/footerText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/layout_vertical_margin"
|
||||
android:paddingHorizontal="@dimen/layout_horizontal_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/footerText"
|
||||
style="@style/Widget.Vector.TextView.Body"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:textColor="?vctr_content_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
tools:text="@string/room_settings_room_notifications_encryption_notice" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:paddingStart="@dimen/layout_horizontal_margin"
|
||||
android:paddingTop="@dimen/layout_vertical_margin"
|
||||
android:paddingEnd="@dimen/layout_horizontal_margin"
|
||||
android:paddingBottom="@dimen/layout_vertical_margin"
|
||||
android:textColor="?vctr_content_secondary"
|
||||
tools:text="@string/room_settings_room_notifications_encryption_notice" />
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/headerText"
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/layout_vertical_margin"
|
||||
android:paddingHorizontal="@dimen/layout_horizontal_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headerText"
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:textColor="?vctr_content_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
tools:text="@string/room_settings_room_notifications_notify_me" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:paddingStart="@dimen/layout_horizontal_margin"
|
||||
android:paddingTop="@dimen/layout_vertical_margin"
|
||||
android:paddingEnd="@dimen/layout_horizontal_margin"
|
||||
android:paddingBottom="@dimen/layout_vertical_margin"
|
||||
android:textColor="?vctr_content_secondary"
|
||||
android:textStyle="bold"
|
||||
tools:text="@string/room_settings_room_notifications_notify_me" />
|
Loading…
Reference in a new issue