From 031c1b409bc01d0ec293e8f1c497d3bfe9514828 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Mon, 4 Apr 2022 19:51:47 +0300 Subject: [PATCH 01/15] Implement Beta opt-in mechanism to inform users about threads. --- .../bottomsheet/BottomSheetActionItem.kt | 5 ++ .../home/room/detail/TimelineFragment.kt | 36 ++++++++++- .../action/MessageActionsEpoxyController.kt | 8 +++ .../action/MessageActionsViewModel.kt | 3 +- .../home/room/threads/ThreadsManager.kt | 61 +++++++++++++++++++ .../settings/VectorSettingsLabsFragment.kt | 1 - .../res/layout/item_bottom_sheet_action.xml | 23 +++++++ vector/src/main/res/values/strings.xml | 4 ++ 8 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt diff --git a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt index 854a5d3419..6c30ae6f63 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt @@ -71,6 +71,9 @@ abstract class BottomSheetActionItem : VectorEpoxyModel(R.id.actionIcon) val text by bind(R.id.actionTitle) val selected by bind(R.id.actionSelected) + val betaLabel by bind(R.id.actionBetaTextView) } } 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 81b037e016..4fbe32bc48 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 @@ -25,6 +25,7 @@ import android.os.Build import android.os.Bundle import android.text.Spannable import android.text.format.DateUtils +import android.text.method.LinkMovementMethod import android.view.HapticFeedbackConstants import android.view.KeyEvent import android.view.LayoutInflater @@ -169,6 +170,7 @@ import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever import im.vector.app.features.home.room.detail.upgrade.MigrateRoomBottomSheet import im.vector.app.features.home.room.detail.views.RoomDetailLazyLoadedViews import im.vector.app.features.home.room.detail.widget.RoomWidgetsBottomSheet +import im.vector.app.features.home.room.threads.ThreadsManager import im.vector.app.features.home.room.threads.arguments.ThreadTimelineArgs import im.vector.app.features.html.EventHtmlRenderer import im.vector.app.features.html.PillImageSpan @@ -251,6 +253,7 @@ class TimelineFragment @Inject constructor( private val notificationDrawerManager: NotificationDrawerManager, private val eventHtmlRenderer: EventHtmlRenderer, private val vectorPreferences: VectorPreferences, + private val threadsManager: ThreadsManager, private val colorProvider: ColorProvider, private val dimensionConverter: DimensionConverter, private val userPreferencesProvider: UserPreferencesProvider, @@ -2199,7 +2202,7 @@ class TimelineFragment @Inject constructor( } is EventSharedAction.ReplyInThread -> { if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) { - navigateToThreadTimeline(action.eventId, action.startsThread) + onReplyInThreadClicked(action) } else { requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit) } @@ -2355,6 +2358,14 @@ class TimelineFragment @Inject constructor( .show() } + private fun onReplyInThreadClicked(action: EventSharedAction.ReplyInThread) { + if (vectorPreferences.areThreadMessagesEnabled()) { + navigateToThreadTimeline(action.eventId, action.startsThread) + } else { + displayThreadsBetaNotice() + } + } + /** * Navigate to Threads timeline for the specified rootThreadEventId * using the ThreadsActivity @@ -2374,6 +2385,29 @@ class TimelineFragment @Inject constructor( } } + /** + * Display a dialog that will let the user to enable threads + */ + + private fun displayThreadsBetaNotice() = + activity?.let { + MaterialAlertDialogBuilder(it) + .setTitle(R.string.threads_beta_enable_notice_title) + .setMessage(threadsManager.getBetaEnableThreadsMessage()) + .setCancelable(true) + .setNegativeButton(R.string.action_not_now) { _, _ -> } + .setPositiveButton(R.string.action_try_it_out) { _, _ -> + timelineViewModel.onCleared() // We should first clear our viewModel + threadsManager.enableThreadsAndRestart(it) + } + .show() + ?.findViewById(android.R.id.message) + ?.apply { + linksClickable = true + movementMethod = LinkMovementMethod.getInstance() + } + } + /** * Navigate to Threads list for the current room * using the ThreadsActivity diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt index 27937047a5..307be220d3 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt @@ -43,6 +43,7 @@ import im.vector.app.features.location.INITIAL_MAP_ZOOM_IN_TIMELINE import im.vector.app.features.location.UrlMapProvider import im.vector.app.features.location.toLocationData import im.vector.app.features.media.ImageContentRenderer +import im.vector.app.features.settings.VectorPreferences import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orTrue @@ -64,6 +65,7 @@ class MessageActionsEpoxyController @Inject constructor( private val errorFormatter: ErrorFormatter, private val spanUtils: SpanUtils, private val eventDetailsFormatter: EventDetailsFormatter, + private val vectorPreferences: VectorPreferences, private val dateFormatter: VectorDateFormatter, private val urlMapProvider: UrlMapProvider, private val locationPinProvider: LocationPinProvider @@ -187,6 +189,8 @@ class MessageActionsEpoxyController @Inject constructor( id("separator_$index") } } else { + val showBetaLabel = action.shouldShowBetaLabel() + bottomSheetActionItem { id("action_$index") iconRes(action.iconResId) @@ -195,6 +199,7 @@ class MessageActionsEpoxyController @Inject constructor( expanded(state.expendedReportContentMenu) listener { host.listener?.didSelectMenuAction(action) } destructive(action.destructive) + showBetaLabel(showBetaLabel) } if (action is EventSharedAction.ReportContent && state.expendedReportContentMenu) { @@ -217,6 +222,9 @@ class MessageActionsEpoxyController @Inject constructor( } } + private fun EventSharedAction.shouldShowBetaLabel(): Boolean = + this is EventSharedAction.ReplyInThread && !vectorPreferences.areThreadMessagesEnabled() + interface MessageActionsEpoxyControllerListener : TimelineEventController.UrlClickCallback { fun didSelectMenuAction(eventAction: EventSharedAction) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index aaaecb0a13..8758bd1efd 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -450,7 +450,8 @@ class MessageActionsViewModel @AssistedInject constructor( private fun canReplyInThread(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean { - if (!vectorPreferences.areThreadMessagesEnabled()) return false +/* We let reply in thread visible even if threads are not enabled, with an enhanced flow to attract users */ +// if (!vectorPreferences.areThreadMessagesEnabled()) return false if (initialState.isFromThreadTimeline) return false if (event.root.isThread()) return false if (event.root.getClearType() != EventType.MESSAGE && diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt new file mode 100644 index 0000000000..1e7ef672f3 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.home.room.threads + +import android.app.Activity +import android.content.Context +import android.text.Spanned +import androidx.core.text.HtmlCompat +import im.vector.app.R +import im.vector.app.features.MainActivity +import im.vector.app.features.MainActivityArgs +import im.vector.app.features.settings.VectorPreferences +import org.matrix.android.sdk.internal.database.lightweight.LightweightSettingsStorage +import javax.inject.Inject + +/** + * The class is responsible for handling thread specific tasks + */ +class ThreadsManager @Inject constructor( + private val vectorPreferences: VectorPreferences, + private val lightweightSettingsStorage: LightweightSettingsStorage, + private val context: Context +) { + + companion object { + const val learnMoreUrl = "https://element.io/help#threads" + } + + /** + * Enable threads and invoke an initial sync. The initial sync is mandatory in order to change + * the already saved DB schema for already received messages + */ + fun enableThreadsAndRestart(activity: Activity) { + vectorPreferences.setThreadMessagesEnabled() + lightweightSettingsStorage.setThreadMessagesEnabled(vectorPreferences.areThreadMessagesEnabled()) + MainActivity.restartApp(activity, MainActivityArgs(clearCache = true)) + } + + /** + * Generates and return an Html spanned string to be rendered especially in dialogs + */ + fun getBetaEnableThreadsMessage(): Spanned { + val href = "Learn more.

" + val message = context.getString(R.string.threads_beta_enable_notice_message, href) + return HtmlCompat.fromHtml(message, HtmlCompat.FROM_HTML_MODE_LEGACY) + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index 003832fb97..605a42ff02 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -27,7 +27,6 @@ import javax.inject.Inject class VectorSettingsLabsFragment @Inject constructor( private val vectorPreferences: VectorPreferences, private val lightweightSettingsStorage: LightweightSettingsStorage - ) : VectorSettingsBaseFragment() { override var titleRes = R.string.room_settings_labs_pref_title diff --git a/vector/src/main/res/layout/item_bottom_sheet_action.xml b/vector/src/main/res/layout/item_bottom_sheet_action.xml index bffcb79df6..e5230620d4 100644 --- a/vector/src/main/res/layout/item_bottom_sheet_action.xml +++ b/vector/src/main/res/layout/item_bottom_sheet_action.xml @@ -82,4 +82,27 @@ tools:ignore="MissingPrefix" tools:visibility="visible" /> + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 9bdbb291a5..03f3ef93f1 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -360,6 +360,7 @@ Enable Disable Not now + Try it out Agree "Change" Remove @@ -734,6 +735,8 @@ From a Thread Threads Approaching Beta 🎉 We’re getting closer to releasing a public Beta for Threads.\n\nAs we prepare for it, we need to make some changes: threads created before this point will be displayed as regular replies.\n\nThis will be a one-off transition as Threads are now part of the Matrix specification. + Threads Beta + Threads help keep your conversations on-topic and easy to track. %sEnabling threads will refresh the app. This may take longer for some accounts. Search @@ -1643,6 +1646,7 @@ Thanks, the suggestion has been successfully sent The suggestion failed to be sent (%s) + BETA Spaces feedback Feedback You’re using a beta version of spaces. Your feedback will help inform the next versions. Your platform and username will be noted to help us use your feedback as much as we can. From 9e48b02b73e605f4a31f1f0667bc5e0ae48dd7c8 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Mon, 4 Apr 2022 19:56:47 +0300 Subject: [PATCH 02/15] Add changelog --- changelog.d/5692.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5692.misc diff --git a/changelog.d/5692.misc b/changelog.d/5692.misc new file mode 100644 index 0000000000..66f1d35eb0 --- /dev/null +++ b/changelog.d/5692.misc @@ -0,0 +1 @@ +Implement threads beta opt-in mechanism to notify users about threads \ No newline at end of file From 2bb6e77be0a8c1ce63f813af55f35f808ccd39a0 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 13:10:59 +0300 Subject: [PATCH 03/15] Rename displayThreadsBetaNotice method --- .../app/features/home/room/detail/TimelineFragment.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 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 4fbe32bc48..9129584017 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 @@ -2362,7 +2362,7 @@ class TimelineFragment @Inject constructor( if (vectorPreferences.areThreadMessagesEnabled()) { navigateToThreadTimeline(action.eventId, action.startsThread) } else { - displayThreadsBetaNotice() + displayThreadsBetaOptInDialog() } } @@ -2385,11 +2385,7 @@ class TimelineFragment @Inject constructor( } } - /** - * Display a dialog that will let the user to enable threads - */ - - private fun displayThreadsBetaNotice() = + private fun displayThreadsBetaOptInDialog() = activity?.let { MaterialAlertDialogBuilder(it) .setTitle(R.string.threads_beta_enable_notice_title) From 7662abc5f7a2b4bf772ecda2c1f8220fd4add0f5 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 13:36:44 +0300 Subject: [PATCH 04/15] Add learn more to string resources --- .../im/vector/app/features/home/room/threads/ThreadsManager.kt | 3 ++- vector/src/main/res/values/strings.xml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt index 1e7ef672f3..bc24a40fe6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt @@ -54,7 +54,8 @@ class ThreadsManager @Inject constructor( * Generates and return an Html spanned string to be rendered especially in dialogs */ fun getBetaEnableThreadsMessage(): Spanned { - val href = "Learn more.

" + val learnMore = context.getString(R.string.action_learn_more) + val href = "$learnMore.

" val message = context.getString(R.string.threads_beta_enable_notice_message, href) return HtmlCompat.fromHtml(message, HtmlCompat.FROM_HTML_MODE_LEGACY) } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 03f3ef93f1..6cd14ac10f 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -385,6 +385,7 @@ Play Dismiss Reset + Learn more Copied to clipboard From 2ac33063829255d7ce413c50b6d52a8162ea28b4 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 13:56:12 +0300 Subject: [PATCH 05/15] Remove duplicate learn more string resources --- .../app/features/login/LoginServerSelectionFragment.kt | 2 +- .../app/features/login2/LoginServerSelectionFragment2.kt | 2 +- .../ftueauth/FtueAuthServerSelectionFragment.kt | 2 +- .../roommemberprofile/RoomMemberProfileController.kt | 4 ++-- .../main/res/layout/fragment_login_server_selection.xml | 2 +- .../main/res/layout/fragment_login_server_url_form.xml | 2 +- vector/src/main/res/layout/item_bottom_sheet_action.xml | 8 ++++---- vector/src/main/res/layout/item_profile_action.xml | 2 +- vector/src/main/res/values/strings.xml | 3 +-- vector/src/main/res/values/strings_login_v2.xml | 2 +- 10 files changed, 14 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt index a29967096a..81f4f06084 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt @@ -56,7 +56,7 @@ class LoginServerSelectionFragment @Inject constructor() : AbstractLoginFragment private fun initTextViews() { views.loginServerChoiceEmsLearnMore.text = span { - text = getString(R.string.login_server_modular_learn_more) + text = getString(R.string.action_learn_more) textDecorationLine = "underline" } } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt index 60e381b047..cd3d359abd 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt @@ -48,7 +48,7 @@ class LoginServerSelectionFragment2 @Inject constructor() : AbstractLoginFragmen views.loginServerChoiceEmsLearnMore.setTextWithColoredPart( fullTextRes = R.string.login_server_modular_learn_more_about_ems, - coloredTextRes = R.string.login_server_modular_learn_more, + coloredTextRes = R.string.action_learn_more, underline = true ) views.loginServerChoiceEmsLearnMore.setOnClickListener { diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt index f72bd2c5d3..b3496f914f 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt @@ -61,7 +61,7 @@ class FtueAuthServerSelectionFragment @Inject constructor() : AbstractFtueAuthFr private fun initTextViews() { views.loginServerChoiceEmsLearnMore.text = span { - text = getString(R.string.login_server_modular_learn_more) + text = getString(R.string.action_learn_more) textDecorationLine = "underline" } } diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt index 545e9f7190..8359113eab 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt @@ -142,7 +142,7 @@ class RoomMemberProfileController @Inject constructor( } else { buildProfileAction( id = "learn_more", - title = stringProvider.getString(R.string.room_profile_section_security_learn_more), + title = stringProvider.getString(R.string.action_learn_more), editable = false, divider = false, action = { callback?.onShowDeviceListNoCrossSigning() } @@ -160,7 +160,7 @@ class RoomMemberProfileController @Inject constructor( buildProfileAction( id = "learn_more", - title = stringProvider.getString(R.string.room_profile_section_security_learn_more), + title = stringProvider.getString(R.string.action_learn_more), editable = false, divider = false, subtitle = stringProvider.getString(R.string.room_profile_encrypted_subtitle), diff --git a/vector/src/main/res/layout/fragment_login_server_selection.xml b/vector/src/main/res/layout/fragment_login_server_selection.xml index 1ea923d7f3..9d665aace7 100644 --- a/vector/src/main/res/layout/fragment_login_server_selection.xml +++ b/vector/src/main/res/layout/fragment_login_server_selection.xml @@ -134,7 +134,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:padding="16dp" - android:text="@string/login_server_modular_learn_more" + android:text="@string/action_learn_more" android:textColor="?colorPrimary" app:layout_constraintBottom_toBottomOf="@id/loginServerChoiceEmsText" app:layout_constraintEnd_toEndOf="parent" diff --git a/vector/src/main/res/layout/fragment_login_server_url_form.xml b/vector/src/main/res/layout/fragment_login_server_url_form.xml index 0a5c10935a..3cc688c11e 100644 --- a/vector/src/main/res/layout/fragment_login_server_url_form.xml +++ b/vector/src/main/res/layout/fragment_login_server_url_form.xml @@ -50,7 +50,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:text="@string/login_server_modular_learn_more" + android:text="@string/action_learn_more" android:textColor="?colorPrimary" /> + app:layout_constraintTop_toTopOf="parent" + tools:visibility="visible" /> diff --git a/vector/src/main/res/layout/item_profile_action.xml b/vector/src/main/res/layout/item_profile_action.xml index 6a29ec6a1c..4ff0907c16 100644 --- a/vector/src/main/res/layout/item_profile_action.xml +++ b/vector/src/main/res/layout/item_profile_action.xml @@ -47,7 +47,7 @@ app:layout_constraintStart_toEndOf="@id/actionIcon" app:layout_constraintTop_toTopOf="parent" app:layout_goneMarginStart="0dp" - tools:text="@string/room_profile_section_security_learn_more" /> + tools:text="@string/action_learn_more" /> Threads Approaching Beta 🎉 We’re getting closer to releasing a public Beta for Threads.\n\nAs we prepare for it, we need to make some changes: threads created before this point will be displayed as regular replies.\n\nThis will be a one-off transition as Threads are now part of the Matrix specification. Threads Beta + Threads help keep your conversations on-topic and easy to track. %sEnabling threads will refresh the app. This may take longer for some accounts. @@ -1901,7 +1902,6 @@ Just like email, accounts have one home, although you can talk to anyone Join millions for free on the largest public server Premium hosting for organisations - Learn more Other Custom & advanced settings @@ -2142,7 +2142,6 @@ Messages here are end-to-end encrypted.\n\nYour messages are secured with locks and only you and the recipient have the unique keys to unlock them. Security Restore Encryption - Learn more More Admin Actions Room settings diff --git a/vector/src/main/res/values/strings_login_v2.xml b/vector/src/main/res/values/strings_login_v2.xml index c84455a665..627310f437 100644 --- a/vector/src/main/res/values/strings_login_v2.xml +++ b/vector/src/main/res/values/strings_login_v2.xml @@ -43,7 +43,7 @@ Associate a phone number Associate a phone number to optionally allow people you know to discover you. The server %s requires you to associate a phone number to create an account. - + %s about Element Matrix Service. \ No newline at end of file From e3ac5ad8c1eb28b5a8dce118b2df25a1220b48d5 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 14:01:14 +0300 Subject: [PATCH 06/15] Remove extra space --- .../vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt index 6c30ae6f63..ed3d55fca9 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt @@ -109,7 +109,7 @@ abstract class BottomSheetActionItem : VectorEpoxyModel Date: Tue, 5 Apr 2022 14:02:08 +0300 Subject: [PATCH 07/15] Improve comment format --- .../home/room/detail/timeline/action/MessageActionsViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index 8758bd1efd..9a73afd897 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -450,7 +450,7 @@ class MessageActionsViewModel @AssistedInject constructor( private fun canReplyInThread(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean { -/* We let reply in thread visible even if threads are not enabled, with an enhanced flow to attract users */ + // We let reply in thread visible even if threads are not enabled, with an enhanced flow to attract users // if (!vectorPreferences.areThreadMessagesEnabled()) return false if (initialState.isFromThreadTimeline) return false if (event.root.isThread()) return false From 6567628b95d8769b529880069391eaf1dcf5613a Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 14:02:41 +0300 Subject: [PATCH 08/15] Format code --- .../vector/app/features/home/room/detail/TimelineFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9129584017..1eb6635df0 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 @@ -2385,7 +2385,7 @@ class TimelineFragment @Inject constructor( } } - private fun displayThreadsBetaOptInDialog() = + private fun displayThreadsBetaOptInDialog() { activity?.let { MaterialAlertDialogBuilder(it) .setTitle(R.string.threads_beta_enable_notice_title) @@ -2403,6 +2403,7 @@ class TimelineFragment @Inject constructor( movementMethod = LinkMovementMethod.getInstance() } } + } /** * Navigate to Threads list for the current room From eecaf9602df70bb5b263c73f8b041129dbba9f14 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 14:12:32 +0300 Subject: [PATCH 09/15] Add urls.xml in vector-config --- vector-config/src/main/res/values/urls.xml | 6 ++++++ .../vector/app/features/home/room/threads/ThreadsManager.kt | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 vector-config/src/main/res/values/urls.xml diff --git a/vector-config/src/main/res/values/urls.xml b/vector-config/src/main/res/values/urls.xml new file mode 100644 index 0000000000..22e3a9ac72 --- /dev/null +++ b/vector-config/src/main/res/values/urls.xml @@ -0,0 +1,6 @@ + + + + + https://element.io/help#threads + \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt index bc24a40fe6..d77af9b99f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt @@ -36,10 +36,6 @@ class ThreadsManager @Inject constructor( private val context: Context ) { - companion object { - const val learnMoreUrl = "https://element.io/help#threads" - } - /** * Enable threads and invoke an initial sync. The initial sync is mandatory in order to change * the already saved DB schema for already received messages @@ -55,6 +51,7 @@ class ThreadsManager @Inject constructor( */ fun getBetaEnableThreadsMessage(): Spanned { val learnMore = context.getString(R.string.action_learn_more) + val learnMoreUrl = context.getString(R.string.threads_learn_more_url) val href = "$learnMore.

" val message = context.getString(R.string.threads_beta_enable_notice_message, href) return HtmlCompat.fromHtml(message, HtmlCompat.FROM_HTML_MODE_LEGACY) From c76dc7b62f413d3513e52ae42c35a30ce2c3c901 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 5 Apr 2022 17:40:27 +0200 Subject: [PATCH 10/15] Update vector/src/main/res/values/strings_login_v2.xml Fix typo --- vector/src/main/res/values/strings_login_v2.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/values/strings_login_v2.xml b/vector/src/main/res/values/strings_login_v2.xml index 627310f437..f7d94d4c32 100644 --- a/vector/src/main/res/values/strings_login_v2.xml +++ b/vector/src/main/res/values/strings_login_v2.xml @@ -43,7 +43,7 @@ Associate a phone number Associate a phone number to optionally allow people you know to discover you. The server %s requires you to associate a phone number to create an account. - + %s about Element Matrix Service. \ No newline at end of file From 72d4c7612a7e0e58abe2c35affede55ed8c11f2f Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 19:39:11 +0300 Subject: [PATCH 11/15] Revert comment change --- vector/src/main/res/values/strings_login_v2.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/values/strings_login_v2.xml b/vector/src/main/res/values/strings_login_v2.xml index f7d94d4c32..627310f437 100644 --- a/vector/src/main/res/values/strings_login_v2.xml +++ b/vector/src/main/res/values/strings_login_v2.xml @@ -43,7 +43,7 @@ Associate a phone number Associate a phone number to optionally allow people you know to discover you. The server %s requires you to associate a phone number to create an account. - + %s about Element Matrix Service. \ No newline at end of file From 5ee2579efcc93c24a56ae86311d6a7b5755221d3 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 19:39:13 +0300 Subject: [PATCH 12/15] Revert "Remove duplicate learn more string resources" This reverts commit 2ac33063829255d7ce413c50b6d52a8162ea28b4. --- .../app/features/login/LoginServerSelectionFragment.kt | 2 +- .../app/features/login2/LoginServerSelectionFragment2.kt | 2 +- .../ftueauth/FtueAuthServerSelectionFragment.kt | 2 +- .../roommemberprofile/RoomMemberProfileController.kt | 4 ++-- .../main/res/layout/fragment_login_server_selection.xml | 2 +- .../main/res/layout/fragment_login_server_url_form.xml | 2 +- vector/src/main/res/layout/item_bottom_sheet_action.xml | 8 ++++---- vector/src/main/res/layout/item_profile_action.xml | 2 +- vector/src/main/res/values/strings.xml | 3 ++- vector/src/main/res/values/strings_login_v2.xml | 2 +- 10 files changed, 15 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt index 81f4f06084..a29967096a 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginServerSelectionFragment.kt @@ -56,7 +56,7 @@ class LoginServerSelectionFragment @Inject constructor() : AbstractLoginFragment private fun initTextViews() { views.loginServerChoiceEmsLearnMore.text = span { - text = getString(R.string.action_learn_more) + text = getString(R.string.login_server_modular_learn_more) textDecorationLine = "underline" } } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt index cd3d359abd..60e381b047 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt @@ -48,7 +48,7 @@ class LoginServerSelectionFragment2 @Inject constructor() : AbstractLoginFragmen views.loginServerChoiceEmsLearnMore.setTextWithColoredPart( fullTextRes = R.string.login_server_modular_learn_more_about_ems, - coloredTextRes = R.string.action_learn_more, + coloredTextRes = R.string.login_server_modular_learn_more, underline = true ) views.loginServerChoiceEmsLearnMore.setOnClickListener { diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt index b3496f914f..f72bd2c5d3 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerSelectionFragment.kt @@ -61,7 +61,7 @@ class FtueAuthServerSelectionFragment @Inject constructor() : AbstractFtueAuthFr private fun initTextViews() { views.loginServerChoiceEmsLearnMore.text = span { - text = getString(R.string.action_learn_more) + text = getString(R.string.login_server_modular_learn_more) textDecorationLine = "underline" } } diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt index 8359113eab..545e9f7190 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt @@ -142,7 +142,7 @@ class RoomMemberProfileController @Inject constructor( } else { buildProfileAction( id = "learn_more", - title = stringProvider.getString(R.string.action_learn_more), + title = stringProvider.getString(R.string.room_profile_section_security_learn_more), editable = false, divider = false, action = { callback?.onShowDeviceListNoCrossSigning() } @@ -160,7 +160,7 @@ class RoomMemberProfileController @Inject constructor( buildProfileAction( id = "learn_more", - title = stringProvider.getString(R.string.action_learn_more), + title = stringProvider.getString(R.string.room_profile_section_security_learn_more), editable = false, divider = false, subtitle = stringProvider.getString(R.string.room_profile_encrypted_subtitle), diff --git a/vector/src/main/res/layout/fragment_login_server_selection.xml b/vector/src/main/res/layout/fragment_login_server_selection.xml index 9d665aace7..1ea923d7f3 100644 --- a/vector/src/main/res/layout/fragment_login_server_selection.xml +++ b/vector/src/main/res/layout/fragment_login_server_selection.xml @@ -134,7 +134,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:padding="16dp" - android:text="@string/action_learn_more" + android:text="@string/login_server_modular_learn_more" android:textColor="?colorPrimary" app:layout_constraintBottom_toBottomOf="@id/loginServerChoiceEmsText" app:layout_constraintEnd_toEndOf="parent" diff --git a/vector/src/main/res/layout/fragment_login_server_url_form.xml b/vector/src/main/res/layout/fragment_login_server_url_form.xml index 3cc688c11e..0a5c10935a 100644 --- a/vector/src/main/res/layout/fragment_login_server_url_form.xml +++ b/vector/src/main/res/layout/fragment_login_server_url_form.xml @@ -50,7 +50,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:text="@string/action_learn_more" + android:text="@string/login_server_modular_learn_more" android:textColor="?colorPrimary" /> + app:layout_constraintTop_toTopOf="parent"/> diff --git a/vector/src/main/res/layout/item_profile_action.xml b/vector/src/main/res/layout/item_profile_action.xml index 4ff0907c16..6a29ec6a1c 100644 --- a/vector/src/main/res/layout/item_profile_action.xml +++ b/vector/src/main/res/layout/item_profile_action.xml @@ -47,7 +47,7 @@ app:layout_constraintStart_toEndOf="@id/actionIcon" app:layout_constraintTop_toTopOf="parent" app:layout_goneMarginStart="0dp" - tools:text="@string/action_learn_more" /> + tools:text="@string/room_profile_section_security_learn_more" /> Threads Approaching Beta 🎉 We’re getting closer to releasing a public Beta for Threads.\n\nAs we prepare for it, we need to make some changes: threads created before this point will be displayed as regular replies.\n\nThis will be a one-off transition as Threads are now part of the Matrix specification. Threads Beta - Threads help keep your conversations on-topic and easy to track. %sEnabling threads will refresh the app. This may take longer for some accounts. @@ -1902,6 +1901,7 @@ Just like email, accounts have one home, although you can talk to anyone Join millions for free on the largest public server Premium hosting for organisations + Learn more Other Custom & advanced settings @@ -2142,6 +2142,7 @@ Messages here are end-to-end encrypted.\n\nYour messages are secured with locks and only you and the recipient have the unique keys to unlock them. Security Restore Encryption + Learn more More Admin Actions Room settings diff --git a/vector/src/main/res/values/strings_login_v2.xml b/vector/src/main/res/values/strings_login_v2.xml index 627310f437..c84455a665 100644 --- a/vector/src/main/res/values/strings_login_v2.xml +++ b/vector/src/main/res/values/strings_login_v2.xml @@ -43,7 +43,7 @@ Associate a phone number Associate a phone number to optionally allow people you know to discover you. The server %s requires you to associate a phone number to create an account. - + %s about Element Matrix Service. \ No newline at end of file From 59d87df0cabfc7565099c741901994a51e16ada0 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 19:44:01 +0300 Subject: [PATCH 13/15] Add string resource comment --- vector/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 6cd14ac10f..a3b916c12b 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -737,6 +737,7 @@ Threads Approaching Beta 🎉 We’re getting closer to releasing a public Beta for Threads.\n\nAs we prepare for it, we need to make some changes: threads created before this point will be displayed as regular replies.\n\nThis will be a one-off transition as Threads are now part of the Matrix specification. Threads Beta + Threads help keep your conversations on-topic and easy to track. %sEnabling threads will refresh the app. This may take longer for some accounts. From 37dc77cc3ea9e1feefa4b989e18b434aeca21dcd Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 20:36:33 +0300 Subject: [PATCH 14/15] Add isValid check to RealmChangeListener to prevent crashes on deleted objects --- .../session/room/timeline/SendingEventsDataSource.kt | 8 +++++--- .../app/features/home/room/detail/TimelineFragment.kt | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/SendingEventsDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/SendingEventsDataSource.kt index cb61222de7..637267a9b1 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/SendingEventsDataSource.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/SendingEventsDataSource.kt @@ -45,9 +45,11 @@ internal class RealmSendingEventsDataSource( private var frozenSendingTimelineEvents: RealmList? = null private val sendingTimelineEventsListener = RealmChangeListener> { events -> - uiEchoManager.onSentEventsInDatabase(events.map { it.eventId }) - updateFrozenResults(events) - onEventsUpdated(false) + if (events.isValid) { + uiEchoManager.onSentEventsInDatabase(events.map { it.eventId }) + updateFrozenResults(events) + onEventsUpdated(false) + } } override fun start() { 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 1eb6635df0..98b7473894 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 @@ -2393,7 +2393,6 @@ class TimelineFragment @Inject constructor( .setCancelable(true) .setNegativeButton(R.string.action_not_now) { _, _ -> } .setPositiveButton(R.string.action_try_it_out) { _, _ -> - timelineViewModel.onCleared() // We should first clear our viewModel threadsManager.enableThreadsAndRestart(it) } .show() From 598892de53b4de1c0c8860e787f05aedfeb6553d Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 5 Apr 2022 20:53:11 +0300 Subject: [PATCH 15/15] Injecting stringProvider instead of context in ThreadsManager class --- .../app/features/home/room/threads/ThreadsManager.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt index d77af9b99f..469a12019a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsManager.kt @@ -17,10 +17,10 @@ package im.vector.app.features.home.room.threads import android.app.Activity -import android.content.Context import android.text.Spanned import androidx.core.text.HtmlCompat import im.vector.app.R +import im.vector.app.core.resources.StringProvider import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs import im.vector.app.features.settings.VectorPreferences @@ -33,7 +33,7 @@ import javax.inject.Inject class ThreadsManager @Inject constructor( private val vectorPreferences: VectorPreferences, private val lightweightSettingsStorage: LightweightSettingsStorage, - private val context: Context + private val stringProvider: StringProvider ) { /** @@ -50,10 +50,10 @@ class ThreadsManager @Inject constructor( * Generates and return an Html spanned string to be rendered especially in dialogs */ fun getBetaEnableThreadsMessage(): Spanned { - val learnMore = context.getString(R.string.action_learn_more) - val learnMoreUrl = context.getString(R.string.threads_learn_more_url) + val learnMore = stringProvider.getString(R.string.action_learn_more) + val learnMoreUrl = stringProvider.getString(R.string.threads_learn_more_url) val href = "$learnMore.

" - val message = context.getString(R.string.threads_beta_enable_notice_message, href) + val message = stringProvider.getString(R.string.threads_beta_enable_notice_message, href) return HtmlCompat.fromHtml(message, HtmlCompat.FROM_HTML_MODE_LEGACY) } }