mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Merge pull request #1224 from vector-im/feature/composer_shield
Add shield in composer
This commit is contained in:
commit
66f6b1ecac
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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,19 @@ 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)
|
||||
composerShieldImageView.isVisible = true
|
||||
val shieldRes = when (roomEncryptionTrustLevel) {
|
||||
RoomEncryptionTrustLevel.Trusted -> R.drawable.ic_shield_trusted
|
||||
RoomEncryptionTrustLevel.Warning -> R.drawable.ic_shield_warning
|
||||
else -> R.drawable.ic_shield_black
|
||||
}
|
||||
composerShieldImageView.setImageDrawable(ContextCompat.getDrawable(context, shieldRes))
|
||||
} else {
|
||||
composerEditText.setHint(R.string.room_message_placeholder)
|
||||
composerShieldImageView.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composer_shield"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
app:layout_constraintTop_toTopOf="@id/composer_avatar_view"
|
||||
app:layout_constraintEnd_toStartOf="@+id/composerEditText"
|
||||
app:layout_constraintBottom_toBottomOf="@id/composer_avatar_view"
|
||||
app:layout_constraintStart_toEndOf="@+id/composer_avatar_view"
|
||||
tools:src="@drawable/ic_shield_black"
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/attachmentButton"
|
||||
android:layout_width="48dp"
|
||||
@ -154,11 +167,11 @@
|
||||
android:minHeight="48dp"
|
||||
android:nextFocusLeft="@id/composerEditText"
|
||||
android:nextFocusUp="@id/composerEditText"
|
||||
android:padding="16dp"
|
||||
android:padding="8dp"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/attachmentButton"
|
||||
app:layout_constraintStart_toEndOf="@+id/composer_avatar_view"
|
||||
app:layout_constraintStart_toEndOf="@+id/composer_shield"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
|
@ -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" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composer_shield"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
app:layout_constraintTop_toTopOf="@id/composer_avatar_view"
|
||||
app:layout_constraintEnd_toStartOf="@+id/composerEditText"
|
||||
app:layout_constraintBottom_toBottomOf="@id/composer_avatar_view"
|
||||
app:layout_constraintStart_toEndOf="@+id/composer_avatar_view"
|
||||
tools:src="@drawable/ic_shield_black"
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/attachmentButton"
|
||||
android:layout_width="48dp"
|
||||
@ -161,7 +176,7 @@
|
||||
android:minHeight="48dp"
|
||||
android:nextFocusLeft="@id/composerEditText"
|
||||
android:nextFocusUp="@id/composerEditText"
|
||||
android:padding="16dp"
|
||||
android:padding="8dp"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/sendButton"
|
||||
|
@ -39,6 +39,13 @@
|
||||
tools:ignore="MissingConstraints"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composer_shield"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
tools:ignore="MissingConstraints"
|
||||
tools:src="@drawable/ic_shield_black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/composer_related_message_sender"
|
||||
android:layout_width="0dp"
|
||||
|
@ -6,7 +6,7 @@
|
||||
<!-- Sections has been created to avoid merge conflict. Let's see if it's better -->
|
||||
|
||||
<!-- BEGIN Strings added by Valere -->
|
||||
|
||||
<string name="room_message_placeholder">Message…</string>
|
||||
<!-- END Strings added by Valere -->
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user