Change hint for encrypted room (fix #210)

This commit is contained in:
Benoit Marty 2019-06-26 18:49:55 +02:00
parent 33f17e4c5c
commit 25b7bf76bf
5 changed files with 17 additions and 4 deletions

View file

@ -501,6 +501,7 @@ class RoomDetailFragment :
} else if (state.asyncInviter.complete) {
vectorBaseActivity.finish()
}
composerLayout.setRoomEncrypted(state.isEncrypted)
}
private fun renderRoomSummary(state: RoomDetailViewState) {

View file

@ -484,7 +484,10 @@ class RoomDetailViewModel(initialState: RoomDetailViewState,
private fun observeRoomSummary() {
room.rx().liveRoomSummary()
.execute { async ->
copy(asyncRoomSummary = async)
copy(
asyncRoomSummary = async,
isEncrypted = room.isEncrypted()
)
}
}

View file

@ -46,7 +46,8 @@ data class RoomDetailViewState(
val asyncInviter: Async<User> = Uninitialized,
val asyncRoomSummary: Async<RoomSummary> = Uninitialized,
val sendMode: SendMode = SendMode.REGULAR,
val selectedEvent: TimelineEvent? = null
val selectedEvent: TimelineEvent? = null,
val isEncrypted: Boolean = false
) : MvRxState {
constructor(args: RoomDetailArgs) : this(roomId = args.roomId, eventId = args.eventId)

View file

@ -9,7 +9,6 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible
import androidx.transition.AutoTransition
import androidx.transition.Transition
import androidx.transition.TransitionManager
@ -113,4 +112,13 @@ class TextComposerView @JvmOverloads constructor(context: Context, attrs: Attrib
it.applyTo(this)
}
}
fun setRoomEncrypted(isEncrypted: Boolean) {
composerEditText.setHint(
if (isEncrypted) {
R.string.room_message_placeholder_encrypted
} else {
R.string.room_message_placeholder_not_encrypted
})
}
}

View file

@ -116,12 +116,12 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:hint="@string/room_message_placeholder_not_encrypted"
android:nextFocusLeft="@id/composerEditText"
android:nextFocusUp="@id/composerEditText"
android:padding="8dp"
android:textColor="?vctr_message_text_color"
android:textSize="14sp"
tools:hint="@string/room_message_placeholder_not_encrypted"
tools:ignore="MissingConstraints" />
</merge>