mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 18:36:21 +03:00
Add shield in composer
This commit is contained in:
parent
391d3cb6b5
commit
c35d854776
7 changed files with 71 additions and 19 deletions
|
@ -19,6 +19,7 @@ Improvements 🙌:
|
||||||
- Cross-Signing | Restore history after recover from passphrase (#1214)
|
- Cross-Signing | Restore history after recover from passphrase (#1214)
|
||||||
- Cross-Sign | QR code scan confirmation screens design update (#1187)
|
- Cross-Sign | QR code scan confirmation screens design update (#1187)
|
||||||
- Emoji Verification | It's not the same butterfly! (#1220)
|
- Emoji Verification | It's not the same butterfly! (#1220)
|
||||||
|
- Cross-Signing | Composer decoration: shields (#1077)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Missing avatar/displayname after verification request message (#841)
|
- Missing avatar/displayname after verification request message (#841)
|
||||||
|
|
|
@ -700,7 +700,7 @@ class RoomDetailFragment @Inject constructor(
|
||||||
val isRoomEncrypted = summary?.isEncrypted ?: false
|
val isRoomEncrypted = summary?.isEncrypted ?: false
|
||||||
if (state.tombstoneEvent == null) {
|
if (state.tombstoneEvent == null) {
|
||||||
composerLayout.visibility = View.VISIBLE
|
composerLayout.visibility = View.VISIBLE
|
||||||
composerLayout.setRoomEncrypted(isRoomEncrypted)
|
composerLayout.setRoomEncrypted(isRoomEncrypted, state.asyncRoomSummary.invoke()?.roomEncryptionTrustLevel)
|
||||||
notificationAreaView.render(NotificationAreaView.State.Hidden)
|
notificationAreaView.render(NotificationAreaView.State.Hidden)
|
||||||
} else {
|
} else {
|
||||||
composerLayout.visibility = View.GONE
|
composerLayout.visibility = View.GONE
|
||||||
|
|
|
@ -26,12 +26,15 @@ import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.constraintlayout.widget.ConstraintSet
|
import androidx.constraintlayout.widget.ConstraintSet
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.text.toSpannable
|
import androidx.core.text.toSpannable
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.transition.AutoTransition
|
import androidx.transition.AutoTransition
|
||||||
import androidx.transition.Transition
|
import androidx.transition.Transition
|
||||||
import androidx.transition.TransitionManager
|
import androidx.transition.TransitionManager
|
||||||
import butterknife.BindView
|
import butterknife.BindView
|
||||||
import butterknife.ButterKnife
|
import butterknife.ButterKnife
|
||||||
|
import im.vector.matrix.android.api.crypto.RoomEncryptionTrustLevel
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import kotlinx.android.synthetic.main.merge_composer_layout.view.*
|
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
|
lateinit var composerEditText: ComposerEditText
|
||||||
@BindView(R.id.composer_avatar_view)
|
@BindView(R.id.composer_avatar_view)
|
||||||
lateinit var composerAvatarImageView: ImageView
|
lateinit var composerAvatarImageView: ImageView
|
||||||
|
@BindView(R.id.composer_shield)
|
||||||
|
lateinit var composerShieldImageView: ImageView
|
||||||
|
|
||||||
private var currentConstraintSetId: Int = -1
|
private var currentConstraintSetId: Int = -1
|
||||||
|
|
||||||
|
@ -158,12 +163,23 @@ class TextComposerView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRoomEncrypted(isEncrypted: Boolean) {
|
fun setRoomEncrypted(isEncrypted: Boolean, roomEncryptionTrustLevel: RoomEncryptionTrustLevel?) {
|
||||||
composerEditText.setHint(
|
|
||||||
if (isEncrypted) {
|
if (isEncrypted) {
|
||||||
R.string.room_message_placeholder_encrypted
|
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 {
|
} else {
|
||||||
R.string.room_message_placeholder_not_encrypted
|
composerEditText.setHint(R.string.room_message_placeholder_not_encrypted)
|
||||||
})
|
composerShieldImageView.isVisible = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,18 +99,31 @@
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="32dp"
|
android:layout_height="32dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="4dp"
|
||||||
android:layout_marginRight="8dp"
|
app:layout_goneMarginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/composerEditText"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="1"
|
app:layout_constraintVertical_bias="1"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/composer_shield"
|
||||||
tools:src="@tools:sample/avatars" />
|
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
|
<ImageButton
|
||||||
android:id="@+id/attachmentButton"
|
android:id="@+id/attachmentButton"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
|
@ -154,11 +167,11 @@
|
||||||
android:minHeight="48dp"
|
android:minHeight="48dp"
|
||||||
android:nextFocusLeft="@id/composerEditText"
|
android:nextFocusLeft="@id/composerEditText"
|
||||||
android:nextFocusUp="@id/composerEditText"
|
android:nextFocusUp="@id/composerEditText"
|
||||||
android:padding="16dp"
|
android:padding="8dp"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/attachmentButton"
|
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"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="@tools:sample/lorem/random" />
|
tools:text="@tools:sample/lorem/random" />
|
||||||
|
|
||||||
|
|
|
@ -107,17 +107,32 @@
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="4dp"
|
||||||
|
app:layout_goneMarginEnd="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
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_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="1"
|
app:layout_constraintVertical_bias="1"
|
||||||
tools:src="@tools:sample/avatars" />
|
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
|
<ImageButton
|
||||||
android:id="@+id/attachmentButton"
|
android:id="@+id/attachmentButton"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
|
@ -161,7 +176,7 @@
|
||||||
android:minHeight="48dp"
|
android:minHeight="48dp"
|
||||||
android:nextFocusLeft="@id/composerEditText"
|
android:nextFocusLeft="@id/composerEditText"
|
||||||
android:nextFocusUp="@id/composerEditText"
|
android:nextFocusUp="@id/composerEditText"
|
||||||
android:padding="16dp"
|
android:padding="8dp"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/sendButton"
|
app:layout_constraintEnd_toStartOf="@+id/sendButton"
|
||||||
|
|
|
@ -39,6 +39,13 @@
|
||||||
tools:ignore="MissingConstraints"
|
tools:ignore="MissingConstraints"
|
||||||
tools:src="@tools:sample/avatars" />
|
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
|
<TextView
|
||||||
android:id="@+id/composer_related_message_sender"
|
android:id="@+id/composer_related_message_sender"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -515,8 +515,8 @@
|
||||||
<string name="room_one_user_is_typing">%s is typing…</string>
|
<string name="room_one_user_is_typing">%s is typing…</string>
|
||||||
<string name="room_two_users_are_typing">%1$s & %2$s are typing…</string>
|
<string name="room_two_users_are_typing">%1$s & %2$s are typing…</string>
|
||||||
<string name="room_many_users_are_typing">%1$s & %2$s & others are typing…</string>
|
<string name="room_many_users_are_typing">%1$s & %2$s & others are typing…</string>
|
||||||
<string name="room_message_placeholder_encrypted">Send an encrypted message…</string>
|
<string name="room_message_placeholder_encrypted">Message…</string>
|
||||||
<string name="room_message_placeholder_not_encrypted">Send a message (unencrypted)…</string>
|
<string name="room_message_placeholder_not_encrypted">Message…</string>
|
||||||
<string name="room_message_placeholder_reply_to_encrypted">Send an encrypted reply…</string>
|
<string name="room_message_placeholder_reply_to_encrypted">Send an encrypted reply…</string>
|
||||||
<string name="room_message_placeholder_reply_to_not_encrypted">Send a reply (unencrypted)…</string>
|
<string name="room_message_placeholder_reply_to_not_encrypted">Send a reply (unencrypted)…</string>
|
||||||
<string name="room_offline_notification">Connectivity to the server has been lost.</string>
|
<string name="room_offline_notification">Connectivity to the server has been lost.</string>
|
||||||
|
|
Loading…
Reference in a new issue