VectorPreferences: Add switch for autoplaying animated images

This patch adds a new switch to VectorPreferences, the vector settings
preferences view and various classes propergating the set value of the
switch into parts of the application touched by the following patches.

Signed-off-by: networkException <git@nwex.de>
This commit is contained in:
networkException 2022-05-26 17:26:27 +02:00
parent 0675b7c16c
commit f86362f065
No known key found for this signature in database
GPG Key ID: C1F2658DC370C8FC
6 changed files with 25 additions and 1 deletions

View File

@ -56,4 +56,8 @@ class UserPreferencesProvider @Inject constructor(private val vectorPreferences:
fun showLiveSenderInfo(): Boolean {
return vectorPreferences.showLiveSenderInfo()
}
fun autoplayAnimatedImages(): Boolean {
return vectorPreferences.autoplayAnimatedImages()
}
}

View File

@ -67,7 +67,8 @@ class MessageItemAttributesFactory @Inject constructor(
threadSummaryFormatted = displayableEventFormatter.formatThreadSummary(threadDetails?.threadSummaryLatestEvent).toString(),
threadDetails = threadDetails,
reactionsSummaryEvents = reactionsSummaryEvents,
areThreadMessagesEnabled = preferencesProvider.areThreadMessagesEnabled()
areThreadMessagesEnabled = preferencesProvider.areThreadMessagesEnabled(),
autoplayAnimatedImages = preferencesProvider.autoplayAnimatedImages()
)
}
}

View File

@ -188,6 +188,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
val threadSummaryFormatted: String? = null,
val threadDetails: ThreadDetails? = null,
val areThreadMessagesEnabled: Boolean = false,
val autoplayAnimatedImages: Boolean = false,
override val reactionsSummaryEvents: ReactionsSummaryEvents? = null,
) : AbsBaseMessageItem.Attributes {

View File

@ -105,6 +105,7 @@ class VectorPreferences @Inject constructor(
private const val SETTINGS_SHOW_EMOJI_KEYBOARD = "SETTINGS_SHOW_EMOJI_KEYBOARD"
private const val SETTINGS_LABS_ENABLE_LATEX_MATHS = "SETTINGS_LABS_ENABLE_LATEX_MATHS"
const val SETTINGS_PRESENCE_USER_ALWAYS_APPEARS_OFFLINE = "SETTINGS_PRESENCE_USER_ALWAYS_APPEARS_OFFLINE"
const val SETTINGS_AUTOPLAY_ANIMATED_IMAGES = "SETTINGS_AUTOPLAY_ANIMATED_IMAGES"
// Room directory
private const val SETTINGS_ROOM_DIRECTORY_SHOW_ALL_PUBLIC_ROOMS = "SETTINGS_ROOM_DIRECTORY_SHOW_ALL_PUBLIC_ROOMS"
@ -773,6 +774,15 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY, false)
}
/**
* Tells if animated image attachments should automatically play their animation in the timeline.
*
* @return true if animated image attachments should automatically play their animation in the timeline
*/
fun autoplayAnimatedImages(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_AUTOPLAY_ANIMATED_IMAGES, false)
}
/**
* Tells if the typing notifications should be sent.
*

View File

@ -973,6 +973,8 @@
<string name="settings_show_read_receipts_summary">Click on the read receipts for a detailed list.</string>
<string name="settings_chat_effects_title">Show chat effects</string>
<string name="settings_chat_effects_description">Use /confetti command or send a message containing ❄️ or 🎉</string>
<string name="settings_autoplay_animated_images_title">Autoplay animated images</string>
<string name="settings_autoplay_animated_images_summary">Play animated images in the timeline as soon as they are visible</string>
<string name="settings_show_join_leave_messages">Show join and leave events</string>
<string name="settings_show_join_leave_messages_summary">Invites, removes, and bans are unaffected.</string>
<string name="settings_show_avatar_display_name_changes_messages">Show account events</string>

View File

@ -140,6 +140,12 @@
android:summary="@string/settings_chat_effects_description"
android:title="@string/settings_chat_effects_title" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_AUTOPLAY_ANIMATED_IMAGES"
android:summary="@string/settings_autoplay_animated_images_summary"
android:title="@string/settings_autoplay_animated_images_title" />
<im.vector.app.core.preference.VectorSwitchPreference
android:key="SETTINGS_VIBRATE_ON_MENTION_KEY"
android:title="@string/settings_vibrate_on_mention"