From d75bd140d90df0870525a7b8b216337c7af28a8b Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 6 Jun 2022 15:59:46 +0300 Subject: [PATCH 1/4] Remove location sharing flag from preferences. --- .../app/features/home/room/detail/TimelineFragment.kt | 3 ++- .../im/vector/app/features/settings/VectorPreferences.kt | 7 ------- .../features/settings/VectorSettingsPreferencesFragment.kt | 2 -- vector/src/main/res/values/strings.xml | 2 ++ vector/src/main/res/xml/vector_settings_preferences.xml | 6 ------ 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 1f8b922090..18f2693182 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -68,6 +68,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.vanniktech.emoji.EmojiPopup +import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.animations.play import im.vector.app.core.dialogs.ConfirmationDialogBuilder @@ -1552,7 +1553,7 @@ class TimelineFragment @Inject constructor( attachmentTypeSelector = AttachmentTypeSelectorView(vectorBaseActivity, vectorBaseActivity.layoutInflater, this@TimelineFragment) attachmentTypeSelector.setAttachmentVisibility( AttachmentTypeSelectorView.Type.LOCATION, - vectorPreferences.isLocationSharingEnabled() + BuildConfig.enableLocationSharing ) attachmentTypeSelector.setAttachmentVisibility( AttachmentTypeSelectorView.Type.POLL, !isThreadTimeLine() 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 5d5e07ee6b..385e552754 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 @@ -191,9 +191,6 @@ class VectorPreferences @Inject constructor( private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH" - // Location Sharing - const val SETTINGS_PREF_ENABLE_LOCATION_SHARING = "SETTINGS_PREF_ENABLE_LOCATION_SHARING" - private const val MEDIA_SAVING_3_DAYS = 0 private const val MEDIA_SAVING_1_WEEK = 1 private const val MEDIA_SAVING_1_MONTH = 2 @@ -1044,10 +1041,6 @@ class VectorPreferences @Inject constructor( } } - fun isLocationSharingEnabled(): Boolean { - return defaultPrefs.getBoolean(SETTINGS_PREF_ENABLE_LOCATION_SHARING, false) && BuildConfig.enableLocationSharing - } - fun labsRenderLocationsInTimeline(): Boolean { return defaultPrefs.getBoolean(SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE, true) } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index 5033400425..8bba46d3cb 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -173,8 +173,6 @@ class VectorSettingsPreferencesFragment @Inject constructor( }) true } - - findPreference(VectorPreferences.SETTINGS_PREF_ENABLE_LOCATION_SHARING)?.isVisible = BuildConfig.enableLocationSharing } private fun updateTakePhotoOrVideoPreferenceSummary() { diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 788dee1bc3..166c28a158 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3017,7 +3017,9 @@ ${app_name} could not access your location ${app_name} could not access your location. Please try again later. Open with + Enable location sharing + Once enabled you will be able to send your location to any room Render user locations in the timeline Failed to load map diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index 1a3c62e0e8..a3b8a3476c 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -72,12 +72,6 @@ android:title="@string/option_take_photo_video" tools:summary="@string/option_always_ask" /> - - From e5063375225b5270c0ddd70c5b6bea1af97f2978 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 6 Jun 2022 19:32:48 +0300 Subject: [PATCH 2/4] Remove labs flag for rendering location events. --- .../room/detail/timeline/factory/MessageItemFactory.kt | 8 +------- .../timeline/style/TimelineMessageLayoutFactory.kt | 10 +++------- .../vector/app/features/settings/VectorPreferences.kt | 5 ----- vector/src/main/res/values/strings.xml | 1 + vector/src/main/res/xml/vector_settings_labs.xml | 5 ----- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index e0316017f2..19ae4e873d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -209,13 +209,7 @@ class MessageItemFactory @Inject constructor( is MessageAudioContent -> buildAudioContent(params, messageContent, informationData, highlight, attributes) is MessageVerificationRequestContent -> buildVerificationRequestMessageItem(messageContent, informationData, highlight, callback, attributes) is MessagePollContent -> buildPollItem(messageContent, informationData, highlight, callback, attributes) - is MessageLocationContent -> { - if (vectorPreferences.labsRenderLocationsInTimeline()) { - buildLocationItem(messageContent, informationData, highlight, attributes) - } else { - buildMessageTextItem(messageContent.body, false, informationData, highlight, callback, attributes) - } - } + is MessageLocationContent -> buildLocationItem(messageContent, informationData, highlight, attributes) is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(params.event, highlight, attributes) else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt index 80405077e7..3d6dee371f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt @@ -62,16 +62,15 @@ class TimelineMessageLayoutFactory @Inject constructor( MessageType.MSGTYPE_STICKER_LOCAL, MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_BEACON_INFO, + MessageType.MSGTYPE_LOCATION, + MessageType.MSGTYPE_BEACON_LOCATION_DATA, ) private val MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE = setOf( MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_BEACON_INFO, - ) - - private val MSG_TYPES_WITH_LOCATION_DATA = setOf( MessageType.MSGTYPE_LOCATION, - MessageType.MSGTYPE_BEACON_LOCATION_DATA + MessageType.MSGTYPE_BEACON_LOCATION_DATA, ) } @@ -147,14 +146,12 @@ class TimelineMessageLayoutFactory @Inject constructor( private fun MessageContent?.isPseudoBubble(): Boolean { if (this == null) return false - if (msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline() return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT } private fun MessageContent?.timestampInsideMessage(): Boolean { return when { this == null -> false - msgType in MSG_TYPES_WITH_LOCATION_DATA -> vectorPreferences.labsRenderLocationsInTimeline() else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE } } @@ -162,7 +159,6 @@ class TimelineMessageLayoutFactory @Inject constructor( private fun MessageContent?.shouldAddMessageOverlay(): Boolean { return when { this == null || msgType == MessageType.MSGTYPE_BEACON_INFO -> false - msgType == MessageType.MSGTYPE_LOCATION -> vectorPreferences.labsRenderLocationsInTimeline() else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE } } 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 385e552754..9d3edeb25a 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 @@ -200,7 +200,6 @@ class VectorPreferences @Inject constructor( private const val TAKE_PHOTO_VIDEO_MODE = "TAKE_PHOTO_VIDEO_MODE" - private const val SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE = "SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE" private const val SETTINGS_LABS_ENABLE_LIVE_LOCATION = "SETTINGS_LABS_ENABLE_LIVE_LOCATION" // This key will be used to identify clients with the old thread support enabled io.element.thread @@ -1041,10 +1040,6 @@ class VectorPreferences @Inject constructor( } } - fun labsRenderLocationsInTimeline(): Boolean { - return defaultPrefs.getBoolean(SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE, true) - } - fun labsEnableLiveLocation(): Boolean { return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, false) } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 166c28a158..a7bc4683a1 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3021,6 +3021,7 @@ Enable location sharing Once enabled you will be able to send your location to any room + Render user locations in the timeline Failed to load map Live location enabled diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index 19ee7e366f..9b9293e2e2 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -64,11 +64,6 @@ android:summary="@string/labs_auto_report_uisi_desc" android:title="@string/labs_auto_report_uisi" /> - - Date: Tue, 7 Jun 2022 01:05:10 +0300 Subject: [PATCH 3/4] Changelog added. --- changelog.d/6244.feature | 1 + .../app/features/settings/VectorSettingsPreferencesFragment.kt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 changelog.d/6244.feature diff --git a/changelog.d/6244.feature b/changelog.d/6244.feature new file mode 100644 index 0000000000..9b02187112 --- /dev/null +++ b/changelog.d/6244.feature @@ -0,0 +1 @@ +Re-organize location settings flags diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index 8bba46d3cb..cada7c97a2 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -24,7 +24,6 @@ import androidx.core.view.children import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import com.google.android.material.dialog.MaterialAlertDialogBuilder -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.dialogs.PhotoOrVideoDialog import im.vector.app.core.extensions.restart From ea714bbdaa21906f2b9a1c204fb91aebc7190f2d Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 7 Jun 2022 13:06:09 +0300 Subject: [PATCH 4/4] Fix lint errors - unused string resources. --- vector/src/main/res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index a7bc4683a1..97ef900ce3 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3018,11 +3018,11 @@ ${app_name} could not access your location. Please try again later. Open with - Enable location sharing + Enable location sharing - Once enabled you will be able to send your location to any room + Once enabled you will be able to send your location to any room - Render user locations in the timeline + Render user locations in the timeline Failed to load map Live location enabled Loading live location…