diff --git a/CHANGES.md b/CHANGES.md index e7f920d788..c1c0a62105 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Improvements 🙌: - Cross-Signing | Restore history after recover from passphrase (#1214) - Cross-Sign | QR code scan confirmation screens design update (#1187) - Emoji Verification | It's not the same butterfly! (#1220) + - Cross-Signing | Composer decoration: shields (#1077) Bugfix 🐛: - Missing avatar/displayname after verification request message (#841) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index 8c45090c91..86f4847ff7 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -700,7 +700,7 @@ class RoomDetailFragment @Inject constructor( val isRoomEncrypted = summary?.isEncrypted ?: false if (state.tombstoneEvent == null) { composerLayout.visibility = View.VISIBLE - composerLayout.setRoomEncrypted(isRoomEncrypted) + composerLayout.setRoomEncrypted(isRoomEncrypted, state.asyncRoomSummary.invoke()?.roomEncryptionTrustLevel) notificationAreaView.render(NotificationAreaView.State.Hidden) } else { composerLayout.visibility = View.GONE diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/TextComposerView.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/TextComposerView.kt index 593ce1a8f6..b494c901a6 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/TextComposerView.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/TextComposerView.kt @@ -26,12 +26,15 @@ import android.widget.ImageView import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet +import androidx.core.content.ContextCompat import androidx.core.text.toSpannable +import androidx.core.view.isVisible import androidx.transition.AutoTransition import androidx.transition.Transition import androidx.transition.TransitionManager import butterknife.BindView import butterknife.ButterKnife +import im.vector.matrix.android.api.crypto.RoomEncryptionTrustLevel import im.vector.riotx.R import kotlinx.android.synthetic.main.merge_composer_layout.view.* @@ -64,6 +67,8 @@ class TextComposerView @JvmOverloads constructor(context: Context, attrs: Attrib lateinit var composerEditText: ComposerEditText @BindView(R.id.composer_avatar_view) lateinit var composerAvatarImageView: ImageView + @BindView(R.id.composer_shield) + lateinit var composerShieldImageView: ImageView private var currentConstraintSetId: Int = -1 @@ -158,12 +163,23 @@ class TextComposerView @JvmOverloads constructor(context: Context, attrs: Attrib } } - fun setRoomEncrypted(isEncrypted: Boolean) { - composerEditText.setHint( - if (isEncrypted) { - R.string.room_message_placeholder_encrypted - } else { - R.string.room_message_placeholder_not_encrypted - }) + fun setRoomEncrypted(isEncrypted: Boolean, roomEncryptionTrustLevel: RoomEncryptionTrustLevel?) { + if (isEncrypted) { + composerEditText.setHint(R.string.room_message_placeholder_encrypted) + composerShieldImageView.isVisible = true + val shield = when (roomEncryptionTrustLevel) { + RoomEncryptionTrustLevel.Trusted -> { + ContextCompat.getDrawable(context, R.drawable.ic_shield_trusted) + } + RoomEncryptionTrustLevel.Warning -> { + ContextCompat.getDrawable(context, R.drawable.ic_shield_warning) + } + else -> ContextCompat.getDrawable(context, R.drawable.ic_shield_black) + } + composerShieldImageView.setImageDrawable(shield) + } else { + composerEditText.setHint(R.string.room_message_placeholder_not_encrypted) + composerShieldImageView.isVisible = false + } } } diff --git a/vector/src/main/res/layout/constraint_set_composer_layout_compact.xml b/vector/src/main/res/layout/constraint_set_composer_layout_compact.xml index ac04dfe3ec..4607f28f34 100644 --- a/vector/src/main/res/layout/constraint_set_composer_layout_compact.xml +++ b/vector/src/main/res/layout/constraint_set_composer_layout_compact.xml @@ -99,18 +99,31 @@ android:layout_width="32dp" android:layout_height="32dp" android:layout_marginStart="8dp" - android:layout_marginLeft="8dp" android:layout_marginTop="8dp" - android:layout_marginEnd="8dp" - android:layout_marginRight="8dp" + android:layout_marginEnd="4dp" + app:layout_goneMarginEnd="8dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/composerEditText" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="1" + app:layout_constraintEnd_toStartOf="@+id/composer_shield" tools:src="@tools:sample/avatars" /> + + + + diff --git a/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml b/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml index d246c988e6..17b350542a 100644 --- a/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml +++ b/vector/src/main/res/layout/constraint_set_composer_layout_expanded.xml @@ -107,17 +107,32 @@ android:layout_marginStart="8dp" android:layout_marginLeft="8dp" android:layout_marginTop="8dp" - android:layout_marginEnd="8dp" + android:layout_marginEnd="4dp" + app:layout_goneMarginEnd="8dp" android:layout_marginRight="8dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/composerEditText" + app:layout_constraintEnd_toStartOf="@+id/composer_shield" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="1" tools:src="@tools:sample/avatars" /> + + + + + + %s is typing… %1$s & %2$s are typing… %1$s & %2$s & others are typing… - Send an encrypted message… - Send a message (unencrypted)… + Message… + Message… Send an encrypted reply… Send a reply (unencrypted)… Connectivity to the server has been lost.