Skip to content

Add setting to allow disabling direct share #7488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2725.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add setting to allow disabling direct share
2 changes: 2 additions & 0 deletions library/ui-strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,6 +56,7 @@ class ShortcutCreator @Inject constructor(
dimensionConverter.dpToPx(72)
}
}
@Inject lateinit var vectorPreferences: VectorPreferences

fun canCreateShortcut(): Boolean {
return ShortcutManagerCompat.isRequestPinShortcutSupported(context)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
*/
Expand Down
6 changes: 6 additions & 0 deletions vector/src/main/res/xml/vector_settings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down