Add setting to allow disabling direct share

Direct share continues to be enabled by default.

As requested in #2725

Signed-off-by: Joaquín Aguirrezabalaga <kinote@kinote.org>
This commit is contained in:
Joaquín Aguirrezabalaga 2022-10-30 11:32:52 +01:00
parent e1393c2d63
commit 3a430efb02
5 changed files with 22 additions and 4 deletions

1
changelog.d/2725.feature Normal file
View file

@ -0,0 +1 @@
Add setting to allow disabling direct share

View file

@ -1032,6 +1032,8 @@
<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_enable_direct_share_title">Enable direct share</string>
<string name="settings_enable_direct_share_summary">Show recent chats in the system share menu</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

@ -29,6 +29,7 @@ import im.vector.app.core.glide.GlideApp
import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.MainActivity
import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
@ -55,6 +56,7 @@ class ShortcutCreator @Inject constructor(
dimensionConverter.dpToPx(72)
}
}
@Inject lateinit var vectorPreferences: VectorPreferences
fun canCreateShortcut(): Boolean {
return ShortcutManagerCompat.isRequestPinShortcutSupported(context)
@ -73,10 +75,12 @@ class ShortcutCreator @Inject constructor(
} catch (failure: Throwable) {
null
}
val categories = if (Build.VERSION.SDK_INT >= 25) {
setOf(directShareCategory, ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION)
} else {
setOf(directShareCategory)
val categories = mutableSetOf<String>()
if (vectorPreferences.directShareEnabled()) {
categories.add(directShareCategory)
}
if (Build.VERSION.SDK_INT >= 25) {
categories.add(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION)
}
return ShortcutInfoCompat.Builder(context, roomSummary.roomId)

View file

@ -123,6 +123,7 @@ class VectorPreferences @Inject constructor(
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"
private const val SETTINGS_ENABLE_DIRECT_SHARE = "SETTINGS_ENABLE_DIRECT_SHARE"
// Room directory
private const val SETTINGS_ROOM_DIRECTORY_SHOW_ALL_PUBLIC_ROOMS = "SETTINGS_ROOM_DIRECTORY_SHOW_ALL_PUBLIC_ROOMS"
@ -1004,6 +1005,10 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_ENABLE_CHAT_EFFECTS, true)
}
fun directShareEnabled(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_ENABLE_DIRECT_SHARE, true)
}
/**
* Return true if Pin code is disabled, or if user set the settings to see full notification content.
*/

View file

@ -147,6 +147,12 @@
android:title="@string/settings_vibrate_on_mention"
app:isPreferenceVisible="@bool/false_not_implemented" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="true"
android:key="SETTINGS_ENABLE_DIRECT_SHARE"
android:summary="@string/settings_enable_direct_share_summary"
android:title="@string/settings_enable_direct_share_title" />
</im.vector.app.core.preference.VectorPreferenceCategory>
<im.vector.app.core.preference.VectorPreferenceCategory