cleaning + rebase
This commit is contained in:
parent
b1ab6eb58f
commit
28a6caf754
|
@ -17,6 +17,7 @@
|
|||
package im.vector.app.features.form
|
||||
|
||||
import android.text.Editable
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.TextView
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
|
|
|
@ -99,11 +99,13 @@ class CreateRoomController @Inject constructor(
|
|||
}
|
||||
if (viewState.roomVisibilityType is CreateRoomViewState.RoomVisibilityType.Public) {
|
||||
// Room alias for public room
|
||||
roomAliasEditItem {
|
||||
formEditTextItem {
|
||||
id("alias")
|
||||
enabled(enableFormElement)
|
||||
value(viewState.roomVisibilityType.aliasLocalPart)
|
||||
homeServer(":" + viewState.homeServerName)
|
||||
inputSuffix(":" + viewState.homeServerName)
|
||||
inputPrefix("#")
|
||||
hint(host.stringProvider.getString(R.string.room_alias_address_hint))
|
||||
errorMessage(
|
||||
host.roomAliasErrorFormatter.format(
|
||||
(((viewState.asyncCreateRoomRequest as? Fail)?.error) as? CreateRoomFailure.AliasError)?.aliasError)
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright 2019 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.roomdirectory.createroom
|
||||
|
||||
import android.text.Editable
|
||||
import android.widget.TextView
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.TextListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.addTextChangedListenerOnce
|
||||
import im.vector.app.core.epoxy.setValueOnce
|
||||
import im.vector.app.core.platform.SimpleTextWatcher
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_room_alias_text_input)
|
||||
abstract class RoomAliasEditItem : VectorEpoxyModel<RoomAliasEditItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute
|
||||
var value: String? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var errorMessage: String? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var homeServer: String? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var enabled: Boolean = true
|
||||
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var onTextChange: TextListener? = null
|
||||
|
||||
private val onTextChangeListener = object : SimpleTextWatcher() {
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
onTextChange?.invoke(s.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textInputLayout.isEnabled = enabled
|
||||
holder.textInputLayout.error = errorMessage
|
||||
|
||||
holder.setValueOnce(holder.textInputEditText, value)
|
||||
holder.textInputEditText.isEnabled = enabled
|
||||
holder.textInputEditText.addTextChangedListenerOnce(onTextChangeListener)
|
||||
holder.homeServerText.text = homeServer
|
||||
}
|
||||
|
||||
override fun shouldSaveViewState(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun unbind(holder: Holder) {
|
||||
super.unbind(holder)
|
||||
holder.textInputEditText.removeTextChangedListener(onTextChangeListener)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val textInputLayout by bind<TextInputLayout>(R.id.itemRoomAliasTextInputLayout)
|
||||
val textInputEditText by bind<TextInputEditText>(R.id.itemRoomAliasTextInputEditText)
|
||||
val homeServerText by bind<TextView>(R.id.itemRoomAliasHomeServer)
|
||||
}
|
||||
}
|
|
@ -36,7 +36,6 @@ import im.vector.app.features.discovery.settingsInfoItem
|
|||
import im.vector.app.features.form.formEditTextItem
|
||||
import im.vector.app.features.form.formSwitchItem
|
||||
import im.vector.app.features.roomdirectory.createroom.RoomAliasErrorFormatter
|
||||
import im.vector.app.features.roomdirectory.createroom.roomAliasEditItem
|
||||
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomType
|
||||
|
@ -246,10 +245,12 @@ class RoomAliasController @Inject constructor(
|
|||
}
|
||||
}
|
||||
is RoomAliasViewState.AddAliasState.Editing -> {
|
||||
roomAliasEditItem {
|
||||
formEditTextItem {
|
||||
id("newLocalAlias")
|
||||
value(data.newLocalAliasState.value)
|
||||
homeServer(":" + data.homeServerName)
|
||||
inputSuffix(":" + data.homeServerName)
|
||||
inputPrefix("#")
|
||||
hint(host.stringProvider.getString(R.string.room_alias_address_hint))
|
||||
errorMessage(host.roomAliasErrorFormatter.format((data.newLocalAliasState.asyncRequest as? Fail)?.error as? RoomAliasError))
|
||||
onTextChange { value ->
|
||||
host.callback?.setNewLocalAliasLocalPart(value)
|
||||
|
|
|
@ -102,7 +102,6 @@ class SpaceDetailEpoxyController @Inject constructor(
|
|||
(((data.aliasVerificationTask as? Fail)?.error) as? RoomAliasError))
|
||||
)
|
||||
onTextChange(host.aliasTextWatcher)
|
||||
showBottomSeparator(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ class SpaceSettingsController @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val isPublic = (data.newRoomJoinRules.newJoinRules ?: data.currentRoomJoinRules) == RoomJoinRules.PUBLIC
|
||||
if (vectorPreferences.labsUseExperimentalRestricted()) {
|
||||
buildProfileAction(
|
||||
id = "joinRule",
|
||||
|
@ -114,7 +115,6 @@ class SpaceSettingsController @Inject constructor(
|
|||
action = { if (data.actionPermissions.canChangeJoinRule) callback?.onJoinRuleClicked() }
|
||||
)
|
||||
} else {
|
||||
val isPublic = (data.newRoomJoinRules.newJoinRules ?: data.currentRoomJoinRules) == RoomJoinRules.PUBLIC
|
||||
formSwitchItem {
|
||||
id("isPublic")
|
||||
enabled(data.actionPermissions.canChangeJoinRule)
|
||||
|
@ -134,18 +134,18 @@ class SpaceSettingsController @Inject constructor(
|
|||
id = "manage_rooms",
|
||||
title = stringProvider.getString(R.string.space_settings_manage_rooms),
|
||||
// subtitle = data.getJoinRuleWording(stringProvider),
|
||||
divider = vectorPreferences.developerMode(),
|
||||
divider = true,
|
||||
editable = data.actionPermissions.canAddChildren,
|
||||
action = {
|
||||
if (data.actionPermissions.canAddChildren) callback?.onManageRooms()
|
||||
}
|
||||
)
|
||||
if (roomSummary.isPublic) {
|
||||
|
||||
if (isPublic) {
|
||||
buildProfileAction(
|
||||
id = "alias",
|
||||
title = stringProvider.getString(R.string.space_settings_alias_title),
|
||||
subtitle = stringProvider.getString(R.string.space_settings_alias_subtitle),
|
||||
dividerColor = dividerColor,
|
||||
divider = true,
|
||||
editable = true,
|
||||
action = { callback?.onRoomAliasesClicked() }
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:colorBackground"
|
||||
android:minHeight="@dimen/item_form_min_height">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemRoomAliasHash"
|
||||
style="@style/Widget.Vector.TextView.HeadlineMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||
android:text="@string/matrix_room_alias_prefix"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/itemRoomAliasTextInputLayout"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/itemRoomAliasTextInputLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:errorEnabled="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/itemRoomAliasHomeServer"
|
||||
app:layout_constraintStart_toEndOf="@+id/itemRoomAliasHash"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<!-- android:imeOptions="actionDone" to fix a crash -->
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/itemRoomAliasTextInputEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/create_room_alias_hint"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemRoomAliasHomeServer"
|
||||
style="@style/Widget.Vector.TextView.HeadlineMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||
android:maxWidth="200dp"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/itemRoomAliasTextInputLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text=":matrix.org" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue