Add encryption shield

Change thread list filtering UI tick to radio buttons
This commit is contained in:
ariskotsomitopoulos 2022-01-14 18:42:57 +02:00
parent ff87f07f65
commit 3a3cce85f8
12 changed files with 62 additions and 20 deletions

View file

@ -1594,6 +1594,7 @@ class TimelineFragment @Inject constructor(
timelineArgs.threadTimelineArgs?.let {
val matrixItem = MatrixItem.RoomItem(it.roomId, it.displayName, it.avatarUrl)
avatarRenderer.render(matrixItem, views.includeThreadToolbar.roomToolbarThreadImageView)
views.includeThreadToolbar.roomToolbarThreadShieldImageView.render(it.roomEncryptionTrustLevel)
views.includeThreadToolbar.roomToolbarThreadSubtitleTextView.text = it.displayName
}
views.includeThreadToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_timeline_title)
@ -2321,6 +2322,7 @@ class TimelineFragment @Inject constructor(
roomId = timelineArgs.roomId,
displayName = roomDetailViewModel.getRoomSummary()?.displayName,
avatarUrl = roomDetailViewModel.getRoomSummary()?.avatarUrl,
roomEncryptionTrustLevel = roomDetailViewModel.getRoomSummary()?.roomEncryptionTrustLevel,
rootThreadEventId = rootThreadEventId)
navigator.openThread(it, roomThreadDetailArgs)
}
@ -2336,6 +2338,7 @@ class TimelineFragment @Inject constructor(
val roomThreadDetailArgs = ThreadTimelineArgs(
roomId = timelineArgs.roomId,
displayName = roomDetailViewModel.getRoomSummary()?.displayName,
roomEncryptionTrustLevel = roomDetailViewModel.getRoomSummary()?.roomEncryptionTrustLevel,
avatarUrl = roomDetailViewModel.getRoomSummary()?.avatarUrl)
navigator.openThreadList(it, roomThreadDetailArgs)
}

View file

@ -126,7 +126,12 @@ class SearchFragment @Inject constructor(
private fun navigateToEvent(event: Event) {
val roomId = event.roomId ?: return
event.getRootThreadEventId()?.let {
val threadTimelineArgs = ThreadTimelineArgs(roomId, displayName = fragmentArgs.roomDisplayName, fragmentArgs.roomAvatarUrl, it)
val threadTimelineArgs = ThreadTimelineArgs(
roomId = roomId,
displayName = fragmentArgs.roomDisplayName,
avatarUrl = fragmentArgs.roomAvatarUrl,
roomEncryptionTrustLevel = null,
rootThreadEventId = it)
navigator.openThread(requireContext(), threadTimelineArgs, event.eventId)
} ?: navigator.openRoom(requireContext(), roomId, event.eventId)
}

View file

@ -100,6 +100,7 @@ class ThreadsActivity : VectorBaseActivity<ActivityThreadsBinding>(), ToolbarCon
roomId = timelineEvent.roomId,
displayName = timelineEvent.senderInfo.displayName,
avatarUrl = timelineEvent.senderInfo.avatarUrl,
roomEncryptionTrustLevel = null,
rootThreadEventId = timelineEvent.eventId)
val commonOption: (FragmentTransaction) -> Unit = {
it.setCustomAnimations(

View file

@ -18,10 +18,12 @@ package im.vector.app.features.home.room.threads.arguments
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
@Parcelize
data class ThreadListArgs(
val roomId: String,
val displayName: String?,
val avatarUrl: String?,
val roomEncryptionTrustLevel: RoomEncryptionTrustLevel?
) : Parcelable

View file

@ -18,11 +18,13 @@ package im.vector.app.features.home.room.threads.arguments
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
@Parcelize
data class ThreadTimelineArgs(
val roomId: String,
val displayName: String?,
val avatarUrl: String?,
val roomEncryptionTrustLevel: RoomEncryptionTrustLevel?,
val rootThreadEventId: String? = null
) : Parcelable

View file

@ -16,17 +16,21 @@
package im.vector.app.features.home.room.threads.list.views
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.AttrRes
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.airbnb.mvrx.parentFragmentViewModel
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.databinding.BottomSheetThreadListBinding
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListViewModel
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListViewState
import im.vector.app.features.themes.ThemeUtils
class ThreadListBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetThreadListBinding>() {
@ -53,8 +57,29 @@ class ThreadListBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetThr
}
private fun renderState(state: ThreadListViewState) {
val tickDrawable = ContextCompat.getDrawable(requireContext(), R.drawable.ic_tick)
views.threadListModalAllThreads.rightIcon = if (state.shouldFilterThreads) null else tickDrawable
views.threadListModalMyThreads.rightIcon = if (state.shouldFilterThreads) tickDrawable else null
val radioOffDrawable = ContextCompat.getDrawable(requireContext(), R.drawable.ic_radio_off)
val radioOnDrawable = ContextCompat.getDrawable(requireContext(), R.drawable.ic_radio_on)
if (state.shouldFilterThreads) {
setRightIconDrawableAllThreads(radioOffDrawable, R.attr.vctr_content_primary)
setRightIconDrawableMyThreads(radioOnDrawable, R.attr.colorPrimary)
} else {
setRightIconDrawableAllThreads(radioOnDrawable, R.attr.colorPrimary)
setRightIconDrawableMyThreads(radioOffDrawable, R.attr.vctr_content_primary)
}
}
private fun setRightIconDrawableAllThreads(drawable: Drawable?, @AttrRes tint: Int) {
views.threadListModalAllThreads.rightIcon = drawable
views.threadListModalAllThreads.rightIcon?.setTintFromAttribute(tint)
}
private fun setRightIconDrawableMyThreads(drawable: Drawable?, @AttrRes tint: Int) {
views.threadListModalMyThreads.rightIcon = drawable
views.threadListModalMyThreads.rightIcon?.setTintFromAttribute(tint)
}
private fun Drawable.setTintFromAttribute(@AttrRes tint: Int) {
DrawableCompat.setTint(this, ThemeUtils.getColor(requireContext(), tint))
}
}

View file

@ -99,6 +99,7 @@ class ThreadListFragment @Inject constructor(
views.includeThreadListToolbar.roomToolbarThreadConstraintLayout.isVisible = true
val matrixItem = MatrixItem.RoomItem(threadListArgs.roomId, threadListArgs.displayName, threadListArgs.avatarUrl)
avatarRenderer.render(matrixItem, views.includeThreadListToolbar.roomToolbarThreadImageView)
views.includeThreadListToolbar.roomToolbarThreadShieldImageView.render(threadListArgs.roomEncryptionTrustLevel)
views.includeThreadListToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_list_title)
views.includeThreadListToolbar.roomToolbarThreadSubtitleTextView.text = threadListArgs.displayName
}

