Cleanup and link

This commit is contained in:
David Langley 2021-08-11 14:31:00 +01:00
parent 92a44cd9d6
commit 00275d9367
11 changed files with 51 additions and 39 deletions

View File

@ -723,7 +723,6 @@ interface FragmentModule {
@FragmentKey(RoomNotificationSettingsFragment::class)
fun bindRoomNotificationSettingsFragment(fragment: RoomNotificationSettingsFragment): Fragment
@Binds
@IntoMap
@FragmentKey(SearchFragment::class)

View File

@ -36,8 +36,6 @@ abstract class NotificationSettingsFooterItem : VectorEpoxyModel<NotificationSet
override fun bind(holder: Holder) {
super.bind(holder)
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))
if (encrypted) {

View File

@ -28,7 +28,6 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick
@EpoxyModelClass(layout = R.layout.item_radio)
abstract class RadioButtonItem : VectorEpoxyModel<RadioButtonItem.Holder>() {

View File

@ -36,8 +36,9 @@ abstract class TextHeaderItem : VectorEpoxyModel<TextHeaderItem.Holder>() {
override fun bind(holder: Holder) {
super.bind(holder)
if (textRes != null) {
holder.textView.setText(textRes!!)
val textResource = textRes
if (textResource != null) {
holder.textView.setText(textResource)
} else {
holder.textView.text = text
}

View File

@ -483,7 +483,6 @@ class RoomListFragment @Inject constructor(
bottomSheet.show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS")
return true
}

View File

@ -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
)

View File

@ -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.RoomNotificationSettingsViewEvents
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewModel
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewState
import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
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
*/
@ -98,7 +92,7 @@ class RoomListQuickActionsBottomSheet :
roomListActionsEpoxyController.listener = this
viewModel.observeViewEvents {
when(it){
when (it) {
is RoomNotificationSettingsViewEvents.Failure -> listener?.handleFailure(it.throwable)
}
}

View File

@ -43,20 +43,12 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
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) {
val notificationViewState = state.notificationSettingsViewState
val roomSummary = notificationViewState.roomSummary() ?: return
val host = this
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) {
// Preview, favorite, settings
@ -102,9 +94,15 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
if (showFull || isV2) {
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) {
val host = this@RoomListQuickActionsEpoxyController
val selected = when (this) {
@ -117,9 +115,9 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
return bottomSheetActionItem {
id("action_$index")
selected(selected)
if(iconResId != null){
if (iconResId != null) {
iconRes(iconResId)
} else{
} else {
showIcon(false)
}
textRes(titleRes)

View File

@ -21,7 +21,6 @@ import androidx.annotation.StringRes
import im.vector.app.R
import im.vector.app.core.platform.VectorSharedAction
sealed class RoomListQuickActionsSharedAction(
@StringRes val titleRes: Int,
@DrawableRes val iconResId: Int?,
@ -61,7 +60,7 @@ sealed class RoomListQuickActionsSharedAction(
R.string.room_list_quick_actions_favorite_add,
R.drawable.ic_star_24dp)
data class Leave(val roomId: String, val showIcon: Boolean=true) : RoomListQuickActionsSharedAction(
data class Leave(val roomId: String, val showIcon: Boolean = true) : RoomListQuickActionsSharedAction(
R.string.room_list_quick_actions_leave,
if (showIcon) R.drawable.ic_room_actions_leave else null,
true

View File

@ -38,14 +38,6 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
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?) {
val host = this
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
}
}

View File

@ -30,13 +30,13 @@ data class RoomNotificationSettingsViewState(
val roomSummary: Async<RoomSummary> = Uninitialized,
val isLoading: Boolean = false,
val roomEncrypted: Boolean = false,
val notificationState: Async<RoomNotificationState> = Uninitialized,
val notificationState: Async<RoomNotificationState> = Uninitialized
) : MvRxState {
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
constructor(args: RoomListActionsArgs) : this(roomId = args.roomId)
}
data class AvatarData (
data class AvatarData(
val displayName: String,
val avatarUrl: String
)
@ -61,6 +61,7 @@ val RoomNotificationSettingsViewState.notificationOptions: List<RoomNotification
get() {
return if (roomEncrypted) {
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
} else
} else {
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
}
}