Add badge in thread list filtering

This commit is contained in:
ariskotsomitopoulos 2022-05-04 19:24:31 +03:00
parent faf5fc0012
commit c5fc1e579d
8 changed files with 100 additions and 8 deletions

View file

@ -136,4 +136,9 @@
<color name="shield_color_black">#17191C</color>
<color name="shield_color_warning">#FF4B55</color>
<!-- Badge Colors -->
<attr name="vctr_badge_color_border" format="color" />
<color name="vctr_badge_color_border_light">#FFFFFF</color>
<color name="vctr_badge_color_border_dark">#21262C</color>
</resources>

View file

@ -30,6 +30,7 @@
<item name="vctr_toolbar_background">@color/element_system_dark</item>
<item name="vctr_message_bubble_inbound">@color/vctr_message_bubble_inbound_dark</item>
<item name="vctr_message_bubble_outbound">@color/vctr_message_bubble_outbound_dark</item>
<item name="vctr_badge_color_border">@color/vctr_badge_color_border_dark</item>
<!-- room message colors -->
<item name="vctr_notice_secondary">#61708B</item>

View file

@ -30,6 +30,7 @@
<item name="vctr_toolbar_background">@color/element_background_light</item>
<item name="vctr_message_bubble_inbound">@color/vctr_message_bubble_inbound_light</item>
<item name="vctr_message_bubble_outbound">@color/vctr_message_bubble_outbound_light</item>
<item name="vctr_badge_color_border">@color/vctr_badge_color_border_light</item>
<!-- room message colors -->
<item name="vctr_notice_secondary">#61708B</item>

View file

@ -19,6 +19,7 @@ package im.vector.app.features.home.room.threads.list.views
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
@ -70,6 +71,16 @@ class ThreadListFragment @Inject constructor(
analyticsScreenName = MobileScreen.ScreenName.ThreadList
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
menu.findItem(R.id.menu_thread_list_filter)?.let { menuItem ->
menuItem.actionView.setOnClickListener {
onOptionsItemSelected(menuItem)
}
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.menu_thread_list_filter -> {
@ -82,6 +93,9 @@ class ThreadListFragment @Inject constructor(
override fun onPrepareOptionsMenu(menu: Menu) {
withState(threadListViewModel) { state ->
val filterIcon = menu.findItem(R.id.menu_thread_list_filter).actionView
val filterBadge = filterIcon.findViewById<View>(R.id.threadListFilterBadge)
filterBadge.isVisible = state.shouldFilterThreads
when (threadListViewModel.canHomeserverUseThreading()) {
true -> menu.findItem(R.id.menu_thread_list_filter).isVisible = !state.threadSummaryList.invoke().isNullOrEmpty()
false -> menu.findItem(R.id.menu_thread_list_filter).isVisible = !state.rootThreadEventList.invoke().isNullOrEmpty()
@ -112,7 +126,8 @@ class ThreadListFragment @Inject constructor(
private fun initTextConstants() {
views.threadListEmptyNoticeTextView.text = String.format(
resources.getString(R.string.thread_list_empty_notice),
resources.getString(R.string.reply_in_thread))
resources.getString(R.string.reply_in_thread)
)
}
private fun initBetaFeedback() {
@ -149,7 +164,8 @@ class ThreadListFragment @Inject constructor(
displayName = threadListArgs.displayName,
avatarUrl = threadListArgs.avatarUrl,
roomEncryptionTrustLevel = null,
rootThreadEventId = threadSummary.rootEventId)
rootThreadEventId = threadSummary.rootEventId
)
(activity as? ThreadsActivity)?.navigateToThreadTimeline(roomThreadDetailArgs)
}
@ -159,7 +175,8 @@ class ThreadListFragment @Inject constructor(
displayName = threadListArgs.displayName,
avatarUrl = threadListArgs.avatarUrl,
roomEncryptionTrustLevel = null,
rootThreadEventId = timelineEvent.eventId)
rootThreadEventId = timelineEvent.eventId
)
(activity as? ThreadsActivity)?.navigateToThreadTimeline(threadTimelineArgs)
}

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<size
android:width="10dp"
android:height="10dp" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="3dp"
android:top="3dp" />
<stroke
android:color="?vctr_badge_color_border"
android:width="3dp"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<size
android:width="10dp"
android:height="10dp" />
<solid android:color="?colorPrimary" />
</shape>
</item>
</layer-list>

View file

@ -92,7 +92,7 @@
android:maxWidth="496dp"
android:minWidth="144dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/threadSummaryTitleTextView"
app:layout_constraintTop_toBottomOf="@id/threadSummaryRootMessageTextView"
@ -108,4 +108,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/threadSummaryConstraintLayout"
app:layout_constraintTop_toBottomOf="@id/threadSummaryConstraintLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,38 @@
<?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="@dimen/menu_item_size"
android:layout_height="@dimen/menu_item_size">
<FrameLayout
android:layout_width="@dimen/menu_item_ripple_size"
android:layout_height="@dimen/menu_item_ripple_size"
android:layout_gravity="center"
android:background="?attr/selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="@dimen/menu_item_icon_size"
android:layout_height="@dimen/menu_item_icon_size"
android:layout_gravity="center"
android:src="@drawable/ic_filter"
tools:ignore="ContentDescription" />
<View
android:id="@+id/threadListFilterBadge"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:layout_gravity="top|end"
android:background="@drawable/thread_filter_badge"
android:visibility="visible"
tools:visibility="visible" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -5,9 +5,10 @@
<item
android:id="@+id/menu_thread_list_filter"
android:icon="@drawable/ic_filter"
android:title="@string/room_threads_filter"
app:actionLayout="@layout/view_thread_list_filter"
app:iconTint="?vctr_content_secondary"
app:showAsAction="ifRoom" />
app:showAsAction="always"
tools:visible="true" />
</menu>
</menu>