mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Prepare alias bottom sheet
This commit is contained in:
parent
2cf2233643
commit
8f80f375f0
4 changed files with 16 additions and 14 deletions
|
@ -26,8 +26,10 @@ import androidx.core.widget.ImageViewCompat
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
@ -67,11 +69,11 @@ abstract class ProfileActionItem : VectorEpoxyModel<ProfileActionItem.Holder>()
|
|||
var destructive: Boolean = false
|
||||
|
||||
@EpoxyAttribute
|
||||
var listener: View.OnClickListener? = null
|
||||
var listener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener(listener)
|
||||
holder.view.onClick(listener)
|
||||
if (listener == null) {
|
||||
holder.view.isClickable = false
|
||||
}
|
||||
|
|
|
@ -59,9 +59,7 @@ fun EpoxyController.buildProfileAction(
|
|||
accessoryRes(accessory)
|
||||
accessoryMatrixItem(accessoryMatrixItem)
|
||||
avatarRenderer(avatarRenderer)
|
||||
listener { _ ->
|
||||
action?.invoke()
|
||||
}
|
||||
listener(action)
|
||||
}
|
||||
|
||||
if (divider) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.errorWithRetryItem
|
||||
import im.vector.app.core.epoxy.loadingItem
|
||||
import im.vector.app.core.epoxy.profiles.buildProfileSection
|
||||
import im.vector.app.core.epoxy.profiles.profileActionItem
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
|
@ -33,7 +34,6 @@ import im.vector.app.features.discovery.settingsInfoItem
|
|||
import im.vector.app.features.form.formEditTextItem
|
||||
import im.vector.app.features.roomdirectory.createroom.RoomAliasErrorFormatter
|
||||
import im.vector.app.features.roomdirectory.createroom.roomAliasEditItem
|
||||
import im.vector.app.features.settings.threepids.threePidItem
|
||||
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -48,12 +48,14 @@ class RoomAliasController @Inject constructor(
|
|||
fun toggleManualPublishForm()
|
||||
fun setNewAlias(value: String)
|
||||
fun addAlias()
|
||||
// TODO Delete some methods below
|
||||
fun removeAlias(altAlias: String)
|
||||
fun setCanonicalAlias(alias: String?)
|
||||
fun removeLocalAlias(alias: String)
|
||||
fun toggleLocalAliasForm()
|
||||
fun setNewLocalAliasLocalPart(value: String)
|
||||
fun addLocalAlias()
|
||||
fun openAlias(alias: String, isPublished: Boolean)
|
||||
}
|
||||
|
||||
var callback: Callback? = null
|
||||
|
@ -97,13 +99,10 @@ class RoomAliasController @Inject constructor(
|
|||
helperTextResId(R.string.room_alias_published_other)
|
||||
}
|
||||
data.alternativeAliases.forEachIndexed { idx, altAlias ->
|
||||
// TODO Rename this item to a more generic name
|
||||
threePidItem {
|
||||
profileActionItem {
|
||||
id("alt_$idx")
|
||||
title(altAlias)
|
||||
if (data.actionPermissions.canChangeCanonicalAlias) {
|
||||
deleteClickListener { callback?.removeAlias(altAlias) }
|
||||
}
|
||||
listener { callback?.openAlias(altAlias, true) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,11 +160,10 @@ class RoomAliasController @Inject constructor(
|
|||
}
|
||||
is Success -> {
|
||||
localAliases().forEachIndexed { idx, localAlias ->
|
||||
// TODO Rename this item to a more generic name
|
||||
threePidItem {
|
||||
profileActionItem {
|
||||
id("loc_$idx")
|
||||
title(localAlias)
|
||||
deleteClickListener { callback?.removeLocalAlias(localAlias) }
|
||||
listener { callback?.openAlias(localAlias, false) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,6 +140,10 @@ class RoomAliasFragment @Inject constructor(
|
|||
viewModel.handle(RoomAliasAction.AddLocalAlias)
|
||||
}
|
||||
|
||||
override fun openAlias(alias: String, isPublished: Boolean) {
|
||||
TODO()
|
||||
}
|
||||
|
||||
override fun removeLocalAlias(alias: String) {
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.dialog_title_confirmation)
|
||||
|
|
Loading…
Reference in a new issue