mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Cleanup and link
This commit is contained in:
parent
92a44cd9d6
commit
00275d9367
11 changed files with 51 additions and 39 deletions
|
@ -723,7 +723,6 @@ interface FragmentModule {
|
||||||
@FragmentKey(RoomNotificationSettingsFragment::class)
|
@FragmentKey(RoomNotificationSettingsFragment::class)
|
||||||
fun bindRoomNotificationSettingsFragment(fragment: RoomNotificationSettingsFragment): Fragment
|
fun bindRoomNotificationSettingsFragment(fragment: RoomNotificationSettingsFragment): Fragment
|
||||||
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@FragmentKey(SearchFragment::class)
|
@FragmentKey(SearchFragment::class)
|
||||||
|
|
|
@ -36,8 +36,6 @@ abstract class NotificationSettingsFooterItem : VectorEpoxyModel<NotificationSet
|
||||||
|
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
|
|
||||||
|
|
||||||
val accountSettingsString = holder.view.context.getString(R.string.room_settings_room_notifications_account_settings)
|
val accountSettingsString = holder.view.context.getString(R.string.room_settings_room_notifications_account_settings)
|
||||||
val manageNotificationsString = StringBuilder(holder.view.context.getString(R.string.room_settings_room_notifications_manage_notifications, accountSettingsString))
|
val manageNotificationsString = StringBuilder(holder.view.context.getString(R.string.room_settings_room_notifications_manage_notifications, accountSettingsString))
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||||
import im.vector.app.core.epoxy.onClick
|
import im.vector.app.core.epoxy.onClick
|
||||||
|
|
||||||
|
|
||||||
@EpoxyModelClass(layout = R.layout.item_radio)
|
@EpoxyModelClass(layout = R.layout.item_radio)
|
||||||
abstract class RadioButtonItem : VectorEpoxyModel<RadioButtonItem.Holder>() {
|
abstract class RadioButtonItem : VectorEpoxyModel<RadioButtonItem.Holder>() {
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,9 @@ abstract class TextHeaderItem : VectorEpoxyModel<TextHeaderItem.Holder>() {
|
||||||
|
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
if (textRes != null) {
|
val textResource = textRes
|
||||||
holder.textView.setText(textRes!!)
|
if (textResource != null) {
|
||||||
|
holder.textView.setText(textResource)
|
||||||
} else {
|
} else {
|
||||||
holder.textView.text = text
|
holder.textView.text = text
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,7 +483,6 @@ class RoomListFragment @Inject constructor(
|
||||||
|
|
||||||
bottomSheet.show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS")
|
bottomSheet.show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS")
|
||||||
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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.home.room.list.actions
|
||||||
|
|
||||||
|
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewState
|
||||||
|
|
||||||
|
data class RoomListQuickActionViewState(
|
||||||
|
val roomListActionsArgs: RoomListActionsArgs,
|
||||||
|
val notificationSettingsViewState: RoomNotificationSettingsViewState
|
||||||
|
)
|
|
@ -34,7 +34,6 @@ import im.vector.app.features.navigation.Navigator
|
||||||
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsAction
|
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsAction
|
||||||
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewEvents
|
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewEvents
|
||||||
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewModel
|
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewModel
|
||||||
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewState
|
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
|
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -51,11 +50,6 @@ data class RoomListActionsArgs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class RoomListQuickActionViewState(
|
|
||||||
val roomListActionsArgs: RoomListActionsArgs,
|
|
||||||
val notificationSettingsViewState: RoomNotificationSettingsViewState
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bottom sheet fragment that shows room information with list of contextual actions
|
* Bottom sheet fragment that shows room information with list of contextual actions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,20 +43,12 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
|
||||||
|
|
||||||
var listener: Listener? = null
|
var listener: Listener? = null
|
||||||
|
|
||||||
@StringRes
|
|
||||||
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when(notificationState) {
|
|
||||||
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
|
|
||||||
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
|
|
||||||
RoomNotificationState.MUTE -> R.string.room_settings_none
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun buildModels(state: RoomListQuickActionViewState) {
|
override fun buildModels(state: RoomListQuickActionViewState) {
|
||||||
val notificationViewState = state.notificationSettingsViewState
|
val notificationViewState = state.notificationSettingsViewState
|
||||||
val roomSummary = notificationViewState.roomSummary() ?: return
|
val roomSummary = notificationViewState.roomSummary() ?: return
|
||||||
val host = this
|
val host = this
|
||||||
val showFull = state.roomListActionsArgs.mode == RoomListActionsArgs.Mode.FULL
|
val showFull = state.roomListActionsArgs.mode == RoomListActionsArgs.Mode.FULL
|
||||||
var isV2 = BuildConfig.USE_NOTIFICATION_SETTINGS_V2
|
val isV2 = BuildConfig.USE_NOTIFICATION_SETTINGS_V2
|
||||||
|
|
||||||
if (showFull || isV2) {
|
if (showFull || isV2) {
|
||||||
// Preview, favorite, settings
|
// Preview, favorite, settings
|
||||||
|
@ -102,9 +94,15 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
|
||||||
if (showFull || isV2) {
|
if (showFull || isV2) {
|
||||||
RoomListQuickActionsSharedAction.Leave(roomSummary.roomId, showIcon = !isV2).toBottomSheetItem(5)
|
RoomListQuickActionsSharedAction.Leave(roomSummary.roomId, showIcon = !isV2).toBottomSheetItem(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when (notificationState) {
|
||||||
|
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
|
||||||
|
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
|
||||||
|
RoomNotificationState.MUTE -> R.string.room_settings_none
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
private fun RoomListQuickActionsSharedAction.toBottomSheetItem(index: Int, roomNotificationState: RoomNotificationState? = null) {
|
private fun RoomListQuickActionsSharedAction.toBottomSheetItem(index: Int, roomNotificationState: RoomNotificationState? = null) {
|
||||||
val host = this@RoomListQuickActionsEpoxyController
|
val host = this@RoomListQuickActionsEpoxyController
|
||||||
val selected = when (this) {
|
val selected = when (this) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import androidx.annotation.StringRes
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorSharedAction
|
import im.vector.app.core.platform.VectorSharedAction
|
||||||
|
|
||||||
|
|
||||||
sealed class RoomListQuickActionsSharedAction(
|
sealed class RoomListQuickActionsSharedAction(
|
||||||
@StringRes val titleRes: Int,
|
@StringRes val titleRes: Int,
|
||||||
@DrawableRes val iconResId: Int?,
|
@DrawableRes val iconResId: Int?,
|
||||||
|
|
|
@ -38,14 +38,6 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
|
||||||
setData(null)
|
setData(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
|
||||||
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when(notificationState) {
|
|
||||||
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
|
|
||||||
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
|
|
||||||
RoomNotificationState.MUTE -> R.string.room_settings_none
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun buildModels(data: RoomNotificationSettingsViewState?) {
|
override fun buildModels(data: RoomNotificationSettingsViewState?) {
|
||||||
val host = this
|
val host = this
|
||||||
data ?: return
|
data ?: return
|
||||||
|
@ -73,4 +65,12 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when (notificationState) {
|
||||||
|
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
|
||||||
|
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
|
||||||
|
RoomNotificationState.MUTE -> R.string.room_settings_none
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ data class RoomNotificationSettingsViewState(
|
||||||
val roomSummary: Async<RoomSummary> = Uninitialized,
|
val roomSummary: Async<RoomSummary> = Uninitialized,
|
||||||
val isLoading: Boolean = false,
|
val isLoading: Boolean = false,
|
||||||
val roomEncrypted: Boolean = false,
|
val roomEncrypted: Boolean = false,
|
||||||
val notificationState: Async<RoomNotificationState> = Uninitialized,
|
val notificationState: Async<RoomNotificationState> = Uninitialized
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||||
constructor(args: RoomListActionsArgs) : this(roomId = args.roomId)
|
constructor(args: RoomListActionsArgs) : this(roomId = args.roomId)
|
||||||
|
@ -61,6 +61,7 @@ val RoomNotificationSettingsViewState.notificationOptions: List<RoomNotification
|
||||||
get() {
|
get() {
|
||||||
return if (roomEncrypted) {
|
return if (roomEncrypted) {
|
||||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
|
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
|
||||||
} else
|
} else {
|
||||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
|
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue