diff --git a/changelog.d/2725.feature b/changelog.d/2725.feature new file mode 100644 index 0000000000..eb3fcaed57 --- /dev/null +++ b/changelog.d/2725.feature @@ -0,0 +1 @@ +Add setting to allow disabling direct share diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 897c2853d8..18d80f7aa4 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -1032,6 +1032,8 @@ Use /confetti command or send a message containing ❄️ or 🎉 Autoplay animated images Play animated images in the timeline as soon as they are visible + Enable direct share + Show recent chats in the system share menu Show join and leave events Invites, removes, and bans are unaffected. Show account events diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt index e0565debf2..a0bcea217f 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt @@ -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() + if (vectorPreferences.directShareEnabled()) { + categories.add(directShareCategory) + } + if (Build.VERSION.SDK_INT >= 25) { + categories.add(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION) } return ShortcutInfoCompat.Builder(context, roomSummary.roomId) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 2dc8b12160..8cfc6a5baa 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -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. */ diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index 172fa5606c..52afe16bbb 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -147,6 +147,12 @@ android:title="@string/settings_vibrate_on_mention" app:isPreferenceVisible="@bool/false_not_implemented" /> + +