View file

@ -569,7 +569,8 @@ class DefaultNavigator @Inject constructor(
threadListArgs = ThreadListArgs(
roomId = threadTimelineArgs.roomId,
displayName = threadTimelineArgs.displayName,
avatarUrl = threadTimelineArgs.avatarUrl
avatarUrl = threadTimelineArgs.avatarUrl,
roomEncryptionTrustLevel = threadTimelineArgs.roomEncryptionTrustLevel
)))
}
}

View file

@ -201,7 +201,12 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
) {
if (this?.navToRoom(roomId, eventId, rawLink, rootThreadEventId) != true) {
rootThreadEventId?.let {
val threadTimelineArgs = ThreadTimelineArgs(roomId, displayName = roomSummary.displayName, roomSummary.avatarUrl, it)
val threadTimelineArgs = ThreadTimelineArgs(
roomId = roomId,
displayName = roomSummary.displayName,
avatarUrl = roomSummary.avatarUrl,
roomEncryptionTrustLevel = roomSummary.roomEncryptionTrustLevel,
rootThreadEventId = it)
navigator.openThread(context, threadTimelineArgs, eventId)
} ?: navigator.openRoom(context, roomId, eventId, buildTask)
}

View file

@ -4,17 +4,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4,6.5h16"
android:strokeWidth="1.8"
android:fillColor="#00000000"
android:strokeColor="#9E9E9E"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
<path
android:pathData="M6,12.5h12M9,18.5h6"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#9E9E9E"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
android:pathData="M10.9996,18H12.9996C13.5496,18 13.9996,17.55 13.9996,17C13.9996,16.45 13.5496,16 12.9996,16H10.9996C10.4496,16 9.9996,16.45 9.9996,17C9.9996,17.55 10.4496,18 10.9996,18ZM2.9996,7C2.9996,7.55 3.4496,8 3.9996,8H19.9996C20.5496,8 20.9996,7.55 20.9996,7C20.9996,6.45 20.5496,6 19.9996,6H3.9996C3.4496,6 2.9996,6.45 2.9996,7ZM6.9996,13H16.9996C17.5496,13 17.9996,12.55 17.9996,12C17.9996,11.45 17.5496,11 16.9996,11H6.9996C6.4496,11 5.9996,11.45 5.9996,12C5.9996,12.55 6.4496,13 6.9996,13Z"
android:fillColor="#737D8C"/>
</vector>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurface"

View file

@ -35,6 +35,15 @@
app:layout_constraintTop_toBottomOf="@id/roomToolbarThreadTitleTextView"
tools:src="@sample/room_round_avatars" />
<im.vector.app.core.ui.views.ShieldImageView
android:id="@+id/roomToolbarThreadShieldImageView"
android:layout_width="10dp"
android:layout_height="10dp"
app:layout_constraintCircle="@id/roomToolbarThreadImageView"
app:layout_constraintCircleAngle="135"
app:layout_constraintCircleRadius="10dp"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/roomToolbarThreadSubtitleTextView"
style="@style/Widget.Vector.TextView.Caption"