mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
a11y
This commit is contained in:
parent
daa007b67d
commit
e7a29857c5
15 changed files with 60 additions and 30 deletions
|
@ -18,6 +18,7 @@ package im.vector.app.core.ui.views
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
|
@ -54,3 +55,12 @@ class ShieldImageView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
fun RoomEncryptionTrustLevel.toDrawableRes(): Int {
|
||||
return when (this) {
|
||||
RoomEncryptionTrustLevel.Default -> R.drawable.ic_shield_black
|
||||
RoomEncryptionTrustLevel.Warning -> R.drawable.ic_shield_warning
|
||||
RoomEncryptionTrustLevel.Trusted -> R.drawable.ic_shield_trusted
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package im.vector.app.features.settings.devices
|
|||
|
||||
import android.graphics.Typeface
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
|
@ -27,6 +26,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.ui.views.ShieldImageView
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
||||
|
@ -75,6 +75,7 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
|||
super.bind(holder)
|
||||
holder.root.setOnClickListener { itemClickAction?.invoke() }
|
||||
|
||||
if (e2eCapable) {
|
||||
val shield = TrustUtils.shieldForTrust(
|
||||
currentDevice,
|
||||
trustedSession,
|
||||
|
@ -82,10 +83,9 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
|||
trusted
|
||||
)
|
||||
|
||||
if (e2eCapable) {
|
||||
holder.trustIcon.setImageResource(shield)
|
||||
holder.trustIcon.render(shield)
|
||||
} else {
|
||||
holder.trustIcon.setImageDrawable(null)
|
||||
holder.trustIcon.render(null)
|
||||
}
|
||||
|
||||
val detailedModeLabels = listOf(
|
||||
|
@ -152,6 +152,6 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
|||
val deviceLastSeenLabelText by bind<TextView>(R.id.itemDeviceLastSeenLabel)
|
||||
val deviceLastSeenText by bind<TextView>(R.id.itemDeviceLastSeen)
|
||||
|
||||
val trustIcon by bind<ImageView>(R.id.itemDeviceTrustLevelIcon)
|
||||
val trustIcon by bind<ShieldImageView>(R.id.itemDeviceTrustLevelIcon)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import im.vector.app.core.resources.StringProvider
|
|||
import im.vector.app.core.ui.list.GenericItem
|
||||
import im.vector.app.core.ui.list.genericFooterItem
|
||||
import im.vector.app.core.ui.list.genericItem
|
||||
import im.vector.app.core.ui.views.toDrawableRes
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
||||
|
@ -62,7 +63,7 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor(
|
|||
trustMSK = data.accountCrossSigningIsTrusted,
|
||||
legacyMode = !data.hasAccountCrossSigning,
|
||||
deviceTrustLevel = cryptoDeviceInfo.trustLevel
|
||||
)
|
||||
).toDrawableRes()
|
||||
|
||||
if (data.hasAccountCrossSigning) {
|
||||
// Cross Signing is enabled
|
||||
|
|
|
@ -16,38 +16,50 @@
|
|||
|
||||
package im.vector.app.features.settings.devices
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import im.vector.app.R
|
||||
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
||||
|
||||
object TrustUtils {
|
||||
|
||||
@DrawableRes
|
||||
fun shieldForTrust(currentDevice: Boolean, trustMSK: Boolean, legacyMode: Boolean, deviceTrustLevel: DeviceTrustLevel?): Int {
|
||||
fun shieldForTrust(currentDevice: Boolean,
|
||||
trustMSK: Boolean,
|
||||
legacyMode: Boolean,
|
||||
deviceTrustLevel: DeviceTrustLevel?): RoomEncryptionTrustLevel {
|
||||
return when {
|
||||
currentDevice -> {
|
||||
if (legacyMode) {
|
||||
// In legacy, current session is always trusted
|
||||
R.drawable.ic_shield_trusted
|
||||
RoomEncryptionTrustLevel.Trusted
|
||||
} else {
|
||||
// If current session doesn't trust MSK, show red shield for current device
|
||||
R.drawable.ic_shield_trusted.takeIf { trustMSK } ?: R.drawable.ic_shield_warning
|
||||
if (trustMSK) {
|
||||
RoomEncryptionTrustLevel.Trusted
|
||||
} else {
|
||||
RoomEncryptionTrustLevel.Warning
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if (legacyMode) {
|
||||
// use local trust
|
||||
R.drawable.ic_shield_trusted.takeIf { deviceTrustLevel?.locallyVerified == true } ?: R.drawable.ic_shield_warning
|
||||
if (deviceTrustLevel?.locallyVerified == true) {
|
||||
RoomEncryptionTrustLevel.Trusted
|
||||
} else {
|
||||
RoomEncryptionTrustLevel.Warning
|
||||
}
|
||||
} else {
|
||||
if (trustMSK) {
|
||||
// use cross sign trust, put locally trusted in black
|
||||
R.drawable.ic_shield_trusted.takeIf { deviceTrustLevel?.crossSigningVerified == true }
|
||||
?: R.drawable.ic_shield_black.takeIf { deviceTrustLevel?.locallyVerified == true }
|
||||
?: R.drawable.ic_shield_warning
|
||||
when {
|
||||
deviceTrustLevel?.crossSigningVerified == true -> RoomEncryptionTrustLevel.Trusted
|
||||
|
||||
deviceTrustLevel?.locallyVerified == true -> RoomEncryptionTrustLevel.Default
|
||||
else -> RoomEncryptionTrustLevel.Warning
|
||||
}
|
||||
} else {
|
||||
// The current session is untrusted, so displays others in black
|
||||
// as we can't know the cross-signing state
|
||||
R.drawable.ic_shield_black
|
||||
RoomEncryptionTrustLevel.Default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/cancel"
|
||||
android:src="@drawable/ic_close_round"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toTopOf="parent"
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/action_close"
|
||||
android:contentDescription="@string/cancel"
|
||||
android:src="@drawable/ic_close_round"
|
||||
app:layout_constraintBottom_toBottomOf="@id/composerRelatedMessageContent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/room_list_quick_actions_low_priority_add"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_low_priority_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bottomSheetRoomPreviewAvatar"
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
android:id="@+id/createDirectRoomUserAvatarChecked"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@string/a11y_checked"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_material_done"
|
||||
android:visibility="visible"
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
<im.vector.app.core.ui.views.ShieldImageView
|
||||
android:id="@+id/itemDeviceTrustLevelIcon"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
android:id="@+id/knownUserAvatarChecked"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@string/a11y_checked"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_material_done"
|
||||
android:visibility="visible"
|
||||
app:tint="@android:color/white"
|
||||
tools:ignore="MissingPrefix" />
|
||||
</FrameLayout>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<ImageView
|
||||
<im.vector.app.core.ui.views.ShieldImageView
|
||||
android:id="@+id/matrixItemAvatarDecoration"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
|
|
|
@ -41,9 +41,9 @@
|
|||
android:id="@+id/roomAvatarCheckedImageView"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:contentDescription="@string/a11y_checked"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_material_done"
|
||||
android:visibility="visible"
|
||||
app:tint="@android:color/white"
|
||||
tools:ignore="MissingPrefix" />
|
||||
|
||||
|
|
|
@ -50,14 +50,14 @@
|
|||
android:id="@+id/messageVerificationRequestStub"
|
||||
style="@style/TimelineContentStubBaseParams"
|
||||
android:layout="@layout/item_timeline_event_verification_stub"
|
||||
tools:layout_marginTop= "250dp"
|
||||
tools:layout_marginTop="250dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/messageVerificationDoneStub"
|
||||
style="@style/TimelineContentStubBaseParams"
|
||||
tools:layout_marginTop= "450dp"
|
||||
android:layout="@layout/item_timeline_event_status_tile_stub"
|
||||
tools:layout_marginTop="450dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ViewStub
|
||||
|
@ -88,6 +88,7 @@
|
|||
android:layout_alignTop="@+id/viewStubContainer"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_toEndOf="@+id/viewStubContainer"
|
||||
android:contentDescription="@string/a11y_error_message_not_sent"
|
||||
android:src="@drawable/ic_warning_badge"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:contentDescription="@string/a11y_error_message_not_sent"
|
||||
android:src="@drawable/ic_warning_badge"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/messageThumbnailView"
|
||||
|
|
|
@ -2845,4 +2845,6 @@
|
|||
<string name="a11y_trust_level_trusted">Trusted trust level</string>
|
||||
<string name="a11y_open_emoji_picker">Open Emoji picker</string>
|
||||
<string name="a11y_close_emoji_picker">Close Emoji picker</string>
|
||||
<string name="a11y_checked">Checked</string>
|
||||
<string name="a11y_error_message_not_sent">Message not sent due to error</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue