Labs: setting to clear highlighted message on scroll

Change-Id: If07012f29159bb10cbd90f410955b49684891945
This commit is contained in:
SpiritCroc 2023-04-25 14:15:47 +02:00
parent 0cc0a191bc
commit aa34c108b5
5 changed files with 27 additions and 0 deletions

View File

@ -229,6 +229,9 @@
<string name="action_send_as_sticker">Send as sticker</string>
<string name="settings_clear_highlight_on_scroll">Clear highlight on scroll</string>
<string name="settings_clear_highlight_on_scroll_summary">Remove highlight from messages when you scroll</string>
<!-- SC-TMP, until merged upstream: https://github.com/vector-im/element-android/pull/5781 -->
<string name="settings_call_ringtone_use_default_stun_title">Allow fallback call assist server</string>
<string name="settings_call_ringtone_use_default_stun_summary">Will use %s as assist when your homeserver does not offer one (your IP address will be seen by the stun server during a call

View File

@ -323,6 +323,8 @@ class TimelineFragment :
private val lazyLoadedViews = RoomDetailLazyLoadedViews()
private val clearHighlightOnScroll by lazy { vectorPreferences.clearHighlightOnScroll() }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
analyticsScreenName = MobileScreen.ScreenName.Room
@ -1335,6 +1337,9 @@ class TimelineFragment :
// If we do not clear the focus manually, it will keep it forever?
// We want to listen to new focus events to re-enable the stickToBottom though.
messageComposerViewModel.handle(MessageComposerAction.ClearFocus)
if (clearHighlightOnScroll) {
timelineViewModel.clearHighlight()
}
}
super.onScrolled(recyclerView, dx, dy)
}

View File

@ -1153,6 +1153,12 @@ class TimelineViewModel @AssistedInject constructor(
_viewEvents.post(RoomDetailViewEvents.NavigateToEvent(targetEventId, action.isFirstUnreadEvent))
}
fun clearHighlight() = withState { state ->
if (state.highlightedEventId != null) {
setState { copy(highlightedEventId = null) }
}
}
private fun handleResendEvent(action: RoomDetailAction.ResendMessage) {
if (room == null) return
val targetEventId = action.eventId

View File

@ -263,6 +263,7 @@ class VectorPreferences @Inject constructor(
const val SETTINGS_ROOM_SORT_ORDER_NULL = "SETTINGS_ROOM_SORT_ORDER_NULL"
const val SETTINGS_ROOM_SORT_ORDER_NON_NULL = "SETTINGS_ROOM_SORT_ORDER_NON_NULL"
private const val SETTINGS_ENABLE_MEMBER_NAME_CLICK = "SETTINGS_ENABLE_MEMBER_NAME_CLICK"
private const val SETTINGS_CLEAR_HIGHLIGHT_ON_SCROLL = "SETTINGS_CLEAR_HIGHLIGHT_ON_SCROLL"
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
@ -1258,6 +1259,11 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_ENABLE_MEMBER_NAME_CLICK, true)
}
// SC addition
fun clearHighlightOnScroll(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_CLEAR_HIGHLIGHT_ON_SCROLL, false)
}
/**
* I likely do more fresh installs of the app than anyone else, so a shortcut to change some of the default settings to
@ -1286,6 +1292,7 @@ class VectorPreferences @Inject constructor(
.putBoolean(SETTINGS_FLOATING_DATE, true)
.putBoolean(SETTINGS_FOLLOW_SYSTEM_LOCALE, true)
.putBoolean(SETTINGS_ENABLE_MEMBER_NAME_CLICK, false)
.putBoolean(SETTINGS_CLEAR_HIGHLIGHT_ON_SCROLL, true)
.apply()
}

View File

@ -37,6 +37,12 @@
android:title="@string/settings_read_receipt_follows_read_marker"
android:summary="@string/settings_read_receipt_follows_read_marker_summary" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_CLEAR_HIGHLIGHT_ON_SCROLL"
android:title="@string/settings_clear_highlight_on_scroll"
android:summary="@string/settings_clear_highlight_on_scroll_summary" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"