From b2e64e6265bc85303f48697a9d151cb07a0a16ad Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 28 Jul 2022 17:25:42 +0200 Subject: [PATCH 01/58] Fixing missing clear on TabLayoutMediator when view is destroyed --- .../ftueauth/FtueAuthSplashCarouselFragment.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index 0d86c4cd24..aaef1ddf01 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -51,6 +51,8 @@ class FtueAuthSplashCarouselFragment @Inject constructor( private val carouselStateFactory: SplashCarouselStateFactory ) : AbstractFtueAuthFragment() { + private var tabLayoutMediator: TabLayoutMediator? = null + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueSplashCarouselBinding { return FragmentFtueSplashCarouselBinding.inflate(inflater, container, false) } @@ -60,10 +62,19 @@ class FtueAuthSplashCarouselFragment @Inject constructor( setupViews() } + override fun onDestroyView() { + tabLayoutMediator?.detach() + tabLayoutMediator = null + views.splashCarousel.adapter = null + super.onDestroyView() + } + private fun setupViews() { val carouselAdapter = carouselController.adapter views.splashCarousel.adapter = carouselAdapter - TabLayoutMediator(views.carouselIndicator, views.splashCarousel) { _, _ -> }.attach() + tabLayoutMediator = TabLayoutMediator(views.carouselIndicator, views.splashCarousel) { _, _ -> } + .also { it.attach() } + carouselController.setData(carouselStateFactory.create()) val isAlreadyHaveAccountEnabled = vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled() From 2b58c42c8bdc3fffa3e3c0bf9bad07c901bbd16a Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 28 Jul 2022 17:30:05 +0200 Subject: [PATCH 02/58] Adding changelog entry --- changelog.d/6680.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6680.misc diff --git a/changelog.d/6680.misc b/changelog.d/6680.misc new file mode 100644 index 0000000000..f42160fbba --- /dev/null +++ b/changelog.d/6680.misc @@ -0,0 +1 @@ +[FTUE] Memory leak on FtueAuthSplashCarouselFragment From 004f40bff568ca13d12077f9858e71f5ba474a1f Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 27 Jul 2022 15:48:40 +0200 Subject: [PATCH 03/58] Setting 5 seconds for min period of update for location tracking --- .../java/im/vector/app/features/location/Config.kt | 2 +- .../im/vector/app/features/location/LocationTracker.kt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/Config.kt b/vector/src/main/java/im/vector/app/features/location/Config.kt index c29e2e911a..6f947290e2 100644 --- a/vector/src/main/java/im/vector/app/features/location/Config.kt +++ b/vector/src/main/java/im/vector/app/features/location/Config.kt @@ -22,5 +22,5 @@ const val DEFAULT_PIN_ID = "DEFAULT_PIN_ID" const val INITIAL_MAP_ZOOM_IN_PREVIEW = 15.0 const val INITIAL_MAP_ZOOM_IN_TIMELINE = 17.0 -const val MIN_TIME_TO_UPDATE_LOCATION_MILLIS = 2 * 1_000L // every 2 seconds +const val MIN_TIME_TO_UPDATE_LOCATION_MILLIS = 5 * 1_000L // every 5 seconds const val MIN_DISTANCE_TO_UPDATE_LOCATION_METERS = 10f diff --git a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt index aa05fe764b..079a65d9b9 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt @@ -61,6 +61,7 @@ class LocationTracker @Inject constructor( @VisibleForTesting var hasLocationFromGPSProvider = false + private var firstLocationHandled = false private val _locations = MutableSharedFlow(replay = 1) /** @@ -68,7 +69,14 @@ class LocationTracker @Inject constructor( */ val locations = _locations.asSharedFlow() .onEach { Timber.d("new location emitted") } - .debounce(MIN_TIME_TO_UPDATE_LOCATION_MILLIS) + .debounce { + if (firstLocationHandled) { + MIN_TIME_TO_UPDATE_LOCATION_MILLIS + } else { + firstLocationHandled = true + 0 + } + } .onEach { Timber.d("new location emitted after debounce") } .map { it.toLocationData() } From 0944b2ff393fa530b7f1d39f3bee4e0f759b1fa0 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 27 Jul 2022 16:02:27 +0200 Subject: [PATCH 04/58] Adding changelog entry --- changelog.d/6653.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6653.misc diff --git a/changelog.d/6653.misc b/changelog.d/6653.misc new file mode 100644 index 0000000000..1b5be1b83f --- /dev/null +++ b/changelog.d/6653.misc @@ -0,0 +1 @@ +[Location share] Update minimum sending period to 5 seconds for a live From 49ad37a7f69b9d59863c6afb6a9591ee93d37824 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 2 Aug 2022 09:27:27 +0200 Subject: [PATCH 05/58] Using Duration to have clearer syntax --- .../java/im/vector/app/features/location/Config.kt | 2 -- .../app/features/location/LocationTracker.kt | 11 +++++++++-- .../app/features/location/LocationTrackerTest.kt | 14 +++++++------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/Config.kt b/vector/src/main/java/im/vector/app/features/location/Config.kt index 6f947290e2..b65b5517d1 100644 --- a/vector/src/main/java/im/vector/app/features/location/Config.kt +++ b/vector/src/main/java/im/vector/app/features/location/Config.kt @@ -22,5 +22,3 @@ const val DEFAULT_PIN_ID = "DEFAULT_PIN_ID" const val INITIAL_MAP_ZOOM_IN_PREVIEW = 15.0 const val INITIAL_MAP_ZOOM_IN_TIMELINE = 17.0 -const val MIN_TIME_TO_UPDATE_LOCATION_MILLIS = 5 * 1_000L // every 5 seconds -const val MIN_DISTANCE_TO_UPDATE_LOCATION_METERS = 10f diff --git a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt index 079a65d9b9..966a2600b4 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt @@ -36,6 +36,10 @@ import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject import javax.inject.Singleton +import kotlin.time.Duration.Companion.seconds + +@VisibleForTesting +const val MIN_DISTANCE_TO_UPDATE_LOCATION_METERS = 10f @Singleton class LocationTracker @Inject constructor( @@ -64,6 +68,9 @@ class LocationTracker @Inject constructor( private var firstLocationHandled = false private val _locations = MutableSharedFlow(replay = 1) + @VisibleForTesting + val minDurationToUpdateLocationMillis = 5.seconds.inWholeMilliseconds + /** * SharedFlow to collect location updates. */ @@ -71,7 +78,7 @@ class LocationTracker @Inject constructor( .onEach { Timber.d("new location emitted") } .debounce { if (firstLocationHandled) { - MIN_TIME_TO_UPDATE_LOCATION_MILLIS + minDurationToUpdateLocationMillis } else { firstLocationHandled = true 0 @@ -103,7 +110,7 @@ class LocationTracker @Inject constructor( locationManager.requestLocationUpdates( provider, - MIN_TIME_TO_UPDATE_LOCATION_MILLIS, + minDurationToUpdateLocationMillis, MIN_DISTANCE_TO_UPDATE_LOCATION_METERS, this ) diff --git a/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt b/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt index 454a73cd70..d6d6410c99 100644 --- a/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt +++ b/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt @@ -75,19 +75,19 @@ class LocationTrackerTest { verifyOrder { fakeLocationManager.instance.requestLocationUpdates( LocationManager.FUSED_PROVIDER, - MIN_TIME_TO_UPDATE_LOCATION_MILLIS, + locationTracker.minDurationToUpdateLocationMillis, MIN_DISTANCE_TO_UPDATE_LOCATION_METERS, locationTracker ) fakeLocationManager.instance.requestLocationUpdates( LocationManager.GPS_PROVIDER, - MIN_TIME_TO_UPDATE_LOCATION_MILLIS, + locationTracker.minDurationToUpdateLocationMillis, MIN_DISTANCE_TO_UPDATE_LOCATION_METERS, locationTracker ) fakeLocationManager.instance.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, - MIN_TIME_TO_UPDATE_LOCATION_MILLIS, + locationTracker.minDurationToUpdateLocationMillis, MIN_DISTANCE_TO_UPDATE_LOCATION_METERS, locationTracker ) @@ -154,7 +154,7 @@ class LocationTrackerTest { locationTracker.onLocationChanged(fusedLocation) locationTracker.onLocationChanged(gpsLocation) locationTracker.onLocationChanged(networkLocation) - advanceTimeBy(MIN_TIME_TO_UPDATE_LOCATION_MILLIS + 1) + advanceTimeBy(locationTracker.minDurationToUpdateLocationMillis + 1) val expectedLocationData = LocationData( latitude = 1.0, @@ -188,7 +188,7 @@ class LocationTrackerTest { locationTracker.onLocationChanged(gpsLocation) locationTracker.onLocationChanged(networkLocation) - advanceTimeBy(MIN_TIME_TO_UPDATE_LOCATION_MILLIS + 1) + advanceTimeBy(locationTracker.minDurationToUpdateLocationMillis + 1) val expectedLocationData = LocationData( latitude = 1.0, @@ -217,7 +217,7 @@ class LocationTrackerTest { val resultUpdates = locationTracker.locations.test(this) locationTracker.onLocationChanged(networkLocation) - advanceTimeBy(MIN_TIME_TO_UPDATE_LOCATION_MILLIS + 1) + advanceTimeBy(locationTracker.minDurationToUpdateLocationMillis + 1) val expectedLocationData = LocationData( latitude = 1.0, @@ -243,7 +243,7 @@ class LocationTrackerTest { val resultUpdates = locationTracker.locations.test(this) locationTracker.requestLastKnownLocation() - advanceTimeBy(MIN_TIME_TO_UPDATE_LOCATION_MILLIS + 1) + advanceTimeBy(locationTracker.minDurationToUpdateLocationMillis + 1) val expectedLocationData = LocationData( latitude = A_LATITUDE, From 274b1a149c941b14bb6b96ece8084ae8eb900614 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 11:42:57 +0100 Subject: [PATCH 06/58] moving analytics config to the config module, it's now up to forks to opt out rather than relying on the package name to not be vector --- .../main/java/im/vector/app/config/Config.kt | 57 +++++++++++++++++++ .../im/vector/app/config/AnalyticsConfig.kt | 27 --------- .../im/vector/app/core/di/SingletonModule.kt | 19 ++++++- .../app/features/analytics/AnalyticsConfig.kt | 14 ++--- .../features/analytics/impl/PostHogFactory.kt | 4 +- .../ui/consent/AnalyticsOptInFragment.kt | 8 +-- .../features/home/HomeActivityViewModel.kt | 5 +- .../VectorSettingsSecurityPrivacyFragment.kt | 5 +- .../im/vector/app/config/AnalyticsConfig.kt | 32 ----------- .../test/fixtures/AnalyticsConfigFixture.kt | 7 +-- 10 files changed, 94 insertions(+), 84 deletions(-) delete mode 100644 vector/src/debug/java/im/vector/app/config/AnalyticsConfig.kt delete mode 100644 vector/src/release/java/im/vector/app/config/AnalyticsConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 7577e6dba5..f96df302e9 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -36,4 +36,61 @@ object Config { * - Changing the value from `true` to `false` will force the app to return to the background sync / Firebase Push. */ const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true + + /** + * The analytics configuration to use for the Debug build type. + * Can be disabled by providing Analytics.Disabled + */ + val DEBUG_ANALYTICS_CONFIG = Analytics.PostHog( + postHogHost = "https://posthog.element.dev", + postHogApiKey = "phc_VtA1L35nw3aeAtHIx1ayrGdzGkss7k1xINeXcoIQzXN", + policyLink = "https://element.io/cookie-policy", + ) + + /** + * The analytics configuration to use for the Release build type. + * Can be disabled by providing Analytics.Disabled + */ + val RELEASE_ANALYTICS_CONFIG = Analytics.PostHog( + postHogHost = "https://posthog.hss.element.io", + postHogApiKey = "phc_Jzsm6DTm6V2705zeU5dcNvQDlonOR68XvX2sh1sEOHO", + policyLink = "https://element.io/cookie-policy", + ) + + /** + * The analytics configuration to use for the Nightly build type. + * Can be disabled by providing Analytics.Disabled + */ + val NIGHTLY_ANALYTICS_CONFIG = RELEASE_ANALYTICS_CONFIG +} + +/** + * The types of analytics Element currently supports + */ +sealed interface Analytics { + + /** + * Disables the analytics integrations. + */ + object Disabled : Analytics + + /** + * Analytics integration via PostHog. + */ + data class PostHog( + /** + * The PostHog instance url. + */ + val postHogHost: String, + + /** + * The PostHog instance API key. + */ + val postHogApiKey: String, + + /** + * A URL to more information about the analytics collection. + */ + val policyLink: String, + ) : Analytics } diff --git a/vector/src/debug/java/im/vector/app/config/AnalyticsConfig.kt b/vector/src/debug/java/im/vector/app/config/AnalyticsConfig.kt deleted file mode 100644 index 63f14f72f6..0000000000 --- a/vector/src/debug/java/im/vector/app/config/AnalyticsConfig.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2021 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.config - -import im.vector.app.BuildConfig -import im.vector.app.features.analytics.AnalyticsConfig - -val analyticsConfig: AnalyticsConfig = object : AnalyticsConfig { - override val isEnabled = BuildConfig.APPLICATION_ID == "im.vector.app.debug" - override val postHogHost = "https://posthog.element.dev" - override val postHogApiKey = "phc_VtA1L35nw3aeAtHIx1ayrGdzGkss7k1xINeXcoIQzXN" - override val policyLink = "https://element.io/cookie-policy" -} diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index c969df74e4..ea3bf98f26 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -31,9 +31,10 @@ import dagger.hilt.components.SingletonComponent import im.vector.app.BuildConfig import im.vector.app.EmojiCompatWrapper import im.vector.app.EmojiSpanify +import im.vector.app.config.Analytics +import im.vector.app.config.Config import im.vector.app.SpaceStateHandler import im.vector.app.SpaceStateHandlerImpl -import im.vector.app.config.analyticsConfig import im.vector.app.core.dispatchers.CoroutineDispatchers import im.vector.app.core.error.DefaultErrorFormatter import im.vector.app.core.error.ErrorFormatter @@ -207,7 +208,21 @@ object VectorStaticModule { @Provides fun providesAnalyticsConfig(): AnalyticsConfig { - return analyticsConfig + val config: Analytics = when (BuildConfig.BUILD_TYPE) { + "debug" -> Config.DEBUG_ANALYTICS_CONFIG + "nightly" -> Config.NIGHTLY_ANALYTICS_CONFIG + "release" -> Config.RELEASE_ANALYTICS_CONFIG + else -> throw IllegalStateException("Unhandled build type: ${BuildConfig.BUILD_TYPE}") + } + return when (config) { + Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") + is Analytics.PostHog -> AnalyticsConfig( + isEnabled = true, + postHogHost = config.postHogHost, + postHogApiKey = config.postHogApiKey, + policyLink = config.policyLink + ) + } } @Provides diff --git a/vector/src/main/java/im/vector/app/features/analytics/AnalyticsConfig.kt b/vector/src/main/java/im/vector/app/features/analytics/AnalyticsConfig.kt index 46119f5563..bffba6fa9c 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/AnalyticsConfig.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/AnalyticsConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * 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. @@ -16,9 +16,9 @@ package im.vector.app.features.analytics -interface AnalyticsConfig { - val isEnabled: Boolean - val postHogHost: String - val postHogApiKey: String - val policyLink: String -} +data class AnalyticsConfig( + val isEnabled: Boolean, + val postHogHost: String, + val postHogApiKey: String, + val policyLink: String, +) diff --git a/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt b/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt index 029732f76c..b86c2cf75a 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt @@ -19,10 +19,10 @@ package im.vector.app.features.analytics.impl import android.content.Context import com.posthog.android.PostHog import im.vector.app.BuildConfig -import im.vector.app.config.analyticsConfig +import im.vector.app.features.analytics.AnalyticsConfig import javax.inject.Inject -class PostHogFactory @Inject constructor(private val context: Context) { +class PostHogFactory @Inject constructor(private val context: Context, private val analyticsConfig: AnalyticsConfig) { fun createPosthog(): PostHog { return PostHog.Builder(context, analyticsConfig.postHogApiKey, analyticsConfig.postHogHost) diff --git a/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt b/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt index 320386aebd..a5bafa2ee6 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt @@ -22,17 +22,17 @@ import android.view.View import android.view.ViewGroup import com.airbnb.mvrx.activityViewModel import im.vector.app.R -import im.vector.app.config.analyticsConfig import im.vector.app.core.extensions.setTextWithColoredPart import im.vector.app.core.platform.OnBackPressed import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.databinding.FragmentAnalyticsOptinBinding +import im.vector.app.features.analytics.AnalyticsConfig import javax.inject.Inject -class AnalyticsOptInFragment @Inject constructor() : - VectorBaseFragment(), - OnBackPressed { +class AnalyticsOptInFragment @Inject constructor( + private val analyticsConfig: AnalyticsConfig, +) : VectorBaseFragment(), OnBackPressed { // Share the view model with the Activity so that the Activity // can decide what to do when the data has been saved diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index eb24a1ba86..cfe76706a5 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -22,11 +22,11 @@ import com.airbnb.mvrx.ViewModelContext import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject -import im.vector.app.config.analyticsConfig import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.platform.VectorViewModel +import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.analytics.AnalyticsTracker import im.vector.app.features.analytics.extensions.toAnalyticsType import im.vector.app.features.analytics.plan.Signup @@ -80,7 +80,8 @@ class HomeActivityViewModel @AssistedInject constructor( private val analyticsStore: AnalyticsStore, private val lightweightSettingsStorage: LightweightSettingsStorage, private val vectorPreferences: VectorPreferences, - private val analyticsTracker: AnalyticsTracker + private val analyticsTracker: AnalyticsTracker, + private val analyticsConfig: AnalyticsConfig, ) : VectorViewModel(initialState) { @AssistedFactory diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt index f25ad0661a..ac8a47b81e 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -35,7 +35,6 @@ import androidx.recyclerview.widget.RecyclerView import com.airbnb.mvrx.fragmentViewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import im.vector.app.R -import im.vector.app.config.analyticsConfig import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.dialogs.ExportKeysDialog import im.vector.app.core.extensions.queryExportKeys @@ -51,6 +50,7 @@ import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.openFileSelection import im.vector.app.core.utils.toast import im.vector.app.databinding.DialogImportE2eKeysBinding +import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.analytics.ui.consent.AnalyticsConsentViewActions import im.vector.app.features.analytics.ui.consent.AnalyticsConsentViewModel @@ -84,7 +84,8 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( private val keysExporter: KeysExporter, private val keysImporter: KeysImporter, private val rawService: RawService, - private val navigator: Navigator + private val navigator: Navigator, + private val analyticsConfig: AnalyticsConfig, ) : VectorSettingsBaseFragment() { override var titleRes = R.string.settings_security_and_privacy diff --git a/vector/src/release/java/im/vector/app/config/AnalyticsConfig.kt b/vector/src/release/java/im/vector/app/config/AnalyticsConfig.kt deleted file mode 100644 index e1427338b2..0000000000 --- a/vector/src/release/java/im/vector/app/config/AnalyticsConfig.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021 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.config - -import im.vector.app.BuildConfig -import im.vector.app.features.analytics.AnalyticsConfig - -private val allowedPackageList = listOf( - "im.vector.app", - "im.vector.app.nightly", -) - -val analyticsConfig: AnalyticsConfig = object : AnalyticsConfig { - override val isEnabled = BuildConfig.APPLICATION_ID in allowedPackageList - override val postHogHost = "https://posthog.hss.element.io" - override val postHogApiKey = "phc_Jzsm6DTm6V2705zeU5dcNvQDlonOR68XvX2sh1sEOHO" - override val policyLink = "https://element.io/cookie-policy" -} diff --git a/vector/src/test/java/im/vector/app/test/fixtures/AnalyticsConfigFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/AnalyticsConfigFixture.kt index 5fbcdd98d1..ea1769ecb2 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/AnalyticsConfigFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/AnalyticsConfigFixture.kt @@ -24,10 +24,5 @@ object AnalyticsConfigFixture { postHogHost: String = "http://posthog.url", postHogApiKey: String = "api-key", policyLink: String = "http://policy.link" - ) = object : AnalyticsConfig { - override val isEnabled: Boolean = isEnabled - override val postHogHost = postHogHost - override val postHogApiKey = postHogApiKey - override val policyLink = policyLink - } + ) = AnalyticsConfig(isEnabled, postHogHost, postHogApiKey, policyLink) } From 87a8c786f722492165ba9477a0e408121d55d3fb Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 12:22:39 +0100 Subject: [PATCH 07/58] moving the voice message limit to the config module --- .../main/java/im/vector/app/config/Config.kt | 5 +++++ vector/build.gradle | 2 -- .../im/vector/app/core/di/SingletonModule.kt | 6 ++++++ .../composer/voice/VoiceMessageConfig.kt | 21 +++++++++++++++++++ .../voice/VoiceMessageRecorderView.kt | 3 ++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index f96df302e9..31bb6ed1e0 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -37,6 +37,11 @@ object Config { */ const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true + /** + * The maximum length of voice messages in milliseconds. + */ + const val VOICE_MESSAGE_LIMIT = 120_000L + /** * The analytics configuration to use for the Debug build type. * Can be disabled by providing Analytics.Disabled diff --git a/vector/build.gradle b/vector/build.gradle index 0b7973a148..d306b06bb3 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -160,8 +160,6 @@ android { buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping" - buildConfigField "Long", "VOICE_MESSAGE_DURATION_LIMIT_MS", "120_000L" - // If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. // This *must* only be set in trusted environments. buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index ea3bf98f26..e1d69f97d9 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -47,6 +47,7 @@ import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.analytics.AnalyticsTracker import im.vector.app.features.analytics.VectorAnalytics import im.vector.app.features.analytics.impl.DefaultVectorAnalytics +import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig import im.vector.app.features.invite.AutoAcceptInvites import im.vector.app.features.invite.CompileTimeAutoAcceptInvites import im.vector.app.features.navigation.DefaultNavigator @@ -228,6 +229,11 @@ object VectorStaticModule { @Provides fun providesPhoneNumberUtil(): PhoneNumberUtil = PhoneNumberUtil.getInstance() + @Provides + fun providesVoiceMessageConfig() = VoiceMessageConfig( + lengthLimitMs = Config.VOICE_MESSAGE_LIMIT + ) + @Provides @Singleton fun providesBuildMeta() = BuildMeta() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageConfig.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageConfig.kt new file mode 100644 index 0000000000..5ba5e40ca8 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageConfig.kt @@ -0,0 +1,21 @@ +/* + * 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.detail.composer.voice + +data class VoiceMessageConfig( + val lengthLimitMs: Long +) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt index 536a582ec1..c2775976fc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt @@ -57,6 +57,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( } @Inject lateinit var clock: Clock + @Inject lateinit var voiceMessageConfig: VoiceMessageConfig // We need to define views as lateinit var to be able to check if initialized for the bug fix on api 21 and 22. @Suppress("UNNECESSARY_LATEINIT") @@ -202,7 +203,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( private fun onRecordingTick(isLocked: Boolean, milliseconds: Long) { voiceMessageViews.renderRecordingTimer(isLocked, milliseconds / 1_000) - val timeDiffToRecordingLimit = BuildConfig.VOICE_MESSAGE_DURATION_LIMIT_MS - milliseconds + val timeDiffToRecordingLimit = voiceMessageConfig.lengthLimitMs - milliseconds if (timeDiffToRecordingLimit <= 0) { post { callback.onRecordingLimitReached() From e795e9da52ef41d6c14306ca8af31f84e800a366 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 12:41:33 +0100 Subject: [PATCH 08/58] porting the onboarding variant selection to the config --- .../src/main/java/im/vector/app/config/Config.kt | 16 ++++++++++++++-- vector/build.gradle | 2 -- .../debug/features/DebugVectorFeatures.kt | 5 +++-- .../im/vector/app/core/di/SingletonModule.kt | 2 +- .../im/vector/app/features/VectorFeatures.kt | 10 ++-------- .../app/features/navigation/DefaultNavigator.kt | 2 +- .../onboarding/OnboardingVariantFactory.kt | 7 ++++--- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 31bb6ed1e0..412e942fd7 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -40,7 +40,12 @@ object Config { /** * The maximum length of voice messages in milliseconds. */ - const val VOICE_MESSAGE_LIMIT = 120_000L + const val VOICE_MESSAGE_LIMIT_MS = 120_000L + + /** + * The onboarding flow + */ + val ONBOARDING_VARIANT = OnboardingVariant.FTUE_AUTH /** * The analytics configuration to use for the Debug build type. @@ -70,7 +75,7 @@ object Config { } /** - * The types of analytics Element currently supports + * The types of analytics Element currently supports. */ sealed interface Analytics { @@ -99,3 +104,10 @@ sealed interface Analytics { val policyLink: String, ) : Analytics } + + +enum class OnboardingVariant { + LEGACY, + LOGIN_2, + FTUE_AUTH +} diff --git a/vector/build.gradle b/vector/build.gradle index d306b06bb3..3fd6237fc4 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -156,8 +156,6 @@ android { buildConfigField "String", "GIT_BRANCH_NAME", "\"${gitBranchName()}\"" buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\"" - buildConfigField "im.vector.app.features.VectorFeatures.OnboardingVariant", "ONBOARDING_VARIANT", "im.vector.app.features.VectorFeatures.OnboardingVariant.FTUE_AUTH" - buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping" // If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 23aad65653..c03a0a8663 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -24,6 +24,7 @@ import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore +import im.vector.app.config.OnboardingVariant import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.VectorFeatures import kotlinx.coroutines.flow.first @@ -39,8 +40,8 @@ class DebugVectorFeatures( private val dataStore = context.dataStore - override fun onboardingVariant(): VectorFeatures.OnboardingVariant { - return readPreferences().getEnum() ?: vectorFeatures.onboardingVariant() + override fun onboardingVariant(): OnboardingVariant { + return readPreferences().getEnum() ?: vectorFeatures.onboardingVariant() } override fun isOnboardingAlreadyHaveAccountSplashEnabled(): Boolean = read(DebugFeatureKeys.onboardingAlreadyHaveAnAccount) diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index e1d69f97d9..64ad9eda6c 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -231,7 +231,7 @@ object VectorStaticModule { @Provides fun providesVoiceMessageConfig() = VoiceMessageConfig( - lengthLimitMs = Config.VOICE_MESSAGE_LIMIT + lengthLimitMs = Config.VOICE_MESSAGE_LIMIT_MS ) @Provides diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 3a56f31b72..592f568835 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -16,8 +16,8 @@ package im.vector.app.features -import im.vector.app.BuildConfig import im.vector.app.config.Config +import im.vector.app.config.OnboardingVariant interface VectorFeatures { @@ -33,16 +33,10 @@ interface VectorFeatures { fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean fun isNewAppLayoutEnabled(): Boolean - - enum class OnboardingVariant { - LEGACY, - LOGIN_2, - FTUE_AUTH - } } class DefaultVectorFeatures : VectorFeatures { - override fun onboardingVariant(): VectorFeatures.OnboardingVariant = BuildConfig.ONBOARDING_VARIANT + override fun onboardingVariant() = Config.ONBOARDING_VARIANT override fun isOnboardingAlreadyHaveAccountSplashEnabled() = true override fun isOnboardingSplashCarouselEnabled() = true override fun isOnboardingUseCaseEnabled() = true diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index d2404b5bb8..20b79d8ba3 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -32,11 +32,11 @@ import androidx.core.util.Pair import androidx.core.view.ViewCompat import com.google.android.material.dialog.MaterialAlertDialogBuilder import im.vector.app.R +import im.vector.app.config.OnboardingVariant import im.vector.app.SpaceStateHandler import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.error.fatalError import im.vector.app.features.VectorFeatures -import im.vector.app.features.VectorFeatures.OnboardingVariant import im.vector.app.features.analytics.AnalyticsTracker import im.vector.app.features.analytics.extensions.toAnalyticsViewRoom import im.vector.app.features.analytics.plan.ViewRoom diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt index 8d9f372bdd..9837db8e91 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt @@ -16,6 +16,7 @@ package im.vector.app.features.onboarding +import im.vector.app.config.OnboardingVariant import im.vector.app.core.platform.ScreenOrientationLocker import im.vector.app.databinding.ActivityLoginBinding import im.vector.app.features.VectorFeatures @@ -34,8 +35,8 @@ class OnboardingVariantFactory @Inject constructor( onboardingViewModel: Lazy, loginViewModel2: Lazy ) = when (vectorFeatures.onboardingVariant()) { - VectorFeatures.OnboardingVariant.LEGACY -> error("Legacy is not supported by the FTUE") - VectorFeatures.OnboardingVariant.FTUE_AUTH -> FtueAuthVariant( + OnboardingVariant.LEGACY -> error("Legacy is not supported by the FTUE") + OnboardingVariant.FTUE_AUTH -> FtueAuthVariant( views = views, onboardingViewModel = onboardingViewModel.value, activity = activity, @@ -43,7 +44,7 @@ class OnboardingVariantFactory @Inject constructor( vectorFeatures = vectorFeatures, orientationLocker = orientationLocker ) - VectorFeatures.OnboardingVariant.LOGIN_2 -> Login2Variant( + OnboardingVariant.LOGIN_2 -> Login2Variant( views = views, loginViewModel = loginViewModel2.value, activity = activity, From f14aabcd2268d5849164891ea801950c728c50f7 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 14:28:48 +0100 Subject: [PATCH 09/58] ports the key sharing strategy to the config --- .../main/java/im/vector/app/config/Config.kt | 23 +++++++ vector/build.gradle | 2 - .../vector/app/core/di/ConfigurationModule.kt | 66 +++++++++++++++++++ .../im/vector/app/core/di/SingletonModule.kt | 6 +- .../home/room/detail/TimelineViewModel.kt | 6 +- .../features/raw/wellknown/CryptoConfig.kt | 23 +++++++ .../raw/wellknown/ElementWellKnownExt.kt | 5 +- 7 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt create mode 100644 vector/src/main/java/im/vector/app/features/raw/wellknown/CryptoConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 412e942fd7..70ccc5bd5e 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -42,6 +42,11 @@ object Config { */ const val VOICE_MESSAGE_LIMIT_MS = 120_000L + /** + * The strategy for sharing device keys + */ + val KEY_SHARING_STRATEGY = KeySharingStrategy.WhenTyping + /** * The onboarding flow */ @@ -111,3 +116,21 @@ enum class OnboardingVariant { LOGIN_2, FTUE_AUTH } + +enum class KeySharingStrategy { + /** + * Keys will be sent for the first time when the first message is sent. + * This is handled by the Matrix SDK so there's no need to do it in Vector. + */ + WhenSendingEvent, + + /** + * Keys will be sent for the first time when the timeline displayed. + */ + WhenEnteringRoom, + + /** + * Keys will be sent for the first time when a typing started. + */ + WhenTyping +} diff --git a/vector/build.gradle b/vector/build.gradle index 3fd6237fc4..3d6f50ed93 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -156,8 +156,6 @@ android { buildConfigField "String", "GIT_BRANCH_NAME", "\"${gitBranchName()}\"" buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\"" - buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping" - // If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. // This *must* only be set in trusted environments. buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt new file mode 100644 index 0000000000..dc4f8dac40 --- /dev/null +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -0,0 +1,66 @@ +/* + * 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.core.di + +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import im.vector.app.BuildConfig +import im.vector.app.config.Analytics +import im.vector.app.config.Config +import im.vector.app.config.KeySharingStrategy +import im.vector.app.features.analytics.AnalyticsConfig +import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy +import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig +import im.vector.app.features.raw.wellknown.CryptoConfig + +@InstallIn(SingletonComponent::class) +@Module +object ConfigurationModule { + + @Provides + fun providesAnalyticsConfig(): AnalyticsConfig { + val config: Analytics = when (BuildConfig.DEBUG) { + true -> Config.DEBUG_ANALYTICS_CONFIG + false -> Config.RELEASE_ANALYTICS_CONFIG + } + return when (config) { + Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") + is Analytics.PostHog -> AnalyticsConfig( + isEnabled = true, + postHogHost = config.postHogHost, + postHogApiKey = config.postHogApiKey, + policyLink = config.policyLink + ) + } + } + + @Provides + fun providesVoiceMessageConfig() = VoiceMessageConfig( + lengthLimitMs = Config.VOICE_MESSAGE_LIMIT_MS + ) + + @Provides + fun providesCryptoConfig() = CryptoConfig( + fallbackKeySharingStrategy = when (Config.KEY_SHARING_STRATEGY) { + KeySharingStrategy.WhenSendingEvent -> OutboundSessionKeySharingStrategy.WhenSendingEvent + KeySharingStrategy.WhenEnteringRoom -> OutboundSessionKeySharingStrategy.WhenSendingEvent + KeySharingStrategy.WhenTyping -> OutboundSessionKeySharingStrategy.WhenSendingEvent + } + ) +} diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 64ad9eda6c..bfa37057e2 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -207,6 +207,9 @@ object VectorStaticModule { return GlobalScope } + @Provides + fun providesPhoneNumberUtil(): PhoneNumberUtil = PhoneNumberUtil.getInstance() + @Provides fun providesAnalyticsConfig(): AnalyticsConfig { val config: Analytics = when (BuildConfig.BUILD_TYPE) { @@ -226,9 +229,6 @@ object VectorStaticModule { } } - @Provides - fun providesPhoneNumberUtil(): PhoneNumberUtil = PhoneNumberUtil.getInstance() - @Provides fun providesVoiceMessageConfig() = VoiceMessageConfig( lengthLimitMs = Config.VOICE_MESSAGE_LIMIT_MS diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index 848bd3aed4..b2a0e52db9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -56,6 +56,7 @@ import im.vector.app.features.location.LocationSharingServiceConnection import im.vector.app.features.location.live.StopLiveLocationShareUseCase import im.vector.app.features.notifications.NotificationDrawerManager import im.vector.app.features.powerlevel.PowerLevelsFlowFactory +import im.vector.app.features.raw.wellknown.CryptoConfig import im.vector.app.features.raw.wellknown.getOutboundSessionKeySharingStrategyOrDefault import im.vector.app.features.raw.wellknown.withElementWellKnown import im.vector.app.features.session.coroutineScope @@ -137,6 +138,7 @@ class TimelineViewModel @AssistedInject constructor( private val locationSharingServiceConnection: LocationSharingServiceConnection, private val stopLiveLocationShareUseCase: StopLiveLocationShareUseCase, private val redactLiveLocationShareEventUseCase: RedactLiveLocationShareEventUseCase, + private val cryptoConfig: CryptoConfig, timelineFactory: TimelineFactory, spaceStateHandler: SpaceStateHandler, ) : VectorViewModel(initialState), @@ -205,7 +207,7 @@ class TimelineViewModel @AssistedInject constructor( // Ensure to share the outbound session keys with all members if (room.roomCryptoService().isEncrypted()) { rawService.withElementWellKnown(viewModelScope, session.sessionParams) { - val strategy = it.getOutboundSessionKeySharingStrategyOrDefault() + val strategy = it.getOutboundSessionKeySharingStrategyOrDefault(cryptoConfig.fallbackKeySharingStrategy) if (strategy == OutboundSessionKeySharingStrategy.WhenEnteringRoom) { prepareForEncryption() } @@ -688,7 +690,7 @@ class TimelineViewModel @AssistedInject constructor( // Ensure outbound session keys if (room.roomCryptoService().isEncrypted()) { rawService.withElementWellKnown(viewModelScope, session.sessionParams) { - val strategy = it.getOutboundSessionKeySharingStrategyOrDefault() + val strategy = it.getOutboundSessionKeySharingStrategyOrDefault(cryptoConfig.fallbackKeySharingStrategy) if (strategy == OutboundSessionKeySharingStrategy.WhenTyping && action.focused) { // Should we add some rate limit here, or do it only once per model lifecycle? prepareForEncryption() diff --git a/vector/src/main/java/im/vector/app/features/raw/wellknown/CryptoConfig.kt b/vector/src/main/java/im/vector/app/features/raw/wellknown/CryptoConfig.kt new file mode 100644 index 0000000000..130fa0078a --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/raw/wellknown/CryptoConfig.kt @@ -0,0 +1,23 @@ +/* + * 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.raw.wellknown + +import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy + +data class CryptoConfig( + val fallbackKeySharingStrategy: OutboundSessionKeySharingStrategy +) diff --git a/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt b/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt index 73662613f7..28c7fecf0b 100644 --- a/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt +++ b/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt @@ -16,7 +16,6 @@ package im.vector.app.features.raw.wellknown -import im.vector.app.BuildConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -35,12 +34,12 @@ suspend fun RawService.getElementWellknown(sessionParams: SessionParams): Elemen fun ElementWellKnown.isE2EByDefault() = elementE2E?.e2eDefault ?: riotE2E?.e2eDefault ?: true -fun ElementWellKnown?.getOutboundSessionKeySharingStrategyOrDefault(): OutboundSessionKeySharingStrategy { +fun ElementWellKnown?.getOutboundSessionKeySharingStrategyOrDefault(fallback: OutboundSessionKeySharingStrategy): OutboundSessionKeySharingStrategy { return when (this?.elementE2E?.outboundsKeyPreSharingMode) { "on_room_opening" -> OutboundSessionKeySharingStrategy.WhenEnteringRoom "on_typing" -> OutboundSessionKeySharingStrategy.WhenTyping "disabled" -> OutboundSessionKeySharingStrategy.WhenSendingEvent - else -> BuildConfig.outboundSessionKeySharingStrategy + else -> fallback } } From 012485b8e385a09f67a6500072682efbd258e456 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 16:18:19 +0100 Subject: [PATCH 10/58] lifting the live location sharing build flag to the config along with debug toggle --- vector-config/src/main/java/im/vector/app/config/Config.kt | 2 ++ vector/build.gradle | 1 - .../features/debug/features/DebugFeaturesStateFactory.kt | 5 +++++ .../app/features/debug/features/DebugVectorFeatures.kt | 3 +++ .../src/main/java/im/vector/app/features/VectorFeatures.kt | 2 ++ .../app/features/home/room/detail/TimelineFragment.kt | 7 ++++--- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 70ccc5bd5e..384dc2e7f7 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -37,6 +37,8 @@ object Config { */ const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true + const val ENABLE_LOCATION_SHARING = true + /** * The maximum length of voice messages in milliseconds. */ diff --git a/vector/build.gradle b/vector/build.gradle index 3d6f50ed93..a3b228b0af 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -160,7 +160,6 @@ android { // This *must* only be set in trusted environments. buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" - buildConfigField "Boolean", "enableLocationSharing", "true" buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\"" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index 8fe65bd387..d7e402c4dc 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -70,6 +70,11 @@ class DebugFeaturesStateFactory @Inject constructor( key = DebugFeatureKeys.allowExternalUnifiedPushDistributors, factory = VectorFeatures::allowExternalUnifiedPushDistributors ), + createBooleanFeature( + label = "Enable Live Location Sharing", + key = DebugFeatureKeys.liveLocationSharing, + factory = VectorFeatures::isLocationSharingEnabled + ), createBooleanFeature( label = "Force usage of OpusEncoder library", key = DebugFeatureKeys.forceUsageOfOpusEncoder, diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index c03a0a8663..031ff11d59 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -67,6 +67,9 @@ class DebugVectorFeatures( override fun isScreenSharingEnabled(): Boolean = read(DebugFeatureKeys.screenSharing) ?: vectorFeatures.isScreenSharingEnabled() + override fun isLocationSharingEnabled(): Boolean = read(DebugFeatureKeys.liveLocationSharing) + ?: vectorFeatures.isLocationSharingEnabled() + override fun forceUsageOfOpusEncoder(): Boolean = read(DebugFeatureKeys.forceUsageOfOpusEncoder) ?: vectorFeatures.forceUsageOfOpusEncoder() diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 592f568835..290d21879d 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -30,6 +30,7 @@ interface VectorFeatures { fun isOnboardingCombinedLoginEnabled(): Boolean fun allowExternalUnifiedPushDistributors(): Boolean fun isScreenSharingEnabled(): Boolean + fun isLocationSharingEnabled(): Boolean fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean fun isNewAppLayoutEnabled(): Boolean @@ -45,6 +46,7 @@ class DefaultVectorFeatures : VectorFeatures { override fun isOnboardingCombinedLoginEnabled() = true override fun allowExternalUnifiedPushDistributors(): Boolean = Config.ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS override fun isScreenSharingEnabled(): Boolean = true + override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun forceUsageOfOpusEncoder(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false override fun isNewAppLayoutEnabled(): Boolean = false 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 7acc77a686..727791c540 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 @@ -67,7 +67,6 @@ 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 @@ -125,6 +124,7 @@ import im.vector.app.core.utils.startInstallFromSourceIntent import im.vector.app.core.utils.toast import im.vector.app.databinding.DialogReportContentBinding import im.vector.app.databinding.FragmentTimelineBinding +import im.vector.app.features.VectorFeatures import im.vector.app.features.analytics.extensions.toAnalyticsInteraction import im.vector.app.features.analytics.plan.Interaction import im.vector.app.features.analytics.plan.MobileScreen @@ -275,7 +275,8 @@ class TimelineFragment @Inject constructor( private val callManager: WebRtcCallManager, private val audioMessagePlaybackTracker: AudioMessagePlaybackTracker, private val shareIntentHandler: ShareIntentHandler, - private val clock: Clock + private val clock: Clock, + private val vectorFeatures: VectorFeatures, ) : VectorBaseFragment(), TimelineEventController.Callback, @@ -1559,7 +1560,7 @@ class TimelineFragment @Inject constructor( attachmentTypeSelector = AttachmentTypeSelectorView(vectorBaseActivity, vectorBaseActivity.layoutInflater, this@TimelineFragment) attachmentTypeSelector.setAttachmentVisibility( AttachmentTypeSelectorView.Type.LOCATION, - BuildConfig.enableLocationSharing + vectorFeatures.isLocationSharingEnabled(), ) attachmentTypeSelector.setAttachmentVisibility( AttachmentTypeSelectorView.Type.POLL, !isThreadTimeLine() From 56afac26ad57198fb38be551a5fb40946cac0bb8 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 16:30:49 +0100 Subject: [PATCH 11/58] creating a location sharing config for holding the map tiler key --- .../main/java/im/vector/app/config/Config.kt | 1 + vector/build.gradle | 2 -- .../vector/app/core/di/ConfigurationModule.kt | 10 +++++++-- .../location/LocationSharingConfig.kt | 21 +++++++++++++++++++ .../app/features/location/UrlMapProvider.kt | 6 +++--- 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 384dc2e7f7..9398cd1457 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -38,6 +38,7 @@ object Config { const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true const val ENABLE_LOCATION_SHARING = true + const val LOCATION_MAP_TILER_KEY = "fU3vlMsMn4Jb6dnEIFsx" /** * The maximum length of voice messages in milliseconds. diff --git a/vector/build.gradle b/vector/build.gradle index a3b228b0af..f9a81eb76c 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -160,8 +160,6 @@ android { // This *must* only be set in trusted environments. buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" - buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\"" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // Keep abiFilter for the universalApk diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index dc4f8dac40..c8469957f6 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -27,6 +27,7 @@ import im.vector.app.config.KeySharingStrategy import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig +import im.vector.app.features.location.LocationSharingConfig import im.vector.app.features.raw.wellknown.CryptoConfig @InstallIn(SingletonComponent::class) @@ -40,7 +41,7 @@ object ConfigurationModule { false -> Config.RELEASE_ANALYTICS_CONFIG } return when (config) { - Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") + Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") is Analytics.PostHog -> AnalyticsConfig( isEnabled = true, postHogHost = config.postHogHost, @@ -60,7 +61,12 @@ object ConfigurationModule { fallbackKeySharingStrategy = when (Config.KEY_SHARING_STRATEGY) { KeySharingStrategy.WhenSendingEvent -> OutboundSessionKeySharingStrategy.WhenSendingEvent KeySharingStrategy.WhenEnteringRoom -> OutboundSessionKeySharingStrategy.WhenSendingEvent - KeySharingStrategy.WhenTyping -> OutboundSessionKeySharingStrategy.WhenSendingEvent + KeySharingStrategy.WhenTyping -> OutboundSessionKeySharingStrategy.WhenSendingEvent } ) + + @Provides + fun providesLocationSharingConfig() = LocationSharingConfig( + mapTilerKey = Config.LOCATION_MAP_TILER_KEY, + ) } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt new file mode 100644 index 0000000000..4615564e41 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt @@ -0,0 +1,21 @@ +/* + * 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.location + +data class LocationSharingConfig( + val mapTilerKey: String, +) diff --git a/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt b/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt index f043006d70..3748b1b19e 100644 --- a/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt +++ b/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt @@ -16,7 +16,6 @@ package im.vector.app.features.location -import im.vector.app.BuildConfig import im.vector.app.features.raw.wellknown.getElementWellknown import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService @@ -25,9 +24,10 @@ import javax.inject.Inject class UrlMapProvider @Inject constructor( private val session: Session, - private val rawService: RawService + private val rawService: RawService, + locationSharingConfig: LocationSharingConfig, ) { - private val keyParam = "?key=${BuildConfig.mapTilerKey}" + private val keyParam = "?key=${locationSharingConfig.mapTilerKey}" private val fallbackMapUrl = buildString { append(MAP_BASE_URL) From b6d052e58d5ebf4ecd82e7656ba5ca14d7fba95e Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 16:46:32 +0100 Subject: [PATCH 12/58] lifting voip setting to a voip config --- .../main/java/im/vector/app/config/Config.kt | 7 ++++++- vector/build.gradle | 4 ---- .../vector/app/core/di/ConfigurationModule.kt | 6 ++++++ .../app/features/call/webrtc/VoipConfig.kt | 21 +++++++++++++++++++ .../features/call/webrtc/WebRtcCallManager.kt | 3 ++- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 9398cd1457..a15ac198b9 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -55,6 +55,12 @@ object Config { */ val ONBOARDING_VARIANT = OnboardingVariant.FTUE_AUTH + /** + * If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. + * This *must* only be set in trusted environments. + */ + const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false + /** * The analytics configuration to use for the Debug build type. * Can be disabled by providing Analytics.Disabled @@ -113,7 +119,6 @@ sealed interface Analytics { ) : Analytics } - enum class OnboardingVariant { LEGACY, LOGIN_2, diff --git a/vector/build.gradle b/vector/build.gradle index f9a81eb76c..0aaf46a6b2 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -156,10 +156,6 @@ android { buildConfigField "String", "GIT_BRANCH_NAME", "\"${gitBranchName()}\"" buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\"" - // If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. - // This *must* only be set in trusted environments. - buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // Keep abiFilter for the universalApk diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index c8469957f6..296f0be070 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -25,6 +25,7 @@ import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.config.KeySharingStrategy import im.vector.app.features.analytics.AnalyticsConfig +import im.vector.app.features.call.webrtc.VoipConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig import im.vector.app.features.location.LocationSharingConfig @@ -69,4 +70,9 @@ object ConfigurationModule { fun providesLocationSharingConfig() = LocationSharingConfig( mapTilerKey = Config.LOCATION_MAP_TILER_KEY, ) + + @Provides + fun providesVoipConfig() = VoipConfig( + handleCallAssertedIdentityEvents = Config.HANDLE_CALL_ASSERTED_IDENTITY_EVENTS + ) } diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt new file mode 100644 index 0000000000..03a9312999 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt @@ -0,0 +1,21 @@ +/* + * 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.call.webrtc + +data class VoipConfig( + val handleCallAssertedIdentityEvents: Boolean +) diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt index b35ab774be..634c61a7b2 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt @@ -74,6 +74,7 @@ class WebRtcCallManager @Inject constructor( private val activeSessionDataSource: ActiveSessionDataSource, private val analyticsTracker: AnalyticsTracker, private val unifiedPushHelper: UnifiedPushHelper, + private val voipConfig: VoipConfig, ) : CallListener, DefaultLifecycleObserver { @@ -444,7 +445,7 @@ class WebRtcCallManager @Inject constructor( } override fun onCallAssertedIdentityReceived(callAssertedIdentityContent: CallAssertedIdentityContent) { - if (!BuildConfig.handleCallAssertedIdentityEvents) { + if (!voipConfig.handleCallAssertedIdentityEvents) { return } val call = callsByCallId[callAssertedIdentityContent.callId] From cc4aae0f4a2dab8546826708b698be21c11b4f6d Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 1 Jul 2022 09:05:04 +0100 Subject: [PATCH 13/58] replacing DEBUG build config flag with injectable property --- .../src/main/java/im/vector/app/VectorApplication.kt | 8 +++++--- .../im/vector/app/core/di/ConfigurationModule.kt | 5 +++-- .../java/im/vector/app/core/di/SingletonModule.kt | 7 ++++++- .../vector/app/core/platform/VectorBaseActivity.kt | 12 +++++------- .../java/im/vector/app/core/resources/BuildMeta.kt | 6 +++--- .../app/features/analytics/impl/PostHogFactory.kt | 9 +++++++-- .../vector/app/features/home/HomeDrawerFragment.kt | 7 ++++--- .../im/vector/app/features/home/ShortcutCreator.kt | 7 +++++-- .../features/home/room/detail/TimelineViewModel.kt | 4 +++- .../home/room/detail/composer/AudioMessageHelper.kt | 4 +++- .../room/detail/timeline/url/PreviewUrlRetriever.kt | 7 ++++--- .../app/features/login/LoginServerUrlFormFragment.kt | 8 +++++--- .../vector/app/features/login/LoginSplashFragment.kt | 6 ++++-- .../features/login2/LoginServerUrlFormFragment2.kt | 8 +++++--- .../LoginSplashSignUpSignInSelectionFragment2.kt | 6 ++++-- .../app/features/notifications/NotificationUtils.kt | 2 ++ .../ftueauth/FtueAuthServerUrlFormFragment.kt | 7 +++++-- .../ftueauth/FtueAuthSplashCarouselFragment.kt | 6 ++++-- .../onboarding/ftueauth/FtueAuthSplashFragment.kt | 6 ++++-- .../im/vector/app/features/settings/VectorLocale.kt | 7 +++++-- .../app/features/settings/VectorPreferences.kt | 4 +++- .../settings/VectorSettingsHelpAboutFragment.kt | 6 ++++-- 22 files changed, 93 insertions(+), 49 deletions(-) diff --git a/vector/src/main/java/im/vector/app/VectorApplication.kt b/vector/src/main/java/im/vector/app/VectorApplication.kt index d3dfbf8c4f..8044ea96f7 100644 --- a/vector/src/main/java/im/vector/app/VectorApplication.kt +++ b/vector/src/main/java/im/vector/app/VectorApplication.kt @@ -41,6 +41,7 @@ import com.vanniktech.emoji.EmojiManager import com.vanniktech.emoji.google.GoogleEmojiProvider import dagger.hilt.android.HiltAndroidApp import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.analytics.VectorAnalytics import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.configuration.VectorConfiguration @@ -99,6 +100,7 @@ class VectorApplication : @Inject lateinit var flipperProxy: FlipperProxy @Inject lateinit var matrix: Matrix @Inject lateinit var fcmHelper: FcmHelper + @Inject lateinit var buildMeta: BuildMeta // font thread handler private var fontThreadHandler: Handler? = null @@ -127,12 +129,12 @@ class VectorApplication : .filterIsInstance(JitsiMeetDefaultLogHandler::class.java) .forEach { Timber.uproot(it) } - if (BuildConfig.DEBUG) { + if (buildMeta.isDebug) { Timber.plant(Timber.DebugTree()) } Timber.plant(vectorFileLogger) - if (BuildConfig.DEBUG) { + if (buildMeta.isDebug) { Stetho.initializeWithDefaults(this) } logInfo() @@ -148,7 +150,7 @@ class VectorApplication : R.array.com_google_android_gms_fonts_certs ) FontsContractCompat.requestFont(this, fontRequest, emojiCompatFontProvider, getFontThreadHandler()) - VectorLocale.init(this) + VectorLocale.init(this, buildMeta) ThemeUtils.init(this) vectorConfiguration.applyToApplicationContext() diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index 296f0be070..10c91a5dd1 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -24,6 +24,7 @@ import im.vector.app.BuildConfig import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.config.KeySharingStrategy +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.call.webrtc.VoipConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy @@ -36,8 +37,8 @@ import im.vector.app.features.raw.wellknown.CryptoConfig object ConfigurationModule { @Provides - fun providesAnalyticsConfig(): AnalyticsConfig { - val config: Analytics = when (BuildConfig.DEBUG) { + fun providesAnalyticsConfig(buildMeta: BuildMeta): AnalyticsConfig { + val config: Analytics = when (buildMeta.isDebug) { true -> Config.DEBUG_ANALYTICS_CONFIG false -> Config.RELEASE_ANALYTICS_CONFIG } diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index bfa37057e2..3ba9eb0f5b 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -23,6 +23,7 @@ import android.content.SharedPreferences import android.content.res.Resources import androidx.preference.PreferenceManager import com.google.i18n.phonenumbers.PhoneNumberUtil +import android.os.Build import dagger.Binds import dagger.Module import dagger.Provides @@ -236,7 +237,11 @@ object VectorStaticModule { @Provides @Singleton - fun providesBuildMeta() = BuildMeta() + fun providesBuildMeta() = BuildMeta( + isDebug = BuildConfig.DEBUG, + sdkInt = Build.VERSION.SDK_INT, + applicationId = BuildConfig.APPLICATION_ID, + ) @Provides @Singleton diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index 5ca5b62d1e..5bbe65d599 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -53,7 +53,6 @@ import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.EntryPointAccessors -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActivityEntryPoint @@ -67,6 +66,7 @@ import im.vector.app.core.extensions.restart import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.extensions.singletonEntryPoint import im.vector.app.core.extensions.toMvRxBundle +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.AndroidSystemSettingsProvider import im.vector.app.core.utils.ToolbarConfig import im.vector.app.core.utils.toast @@ -155,11 +155,9 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver protected lateinit var bugReporter: BugReporter private lateinit var pinLocker: PinLocker - @Inject - lateinit var rageShake: RageShake - - @Inject - lateinit var fontScalePreferences: FontScalePreferences + @Inject lateinit var rageShake: RageShake + @Inject lateinit var buildMeta: BuildMeta + @Inject lateinit var fontScalePreferences: FontScalePreferences lateinit var navigator: Navigator private set @@ -409,7 +407,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver } DebugReceiver .getIntentFilter(this) - .takeIf { BuildConfig.DEBUG } + .takeIf { buildMeta.isDebug } ?.let { debugReceiver = DebugReceiver() registerReceiver(debugReceiver, it) diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index 14d97e4c8f..beed091b58 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -16,8 +16,8 @@ package im.vector.app.core.resources -import android.os.Build - data class BuildMeta( - val sdkInt: Int = Build.VERSION.SDK_INT + val isDebug: Boolean, + val sdkInt: Int, + val applicationId: String, ) diff --git a/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt b/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt index b86c2cf75a..6ff10cfb7f 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt @@ -19,10 +19,15 @@ package im.vector.app.features.analytics.impl import android.content.Context import com.posthog.android.PostHog import im.vector.app.BuildConfig +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.analytics.AnalyticsConfig import javax.inject.Inject -class PostHogFactory @Inject constructor(private val context: Context, private val analyticsConfig: AnalyticsConfig) { +class PostHogFactory @Inject constructor( + private val context: Context, + private val analyticsConfig: AnalyticsConfig, + private val buildMeta: BuildMeta, +) { fun createPosthog(): PostHog { return PostHog.Builder(context, analyticsConfig.postHogApiKey, analyticsConfig.postHogHost) @@ -43,7 +48,7 @@ class PostHogFactory @Inject constructor(private val context: Context, private v } private fun getLogLevel(): PostHog.LogLevel { - return if (BuildConfig.DEBUG) { + return if (buildMeta.isDebug) { PostHog.LogLevel.DEBUG } else { PostHog.LogLevel.INFO diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDrawerFragment.kt b/vector/src/main/java/im/vector/app/features/home/HomeDrawerFragment.kt index 9ce950ba31..8c2f6c45ff 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDrawerFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDrawerFragment.kt @@ -23,11 +23,11 @@ import android.view.ViewGroup import androidx.core.app.ActivityOptionsCompat import androidx.core.view.ViewCompat import androidx.core.view.isVisible -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.observeK import im.vector.app.core.extensions.replaceChildFragment import im.vector.app.core.platform.VectorBaseFragment +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.startSharePlainTextIntent import im.vector.app.databinding.FragmentHomeDrawerBinding import im.vector.app.features.analytics.plan.MobileScreen @@ -43,7 +43,8 @@ import javax.inject.Inject class HomeDrawerFragment @Inject constructor( private val session: Session, private val vectorPreferences: VectorPreferences, - private val avatarRenderer: AvatarRenderer + private val avatarRenderer: AvatarRenderer, + private val buildMeta: BuildMeta, ) : VectorBaseFragment() { private lateinit var sharedActionViewModel: HomeSharedActionViewModel @@ -112,7 +113,7 @@ class HomeDrawerFragment @Inject constructor( } // Debug menu - views.homeDrawerHeaderDebugView.isVisible = BuildConfig.DEBUG && vectorPreferences.developerMode() + views.homeDrawerHeaderDebugView.isVisible = buildMeta.isDebug && vectorPreferences.developerMode() views.homeDrawerHeaderDebugView.debouncedClicks { sharedActionViewModel.post(HomeActivitySharedAction.CloseDrawer) navigator.openDebug(requireActivity()) 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 a51b8eff63..bcf3c5a5cb 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 @@ -26,6 +26,7 @@ import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.graphics.drawable.IconCompat import im.vector.app.BuildConfig 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 org.matrix.android.sdk.api.session.room.model.RoomSummary @@ -35,13 +36,15 @@ import javax.inject.Inject private val useAdaptiveIcon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O private const val adaptiveIconSizeDp = 108 private const val adaptiveIconOuterSidesDp = 18 -private const val directShareCategory = BuildConfig.APPLICATION_ID + ".SHORTCUT_SHARE" class ShortcutCreator @Inject constructor( private val context: Context, private val avatarRenderer: AvatarRenderer, - private val dimensionConverter: DimensionConverter + private val dimensionConverter: DimensionConverter, + buildMeta: BuildMeta, ) { + + private val directShareCategory = buildMeta.applicationId + ".SHORTCUT_SHARE" private val adaptiveIconSize = dimensionConverter.dpToPx(adaptiveIconSizeDp) private val adaptiveIconOuterSides = dimensionConverter.dpToPx(adaptiveIconOuterSidesDp) private val iconSize by lazy { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index b2a0e52db9..7bd6ab2ea1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -33,6 +33,7 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.mvrx.runCatchingToAsync import im.vector.app.core.platform.VectorViewModel +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.BehaviorDataSource import im.vector.app.features.analytics.AnalyticsTracker @@ -139,6 +140,7 @@ class TimelineViewModel @AssistedInject constructor( private val stopLiveLocationShareUseCase: StopLiveLocationShareUseCase, private val redactLiveLocationShareEventUseCase: RedactLiveLocationShareEventUseCase, private val cryptoConfig: CryptoConfig, + buildMeta: BuildMeta, timelineFactory: TimelineFactory, spaceStateHandler: SpaceStateHandler, ) : VectorViewModel(initialState), @@ -152,7 +154,7 @@ class TimelineViewModel @AssistedInject constructor( val timeline = timelineFactory.createTimeline(viewModelScope, room, eventId, initialState.rootThreadEventId) // Same lifecycle than the ViewModel (survive to screen rotation) - val previewUrlRetriever = PreviewUrlRetriever(session, viewModelScope) + val previewUrlRetriever = PreviewUrlRetriever(session, viewModelScope, buildMeta) // Slot to keep a pending action during permission request var pendingAction: RoomDetailAction? = null diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt index 9374d51228..6f8d78a32d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt @@ -21,6 +21,7 @@ import android.media.AudioAttributes import android.media.MediaPlayer import androidx.core.content.FileProvider import im.vector.app.BuildConfig +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.voice.VoiceFailure import im.vector.app.features.voice.VoiceRecorder @@ -43,6 +44,7 @@ import javax.inject.Inject class AudioMessageHelper @Inject constructor( private val context: Context, private val playbackTracker: AudioMessagePlaybackTracker, + private val buildMeta: BuildMeta, voiceRecorderProvider: VoiceRecorderProvider ) { private var mediaPlayer: MediaPlayer? = null @@ -88,7 +90,7 @@ class AudioMessageHelper @Inject constructor( try { voiceMessageFile?.let { - val outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", it, "Voice message.${it.extension}") + val outputFileUri = FileProvider.getUriForFile(context, buildMeta.applicationId + ".fileProvider", it, "Voice message.${it.extension}") return outputFileUri .toMultiPickerAudioType(context) ?.apply { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlRetriever.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlRetriever.kt index eef649dbc0..1c5cdd2562 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlRetriever.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlRetriever.kt @@ -16,7 +16,7 @@ package im.vector.app.features.home.room.detail.timeline.url -import im.vector.app.BuildConfig +import im.vector.app.core.resources.BuildMeta import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -27,7 +27,8 @@ import org.matrix.android.sdk.api.session.room.timeline.getLatestEventId class PreviewUrlRetriever( session: Session, - private val coroutineScope: CoroutineScope + private val coroutineScope: CoroutineScope, + private val buildMeta: BuildMeta, ) { private val mediaService = session.mediaService() @@ -77,7 +78,7 @@ class PreviewUrlRetriever( mediaService.getPreviewUrl( url = urlToRetrieve, timestamp = null, - cacheStrategy = if (BuildConfig.DEBUG) CacheStrategy.NoCache else CacheStrategy.TtlCache(CACHE_VALIDITY, false) + cacheStrategy = if (buildMeta.isDebug) CacheStrategy.NoCache else CacheStrategy.TtlCache(CACHE_VALIDITY, false) ) }.fold( { diff --git a/vector/src/main/java/im/vector/app/features/login/LoginServerUrlFormFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginServerUrlFormFragment.kt index b0adeff04b..937e1bdf55 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginServerUrlFormFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginServerUrlFormFragment.kt @@ -27,9 +27,9 @@ import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.google.android.material.textfield.TextInputLayout -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.ensureProtocol import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.databinding.FragmentLoginServerUrlFormBinding @@ -43,7 +43,9 @@ import javax.inject.Inject /** * In this screen, the user is prompted to enter a homeserver url. */ -class LoginServerUrlFormFragment @Inject constructor() : AbstractLoginFragment() { +class LoginServerUrlFormFragment @Inject constructor( + private val buildMeta: BuildMeta, +) : AbstractLoginFragment() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginServerUrlFormBinding { return FragmentLoginServerUrlFormBinding.inflate(inflater, container, false) @@ -99,7 +101,7 @@ class LoginServerUrlFormFragment @Inject constructor() : AbstractLoginFragment() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSplashBinding { @@ -57,7 +59,7 @@ class LoginSplashFragment @Inject constructor( private fun setupViews() { views.loginSplashSubmit.debouncedClicks { getStarted() } - if (BuildConfig.DEBUG || vectorPreferences.developerMode()) { + if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginServerUrlFormFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginServerUrlFormFragment2.kt index bcd2d84346..50f8f38634 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginServerUrlFormFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginServerUrlFormFragment2.kt @@ -26,9 +26,9 @@ import android.widget.ArrayAdapter import androidx.core.view.isInvisible import androidx.lifecycle.lifecycleScope import com.google.android.material.textfield.TextInputLayout -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.ensureProtocol import im.vector.app.databinding.FragmentLoginServerUrlForm2Binding import kotlinx.coroutines.flow.launchIn @@ -43,7 +43,9 @@ import javax.net.ssl.HttpsURLConnection /** * In this screen, the user is prompted to enter a homeserver url. */ -class LoginServerUrlFormFragment2 @Inject constructor() : AbstractLoginFragment2() { +class LoginServerUrlFormFragment2 @Inject constructor( + private val buildMeta: BuildMeta, +) : AbstractLoginFragment2() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginServerUrlForm2Binding { return FragmentLoginServerUrlForm2Binding.inflate(inflater, container, false) @@ -80,7 +82,7 @@ class LoginServerUrlFormFragment2 @Inject constructor() : AbstractLoginFragment2 } private fun setupUi(state: LoginViewState2) { - val completions = state.knownCustomHomeServersUrls + if (BuildConfig.DEBUG) listOf("http://10.0.2.2:8080") else emptyList() + val completions = state.knownCustomHomeServersUrls + if (buildMeta.isDebug) listOf("http://10.0.2.2:8080") else emptyList() views.loginServerUrlFormHomeServerUrl.setAdapter( ArrayAdapter( requireContext(), diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt index 611b5f4cd2..8bc9bed9e2 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt @@ -23,6 +23,7 @@ import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible import im.vector.app.BuildConfig +import im.vector.app.core.resources.BuildMeta import im.vector.app.databinding.FragmentLoginSplash2Binding import im.vector.app.features.settings.VectorPreferences import javax.inject.Inject @@ -32,7 +33,8 @@ import javax.inject.Inject * This is the new splash screen. */ class LoginSplashSignUpSignInSelectionFragment2 @Inject constructor( - private val vectorPreferences: VectorPreferences + private val vectorPreferences: VectorPreferences, + private val buildMeta: BuildMeta, ) : AbstractLoginFragment2() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSplash2Binding { @@ -49,7 +51,7 @@ class LoginSplashSignUpSignInSelectionFragment2 @Inject constructor( views.loginSignupSigninSignUp.setOnClickListener { signUp() } views.loginSignupSigninSignIn.setOnClickListener { signIn() } - if (BuildConfig.DEBUG || vectorPreferences.developerMode()) { + if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index b5bd02b9d5..0985823000 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -49,6 +49,7 @@ import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.createIgnoredUri import im.vector.app.core.platform.PendingIntentCompat +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.StringProvider import im.vector.app.core.services.CallAndroidService import im.vector.app.core.time.Clock @@ -79,6 +80,7 @@ class NotificationUtils @Inject constructor( private val stringProvider: StringProvider, private val vectorPreferences: VectorPreferences, private val clock: Clock, + private val buildMeta: BuildMeta, ) { companion object { diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt index b2a99ffb7e..525e4eeb9b 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt @@ -30,6 +30,7 @@ import com.google.android.material.textfield.TextInputLayout import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.ensureProtocol import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.databinding.FragmentLoginServerUrlFormBinding @@ -47,7 +48,9 @@ import javax.inject.Inject /** * In this screen, the user is prompted to enter a homeserver url. */ -class FtueAuthServerUrlFormFragment @Inject constructor() : AbstractFtueAuthFragment() { +class FtueAuthServerUrlFormFragment @Inject constructor( + private val buildMeta: BuildMeta, +) : AbstractFtueAuthFragment() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginServerUrlFormBinding { return FragmentLoginServerUrlFormBinding.inflate(inflater, container, false) @@ -103,7 +106,7 @@ class FtueAuthServerUrlFormFragment @Inject constructor() : AbstractFtueAuthFrag views.loginServerUrlFormNotice.text = getString(R.string.login_server_url_form_common_notice) } } - val completions = state.knownCustomHomeServersUrls + if (BuildConfig.DEBUG) listOf("http://10.0.2.2:8080") else emptyList() + val completions = state.knownCustomHomeServersUrls + if (buildMeta.isDebug) listOf("http://10.0.2.2:8080") else emptyList() views.loginServerUrlFormHomeServerUrl.setAdapter( ArrayAdapter( requireContext(), diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index 0d86c4cd24..2d12a1be7c 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -31,6 +31,7 @@ import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.incrementByOneAndWrap import im.vector.app.core.extensions.setCurrentItem +import im.vector.app.core.resources.BuildMeta import im.vector.app.databinding.FragmentFtueSplashCarouselBinding import im.vector.app.features.VectorFeatures import im.vector.app.features.onboarding.OnboardingAction @@ -48,7 +49,8 @@ class FtueAuthSplashCarouselFragment @Inject constructor( private val vectorPreferences: VectorPreferences, private val vectorFeatures: VectorFeatures, private val carouselController: SplashCarouselController, - private val carouselStateFactory: SplashCarouselStateFactory + private val carouselStateFactory: SplashCarouselStateFactory, + private val buildMeta: BuildMeta, ) : AbstractFtueAuthFragment() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueSplashCarouselBinding { @@ -76,7 +78,7 @@ class FtueAuthSplashCarouselFragment @Inject constructor( debouncedClicks { alreadyHaveAnAccount() } } - if (BuildConfig.DEBUG || vectorPreferences.developerMode()) { + if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}#${BuildConfig.BUILD_NUMBER}\n" + diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt index cd1e4b2714..d4e5722896 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt @@ -24,6 +24,7 @@ import android.view.ViewGroup import androidx.core.view.isVisible import im.vector.app.BuildConfig import im.vector.app.R +import im.vector.app.core.resources.BuildMeta import im.vector.app.databinding.FragmentFtueAuthSplashBinding import im.vector.app.features.VectorFeatures import im.vector.app.features.onboarding.OnboardingAction @@ -36,7 +37,8 @@ import javax.inject.Inject */ class FtueAuthSplashFragment @Inject constructor( private val vectorPreferences: VectorPreferences, - private val vectorFeatures: VectorFeatures + private val vectorFeatures: VectorFeatures, + private val buildMeta: BuildMeta, ) : AbstractFtueAuthFragment() { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueAuthSplashBinding { @@ -59,7 +61,7 @@ class FtueAuthSplashFragment @Inject constructor( debouncedClicks { alreadyHaveAnAccount() } } - if (BuildConfig.DEBUG || vectorPreferences.developerMode()) { + if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt index 326f20845f..6c85fa30d2 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt @@ -22,6 +22,7 @@ import androidx.core.content.edit import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.DefaultSharedPreferences +import im.vector.app.core.resources.BuildMeta import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import timber.log.Timber @@ -53,12 +54,14 @@ object VectorLocale { private set private lateinit var context: Context + private lateinit var buildMeta: BuildMeta /** * Init this object. */ - fun init(context: Context) { + fun init(context: Context, buildMeta: BuildMeta) { this.context = context + this.buildMeta = buildMeta val preferences = DefaultSharedPreferences.getInstance(context) if (preferences.contains(APPLICATION_LOCALE_LANGUAGE_KEY)) { @@ -174,7 +177,7 @@ object VectorLocale { .setScript(script) .build() } catch (exception: IllformedLocaleException) { - if (BuildConfig.DEBUG) { + if (buildMeta.isDebug) { throw exception } // Ignore this locale in production 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 3b202969e5..410f883f1d 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 @@ -26,6 +26,7 @@ import com.squareup.seismic.ShakeDetector import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.DefaultSharedPreferences +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.time.Clock import im.vector.app.features.disclaimer.SHARED_PREF_KEY import im.vector.app.features.home.ShortcutsHandler @@ -38,6 +39,7 @@ import javax.inject.Inject class VectorPreferences @Inject constructor( private val context: Context, private val clock: Clock, + private val buildMeta: BuildMeta, ) { companion object { @@ -364,7 +366,7 @@ class VectorPreferences @Inject constructor( } fun failFast(): Boolean { - return BuildConfig.DEBUG || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false)) + return buildMeta.isDebug || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false)) } fun didAskUserToEnableSessionPush(): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt index 5844467a1f..977e2fbeba 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt @@ -22,6 +22,7 @@ import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.orEmpty import im.vector.app.core.preference.VectorPreference +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.FirstThrottler import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.openAppSettingsPage @@ -32,7 +33,8 @@ import org.matrix.android.sdk.api.Matrix import javax.inject.Inject class VectorSettingsHelpAboutFragment @Inject constructor( - private val versionProvider: VersionProvider + private val versionProvider: VersionProvider, + private val buildMeta: BuildMeta, ) : VectorSettingsBaseFragment() { override var titleRes = R.string.preference_root_help_about @@ -66,7 +68,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor( findPreference(VectorPreferences.SETTINGS_VERSION_PREFERENCE_KEY)!!.let { it.summary = buildString { append(versionProvider.getVersion(longFormat = false, useBuildNumber = true)) - if (BuildConfig.DEBUG) { + if (buildMeta.isDebug) { append(" ") append(BuildConfig.GIT_BRANCH_NAME) } From 9fe3fc69dd678b3b84db97c3a7d4ba48eacf68d0 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 1 Jul 2022 14:20:18 +0100 Subject: [PATCH 14/58] extracting the config models to their own files --- .../java/im/vector/app/config/Analytics.kt | 48 ++++++++++++++++ .../main/java/im/vector/app/config/Config.kt | 55 ------------------- .../vector/app/config/KeySharingStrategy.kt | 35 ++++++++++++ .../im/vector/app/config/OnboardingVariant.kt | 23 ++++++++ .../vector/app/core/di/ConfigurationModule.kt | 10 ++-- .../im/vector/app/core/di/SingletonModule.kt | 24 -------- 6 files changed, 112 insertions(+), 83 deletions(-) create mode 100644 vector-config/src/main/java/im/vector/app/config/Analytics.kt create mode 100644 vector-config/src/main/java/im/vector/app/config/KeySharingStrategy.kt create mode 100644 vector-config/src/main/java/im/vector/app/config/OnboardingVariant.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Analytics.kt b/vector-config/src/main/java/im/vector/app/config/Analytics.kt new file mode 100644 index 0000000000..7fdc78dc8a --- /dev/null +++ b/vector-config/src/main/java/im/vector/app/config/Analytics.kt @@ -0,0 +1,48 @@ +/* + * 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.config + +/** + * The types of analytics Element currently supports. + */ +sealed interface Analytics { + + /** + * Disables the analytics integrations. + */ + object Disabled : Analytics + + /** + * Analytics integration via PostHog. + */ + data class PostHog( + /** + * The PostHog instance url. + */ + val postHogHost: String, + + /** + * The PostHog instance API key. + */ + val postHogApiKey: String, + + /** + * A URL to more information about the analytics collection. + */ + val policyLink: String, + ) : Analytics +} diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index a15ac198b9..ef9b6a7b8d 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -87,58 +87,3 @@ object Config { */ val NIGHTLY_ANALYTICS_CONFIG = RELEASE_ANALYTICS_CONFIG } - -/** - * The types of analytics Element currently supports. - */ -sealed interface Analytics { - - /** - * Disables the analytics integrations. - */ - object Disabled : Analytics - - /** - * Analytics integration via PostHog. - */ - data class PostHog( - /** - * The PostHog instance url. - */ - val postHogHost: String, - - /** - * The PostHog instance API key. - */ - val postHogApiKey: String, - - /** - * A URL to more information about the analytics collection. - */ - val policyLink: String, - ) : Analytics -} - -enum class OnboardingVariant { - LEGACY, - LOGIN_2, - FTUE_AUTH -} - -enum class KeySharingStrategy { - /** - * Keys will be sent for the first time when the first message is sent. - * This is handled by the Matrix SDK so there's no need to do it in Vector. - */ - WhenSendingEvent, - - /** - * Keys will be sent for the first time when the timeline displayed. - */ - WhenEnteringRoom, - - /** - * Keys will be sent for the first time when a typing started. - */ - WhenTyping -} diff --git a/vector-config/src/main/java/im/vector/app/config/KeySharingStrategy.kt b/vector-config/src/main/java/im/vector/app/config/KeySharingStrategy.kt new file mode 100644 index 0000000000..51f3d81151 --- /dev/null +++ b/vector-config/src/main/java/im/vector/app/config/KeySharingStrategy.kt @@ -0,0 +1,35 @@ +/* + * 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.config + +enum class KeySharingStrategy { + /** + * Keys will be sent for the first time when the first message is sent. + * This is handled by the Matrix SDK so there's no need to do it in Vector. + */ + WhenSendingEvent, + + /** + * Keys will be sent for the first time when the timeline displayed. + */ + WhenEnteringRoom, + + /** + * Keys will be sent for the first time when a typing started. + */ + WhenTyping +} diff --git a/vector-config/src/main/java/im/vector/app/config/OnboardingVariant.kt b/vector-config/src/main/java/im/vector/app/config/OnboardingVariant.kt new file mode 100644 index 0000000000..ae8cfd1172 --- /dev/null +++ b/vector-config/src/main/java/im/vector/app/config/OnboardingVariant.kt @@ -0,0 +1,23 @@ +/* + * 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.config + +enum class OnboardingVariant { + LEGACY, + LOGIN_2, + FTUE_AUTH +} diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index 10c91a5dd1..25d3d8311f 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -37,10 +37,12 @@ import im.vector.app.features.raw.wellknown.CryptoConfig object ConfigurationModule { @Provides - fun providesAnalyticsConfig(buildMeta: BuildMeta): AnalyticsConfig { - val config: Analytics = when (buildMeta.isDebug) { - true -> Config.DEBUG_ANALYTICS_CONFIG - false -> Config.RELEASE_ANALYTICS_CONFIG + fun providesAnalyticsConfig(): AnalyticsConfig { + val config: Analytics = when (BuildConfig.BUILD_TYPE) { + "debug" -> Config.DEBUG_ANALYTICS_CONFIG + "nightly" -> Config.NIGHTLY_ANALYTICS_CONFIG + "release" -> Config.RELEASE_ANALYTICS_CONFIG + else -> throw IllegalStateException("Unhandled build type: ${BuildConfig.BUILD_TYPE}") } return when (config) { Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 3ba9eb0f5b..0b7e3b347d 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -211,30 +211,6 @@ object VectorStaticModule { @Provides fun providesPhoneNumberUtil(): PhoneNumberUtil = PhoneNumberUtil.getInstance() - @Provides - fun providesAnalyticsConfig(): AnalyticsConfig { - val config: Analytics = when (BuildConfig.BUILD_TYPE) { - "debug" -> Config.DEBUG_ANALYTICS_CONFIG - "nightly" -> Config.NIGHTLY_ANALYTICS_CONFIG - "release" -> Config.RELEASE_ANALYTICS_CONFIG - else -> throw IllegalStateException("Unhandled build type: ${BuildConfig.BUILD_TYPE}") - } - return when (config) { - Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") - is Analytics.PostHog -> AnalyticsConfig( - isEnabled = true, - postHogHost = config.postHogHost, - postHogApiKey = config.postHogApiKey, - policyLink = config.policyLink - ) - } - } - - @Provides - fun providesVoiceMessageConfig() = VoiceMessageConfig( - lengthLimitMs = Config.VOICE_MESSAGE_LIMIT_MS - ) - @Provides @Singleton fun providesBuildMeta() = BuildMeta( From 811b2e8c75746878b651ee046ee31f1312eed745 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 1 Jul 2022 14:51:16 +0100 Subject: [PATCH 15/58] accessing the notification action ids via a dedicated class which builds upon the application id --- .../core/pushers/VectorMessagingReceiver.kt | 4 +- .../core/utils/ExternalApplicationsUtil.kt | 6 +-- .../NotificationBroadcastReceiver.kt | 13 ++--- .../notifications/NotificationUtils.kt | 51 ++++++++++--------- ...ttingsNotificationsTroubleshootFragment.kt | 8 +-- 5 files changed, 44 insertions(+), 38 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt index 0d6828f569..9764347ec1 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -31,6 +31,7 @@ import im.vector.app.core.network.WifiDetector import im.vector.app.core.pushers.model.PushData import im.vector.app.core.services.GuardServiceStarter import im.vector.app.features.notifications.NotifiableEventResolver +import im.vector.app.features.notifications.NotificationActionIds import im.vector.app.features.notifications.NotificationDrawerManager import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.settings.BackgroundSyncMode @@ -68,6 +69,7 @@ class VectorMessagingReceiver : MessagingReceiver() { @Inject lateinit var unifiedPushHelper: UnifiedPushHelper @Inject lateinit var unifiedPushStore: UnifiedPushStore @Inject lateinit var pushParser: PushParser + @Inject lateinit var actionIds: NotificationActionIds private val coroutineScope = CoroutineScope(SupervisorJob()) @@ -100,7 +102,7 @@ class VectorMessagingReceiver : MessagingReceiver() { // Diagnostic Push if (pushData.eventId == PushersManager.TEST_EVENT_ID) { - val intent = Intent(NotificationUtils.PUSH_ACTION) + val intent = Intent(actionIds.PUSH_ACTION) LocalBroadcastManager.getInstance(context).sendBroadcast(intent) return } diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index 3a8ffac543..9f7f0a70a6 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -182,7 +182,7 @@ fun openUri(activity: Activity, uri: String) { */ fun openMedia(activity: Activity, savedMediaPath: String, mimeType: String) { val file = File(savedMediaPath) - val uri = FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".fileProvider", file) + val uri = FileProvider.getUriForFile(activity, activity.packageName + ".fileProvider", file) val intent = Intent(Intent.ACTION_VIEW).apply { setDataAndType(uri, mimeType) @@ -214,7 +214,7 @@ fun openLocation(activity: Activity, latitude: Double, longitude: Double) { fun shareMedia(context: Context, file: File, mediaMimeType: String?) { val mediaUri = try { - FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", file) + FileProvider.getUriForFile(context, context.packageName + ".fileProvider", file) } catch (e: Exception) { Timber.e(e, "onMediaAction Selected File cannot be shared") return @@ -376,7 +376,7 @@ private fun addToGallery(savedFile: File, mediaMimeType: String?, context: Conte /** * Open the play store to the provided application Id, default to this app. */ -fun openPlayStore(activity: Activity, appId: String = BuildConfig.APPLICATION_ID) { +fun openPlayStore(activity: Activity, appId: String) { try { activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appId"))) } catch (activityNotFoundException: ActivityNotFoundException) { diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt index c01be9a44f..9e87b4d325 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt @@ -48,31 +48,32 @@ class NotificationBroadcastReceiver : BroadcastReceiver() { @Inject lateinit var activeSessionHolder: ActiveSessionHolder @Inject lateinit var analyticsTracker: AnalyticsTracker @Inject lateinit var clock: Clock + @Inject lateinit var actionIds: NotificationActionIds override fun onReceive(context: Context?, intent: Intent?) { if (intent == null || context == null) return Timber.v("NotificationBroadcastReceiver received : $intent") when (intent.action) { - NotificationUtils.SMART_REPLY_ACTION -> + actionIds.SMART_REPLY_ACTION -> handleSmartReply(intent, context) - NotificationUtils.DISMISS_ROOM_NOTIF_ACTION -> + actionIds.DISMISS_ROOM_NOTIF_ACTION -> intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMessagesForRoom(roomId) } } - NotificationUtils.DISMISS_SUMMARY_ACTION -> + actionIds.DISMISS_SUMMARY_ACTION -> notificationDrawerManager.clearAllEvents() - NotificationUtils.MARK_ROOM_READ_ACTION -> + actionIds.MARK_ROOM_READ_ACTION -> intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMessagesForRoom(roomId) } handleMarkAsRead(roomId) } - NotificationUtils.JOIN_ACTION -> { + actionIds.JOIN_ACTION -> { intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(roomId) } handleJoinRoom(roomId) } } - NotificationUtils.REJECT_ACTION -> { + actionIds.REJECT_ACTION -> { intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(roomId) } handleRejectRoom(roomId) diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 0985823000..02667cee7f 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -45,7 +45,6 @@ import androidx.core.content.getSystemService import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.drawable.IconCompat import androidx.fragment.app.Fragment -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.createIgnoredUri import im.vector.app.core.platform.PendingIntentCompat @@ -74,13 +73,30 @@ import kotlin.random.Random * Util class for creating notifications. * Note: Cannot inject ColorProvider in the constructor, because it requires an Activity */ + +data class NotificationActionIds @Inject constructor( + private val buildMeta: BuildMeta, +) { + + val JOIN_ACTION = "${buildMeta.applicationId}.NotificationActions.JOIN_ACTION" + val REJECT_ACTION = "${buildMeta.applicationId}.NotificationActions.REJECT_ACTION" + val QUICK_LAUNCH_ACTION = "${buildMeta.applicationId}.NotificationActions.QUICK_LAUNCH_ACTION" + val MARK_ROOM_READ_ACTION = "${buildMeta.applicationId}.NotificationActions.MARK_ROOM_READ_ACTION" + val SMART_REPLY_ACTION = "${buildMeta.applicationId}.NotificationActions.SMART_REPLY_ACTION" + val DISMISS_SUMMARY_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_SUMMARY_ACTION" + val DISMISS_ROOM_NOTIF_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION" + val TAP_TO_VIEW_ACTION = "${buildMeta.applicationId}.NotificationActions.TAP_TO_VIEW_ACTION" + val DIAGNOSTIC_ACTION = "${buildMeta.applicationId}.NotificationActions.DIAGNOSTIC" + val PUSH_ACTION = "${buildMeta.applicationId}.PUSH" +} + @Singleton class NotificationUtils @Inject constructor( private val context: Context, private val stringProvider: StringProvider, private val vectorPreferences: VectorPreferences, private val clock: Clock, - private val buildMeta: BuildMeta, + private val actionIds: NotificationActionIds, ) { companion object { @@ -96,21 +112,6 @@ class NotificationUtils @Inject constructor( */ const val NOTIFICATION_ID_FOREGROUND_SERVICE = 61 - /* ========================================================================================== - * IDs for actions - * ========================================================================================== */ - - const val JOIN_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.JOIN_ACTION" - const val REJECT_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.REJECT_ACTION" - private const val QUICK_LAUNCH_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.QUICK_LAUNCH_ACTION" - const val MARK_ROOM_READ_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.MARK_ROOM_READ_ACTION" - const val SMART_REPLY_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.SMART_REPLY_ACTION" - const val DISMISS_SUMMARY_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.DISMISS_SUMMARY_ACTION" - const val DISMISS_ROOM_NOTIF_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION" - const val TAP_TO_VIEW_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.TAP_TO_VIEW_ACTION" - const val DIAGNOSTIC_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.DIAGNOSTIC" - const val PUSH_ACTION = "${BuildConfig.APPLICATION_ID}.PUSH" - /* ========================================================================================== * IDs for channels * ========================================================================================== */ @@ -653,7 +654,7 @@ class NotificationUtils @Inject constructor( // Add actions and notification intents // Mark room as read val markRoomReadIntent = Intent(context, NotificationBroadcastReceiver::class.java) - markRoomReadIntent.action = MARK_ROOM_READ_ACTION + markRoomReadIntent.action = actionIds.MARK_ROOM_READ_ACTION markRoomReadIntent.data = createIgnoredUri(roomInfo.roomId) markRoomReadIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) val markRoomReadPendingIntent = PendingIntent.getBroadcast( @@ -700,7 +701,7 @@ class NotificationUtils @Inject constructor( val intent = Intent(context, NotificationBroadcastReceiver::class.java) intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) - intent.action = DISMISS_ROOM_NOTIF_ACTION + intent.action = actionIds.DISMISS_ROOM_NOTIF_ACTION val pendingIntent = PendingIntent.getBroadcast( context.applicationContext, clock.epochMillis().toInt(), @@ -735,7 +736,7 @@ class NotificationUtils @Inject constructor( val roomId = inviteNotifiableEvent.roomId // offer to type a quick reject button val rejectIntent = Intent(context, NotificationBroadcastReceiver::class.java) - rejectIntent.action = REJECT_ACTION + rejectIntent.action = actionIds.REJECT_ACTION rejectIntent.data = createIgnoredUri("$roomId&$matrixId") rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) val rejectIntentPendingIntent = PendingIntent.getBroadcast( @@ -753,7 +754,7 @@ class NotificationUtils @Inject constructor( // offer to type a quick accept button val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java) - joinIntent.action = JOIN_ACTION + joinIntent.action = actionIds.JOIN_ACTION joinIntent.data = createIgnoredUri("$roomId&$matrixId") joinIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) val joinIntentPendingIntent = PendingIntent.getBroadcast( @@ -836,7 +837,7 @@ class NotificationUtils @Inject constructor( private fun buildOpenRoomIntent(roomId: String): PendingIntent? { val roomIntentTap = RoomDetailActivity.newIntent(context, TimelineArgs(roomId = roomId, switchToParentSpace = true), true) - roomIntentTap.action = TAP_TO_VIEW_ACTION + roomIntentTap.action = actionIds.TAP_TO_VIEW_ACTION // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that roomIntentTap.data = createIgnoredUri("openRoom?$roomId") @@ -874,7 +875,7 @@ class NotificationUtils @Inject constructor( val intent: Intent if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent = Intent(context, NotificationBroadcastReceiver::class.java) - intent.action = SMART_REPLY_ACTION + intent.action = actionIds.SMART_REPLY_ACTION intent.data = createIgnoredUri(roomId) intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) return PendingIntent.getBroadcast( @@ -950,7 +951,7 @@ class NotificationUtils @Inject constructor( private fun getDismissSummaryPendingIntent(): PendingIntent { val intent = Intent(context, NotificationBroadcastReceiver::class.java) - intent.action = DISMISS_SUMMARY_ACTION + intent.action = actionIds.DISMISS_SUMMARY_ACTION intent.data = createIgnoredUri("deleteSummary") return PendingIntent.getBroadcast( context.applicationContext, @@ -989,7 +990,7 @@ class NotificationUtils @Inject constructor( fun displayDiagnosticNotification() { val testActionIntent = Intent(context, TestNotificationReceiver::class.java) - testActionIntent.action = DIAGNOSTIC_ACTION + testActionIntent.action = actionIds.DIAGNOSTIC_ACTION val testPendingIntent = PendingIntent.getBroadcast( context, 0, diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt index 0eb22bf24d..635021cc54 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt @@ -34,6 +34,7 @@ import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSettingsNotificationsTroubleshootBinding +import im.vector.app.features.notifications.NotificationActionIds import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.rageshake.BugReporter import im.vector.app.features.settings.VectorSettingsFragmentInteractionListener @@ -46,7 +47,8 @@ import javax.inject.Inject class VectorSettingsNotificationsTroubleshootFragment @Inject constructor( private val bugReporter: BugReporter, - private val testManagerFactory: NotificationTroubleshootTestManagerFactory + private val testManagerFactory: NotificationTroubleshootTestManagerFactory, + private val actionIds: NotificationActionIds, ) : VectorBaseFragment() { private var testManager: NotificationTroubleshootTestManager? = null @@ -151,11 +153,11 @@ class VectorSettingsNotificationsTroubleshootFragment @Inject constructor( tryOrNull("Unable to register the receiver") { LocalBroadcastManager.getInstance(requireContext()) - .registerReceiver(broadcastReceiverPush, IntentFilter(NotificationUtils.PUSH_ACTION)) + .registerReceiver(broadcastReceiverPush, IntentFilter(actionIds.PUSH_ACTION)) } tryOrNull("Unable to register the receiver") { LocalBroadcastManager.getInstance(requireContext()) - .registerReceiver(broadcastReceiverNotification, IntentFilter(NotificationUtils.DIAGNOSTIC_ACTION)) + .registerReceiver(broadcastReceiverNotification, IntentFilter(actionIds.DIAGNOSTIC_ACTION)) } } From d42c27bfe0a13699e9b8ea6de107dff1c322ff1c Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 1 Jul 2022 15:00:39 +0100 Subject: [PATCH 16/58] lifting the low privacy build config to the config --- .../src/main/java/im/vector/app/config/Config.kt | 2 ++ vector/build.gradle | 2 -- .../main/java/im/vector/app/core/di/SingletonModule.kt | 4 +--- .../vector/app/core/pushers/VectorMessagingReceiver.kt | 6 ++++-- .../java/im/vector/app/core/resources/BuildMeta.kt | 1 + .../im/vector/app/features/location/LocationTracker.kt | 10 ++++++---- .../features/notifications/NotifiableEventResolver.kt | 4 +++- .../notifications/NotificationDrawerManager.kt | 6 ++++-- .../app/features/location/LocationTrackerTest.kt | 3 ++- .../im/vector/app/test/fixtures/BuildMetaFixture.kt | 7 ++++++- 10 files changed, 29 insertions(+), 16 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index ef9b6a7b8d..61b371939b 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -61,6 +61,8 @@ object Config { */ const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false + const val LOW_PRIVACY_LOG_ENABLE = false + /** * The analytics configuration to use for the Debug build type. * Can be disabled by providing Analytics.Disabled diff --git a/vector/build.gradle b/vector/build.gradle index 0aaf46a6b2..4b1942069c 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -237,7 +237,6 @@ android { resValue "string", "app_name", "Element dbg" resValue "color", "launcher_background", "#0DBD8B" - buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false" // Set to true if you want to enable strict mode in debug buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" @@ -252,7 +251,6 @@ android { resValue "string", "app_name", "Element" resValue "color", "launcher_background", "#0DBD8B" - buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false" buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" // When updating this block, please also update the same block in the `nightly` buildType below diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 0b7e3b347d..2807fd9c5c 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -32,7 +32,6 @@ import dagger.hilt.components.SingletonComponent import im.vector.app.BuildConfig import im.vector.app.EmojiCompatWrapper import im.vector.app.EmojiSpanify -import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.SpaceStateHandler import im.vector.app.SpaceStateHandlerImpl @@ -44,11 +43,9 @@ import im.vector.app.core.time.Clock import im.vector.app.core.time.DefaultClock import im.vector.app.core.utils.AndroidSystemSettingsProvider import im.vector.app.core.utils.SystemSettingsProvider -import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.analytics.AnalyticsTracker import im.vector.app.features.analytics.VectorAnalytics import im.vector.app.features.analytics.impl.DefaultVectorAnalytics -import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig import im.vector.app.features.invite.AutoAcceptInvites import im.vector.app.features.invite.CompileTimeAutoAcceptInvites import im.vector.app.features.navigation.DefaultNavigator @@ -217,6 +214,7 @@ object VectorStaticModule { isDebug = BuildConfig.DEBUG, sdkInt = Build.VERSION.SDK_INT, applicationId = BuildConfig.APPLICATION_ID, + lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE, ) @Provides diff --git a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt index 9764347ec1..6df08b89f4 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -29,6 +29,7 @@ import im.vector.app.BuildConfig import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.network.WifiDetector import im.vector.app.core.pushers.model.PushData +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.services.GuardServiceStarter import im.vector.app.features.notifications.NotifiableEventResolver import im.vector.app.features.notifications.NotificationActionIds @@ -70,6 +71,7 @@ class VectorMessagingReceiver : MessagingReceiver() { @Inject lateinit var unifiedPushStore: UnifiedPushStore @Inject lateinit var pushParser: PushParser @Inject lateinit var actionIds: NotificationActionIds + @Inject lateinit var buildMeta: BuildMeta private val coroutineScope = CoroutineScope(SupervisorJob()) @@ -89,7 +91,7 @@ class VectorMessagingReceiver : MessagingReceiver() { Timber.tag(loggerTag.value).d("## onMessage() received") val sMessage = String(message) - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.tag(loggerTag.value).d("## onMessage() $sMessage") } @@ -173,7 +175,7 @@ class VectorMessagingReceiver : MessagingReceiver() { */ private suspend fun onMessageReceivedInternal(pushData: PushData) { try { - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.tag(loggerTag.value).d("## onMessageReceivedInternal() : $pushData") } else { Timber.tag(loggerTag.value).d("## onMessageReceivedInternal()") diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index beed091b58..8571eae9f2 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -20,4 +20,5 @@ data class BuildMeta( val isDebug: Boolean, val sdkInt: Int, val applicationId: String, + val lowPrivacyLoggingEnabled: Boolean, ) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt index aa05fe764b..0103fe3a94 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt @@ -26,6 +26,7 @@ import androidx.core.content.getSystemService import androidx.core.location.LocationListenerCompat import im.vector.app.BuildConfig import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.session.coroutineScope import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow @@ -40,7 +41,8 @@ import javax.inject.Singleton @Singleton class LocationTracker @Inject constructor( context: Context, - private val activeSessionHolder: ActiveSessionHolder + private val activeSessionHolder: ActiveSessionHolder, + private val buildMeta: BuildMeta, ) : LocationListenerCompat { private val locationManager = context.getSystemService() @@ -104,7 +106,7 @@ class LocationTracker @Inject constructor( } .maxByOrNull { location -> location.time } ?.let { latestKnownLocation -> - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.d("lastKnownLocation: $latestKnownLocation") } else { Timber.d("lastKnownLocation: ${latestKnownLocation.provider}") @@ -162,7 +164,7 @@ class LocationTracker @Inject constructor( } override fun onLocationChanged(location: Location) { - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.d("onLocationChanged: $location") } else { Timber.d("onLocationChanged: ${location.provider}") @@ -196,7 +198,7 @@ class LocationTracker @Inject constructor( private fun notifyLocation(location: Location) { activeSessionHolder.getSafeActiveSession()?.coroutineScope?.launch { - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.d("notify location: $location") } else { Timber.d("notify location: ${location.provider}") diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt index 1ca72b8399..77cb749513 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt @@ -19,6 +19,7 @@ import android.net.Uri import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.takeAs +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.StringProvider import im.vector.app.core.time.Clock import im.vector.app.features.displayname.getBestName @@ -62,6 +63,7 @@ class NotifiableEventResolver @Inject constructor( private val noticeEventFormatter: NoticeEventFormatter, private val displayableEventFormatter: DisplayableEventFormatter, private val clock: Clock, + private val buildMeta: BuildMeta, ) { // private val eventDisplay = RiotEventDisplay(context) @@ -264,7 +266,7 @@ class NotifiableEventResolver @Inject constructor( ) } else { Timber.e("## unsupported notifiable event for eventId [${event.eventId}]") - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.e("## unsupported notifiable event for event [$event]") } // TODO generic handling? diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt index 686ed324dc..8bf427c031 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt @@ -22,6 +22,7 @@ import androidx.annotation.WorkerThread import im.vector.app.ActiveSessionDataSource import im.vector.app.BuildConfig import im.vector.app.R +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.FirstThrottler import im.vector.app.features.displayname.getBestName import im.vector.app.features.settings.VectorPreferences @@ -46,7 +47,8 @@ class NotificationDrawerManager @Inject constructor( private val activeSessionDataSource: ActiveSessionDataSource, private val notifiableEventProcessor: NotifiableEventProcessor, private val notificationRenderer: NotificationRenderer, - private val notificationEventPersistence: NotificationEventPersistence + private val notificationEventPersistence: NotificationEventPersistence, + private val buildMeta: BuildMeta, ) { private val handlerThread: HandlerThread = HandlerThread("NotificationDrawerManager", Thread.MIN_PRIORITY) @@ -92,7 +94,7 @@ class NotificationDrawerManager @Inject constructor( } // If we support multi session, event list should be per userId // Currently only manage single session - if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { + if (buildMeta.lowPrivacyLoggingEnabled) { Timber.d("onNotifiableEventReceived(): $notifiableEvent") } else { Timber.d("onNotifiableEventReceived(): is push: ${notifiableEvent.canBeReplaced}") diff --git a/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt b/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt index 454a73cd70..54f7412238 100644 --- a/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt +++ b/vector/src/test/java/im/vector/app/features/location/LocationTrackerTest.kt @@ -23,6 +23,7 @@ import im.vector.app.features.session.coroutineScope import im.vector.app.test.fakes.FakeActiveSessionHolder import im.vector.app.test.fakes.FakeContext import im.vector.app.test.fakes.FakeLocationManager +import im.vector.app.test.fixtures.aBuildMeta import im.vector.app.test.test import io.mockk.every import io.mockk.just @@ -56,7 +57,7 @@ class LocationTrackerTest { @Before fun setUp() { mockkStatic("im.vector.app.features.session.SessionCoroutineScopesKt") - locationTracker = LocationTracker(fakeContext.instance, fakeActiveSessionHolder.instance) + locationTracker = LocationTracker(fakeContext.instance, fakeActiveSessionHolder.instance, aBuildMeta()) fakeLocationManager.givenRemoveUpdates(locationTracker) } diff --git a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt index b0e6b1dd51..347b49400e 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt @@ -19,4 +19,9 @@ package im.vector.app.test.fixtures import android.os.Build import im.vector.app.core.resources.BuildMeta -fun aBuildMeta() = BuildMeta(Build.VERSION_CODES.O) +fun aBuildMeta() = BuildMeta( + isDebug = false, + sdkInt = Build.VERSION_CODES.O, + applicationId = "im.vector", + lowPrivacyLoggingEnabled = false, +) From df02f505adfd5c438c4af7eabc37efececfba912 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 1 Jul 2022 15:25:19 +0100 Subject: [PATCH 17/58] moving git versioning to the buildMeta abstraction --- .../src/main/java/im/vector/app/config/Config.kt | 1 + vector/build.gradle | 6 ------ .../main/java/im/vector/app/VectorApplication.kt | 2 +- .../java/im/vector/app/core/di/SingletonModule.kt | 6 ++++++ .../java/im/vector/app/core/resources/BuildMeta.kt | 6 ++++++ .../app/features/login/LoginSplashFragment.kt | 6 +++--- .../LoginSplashSignUpSignInSelectionFragment2.kt | 6 +++--- .../ftueauth/FtueAuthSplashCarouselFragment.kt | 4 ++-- .../onboarding/ftueauth/FtueAuthSplashFragment.kt | 6 +++--- .../vector/app/features/rageshake/BugReporter.kt | 14 ++++++++------ .../settings/VectorSettingsHelpAboutFragment.kt | 2 +- .../vector/app/features/version/VersionProvider.kt | 12 ++++++++---- .../vector/app/test/fixtures/BuildMetaFixture.kt | 6 ++++++ 13 files changed, 48 insertions(+), 29 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 61b371939b..b0138296a7 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -62,6 +62,7 @@ object Config { const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false const val LOW_PRIVACY_LOG_ENABLE = false + const val ENABLE_STRICT_MODE_LOGS = false /** * The analytics configuration to use for the Debug build type. diff --git a/vector/build.gradle b/vector/build.gradle index 4b1942069c..5910014a99 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -237,9 +237,6 @@ android { resValue "string", "app_name", "Element dbg" resValue "color", "launcher_background", "#0DBD8B" - // Set to true if you want to enable strict mode in debug - buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" - signingConfig signingConfigs.debug if (project.hasProperty("coverage")) { @@ -251,9 +248,6 @@ android { resValue "string", "app_name", "Element" resValue "color", "launcher_background", "#0DBD8B" - buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" - - // When updating this block, please also update the same block in the `nightly` buildType below postprocessing { removeUnusedCode true removeUnusedResources true diff --git a/vector/src/main/java/im/vector/app/VectorApplication.kt b/vector/src/main/java/im/vector/app/VectorApplication.kt index 8044ea96f7..9d362f9dc0 100644 --- a/vector/src/main/java/im/vector/app/VectorApplication.kt +++ b/vector/src/main/java/im/vector/app/VectorApplication.kt @@ -198,7 +198,7 @@ class VectorApplication : } private fun enableStrictModeIfNeeded() { - if (BuildConfig.ENABLE_STRICT_MODE_LOGS) { + if (buildMeta.enableStrictModeLogs) { StrictMode.setThreadPolicy( StrictMode.ThreadPolicy.Builder() .detectAll() diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 2807fd9c5c..208fbb6d73 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -215,6 +215,12 @@ object VectorStaticModule { sdkInt = Build.VERSION.SDK_INT, applicationId = BuildConfig.APPLICATION_ID, lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE, + enableStrictModeLogs = Config.ENABLE_STRICT_MODE_LOGS, + versionName = BuildConfig.VERSION_NAME, + gitRevision = BuildConfig.GIT_REVISION, + gitRevisionDate = BuildConfig.GIT_REVISION_DATE, + gitBranchName = BuildConfig.GIT_BRANCH_NAME, + buildNumber = BuildConfig.BUILD_NUMBER, ) @Provides diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index 8571eae9f2..dac4b8b9ed 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -21,4 +21,10 @@ data class BuildMeta( val sdkInt: Int, val applicationId: String, val lowPrivacyLoggingEnabled: Boolean, + val enableStrictModeLogs: Boolean, + val versionName: String, + val gitRevision: String, + val gitRevisionDate: String, + val gitBranchName: String, + val buildNumber: String, ) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt index 1cfabc1554..4e8df32d10 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt @@ -62,9 +62,9 @@ class LoginSplashFragment @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" + - "Build: ${BuildConfig.BUILD_NUMBER}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" + + "Branch: ${buildMeta.gitBranchName}\n" + + "Build: ${buildMeta.buildNumber}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt index 8bc9bed9e2..e967f981d5 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt @@ -54,9 +54,9 @@ class LoginSplashSignUpSignInSelectionFragment2 @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" + - "Build: ${BuildConfig.BUILD_NUMBER}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" + + "Branch: ${buildMeta.gitBranchName}\n" + + "Build: ${buildMeta.buildNumber}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index 2d12a1be7c..fd128ae5be 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -81,8 +81,8 @@ class FtueAuthSplashCarouselFragment @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}#${BuildConfig.BUILD_NUMBER}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}#${buildMeta.buildNumber}\n" + + "Branch: ${buildMeta.gitBranchName}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } views.splashCarousel.registerAutomaticUntilInteractionTransitions() diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt index d4e5722896..8dc9bf7cea 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt @@ -64,9 +64,9 @@ class FtueAuthSplashFragment @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" + - "Build: ${BuildConfig.BUILD_NUMBER}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" + + "Branch: ${buildMeta.gitBranchName}\n" + + "Build: ${buildMeta.buildNumber}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } } diff --git a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt index e2e5ee2c6e..a327395fd0 100755 --- a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt @@ -30,6 +30,7 @@ import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.extensions.getAllChildFragments import im.vector.app.core.extensions.toOnOff +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.settings.VectorLocale import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.devtools.GossipingEventsSerializer @@ -74,7 +75,8 @@ class BugReporter @Inject constructor( private val vectorPreferences: VectorPreferences, private val vectorFileLogger: VectorFileLogger, private val systemLocaleProvider: SystemLocaleProvider, - private val matrix: Matrix + private val matrix: Matrix, + private val buildMeta: BuildMeta, ) { var inMultiWindowMode = false @@ -278,14 +280,14 @@ class BugReporter @Inject constructor( .addFormDataPart("can_contact", canContact.toString()) .addFormDataPart("device_id", deviceId) .addFormDataPart("version", versionProvider.getVersion(longFormat = true, useBuildNumber = false)) - .addFormDataPart("branch_name", BuildConfig.GIT_BRANCH_NAME) + .addFormDataPart("branch_name", buildMeta.gitBranchName) .addFormDataPart("matrix_sdk_version", Matrix.getSdkVersion()) .addFormDataPart("olm_version", olmVersion) .addFormDataPart("device", Build.MODEL.trim()) .addFormDataPart("verbose_log", vectorPreferences.labAllowedExtendedLogging().toOnOff()) .addFormDataPart("multi_window", inMultiWindowMode.toOnOff()) .addFormDataPart( - "os", Build.VERSION.RELEASE + " (API " + Build.VERSION.SDK_INT + ") " + + "os", Build.VERSION.RELEASE + " (API " + buildMeta.sdkInt + ") " + Build.VERSION.INCREMENTAL + "-" + Build.VERSION.CODENAME ) .addFormDataPart("locale", Locale.getDefault().toString()) @@ -299,7 +301,7 @@ class BugReporter @Inject constructor( } } - val buildNumber = BuildConfig.BUILD_NUMBER + val buildNumber = buildMeta.buildNumber if (buildNumber.isNotEmpty() && buildNumber != "0") { builder.addFormDataPart("build_number", buildNumber) } @@ -339,9 +341,9 @@ class BugReporter @Inject constructor( screenshot = null // add some github labels - builder.addFormDataPart("label", BuildConfig.VERSION_NAME) + builder.addFormDataPart("label", buildMeta.versionName) builder.addFormDataPart("label", BuildConfig.FLAVOR_DESCRIPTION) - builder.addFormDataPart("label", BuildConfig.GIT_BRANCH_NAME) + builder.addFormDataPart("label", buildMeta.gitBranchName) // Special for Element builder.addFormDataPart("label", "[Element]") diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt index 977e2fbeba..f818d02e45 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt @@ -70,7 +70,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor( append(versionProvider.getVersion(longFormat = false, useBuildNumber = true)) if (buildMeta.isDebug) { append(" ") - append(BuildConfig.GIT_BRANCH_NAME) + append(buildMeta.gitBranchName) } } diff --git a/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt b/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt index 96a7d917e5..c3d5532854 100644 --- a/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt +++ b/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt @@ -17,10 +17,14 @@ package im.vector.app.features.version import im.vector.app.BuildConfig +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.VersionCodeProvider import javax.inject.Inject -class VersionProvider @Inject constructor(private val versionCodeProvider: VersionCodeProvider) { +class VersionProvider @Inject constructor( + private val versionCodeProvider: VersionCodeProvider, + private val buildMeta: BuildMeta, +) { fun getVersion(longFormat: Boolean, useBuildNumber: Boolean): String { var result = "${BuildConfig.VERSION_NAME} [${versionCodeProvider.getVersionCode()}]" @@ -31,9 +35,9 @@ class VersionProvider @Inject constructor(private val versionCodeProvider: Versi flavor += "-" } - var gitVersion = BuildConfig.GIT_REVISION - val gitRevisionDate = BuildConfig.GIT_REVISION_DATE - val buildNumber = BuildConfig.BUILD_NUMBER + var gitVersion = buildMeta.gitRevision + val gitRevisionDate = buildMeta.gitRevisionDate + val buildNumber = buildMeta.buildNumber var useLongFormat = longFormat diff --git a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt index 347b49400e..89ef96ecbc 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt @@ -24,4 +24,10 @@ fun aBuildMeta() = BuildMeta( sdkInt = Build.VERSION_CODES.O, applicationId = "im.vector", lowPrivacyLoggingEnabled = false, + enableStrictModeLogs = false, + versionName = "app-version-name", + gitRevision = "abcdef", + gitRevisionDate = "01-01-01", + gitBranchName = "a-branch-name", + buildNumber = "100", ) From 18943e34533bda81673d3586827003600c69465b Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 1 Jul 2022 15:26:03 +0100 Subject: [PATCH 18/58] removing unused buildconfig option --- vector/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/vector/build.gradle b/vector/build.gradle index 5910014a99..56a3f0eb80 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -308,7 +308,6 @@ android { versionName "${versionMajor}.${versionMinor}.${versionPatch}${getGplayVersionSuffix()}" resValue "bool", "isGplay", "true" - buildConfigField "boolean", "ALLOW_FCM_USE", "true" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\"" } @@ -319,7 +318,6 @@ android { versionName "${versionMajor}.${versionMinor}.${versionPatch}${getFdroidVersionSuffix()}" resValue "bool", "isGplay", "false" - buildConfigField "boolean", "ALLOW_FCM_USE", "false" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\"" } From cceac66504cda0392a95a67086440047eec75147 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 8 Jul 2022 16:53:08 +0100 Subject: [PATCH 19/58] moving build flavor information to the build meta --- .../src/main/java/im/vector/app/core/di/SingletonModule.kt | 2 ++ .../src/main/java/im/vector/app/core/resources/BuildMeta.kt | 2 ++ .../java/im/vector/app/features/rageshake/BugReporter.kt | 3 +-- .../im/vector/app/features/raw/wellknown/ElementWellKnown.kt | 2 +- .../java/im/vector/app/features/version/VersionProvider.kt | 5 ++--- .../java/im/vector/app/test/fixtures/BuildMetaFixture.kt | 2 ++ 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 208fbb6d73..ac6ec3ede1 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -221,6 +221,8 @@ object VectorStaticModule { gitRevisionDate = BuildConfig.GIT_REVISION_DATE, gitBranchName = BuildConfig.GIT_BRANCH_NAME, buildNumber = BuildConfig.BUILD_NUMBER, + flavorDescription = BuildConfig.FLAVOR_DESCRIPTION, + flavorShortDescription = BuildConfig.SHORT_FLAVOR_DESCRIPTION, ) @Provides diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index dac4b8b9ed..cdc3fdd9c6 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -27,4 +27,6 @@ data class BuildMeta( val gitRevisionDate: String, val gitBranchName: String, val buildNumber: String, + val flavorDescription: String, + val flavorShortDescription: String, ) diff --git a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt index a327395fd0..150f87bc02 100755 --- a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt @@ -25,7 +25,6 @@ import android.view.View import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentActivity import com.squareup.moshi.Types -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.extensions.getAllChildFragments @@ -342,7 +341,7 @@ class BugReporter @Inject constructor( // add some github labels builder.addFormDataPart("label", buildMeta.versionName) - builder.addFormDataPart("label", BuildConfig.FLAVOR_DESCRIPTION) + builder.addFormDataPart("label", buildMeta.flavorDescription) builder.addFormDataPart("label", buildMeta.gitBranchName) // Special for Element diff --git a/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnown.kt b/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnown.kt index 0df5f0e9cf..78329350d3 100644 --- a/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnown.kt +++ b/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnown.kt @@ -68,7 +68,7 @@ data class E2EWellKnownConfig( val secureBackupSetupMethods: List? = null, /** - * Configuration for sharing keys strategy which should be used instead of [im.vector.app.BuildConfig.outboundSessionKeySharingStrategy]. + * Configuration for sharing keys strategy which should be used instead of [im.vector.app.config.Config.KEY_SHARING_STRATEGY]. * One of on_room_opening, on_typing or disabled. */ @Json(name = "outbound_keys_pre_sharing_mode") diff --git a/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt b/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt index c3d5532854..4c8188dc8b 100644 --- a/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt +++ b/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt @@ -16,7 +16,6 @@ package im.vector.app.features.version -import im.vector.app.BuildConfig import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.VersionCodeProvider import javax.inject.Inject @@ -27,9 +26,9 @@ class VersionProvider @Inject constructor( ) { fun getVersion(longFormat: Boolean, useBuildNumber: Boolean): String { - var result = "${BuildConfig.VERSION_NAME} [${versionCodeProvider.getVersionCode()}]" + var result = "${buildMeta.versionName} [${versionCodeProvider.getVersionCode()}]" - var flavor = BuildConfig.SHORT_FLAVOR_DESCRIPTION + var flavor = buildMeta.flavorShortDescription if (flavor.isNotBlank()) { flavor += "-" diff --git a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt index 89ef96ecbc..50c9944794 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt @@ -30,4 +30,6 @@ fun aBuildMeta() = BuildMeta( gitRevisionDate = "01-01-01", gitBranchName = "a-branch-name", buildNumber = "100", + flavorDescription = "Gplay", + flavorShortDescription = "", ) From c07296c94d005783f3b002be4df64ad2739044e1 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 11 Jul 2022 09:55:33 +0100 Subject: [PATCH 20/58] adding changelog entry --- changelog.d/6406.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6406.misc diff --git a/changelog.d/6406.misc b/changelog.d/6406.misc new file mode 100644 index 0000000000..27cf3c6493 --- /dev/null +++ b/changelog.d/6406.misc @@ -0,0 +1 @@ +[Modularization] Provides abstraction to avoids direct usages of BuildConfig From 3d207f93f1e3a7bc5f7612b6d8ff780dba9d0b89 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 11 Jul 2022 10:07:11 +0100 Subject: [PATCH 21/58] removing unused imports and fixing missing full stop on docs --- vector-config/src/main/java/im/vector/app/config/Config.kt | 4 ++-- .../main/java/im/vector/app/core/di/ConfigurationModule.kt | 1 - .../im/vector/app/core/pushers/VectorMessagingReceiver.kt | 2 -- .../java/im/vector/app/core/utils/ExternalApplicationsUtil.kt | 1 - .../im/vector/app/features/analytics/impl/PostHogFactory.kt | 1 - .../im/vector/app/features/call/webrtc/WebRtcCallManager.kt | 1 - .../main/java/im/vector/app/features/home/ShortcutCreator.kt | 1 - .../features/home/room/detail/composer/AudioMessageHelper.kt | 1 - .../room/detail/composer/voice/VoiceMessageRecorderView.kt | 1 - .../java/im/vector/app/features/location/LocationTracker.kt | 1 - .../java/im/vector/app/features/login/LoginSplashFragment.kt | 1 - .../login2/LoginSplashSignUpSignInSelectionFragment2.kt | 1 - .../app/features/notifications/NotifiableEventResolver.kt | 1 - .../app/features/notifications/NotificationDrawerManager.kt | 1 - .../onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt | 1 - .../onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt | 1 - .../features/onboarding/ftueauth/FtueAuthSplashFragment.kt | 1 - .../main/java/im/vector/app/features/settings/VectorLocale.kt | 1 - .../java/im/vector/app/features/settings/VectorPreferences.kt | 1 - .../app/features/settings/VectorSettingsHelpAboutFragment.kt | 1 - .../VectorSettingsNotificationsTroubleshootFragment.kt | 1 - 21 files changed, 2 insertions(+), 23 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index b0138296a7..f660799d06 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -46,12 +46,12 @@ object Config { const val VOICE_MESSAGE_LIMIT_MS = 120_000L /** - * The strategy for sharing device keys + * The strategy for sharing device keys. */ val KEY_SHARING_STRATEGY = KeySharingStrategy.WhenTyping /** - * The onboarding flow + * The onboarding flow. */ val ONBOARDING_VARIANT = OnboardingVariant.FTUE_AUTH diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index 25d3d8311f..de71969e1b 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -20,7 +20,6 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import im.vector.app.BuildConfig import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.config.KeySharingStrategy diff --git a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt index 6df08b89f4..bff8a0ebe7 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -25,7 +25,6 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.ProcessLifecycleOwner import androidx.localbroadcastmanager.content.LocalBroadcastManager import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.BuildConfig import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.network.WifiDetector import im.vector.app.core.pushers.model.PushData @@ -34,7 +33,6 @@ import im.vector.app.core.services.GuardServiceStarter import im.vector.app.features.notifications.NotifiableEventResolver import im.vector.app.features.notifications.NotificationActionIds import im.vector.app.features.notifications.NotificationDrawerManager -import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.settings.BackgroundSyncMode import im.vector.app.features.settings.VectorDataStore import im.vector.app.features.settings.VectorPreferences diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index 9f7f0a70a6..d52b7088ff 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -39,7 +39,6 @@ import androidx.browser.customtabs.CustomTabsSession import androidx.core.app.ShareCompat import androidx.core.content.FileProvider import androidx.core.content.getSystemService -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.themes.ThemeUtils diff --git a/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt b/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt index 6ff10cfb7f..7442989352 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/impl/PostHogFactory.kt @@ -18,7 +18,6 @@ package im.vector.app.features.analytics.impl import android.content.Context import com.posthog.android.PostHog -import im.vector.app.BuildConfig import im.vector.app.core.resources.BuildMeta import im.vector.app.features.analytics.AnalyticsConfig import javax.inject.Inject diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt index 634c61a7b2..074779c6cc 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt @@ -20,7 +20,6 @@ import android.content.Context import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import im.vector.app.ActiveSessionDataSource -import im.vector.app.BuildConfig import im.vector.app.core.pushers.UnifiedPushHelper import im.vector.app.core.services.CallAndroidService import im.vector.app.features.analytics.AnalyticsTracker 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 bcf3c5a5cb..861fdc64b2 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 @@ -24,7 +24,6 @@ import androidx.annotation.WorkerThread import androidx.core.content.pm.ShortcutInfoCompat import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.graphics.drawable.IconCompat -import im.vector.app.BuildConfig import im.vector.app.core.glide.GlideApp import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.DimensionConverter diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt index 6f8d78a32d..2e150daee6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt @@ -20,7 +20,6 @@ import android.content.Context import android.media.AudioAttributes import android.media.MediaPlayer import androidx.core.content.FileProvider -import im.vector.app.BuildConfig import im.vector.app.core.resources.BuildMeta import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.voice.VoiceFailure diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt index c2775976fc..13e0477ab6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt @@ -21,7 +21,6 @@ import android.util.AttributeSet import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.hardware.vibrate import im.vector.app.core.time.Clock diff --git a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt index 0103fe3a94..a416cd90f5 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt @@ -24,7 +24,6 @@ import androidx.annotation.RequiresPermission import androidx.annotation.VisibleForTesting import androidx.core.content.getSystemService import androidx.core.location.LocationListenerCompat -import im.vector.app.BuildConfig import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.resources.BuildMeta import im.vector.app.features.session.coroutineScope diff --git a/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt index 4e8df32d10..7f5e87967b 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt @@ -23,7 +23,6 @@ import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible import com.google.android.material.dialog.MaterialAlertDialogBuilder -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.resources.BuildMeta import im.vector.app.databinding.FragmentLoginSplashBinding diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt index e967f981d5..84af28f75e 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt @@ -22,7 +22,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible -import im.vector.app.BuildConfig import im.vector.app.core.resources.BuildMeta import im.vector.app.databinding.FragmentLoginSplash2Binding import im.vector.app.features.settings.VectorPreferences diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt index 77cb749513..1cf80de4ee 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt @@ -16,7 +16,6 @@ package im.vector.app.features.notifications import android.net.Uri -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.takeAs import im.vector.app.core.resources.BuildMeta diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt index 8bf427c031..5f43ff6b90 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt @@ -20,7 +20,6 @@ import android.os.Handler import android.os.HandlerThread import androidx.annotation.WorkerThread import im.vector.app.ActiveSessionDataSource -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.resources.BuildMeta import im.vector.app.core.utils.FirstThrottler diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt index 525e4eeb9b..b16ad3ee93 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthServerUrlFormFragment.kt @@ -27,7 +27,6 @@ import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.google.android.material.textfield.TextInputLayout -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.resources.BuildMeta diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index fd128ae5be..6ad5df3fef 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -27,7 +27,6 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayoutMediator -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.incrementByOneAndWrap import im.vector.app.core.extensions.setCurrentItem diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt index 8dc9bf7cea..a04e8a5c01 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt @@ -22,7 +22,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.resources.BuildMeta import im.vector.app.databinding.FragmentFtueAuthSplashBinding diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt index 6c85fa30d2..4666d586d3 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt @@ -19,7 +19,6 @@ package im.vector.app.features.settings import android.content.Context import android.content.res.Configuration import androidx.core.content.edit -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.DefaultSharedPreferences import im.vector.app.core.resources.BuildMeta 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 410f883f1d..ac14bfc3c7 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 @@ -23,7 +23,6 @@ import android.provider.MediaStore import androidx.annotation.BoolRes import androidx.core.content.edit import com.squareup.seismic.ShakeDetector -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.DefaultSharedPreferences import im.vector.app.core.resources.BuildMeta diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt index f818d02e45..df7baa7397 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt @@ -18,7 +18,6 @@ package im.vector.app.features.settings import android.os.Bundle import androidx.preference.Preference -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.extensions.orEmpty import im.vector.app.core.preference.VectorPreference diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt index 635021cc54..a063208da9 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt @@ -35,7 +35,6 @@ import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSettingsNotificationsTroubleshootBinding import im.vector.app.features.notifications.NotificationActionIds -import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.rageshake.BugReporter import im.vector.app.features.settings.VectorSettingsFragmentInteractionListener import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager From fe1019f29f67f150cf92d5fbece43f8f6ab337b1 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 11 Jul 2022 12:02:57 +0100 Subject: [PATCH 22/58] using Config strict mode flag directly within the Application as the build meta can't be injected before super application.onCreate --- vector/src/main/java/im/vector/app/VectorApplication.kt | 3 ++- vector/src/main/java/im/vector/app/core/di/SingletonModule.kt | 1 - vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt | 1 - .../test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/VectorApplication.kt b/vector/src/main/java/im/vector/app/VectorApplication.kt index 9d362f9dc0..b1bd0fc308 100644 --- a/vector/src/main/java/im/vector/app/VectorApplication.kt +++ b/vector/src/main/java/im/vector/app/VectorApplication.kt @@ -40,6 +40,7 @@ import com.mapbox.mapboxsdk.Mapbox import com.vanniktech.emoji.EmojiManager import com.vanniktech.emoji.google.GoogleEmojiProvider import dagger.hilt.android.HiltAndroidApp +import im.vector.app.config.Config import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.resources.BuildMeta import im.vector.app.features.analytics.VectorAnalytics @@ -198,7 +199,7 @@ class VectorApplication : } private fun enableStrictModeIfNeeded() { - if (buildMeta.enableStrictModeLogs) { + if (Config.ENABLE_STRICT_MODE_LOGS) { StrictMode.setThreadPolicy( StrictMode.ThreadPolicy.Builder() .detectAll() diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index ac6ec3ede1..8c1fc7744d 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -215,7 +215,6 @@ object VectorStaticModule { sdkInt = Build.VERSION.SDK_INT, applicationId = BuildConfig.APPLICATION_ID, lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE, - enableStrictModeLogs = Config.ENABLE_STRICT_MODE_LOGS, versionName = BuildConfig.VERSION_NAME, gitRevision = BuildConfig.GIT_REVISION, gitRevisionDate = BuildConfig.GIT_REVISION_DATE, diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index cdc3fdd9c6..0249cfc371 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -21,7 +21,6 @@ data class BuildMeta( val sdkInt: Int, val applicationId: String, val lowPrivacyLoggingEnabled: Boolean, - val enableStrictModeLogs: Boolean, val versionName: String, val gitRevision: String, val gitRevisionDate: String, diff --git a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt index 50c9944794..1709b6601d 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt @@ -24,7 +24,6 @@ fun aBuildMeta() = BuildMeta( sdkInt = Build.VERSION_CODES.O, applicationId = "im.vector", lowPrivacyLoggingEnabled = false, - enableStrictModeLogs = false, versionName = "app-version-name", gitRevision = "abcdef", gitRevisionDate = "01-01-01", From cb59d82846e0cc7f660df20317bd968337ed3b94 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 11 Jul 2022 12:50:14 +0100 Subject: [PATCH 23/58] extracting the notification action ids to their own file --- .../notifications/NotificationActionIds.kt | 41 +++++++++++++++++++ .../notifications/NotificationUtils.kt | 22 ---------- 2 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt new file mode 100644 index 0000000000..c83a1f2f4a --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt @@ -0,0 +1,41 @@ +/* + * 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.notifications + +import im.vector.app.core.resources.BuildMeta +import javax.inject.Inject + +/** + * Util class for creating notifications. + * Note: Cannot inject ColorProvider in the constructor, because it requires an Activity + */ + +data class NotificationActionIds @Inject constructor( + private val buildMeta: BuildMeta, +) { + + val JOIN_ACTION = "${buildMeta.applicationId}.NotificationActions.JOIN_ACTION" + val REJECT_ACTION = "${buildMeta.applicationId}.NotificationActions.REJECT_ACTION" + val QUICK_LAUNCH_ACTION = "${buildMeta.applicationId}.NotificationActions.QUICK_LAUNCH_ACTION" + val MARK_ROOM_READ_ACTION = "${buildMeta.applicationId}.NotificationActions.MARK_ROOM_READ_ACTION" + val SMART_REPLY_ACTION = "${buildMeta.applicationId}.NotificationActions.SMART_REPLY_ACTION" + val DISMISS_SUMMARY_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_SUMMARY_ACTION" + val DISMISS_ROOM_NOTIF_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION" + val TAP_TO_VIEW_ACTION = "${buildMeta.applicationId}.NotificationActions.TAP_TO_VIEW_ACTION" + val DIAGNOSTIC_ACTION = "${buildMeta.applicationId}.NotificationActions.DIAGNOSTIC" + val PUSH_ACTION = "${buildMeta.applicationId}.PUSH" +} diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 02667cee7f..2fdba3b524 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -48,7 +48,6 @@ import androidx.fragment.app.Fragment import im.vector.app.R import im.vector.app.core.extensions.createIgnoredUri import im.vector.app.core.platform.PendingIntentCompat -import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.StringProvider import im.vector.app.core.services.CallAndroidService import im.vector.app.core.time.Clock @@ -69,27 +68,6 @@ import javax.inject.Inject import javax.inject.Singleton import kotlin.random.Random -/** - * Util class for creating notifications. - * Note: Cannot inject ColorProvider in the constructor, because it requires an Activity - */ - -data class NotificationActionIds @Inject constructor( - private val buildMeta: BuildMeta, -) { - - val JOIN_ACTION = "${buildMeta.applicationId}.NotificationActions.JOIN_ACTION" - val REJECT_ACTION = "${buildMeta.applicationId}.NotificationActions.REJECT_ACTION" - val QUICK_LAUNCH_ACTION = "${buildMeta.applicationId}.NotificationActions.QUICK_LAUNCH_ACTION" - val MARK_ROOM_READ_ACTION = "${buildMeta.applicationId}.NotificationActions.MARK_ROOM_READ_ACTION" - val SMART_REPLY_ACTION = "${buildMeta.applicationId}.NotificationActions.SMART_REPLY_ACTION" - val DISMISS_SUMMARY_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_SUMMARY_ACTION" - val DISMISS_ROOM_NOTIF_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION" - val TAP_TO_VIEW_ACTION = "${buildMeta.applicationId}.NotificationActions.TAP_TO_VIEW_ACTION" - val DIAGNOSTIC_ACTION = "${buildMeta.applicationId}.NotificationActions.DIAGNOSTIC" - val PUSH_ACTION = "${buildMeta.applicationId}.PUSH" -} - @Singleton class NotificationUtils @Inject constructor( private val context: Context, From 8b9d1bb0d8b5d66b6c54b7f41800944188010c77 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 11 Jul 2022 16:58:58 +0100 Subject: [PATCH 24/58] making use of the existing sdk int provider instead of supplying it via the BuildMeta --- .../main/java/im/vector/app/core/di/ConfigurationModule.kt | 1 + .../src/main/java/im/vector/app/core/di/SingletonModule.kt | 2 -- .../src/main/java/im/vector/app/core/extensions/Context.kt | 6 +++--- .../src/main/java/im/vector/app/core/resources/BuildMeta.kt | 1 - .../live/tracking/LiveLocationNotificationBuilder.kt | 4 +++- .../vector/app/features/onboarding/OnboardingViewModel.kt | 6 +++--- .../java/im/vector/app/features/rageshake/BugReporter.kt | 5 ++++- .../app/features/onboarding/OnboardingViewModelTest.kt | 5 +++-- .../java/im/vector/app/test/fixtures/BuildMetaFixture.kt | 2 -- 9 files changed, 17 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index de71969e1b..25d3d8311f 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -20,6 +20,7 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import im.vector.app.BuildConfig import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.config.KeySharingStrategy diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 8c1fc7744d..9756525137 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -23,7 +23,6 @@ import android.content.SharedPreferences import android.content.res.Resources import androidx.preference.PreferenceManager import com.google.i18n.phonenumbers.PhoneNumberUtil -import android.os.Build import dagger.Binds import dagger.Module import dagger.Provides @@ -212,7 +211,6 @@ object VectorStaticModule { @Singleton fun providesBuildMeta() = BuildMeta( isDebug = BuildConfig.DEBUG, - sdkInt = Build.VERSION.SDK_INT, applicationId = BuildConfig.APPLICATION_ID, lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE, versionName = BuildConfig.VERSION_NAME, diff --git a/vector/src/main/java/im/vector/app/core/extensions/Context.kt b/vector/src/main/java/im/vector/app/core/extensions/Context.kt index 509dd6a862..14e639bf32 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/Context.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/Context.kt @@ -37,7 +37,7 @@ import androidx.datastore.preferences.core.Preferences import dagger.hilt.EntryPoints import im.vector.app.core.datastore.dataStoreProvider import im.vector.app.core.di.SingletonEntryPoint -import im.vector.app.core.resources.BuildMeta +import org.matrix.android.sdk.api.util.BuildVersionSdkIntProvider import java.io.OutputStream import kotlin.math.roundToInt @@ -93,9 +93,9 @@ fun Context.safeOpenOutputStream(uri: Uri): OutputStream? { */ @Suppress("deprecation") @SuppressLint("NewApi") // false positive -fun Context.inferNoConnectivity(buildMeta: BuildMeta): Boolean { +fun Context.inferNoConnectivity(sdkIntProvider: BuildVersionSdkIntProvider): Boolean { val connectivityManager = getSystemService()!! - return if (buildMeta.sdkInt > Build.VERSION_CODES.M) { + return if (sdkIntProvider.get() > Build.VERSION_CODES.M) { val networkCapabilities = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) when { networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true -> false diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index 0249cfc371..6c25348ea1 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -18,7 +18,6 @@ package im.vector.app.core.resources data class BuildMeta( val isDebug: Boolean, - val sdkInt: Int, val applicationId: String, val lowPrivacyLoggingEnabled: Boolean, val versionName: String, diff --git a/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt b/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt index b8dd17e8fd..5aa9cd0971 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt @@ -31,6 +31,7 @@ import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.home.room.detail.arguments.TimelineArgs import im.vector.app.features.location.live.map.LiveLocationMapViewActivity import im.vector.app.features.location.live.map.LiveLocationMapViewArgs +import im.vector.app.features.notifications.NotificationActionIds import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.themes.ThemeUtils import javax.inject.Inject @@ -41,6 +42,7 @@ class LiveLocationNotificationBuilder @Inject constructor( private val context: Context, private val stringProvider: StringProvider, private val clock: Clock, + private val actionIds: NotificationActionIds, ) { /** @@ -66,7 +68,7 @@ class LiveLocationNotificationBuilder @Inject constructor( liveLocationMapViewArgs = LiveLocationMapViewArgs(roomId = roomId), firstStartMainActivity = true ) - mapIntent.action = NotificationUtils.TAP_TO_VIEW_ACTION + mapIntent.action = actionIds.TAP_TO_VIEW_ACTION // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that mapIntent.data = createIgnoredUri("openLiveLocationMap?$roomId") diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt index 6cadb4308a..8136dc379b 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt @@ -32,7 +32,6 @@ import im.vector.app.core.extensions.isMatrixId import im.vector.app.core.extensions.toReducedUrl import im.vector.app.core.extensions.vectorStore import im.vector.app.core.platform.VectorViewModel -import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.ensureProtocol import im.vector.app.core.utils.ensureTrailingSlash @@ -63,6 +62,7 @@ import org.matrix.android.sdk.api.auth.registration.RegistrationAvailability import org.matrix.android.sdk.api.auth.registration.RegistrationWizard import org.matrix.android.sdk.api.failure.isHomeserverUnavailable import org.matrix.android.sdk.api.session.Session +import org.matrix.android.sdk.api.util.BuildVersionSdkIntProvider import timber.log.Timber import java.util.UUID import java.util.concurrent.CancellationException @@ -86,7 +86,7 @@ class OnboardingViewModel @AssistedInject constructor( private val startAuthenticationFlowUseCase: StartAuthenticationFlowUseCase, private val vectorOverrides: VectorOverrides, private val registrationActionHandler: RegistrationActionHandler, - private val buildMeta: BuildMeta, + private val sdkIntProvider: BuildVersionSdkIntProvider, ) : VectorViewModel(initialState) { @AssistedFactory @@ -708,7 +708,7 @@ class OnboardingViewModel @AssistedInject constructor( private fun onAuthenticationStartError(error: Throwable, trigger: OnboardingAction.HomeServerChange) { when { - error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(buildMeta) -> _viewEvents.post( + error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(sdkIntProvider) -> _viewEvents.post( OnboardingViewEvents.Failure(error) ) deeplinkUrlIsUnavailable(error, trigger) -> _viewEvents.post( diff --git a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt index 150f87bc02..ad09593ebd 100755 --- a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt @@ -25,6 +25,7 @@ import android.view.View import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentActivity import com.squareup.moshi.Types +import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.extensions.getAllChildFragments @@ -50,6 +51,7 @@ import okhttp3.Response import org.json.JSONException import org.json.JSONObject import org.matrix.android.sdk.api.Matrix +import org.matrix.android.sdk.api.util.BuildVersionSdkIntProvider import org.matrix.android.sdk.api.util.JsonDict import org.matrix.android.sdk.api.util.MatrixJsonParser import org.matrix.android.sdk.api.util.MimeTypes @@ -76,6 +78,7 @@ class BugReporter @Inject constructor( private val systemLocaleProvider: SystemLocaleProvider, private val matrix: Matrix, private val buildMeta: BuildMeta, + private val sdkIntProvider: BuildVersionSdkIntProvider, ) { var inMultiWindowMode = false @@ -286,7 +289,7 @@ class BugReporter @Inject constructor( .addFormDataPart("verbose_log", vectorPreferences.labAllowedExtendedLogging().toOnOff()) .addFormDataPart("multi_window", inMultiWindowMode.toOnOff()) .addFormDataPart( - "os", Build.VERSION.RELEASE + " (API " + buildMeta.sdkInt + ") " + + "os", Build.VERSION.RELEASE + " (API " + sdkIntProvider.get() + ") " + Build.VERSION.INCREMENTAL + "-" + Build.VERSION.CODENAME ) .addFormDataPart("locale", Locale.getDefault().toString()) diff --git a/vector/src/test/java/im/vector/app/features/onboarding/OnboardingViewModelTest.kt b/vector/src/test/java/im/vector/app/features/onboarding/OnboardingViewModelTest.kt index a9bbb3eb07..61d3101b64 100644 --- a/vector/src/test/java/im/vector/app/features/onboarding/OnboardingViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/onboarding/OnboardingViewModelTest.kt @@ -17,6 +17,7 @@ package im.vector.app.features.onboarding import android.net.Uri +import android.os.Build import com.airbnb.mvrx.test.MvRxTestRule import im.vector.app.R import im.vector.app.features.login.LoginConfig @@ -24,6 +25,7 @@ import im.vector.app.features.login.LoginMode import im.vector.app.features.login.ReAuthHelper import im.vector.app.features.login.SignMode import im.vector.app.features.onboarding.StartAuthenticationFlowUseCase.StartAuthenticationResult +import im.vector.app.test.TestBuildVersionSdkIntProvider import im.vector.app.test.fakes.FakeActiveSessionHolder import im.vector.app.test.fakes.FakeAnalyticsTracker import im.vector.app.test.fakes.FakeAuthenticationService @@ -43,7 +45,6 @@ import im.vector.app.test.fakes.FakeVectorFeatures import im.vector.app.test.fakes.FakeVectorOverrides import im.vector.app.test.fakes.toTestString import im.vector.app.test.fixtures.a401ServerError -import im.vector.app.test.fixtures.aBuildMeta import im.vector.app.test.fixtures.aHomeServerCapabilities import im.vector.app.test.test import kotlinx.coroutines.test.runTest @@ -720,7 +721,7 @@ class OnboardingViewModelTest { fakeStartAuthenticationFlowUseCase.instance, FakeVectorOverrides(), fakeRegistrationActionHandler.instance, - aBuildMeta(), + TestBuildVersionSdkIntProvider().also { it.value = Build.VERSION_CODES.O }, ).also { viewModel = it initialState = state diff --git a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt index 1709b6601d..4f4649106d 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt @@ -16,12 +16,10 @@ package im.vector.app.test.fixtures -import android.os.Build import im.vector.app.core.resources.BuildMeta fun aBuildMeta() = BuildMeta( isDebug = false, - sdkInt = Build.VERSION_CODES.O, applicationId = "im.vector", lowPrivacyLoggingEnabled = false, versionName = "app-version-name", From 9b1def3c1d29dd847632c32ab6a78dd8635bec0a Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 11 Jul 2022 17:00:51 +0100 Subject: [PATCH 25/58] updating variable casing as they're no longer const val or file level --- .../core/pushers/VectorMessagingReceiver.kt | 2 +- .../LiveLocationNotificationBuilder.kt | 2 +- .../notifications/NotificationActionIds.kt | 20 +++++++++---------- .../NotificationBroadcastReceiver.kt | 12 +++++------ .../notifications/NotificationUtils.kt | 16 +++++++-------- ...ttingsNotificationsTroubleshootFragment.kt | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt index bff8a0ebe7..8e88e44627 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -102,7 +102,7 @@ class VectorMessagingReceiver : MessagingReceiver() { // Diagnostic Push if (pushData.eventId == PushersManager.TEST_EVENT_ID) { - val intent = Intent(actionIds.PUSH_ACTION) + val intent = Intent(actionIds.push) LocalBroadcastManager.getInstance(context).sendBroadcast(intent) return } diff --git a/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt b/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt index 5aa9cd0971..5bc730f3d7 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt @@ -68,7 +68,7 @@ class LiveLocationNotificationBuilder @Inject constructor( liveLocationMapViewArgs = LiveLocationMapViewArgs(roomId = roomId), firstStartMainActivity = true ) - mapIntent.action = actionIds.TAP_TO_VIEW_ACTION + mapIntent.action = actionIds.tapToView // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that mapIntent.data = createIgnoredUri("openLiveLocationMap?$roomId") diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt index c83a1f2f4a..3bd7a635ae 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationActionIds.kt @@ -28,14 +28,14 @@ data class NotificationActionIds @Inject constructor( private val buildMeta: BuildMeta, ) { - val JOIN_ACTION = "${buildMeta.applicationId}.NotificationActions.JOIN_ACTION" - val REJECT_ACTION = "${buildMeta.applicationId}.NotificationActions.REJECT_ACTION" - val QUICK_LAUNCH_ACTION = "${buildMeta.applicationId}.NotificationActions.QUICK_LAUNCH_ACTION" - val MARK_ROOM_READ_ACTION = "${buildMeta.applicationId}.NotificationActions.MARK_ROOM_READ_ACTION" - val SMART_REPLY_ACTION = "${buildMeta.applicationId}.NotificationActions.SMART_REPLY_ACTION" - val DISMISS_SUMMARY_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_SUMMARY_ACTION" - val DISMISS_ROOM_NOTIF_ACTION = "${buildMeta.applicationId}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION" - val TAP_TO_VIEW_ACTION = "${buildMeta.applicationId}.NotificationActions.TAP_TO_VIEW_ACTION" - val DIAGNOSTIC_ACTION = "${buildMeta.applicationId}.NotificationActions.DIAGNOSTIC" - val PUSH_ACTION = "${buildMeta.applicationId}.PUSH" + val join = "${buildMeta.applicationId}.NotificationActions.JOIN_ACTION" + val reject = "${buildMeta.applicationId}.NotificationActions.REJECT_ACTION" + val quickLaunch = "${buildMeta.applicationId}.NotificationActions.QUICK_LAUNCH_ACTION" + val markRoomRead = "${buildMeta.applicationId}.NotificationActions.MARK_ROOM_READ_ACTION" + val smartReply = "${buildMeta.applicationId}.NotificationActions.SMART_REPLY_ACTION" + val dismissSummary = "${buildMeta.applicationId}.NotificationActions.DISMISS_SUMMARY_ACTION" + val dismissRoom = "${buildMeta.applicationId}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION" + val tapToView = "${buildMeta.applicationId}.NotificationActions.TAP_TO_VIEW_ACTION" + val diagnostic = "${buildMeta.applicationId}.NotificationActions.DIAGNOSTIC" + val push = "${buildMeta.applicationId}.PUSH" } diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt index 9e87b4d325..3fe0898eb4 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt @@ -54,26 +54,26 @@ class NotificationBroadcastReceiver : BroadcastReceiver() { if (intent == null || context == null) return Timber.v("NotificationBroadcastReceiver received : $intent") when (intent.action) { - actionIds.SMART_REPLY_ACTION -> + actionIds.smartReply -> handleSmartReply(intent, context) - actionIds.DISMISS_ROOM_NOTIF_ACTION -> + actionIds.dismissRoom -> intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMessagesForRoom(roomId) } } - actionIds.DISMISS_SUMMARY_ACTION -> + actionIds.dismissSummary -> notificationDrawerManager.clearAllEvents() - actionIds.MARK_ROOM_READ_ACTION -> + actionIds.markRoomRead -> intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMessagesForRoom(roomId) } handleMarkAsRead(roomId) } - actionIds.JOIN_ACTION -> { + actionIds.join -> { intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(roomId) } handleJoinRoom(roomId) } } - actionIds.REJECT_ACTION -> { + actionIds.reject -> { intent.getStringExtra(KEY_ROOM_ID)?.let { roomId -> notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(roomId) } handleRejectRoom(roomId) diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 2fdba3b524..8f05819fc4 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -632,7 +632,7 @@ class NotificationUtils @Inject constructor( // Add actions and notification intents // Mark room as read val markRoomReadIntent = Intent(context, NotificationBroadcastReceiver::class.java) - markRoomReadIntent.action = actionIds.MARK_ROOM_READ_ACTION + markRoomReadIntent.action = actionIds.markRoomRead markRoomReadIntent.data = createIgnoredUri(roomInfo.roomId) markRoomReadIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) val markRoomReadPendingIntent = PendingIntent.getBroadcast( @@ -679,7 +679,7 @@ class NotificationUtils @Inject constructor( val intent = Intent(context, NotificationBroadcastReceiver::class.java) intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) - intent.action = actionIds.DISMISS_ROOM_NOTIF_ACTION + intent.action = actionIds.dismissRoom val pendingIntent = PendingIntent.getBroadcast( context.applicationContext, clock.epochMillis().toInt(), @@ -714,7 +714,7 @@ class NotificationUtils @Inject constructor( val roomId = inviteNotifiableEvent.roomId // offer to type a quick reject button val rejectIntent = Intent(context, NotificationBroadcastReceiver::class.java) - rejectIntent.action = actionIds.REJECT_ACTION + rejectIntent.action = actionIds.reject rejectIntent.data = createIgnoredUri("$roomId&$matrixId") rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) val rejectIntentPendingIntent = PendingIntent.getBroadcast( @@ -732,7 +732,7 @@ class NotificationUtils @Inject constructor( // offer to type a quick accept button val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java) - joinIntent.action = actionIds.JOIN_ACTION + joinIntent.action = actionIds.join joinIntent.data = createIgnoredUri("$roomId&$matrixId") joinIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) val joinIntentPendingIntent = PendingIntent.getBroadcast( @@ -815,7 +815,7 @@ class NotificationUtils @Inject constructor( private fun buildOpenRoomIntent(roomId: String): PendingIntent? { val roomIntentTap = RoomDetailActivity.newIntent(context, TimelineArgs(roomId = roomId, switchToParentSpace = true), true) - roomIntentTap.action = actionIds.TAP_TO_VIEW_ACTION + roomIntentTap.action = actionIds.tapToView // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that roomIntentTap.data = createIgnoredUri("openRoom?$roomId") @@ -853,7 +853,7 @@ class NotificationUtils @Inject constructor( val intent: Intent if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent = Intent(context, NotificationBroadcastReceiver::class.java) - intent.action = actionIds.SMART_REPLY_ACTION + intent.action = actionIds.smartReply intent.data = createIgnoredUri(roomId) intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) return PendingIntent.getBroadcast( @@ -929,7 +929,7 @@ class NotificationUtils @Inject constructor( private fun getDismissSummaryPendingIntent(): PendingIntent { val intent = Intent(context, NotificationBroadcastReceiver::class.java) - intent.action = actionIds.DISMISS_SUMMARY_ACTION + intent.action = actionIds.dismissSummary intent.data = createIgnoredUri("deleteSummary") return PendingIntent.getBroadcast( context.applicationContext, @@ -968,7 +968,7 @@ class NotificationUtils @Inject constructor( fun displayDiagnosticNotification() { val testActionIntent = Intent(context, TestNotificationReceiver::class.java) - testActionIntent.action = actionIds.DIAGNOSTIC_ACTION + testActionIntent.action = actionIds.diagnostic val testPendingIntent = PendingIntent.getBroadcast( context, 0, diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt index a063208da9..8a3407b428 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt @@ -152,11 +152,11 @@ class VectorSettingsNotificationsTroubleshootFragment @Inject constructor( tryOrNull("Unable to register the receiver") { LocalBroadcastManager.getInstance(requireContext()) - .registerReceiver(broadcastReceiverPush, IntentFilter(actionIds.PUSH_ACTION)) + .registerReceiver(broadcastReceiverPush, IntentFilter(actionIds.push)) } tryOrNull("Unable to register the receiver") { LocalBroadcastManager.getInstance(requireContext()) - .registerReceiver(broadcastReceiverNotification, IntentFilter(actionIds.DIAGNOSTIC_ACTION)) + .registerReceiver(broadcastReceiverNotification, IntentFilter(actionIds.diagnostic)) } } From 3c1e183ed6006a94bb6bf3589cae5e867af3b030 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 29 Jul 2022 13:34:48 +0100 Subject: [PATCH 26/58] using low privacy log from the vector module for code within vector, instead of the sdk flag --- .../features/attachments/AttachmentsHelper.kt | 18 ++++++++++-------- .../home/room/detail/TimelineFragment.kt | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentsHelper.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentsHelper.kt index d0843b3b64..f8aa22f418 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentsHelper.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentsHelper.kt @@ -23,9 +23,9 @@ import android.os.Bundle import androidx.activity.result.ActivityResultLauncher import im.vector.app.core.dialogs.PhotoOrVideoDialog import im.vector.app.core.platform.Restorable +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.settings.VectorPreferences import im.vector.lib.multipicker.MultiPicker -import org.matrix.android.sdk.BuildConfig import org.matrix.android.sdk.api.session.content.ContentAttachmentData import timber.log.Timber @@ -35,15 +35,14 @@ private const val PENDING_TYPE_KEY = "PENDING_TYPE_KEY" /** * This class helps to handle attachments by providing simple methods. */ -class AttachmentsHelper(val context: Context, val callback: Callback) : Restorable { +class AttachmentsHelper( + val context: Context, + val callback: Callback, + private val buildMeta: BuildMeta, +) : Restorable { interface Callback { - fun onContactAttachmentReady(contactAttachment: ContactAttachment) { - if (BuildConfig.LOG_PRIVATE_DATA) { - Timber.v("On contact attachment ready: $contactAttachment") - } - } - + fun onContactAttachmentReady(contactAttachment: ContactAttachment) fun onContentAttachmentsReady(attachments: List) } @@ -144,6 +143,9 @@ class AttachmentsHelper(val context: Context, val callback: Callback) : Restorab .firstOrNull() ?.toContactAttachment() ?.let { + if (buildMeta.lowPrivacyLoggingEnabled) { + Timber.v("On contact attachment ready: $it") + } callback.onContactAttachmentReady(it) } } 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 727791c540..8f9564789a 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 @@ -91,6 +91,7 @@ import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.platform.VectorMenuProvider import im.vector.app.core.platform.lifecycleAwareLazy import im.vector.app.core.platform.showOptimizedSnackbar +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.ColorProvider import im.vector.app.core.resources.UserPreferencesProvider import im.vector.app.core.time.Clock @@ -277,6 +278,7 @@ class TimelineFragment @Inject constructor( private val shareIntentHandler: ShareIntentHandler, private val clock: Clock, private val vectorFeatures: VectorFeatures, + private val buildMeta: BuildMeta, ) : VectorBaseFragment(), TimelineEventController.Callback, @@ -373,7 +375,7 @@ class TimelineFragment @Inject constructor( sharedActionViewModel = activityViewModelProvider.get(MessageSharedActionViewModel::class.java) sharedActivityActionViewModel = activityViewModelProvider.get(RoomDetailSharedActionViewModel::class.java) knownCallsViewModel = activityViewModelProvider.get(SharedKnownCallsViewModel::class.java) - attachmentsHelper = AttachmentsHelper(requireContext(), this).register() + attachmentsHelper = AttachmentsHelper(requireContext(), this, buildMeta).register() callActionsHandler = StartCallActionsHandler( roomId = timelineArgs.roomId, fragment = this, @@ -2647,7 +2649,6 @@ class TimelineFragment @Inject constructor( } override fun onContactAttachmentReady(contactAttachment: ContactAttachment) { - super.onContactAttachmentReady(contactAttachment) val formattedContact = contactAttachment.toHumanReadable() messageComposerViewModel.handle(MessageComposerAction.SendMessage(formattedContact, false)) } From d1a63ccd2dd196f77b8d20f1b4e96205860b8d0c Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 29 Jul 2022 14:21:22 +0100 Subject: [PATCH 27/58] removing unused import --- .../src/main/java/im/vector/app/core/di/ConfigurationModule.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index 25d3d8311f..a75b3fa46b 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -24,7 +24,6 @@ import im.vector.app.BuildConfig import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.config.KeySharingStrategy -import im.vector.app.core.resources.BuildMeta import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.call.webrtc.VoipConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy From 2ee52f20623c59d8a6c51288073152f01206b811 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 2 Aug 2022 15:31:13 +0100 Subject: [PATCH 28/58] fixing import ordering --- vector/src/main/java/im/vector/app/core/di/SingletonModule.kt | 2 +- .../java/im/vector/app/features/navigation/DefaultNavigator.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 9756525137..6959f17586 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -31,9 +31,9 @@ import dagger.hilt.components.SingletonComponent import im.vector.app.BuildConfig import im.vector.app.EmojiCompatWrapper import im.vector.app.EmojiSpanify -import im.vector.app.config.Config import im.vector.app.SpaceStateHandler import im.vector.app.SpaceStateHandlerImpl +import im.vector.app.config.Config import im.vector.app.core.dispatchers.CoroutineDispatchers import im.vector.app.core.error.DefaultErrorFormatter import im.vector.app.core.error.ErrorFormatter diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index 20b79d8ba3..38db642287 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -32,8 +32,8 @@ import androidx.core.util.Pair import androidx.core.view.ViewCompat import com.google.android.material.dialog.MaterialAlertDialogBuilder import im.vector.app.R -import im.vector.app.config.OnboardingVariant import im.vector.app.SpaceStateHandler +import im.vector.app.config.OnboardingVariant import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.error.fatalError import im.vector.app.features.VectorFeatures From 4bff816056de0f22e7f6f8d53dc5531f9d6c4af5 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 3 Aug 2022 08:30:10 +0100 Subject: [PATCH 29/58] fixing auto merge compile error --- .../java/im/vector/app/features/home/NewHomeDetailFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt index 36372fc73a..7ca42e1338 100644 --- a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt @@ -28,8 +28,8 @@ import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.google.android.material.badge.BadgeDrawable -import im.vector.app.AppStateHandler import im.vector.app.R +import im.vector.app.SpaceStateHandler import im.vector.app.core.extensions.commitTransaction import im.vector.app.core.extensions.toMvRxBundle import im.vector.app.core.platform.OnBackPressed @@ -69,7 +69,7 @@ class NewHomeDetailFragment @Inject constructor( private val alertManager: PopupAlertManager, private val callManager: WebRtcCallManager, private val vectorPreferences: VectorPreferences, - private val appStateHandler: AppStateHandler, + private val appStateHandler: SpaceStateHandler, private val session: Session, ) : VectorBaseFragment(), KeysBackupBanner.Delegate, From ee553d66933de1ec9c0c13d1a7552cc33b7cd9f3 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 3 Aug 2022 10:23:49 +0100 Subject: [PATCH 30/58] making use of gradle_opts environment var to attempt to limit the jvm environment and fix gradle crashing --- .github/workflows/build.yml | 10 ++++------ .github/workflows/nightly.yml | 6 ++---- .github/workflows/post-pr.yml | 6 ++---- .github/workflows/quality.yml | 10 ++++------ .github/workflows/tests.yml | 12 +++++------- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c0491fda4..a48af91fba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,10 +7,8 @@ on: # Enrich gradle.properties for CI/CD env: - CI_GRADLE_ARG_PROPERTIES: > - -Porg.gradle.jvmargs=-Xmx4g - -Porg.gradle.parallel=false - --no-daemon + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon jobs: debug: @@ -36,7 +34,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Assemble ${{ matrix.target }} debug apk - run: ./gradlew assemble${{ matrix.target }}Debug $CI_GRADLE_ARG_PROPERTIES --stacktrace + run: ./gradlew assemble${{ matrix.target }}Debug $CI_GRADLE_ARG_PROPERTIES - name: Upload ${{ matrix.target }} debug APKs uses: actions/upload-artifact@v3 with: @@ -61,7 +59,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Assemble GPlay unsigned apk - run: ./gradlew clean assembleGplayRelease $CI_GRADLE_ARG_PROPERTIES --stacktrace + run: ./gradlew clean assembleGplayRelease $CI_GRADLE_ARG_PROPERTIES - name: Upload Gplay unsigned APKs uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 36fd225674..6f2d55d318 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,10 +6,8 @@ on: - cron: "0 4 * * *" env: - CI_GRADLE_ARG_PROPERTIES: > - -Porg.gradle.jvmargs=-Xmx4g - -Porg.gradle.parallel=false - --no-daemon + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon jobs: nightly: diff --git a/.github/workflows/post-pr.yml b/.github/workflows/post-pr.yml index a7f1d6f204..e7eb7dce99 100644 --- a/.github/workflows/post-pr.yml +++ b/.github/workflows/post-pr.yml @@ -10,10 +10,8 @@ on: # Enrich gradle.properties for CI/CD env: - CI_GRADLE_ARG_PROPERTIES: > - -Porg.gradle.jvmargs=-Xmx4g - -Porg.gradle.parallel=false - --no-daemon + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon jobs: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 56a7c8b97b..9f39e6895d 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -7,10 +7,8 @@ on: # Enrich gradle.properties for CI/CD env: - CI_GRADLE_ARG_PROPERTIES: > - -Porg.gradle.jvmargs=-Xmx4g - -Porg.gradle.parallel=false - --no-daemon + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon jobs: check: @@ -51,8 +49,8 @@ jobs: - name: Run lint # Not always, if ktlint or detekt fail, avoid running the long lint check. run: | - ./gradlew lintGplayRelease --stacktrace $CI_GRADLE_ARG_PROPERTIES - ./gradlew lintFdroidRelease --stacktrace $CI_GRADLE_ARG_PROPERTIES + ./gradlew lintGplayRelease $CI_GRADLE_ARG_PROPERTIES + ./gradlew lintFdroidRelease $CI_GRADLE_ARG_PROPERTIES - name: Upload reports if: always() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b9aa1a851..11048503d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,10 +7,8 @@ on: # Enrich gradle.properties for CI/CD env: - CI_GRADLE_ARG_PROPERTIES: > - -Porg.gradle.jvmargs=-Xmx4g - -Porg.gradle.parallel=false - --no-daemon + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon jobs: tests: @@ -67,9 +65,9 @@ jobs: disable-animations: true emulator-build: 7425822 script: | - ./gradlew unitTestsWithCoverage --stacktrace $CI_GRADLE_ARG_PROPERTIES - ./gradlew instrumentationTestsWithCoverage --stacktrace $CI_GRADLE_ARG_PROPERTIES - ./gradlew generateCoverageReport --stacktrace $CI_GRADLE_ARG_PROPERTIES + ./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES + ./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES + ./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES - run: ./gradlew sonarqube $CI_GRADLE_ARG_PROPERTIES if: always() # we may have failed a previous step and retried, that's OK env: From c6e263a6d31a50c7d16da6a979ee14e60dd562af Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 3 Aug 2022 15:45:57 +0100 Subject: [PATCH 31/58] allowing parallel builds to occur now that the memory is constrained --- .github/workflows/nightly.yml | 2 +- .github/workflows/post-pr.yml | 2 +- .github/workflows/quality.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6f2d55d318..bb6e205b7f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,7 +7,7 @@ on: env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon jobs: nightly: diff --git a/.github/workflows/post-pr.yml b/.github/workflows/post-pr.yml index e7eb7dce99..dbaee1a978 100644 --- a/.github/workflows/post-pr.yml +++ b/.github/workflows/post-pr.yml @@ -11,7 +11,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon jobs: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 9f39e6895d..7dec734dff 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -8,7 +8,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon jobs: check: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 11048503d5..584e0834a9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 -Porg.gradle.parallel=false --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon jobs: tests: From b625d6a9bcffc64e77b2db37a2b3554c5fca112f Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 3 Aug 2022 15:53:27 +0100 Subject: [PATCH 32/58] reducing CI workers to github VM limit --- .github/workflows/build.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/post-pr.yml | 2 +- .github/workflows/quality.yml | 2 +- .github/workflows/tests.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a48af91fba..f2be46a4f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: debug: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index bb6e205b7f..bd2b5491be 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,7 +7,7 @@ on: env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: nightly: diff --git a/.github/workflows/post-pr.yml b/.github/workflows/post-pr.yml index dbaee1a978..c78aa72b35 100644 --- a/.github/workflows/post-pr.yml +++ b/.github/workflows/post-pr.yml @@ -11,7 +11,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 7dec734dff..edc72ed3cc 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -8,7 +8,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: check: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 584e0834a9..80933dd1c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: tests: From b0f73b029c3dab71334e430511114b8868e47dd0 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 4 Aug 2022 10:00:47 +0100 Subject: [PATCH 33/58] upping the jvm limit but keeping the kotlin daemon constrained --- .github/workflows/build.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/post-pr.yml | 2 +- .github/workflows/quality.yml | 2 +- .github/workflows/tests.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2be46a4f6..933c442501 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index bd2b5491be..3083bc79ca 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,7 +6,7 @@ on: - cron: "0 4 * * *" env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: diff --git a/.github/workflows/post-pr.yml b/.github/workflows/post-pr.yml index c78aa72b35..5cde95e625 100644 --- a/.github/workflows/post-pr.yml +++ b/.github/workflows/post-pr.yml @@ -10,7 +10,7 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index edc72ed3cc..6e5e2e4d67 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -7,7 +7,7 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 80933dd1c2..49c87bfd7d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2560m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon jobs: From 99de618bed6a0669e46bd6c789ba5c9dda26d29f Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 4 Aug 2022 14:18:03 +0100 Subject: [PATCH 34/58] adding edit text ids so that the content can automatically be restored by the fragment manager --- vector/src/main/res/layout/fragment_ftue_combined_login.xml | 2 ++ vector/src/main/res/layout/fragment_ftue_combined_register.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/vector/src/main/res/layout/fragment_ftue_combined_login.xml b/vector/src/main/res/layout/fragment_ftue_combined_login.xml index 9533ab29fc..12943b4dc0 100644 --- a/vector/src/main/res/layout/fragment_ftue_combined_login.xml +++ b/vector/src/main/res/layout/fragment_ftue_combined_login.xml @@ -147,6 +147,7 @@ app:layout_constraintTop_toBottomOf="@id/serverSelectionSpacing"> Date: Thu, 4 Aug 2022 14:25:05 +0100 Subject: [PATCH 35/58] fixing login/account creation errors showing when navigating to another screen - was caused by the lost focus callback being triggered by onPause, fixed by only triggering if the current view is in the resumed state --- .../im/vector/app/core/extensions/TextInputLayout.kt | 9 +++++++-- .../onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt | 4 +++- .../ftueauth/FtueAuthCombinedRegisterFragment.kt | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt b/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt index 4739840f01..f1b5f5ce09 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt @@ -78,10 +78,15 @@ fun TextInputLayout.setOnImeDoneListener(action: () -> Unit) { } } -fun TextInputLayout.setOnFocusLostListener(action: () -> Unit) { +/** + * Set a listener for when the input has lost focus, such as moving to the another input field. + * The listener is only called when the view is in a resumed state to avoid triggers when exiting a screen. + */ +fun TextInputLayout.setOnFocusLostListener(lifecycleOwner: LifecycleOwner, action: () -> Unit) { + lifecycleOwner.lifecycle editText().setOnFocusChangeListener { _, hasFocus -> when (hasFocus) { - false -> action() + false -> lifecycleOwner.lifecycleScope.launchWhenResumed { action() } else -> { // do nothing } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt index 58b1edddf8..c2d2346765 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt @@ -63,7 +63,9 @@ class FtueAuthCombinedLoginFragment @Inject constructor( views.loginRoot.realignPercentagesToParent() views.editServerButton.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection)) } views.loginPasswordInput.setOnImeDoneListener { submit() } - views.loginInput.setOnFocusLostListener { viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content())) } + views.loginInput.setOnFocusLostListener(viewLifecycleOwner) { + viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content())) + } views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) } } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedRegisterFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedRegisterFragment.kt index c69706a17b..8340fb903a 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedRegisterFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedRegisterFragment.kt @@ -86,7 +86,7 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu views.createAccountEntryFooter.text = "" } - views.createAccountInput.setOnFocusLostListener { + views.createAccountInput.setOnFocusLostListener(viewLifecycleOwner) { viewModel.handle(OnboardingAction.UserNameEnteredAction.Registration(views.createAccountInput.content())) } } From b6582c41443c2f4960d0554aa1977b5590407ebc Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 4 Aug 2022 14:29:26 +0100 Subject: [PATCH 36/58] adding changelog entry --- changelog.d/6737.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6737.bugfix diff --git a/changelog.d/6737.bugfix b/changelog.d/6737.bugfix new file mode 100644 index 0000000000..6568e9ff31 --- /dev/null +++ b/changelog.d/6737.bugfix @@ -0,0 +1 @@ +Fixes onboarding login/account creation errors showing after navigation From 8470ac9731c18bfd12945d3afbc2722ab61d3b44 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 4 Aug 2022 15:03:00 +0100 Subject: [PATCH 37/58] removing unneeded --stacktrace flag, it's part of the CI_GRADLE_ARG_PROPERTIES --- .github/workflows/nightly.yml | 2 +- .github/workflows/tests.yml | 8 ++++---- docs/nightly_build.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3083bc79ca..51c1b32e82 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -38,7 +38,7 @@ jobs: yes n | towncrier build --version nightly - name: Build and upload Gplay Nightly APK run: | - ./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES --stacktrace + ./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES env: ELEMENT_ANDROID_NIGHTLY_KEYID: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_KEYID }} ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 49c87bfd7d..2a89ed3040 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,9 +49,9 @@ jobs: disable-animations: true emulator-build: 7425822 script: | - ./gradlew unitTestsWithCoverage --stacktrace $CI_GRADLE_ARG_PROPERTIES - ./gradlew instrumentationTestsWithCoverage --stacktrace $CI_GRADLE_ARG_PROPERTIES - ./gradlew generateCoverageReport --stacktrace $CI_GRADLE_ARG_PROPERTIES + ./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES + ./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES + ./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES # NB: continue-on-error marks steps.tests.conclusion = 'success' but leaves stes.tests.outcome = 'failure' - name: Run all the codecoverage tests at once (retry if emulator failed) uses: reactivecircus/android-emulator-runner@v2 @@ -112,5 +112,5 @@ jobs: # restore-keys: | # ${{ runner.os }}-gradle- # - name: Build Android Tests -# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES --stacktrace +# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES diff --git a/docs/nightly_build.md b/docs/nightly_build.md index 91f18214c4..7750e0466a 100644 --- a/docs/nightly_build.md +++ b/docs/nightly_build.md @@ -48,7 +48,7 @@ mv towncrier.toml towncrier.toml.bak sed 's/CHANGES\.md/CHANGES_NIGHTLY\.md/' towncrier.toml.bak > towncrier.toml rm towncrier.toml.bak yes n | towncrier --version nightly -./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES --stacktrace +./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES ``` Then you can reset the change on the codebase. From 09a91c4541965c088bfce3d06deaaef51cc6c3c9 Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:54:53 +0100 Subject: [PATCH 38/58] Make it easier to find developer sign-off instructions (#6739) * Make it easier to find sign-off instructions by linking directly to DCO docs from danger message. --- changelog.d/6739.misc | 1 + tools/danger/dangerfile.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/6739.misc diff --git a/changelog.d/6739.misc b/changelog.d/6739.misc new file mode 100644 index 0000000000..5e5de00831 --- /dev/null +++ b/changelog.d/6739.misc @@ -0,0 +1 @@ +Link directly to DCO docs from danger message. diff --git a/tools/danger/dangerfile.js b/tools/danger/dangerfile.js index 59a616db4a..4efd236419 100644 --- a/tools/danger/dangerfile.js +++ b/tools/danger/dangerfile.js @@ -83,7 +83,7 @@ if (requiresSignOff) { const hasPRBodySignOff = pr.body.includes(signOff) const hasCommitSignOff = danger.git.commits.every(commit => commit.message.includes(signOff)) if (!hasPRBodySignOff && !hasCommitSignOff) { - fail("Please add a sign-off to either the PR description or to the commits themselves.") + fail("Please add a sign-off to either the PR description or to the commits themselves. See instructions [here](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#sign-off).") } } From 8b8a4f3d7be1eee231f27a399c052f4a090cb63b Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 28 Jul 2022 16:51:11 +0200 Subject: [PATCH 39/58] Fixing missing clear on audio tracker listeners --- .../im/vector/app/features/home/room/detail/TimelineFragment.kt | 1 + 1 file changed, 1 insertion(+) 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 8f9564789a..62677ce9ef 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 @@ -966,6 +966,7 @@ class TimelineFragment @Inject constructor( override fun onDestroyView() { audioMessagePlaybackTracker.makeAllPlaybacksIdle() + audioMessagePlaybackTracker.clear() lazyLoadedViews.unBind() timelineEventController.callback = null timelineEventController.removeModelBuildListener(modelBuildListener) From 018772ca9a8f1fbcce92e73fc8310d06e590816a Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 28 Jul 2022 16:57:08 +0200 Subject: [PATCH 40/58] Adding changelog entry --- changelog.d/6678.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6678.misc diff --git a/changelog.d/6678.misc b/changelog.d/6678.misc new file mode 100644 index 0000000000..a7a53257d8 --- /dev/null +++ b/changelog.d/6678.misc @@ -0,0 +1 @@ +[Timeline] Memory leak in audio message playback tracker From 81cba3d27520bee6acd311e38cd8c6b977d6b138 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Jul 2022 09:44:23 +0200 Subject: [PATCH 41/58] Using ViewModel to handle clearing of audio controller --- .../vector/app/features/home/room/detail/TimelineFragment.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 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 62677ce9ef..220893b31c 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 @@ -965,8 +965,7 @@ class TimelineFragment @Inject constructor( } override fun onDestroyView() { - audioMessagePlaybackTracker.makeAllPlaybacksIdle() - audioMessagePlaybackTracker.clear() + messageComposerViewModel.handle(MessageComposerAction.EndAllVoiceActions()) lazyLoadedViews.unBind() timelineEventController.callback = null timelineEventController.removeModelBuildListener(modelBuildListener) @@ -1099,7 +1098,7 @@ class TimelineFragment @Inject constructor( else -> state.isAllowedToManageWidgets } menu.findItem(R.id.video_call).icon?.alpha = if (callButtonsEnabled) 0xFF else 0x40 - menu.findItem(R.id.voice_call).icon?.alpha = if (callButtonsEnabled || state.hasActiveElementCallWidget()) 0xFF else 0x40 + menu.findItem(R.id.voice_call).icon?.alpha = if (callButtonsEnabled || state.hasActiveElementCallWidget()) 0xFF else 0x40 val matrixAppsMenuItem = menu.findItem(R.id.open_matrix_apps) val widgetsCount = state.activeRoomWidgets.invoke()?.size ?: 0 From 64c25f073ce82eddc9c431798f8c88e5852eb0ec Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 1 Aug 2022 09:35:29 +0200 Subject: [PATCH 42/58] Calling directly the ViewModel clear method instead of using a view action --- .../vector/app/features/home/room/detail/TimelineFragment.kt | 2 +- .../home/room/detail/composer/MessageComposerAction.kt | 1 - .../home/room/detail/composer/MessageComposerViewModel.kt | 3 +-- 3 files changed, 2 insertions(+), 4 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 220893b31c..f164183914 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 @@ -965,7 +965,7 @@ class TimelineFragment @Inject constructor( } override fun onDestroyView() { - messageComposerViewModel.handle(MessageComposerAction.EndAllVoiceActions()) + messageComposerViewModel.endAllVoiceActions() lazyLoadedViews.unBind() timelineEventController.callback = null timelineEventController.removeModelBuildListener(modelBuildListener) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerAction.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerAction.kt index 0da324ffc2..527f42a67a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerAction.kt @@ -41,7 +41,6 @@ sealed class MessageComposerAction : VectorViewModelAction { object PauseRecordingVoiceMessage : MessageComposerAction() data class PlayOrPauseVoicePlayback(val eventId: String, val messageAudioContent: MessageAudioContent) : MessageComposerAction() object PlayOrPauseRecordingPlayback : MessageComposerAction() - data class EndAllVoiceActions(val deleteRecord: Boolean = true) : MessageComposerAction() data class VoiceWaveformTouchedUp(val eventId: String, val duration: Int, val percentage: Float) : MessageComposerAction() data class VoiceWaveformMovedTo(val eventId: String, val duration: Int, val percentage: Float) : MessageComposerAction() data class AudioSeekBarMovedTo(val eventId: String, val duration: Int, val percentage: Float) : MessageComposerAction() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt index ce4235a825..ca86010915 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt @@ -107,7 +107,6 @@ class MessageComposerViewModel @AssistedInject constructor( is MessageComposerAction.PlayOrPauseVoicePlayback -> handlePlayOrPauseVoicePlayback(action) MessageComposerAction.PauseRecordingVoiceMessage -> handlePauseRecordingVoiceMessage() MessageComposerAction.PlayOrPauseRecordingPlayback -> handlePlayOrPauseRecordingPlayback() - is MessageComposerAction.EndAllVoiceActions -> handleEndAllVoiceActions(action.deleteRecord) is MessageComposerAction.InitializeVoiceRecorder -> handleInitializeVoiceRecorder(action.attachmentData) is MessageComposerAction.OnEntersBackground -> handleEntersBackground(action.composerText) is MessageComposerAction.VoiceWaveformTouchedUp -> handleVoiceWaveformTouchedUp(action) @@ -887,7 +886,7 @@ class MessageComposerViewModel @AssistedInject constructor( audioMessageHelper.startOrPauseRecordingPlayback() } - private fun handleEndAllVoiceActions(deleteRecord: Boolean) { + fun endAllVoiceActions(deleteRecord: Boolean = true) { audioMessageHelper.clearTracker() audioMessageHelper.stopAllVoiceActions(deleteRecord) } From 8f91278d1ada58b8c36294eb0a51122621d96566 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Jul 2022 15:58:18 +0200 Subject: [PATCH 43/58] Creating custom view for map loading error --- .../features/location/MapLoadingErrorView.kt | 38 +++++++++++++++++ .../res/layout/view_map_loading_error.xml | 42 +++++++++++++++++++ vector/src/main/res/values/strings.xml | 4 +- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt create mode 100644 vector/src/main/res/layout/view_map_loading_error.xml diff --git a/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt new file mode 100644 index 0000000000..45b7dfd6d6 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt @@ -0,0 +1,38 @@ +/* + * 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.location + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import im.vector.app.databinding.ViewMapLoadingErrorBinding + +/** + * Custom view to display an error when map fails to load. + */ +class MapLoadingErrorView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + init { + ViewMapLoadingErrorBinding.inflate( + LayoutInflater.from(context), + this + ) + } +} diff --git a/vector/src/main/res/layout/view_map_loading_error.xml b/vector/src/main/res/layout/view_map_loading_error.xml new file mode 100644 index 0000000000..dca03bf49b --- /dev/null +++ b/vector/src/main/res/layout/view_map_loading_error.xml @@ -0,0 +1,42 @@ + + + + + + + + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 6b4eec1c9c..142cc3a8d9 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3113,7 +3113,9 @@ ${app_name} could not access your location ${app_name} could not access your location. Please try again later. Open with - Failed to load map + + Failed to load map + Unable to load map\nThis home server may not be configured to display maps. Live location enabled Loading live location… Live location ended From b83acf373d932fd0b4939373d24737d14f2230be Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Jul 2022 16:37:52 +0200 Subject: [PATCH 44/58] Adding error view in preview and sharing fragments --- .../res/layout/fragment_location_preview.xml | 18 ++++++++++++++++-- .../res/layout/fragment_location_sharing.xml | 10 ++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/vector/src/main/res/layout/fragment_location_preview.xml b/vector/src/main/res/layout/fragment_location_preview.xml index 5499e5b427..126edbb5e1 100644 --- a/vector/src/main/res/layout/fragment_location_preview.xml +++ b/vector/src/main/res/layout/fragment_location_preview.xml @@ -6,9 +6,23 @@ + + diff --git a/vector/src/main/res/layout/fragment_location_sharing.xml b/vector/src/main/res/layout/fragment_location_sharing.xml index cd15f418ea..7d9241c42b 100644 --- a/vector/src/main/res/layout/fragment_location_sharing.xml +++ b/vector/src/main/res/layout/fragment_location_sharing.xml @@ -35,6 +35,16 @@ app:layout_constraintStart_toStartOf="@id/mapView" app:layout_constraintTop_toTopOf="@id/mapView" /> + + Date: Fri, 29 Jul 2022 16:41:46 +0200 Subject: [PATCH 45/58] Fix missing icon in error view --- vector/src/main/res/layout/view_map_loading_error.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/layout/view_map_loading_error.xml b/vector/src/main/res/layout/view_map_loading_error.xml index dca03bf49b..f8a6679e06 100644 --- a/vector/src/main/res/layout/view_map_loading_error.xml +++ b/vector/src/main/res/layout/view_map_loading_error.xml @@ -25,7 +25,7 @@ android:layout_width="28dp" android:layout_height="28dp" android:contentDescription="@string/a11y_location_share_option_pinned_icon" - tools:src="@drawable/ic_warning_badge" /> + android:src="@drawable/ic_warning_badge" /> Date: Fri, 29 Jul 2022 16:42:26 +0200 Subject: [PATCH 46/58] Keep the previous loading map error string for timeline --- vector/src/main/res/values/strings.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 142cc3a8d9..d1b2d237d9 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3113,8 +3113,7 @@ ${app_name} could not access your location ${app_name} could not access your location. Please try again later. Open with - - Failed to load map + Failed to load map Unable to load map\nThis home server may not be configured to display maps. Live location enabled Loading live location… From e0e06c6ac8865bdf974abbc487099e684b6c43b3 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 1 Aug 2022 09:18:55 +0200 Subject: [PATCH 47/58] Handling map loading error in sharing and preview fragment --- .../app/core/di/MavericksViewModelModule.kt | 6 +++ .../location/LocationPreviewAction.kt | 23 +++++++++ .../location/LocationPreviewFragment.kt | 20 ++++++++ .../location/LocationPreviewViewModel.kt | 48 +++++++++++++++++++ .../location/LocationPreviewViewState.kt | 23 +++++++++ .../location/LocationSharingAction.kt | 1 + .../location/LocationSharingFragment.kt | 44 ++++++++++++----- .../location/LocationSharingViewModel.kt | 5 ++ .../location/LocationSharingViewState.kt | 1 + .../res/layout/fragment_location_sharing.xml | 20 ++++---- 10 files changed, 168 insertions(+), 23 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt create mode 100644 vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt create mode 100644 vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt diff --git a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt index 9b511a1bfd..3936b9eef7 100644 --- a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt @@ -54,6 +54,7 @@ import im.vector.app.features.home.room.list.RoomListViewModel import im.vector.app.features.home.room.list.home.HomeRoomListViewModel import im.vector.app.features.homeserver.HomeServerCapabilitiesViewModel import im.vector.app.features.invite.InviteUsersToRoomViewModel +import im.vector.app.features.location.LocationPreviewViewModel import im.vector.app.features.location.LocationSharingViewModel import im.vector.app.features.location.live.map.LiveLocationMapViewModel import im.vector.app.features.login.LoginViewModel @@ -605,6 +606,11 @@ interface MavericksViewModelModule { @MavericksViewModelKey(LocationSharingViewModel::class) fun createLocationSharingViewModelFactory(factory: LocationSharingViewModel.Factory): MavericksAssistedViewModelFactory<*, *> + @Binds + @IntoMap + @MavericksViewModelKey(LocationPreviewViewModel::class) + fun createLocationPreviewViewModelFactory(factory: LocationPreviewViewModel.Factory): MavericksAssistedViewModelFactory<*, *> + @Binds @IntoMap @MavericksViewModelKey(VectorAttachmentViewerViewModel::class) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt b/vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt new file mode 100644 index 0000000000..75474c3f34 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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.location + +import im.vector.app.core.platform.VectorViewModelAction + +sealed class LocationPreviewAction : VectorViewModelAction { + object ShowMapLoadingError : LocationPreviewAction() +} diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt index 131119a7aa..e8443afbc3 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt @@ -21,8 +21,11 @@ import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.args +import com.airbnb.mvrx.fragmentViewModel +import com.airbnb.mvrx.withState import com.mapbox.mapboxsdk.maps.MapView import im.vector.app.R import im.vector.app.core.platform.VectorBaseFragment @@ -44,9 +47,13 @@ class LocationPreviewFragment @Inject constructor( private val args: LocationSharingArgs by args() + private val viewModel: LocationPreviewViewModel by fragmentViewModel() + // Keep a ref to handle properly the onDestroy callback private var mapView: WeakReference? = null + private var mapLoadingErrorListener: MapView.OnDidFailLoadingMapListener? = null + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLocationPreviewBinding { return FragmentLocationPreviewBinding.inflate(layoutInflater, container, false) } @@ -55,6 +62,9 @@ class LocationPreviewFragment @Inject constructor( super.onViewCreated(view, savedInstanceState) mapView = WeakReference(views.mapView) + mapLoadingErrorListener = MapView.OnDidFailLoadingMapListener { + viewModel.handle(LocationPreviewAction.ShowMapLoadingError) + }.also { views.mapView.addOnDidFailLoadingMapListener(it) } views.mapView.onCreate(savedInstanceState) lifecycleScope.launchWhenCreated { @@ -63,6 +73,12 @@ class LocationPreviewFragment @Inject constructor( } } + override fun onDestroyView() { + mapLoadingErrorListener?.let { mapView?.get()?.removeOnDidFailLoadingMapListener(it) } + mapLoadingErrorListener = null + super.onDestroyView() + } + override fun onResume() { super.onResume() views.mapView.onResume() @@ -99,6 +115,10 @@ class LocationPreviewFragment @Inject constructor( super.onDestroy() } + override fun invalidate() = withState(viewModel) { state -> + views.mapPreviewLoadingError.isVisible = state.loadingMapHasFailed + } + override fun getMenuRes() = R.menu.menu_location_preview override fun handleMenuItemSelected(item: MenuItem): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt new file mode 100644 index 0000000000..5987bd22f8 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt @@ -0,0 +1,48 @@ +/* + * 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.location + +import com.airbnb.mvrx.MavericksViewModelFactory +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import im.vector.app.core.di.MavericksAssistedViewModelFactory +import im.vector.app.core.di.hiltMavericksViewModelFactory +import im.vector.app.core.platform.EmptyViewEvents +import im.vector.app.core.platform.VectorViewModel + +class LocationPreviewViewModel @AssistedInject constructor( + @Assisted private val initialState: LocationPreviewViewState, +) : VectorViewModel(initialState) { + + @AssistedFactory + interface Factory : MavericksAssistedViewModelFactory { + override fun create(initialState: LocationPreviewViewState): LocationPreviewViewModel + } + + companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() + + override fun handle(action: LocationPreviewAction) { + when (action) { + LocationPreviewAction.ShowMapLoadingError -> handleShowMapLoadingError() + } + } + + private fun handleShowMapLoadingError() { + setState { copy(loadingMapHasFailed = true) } + } +} diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt b/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt new file mode 100644 index 0000000000..c3bc86b704 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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.location + +import com.airbnb.mvrx.MavericksState + +data class LocationPreviewViewState( + val loadingMapHasFailed: Boolean = false +) : MavericksState diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingAction.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingAction.kt index 264b1f0e0b..5a1edbf8a1 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingAction.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingAction.kt @@ -25,4 +25,5 @@ sealed class LocationSharingAction : VectorViewModelAction { object ZoomToUserLocation : LocationSharingAction() object LiveLocationSharingRequested : LocationSharingAction() data class StartLiveLocationSharing(val durationMillis: Long) : LocationSharingAction() + object ShowMapLoadingError : LocationSharingAction() } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index ca524a0126..d96410010e 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -24,6 +24,7 @@ import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.core.view.isGone +import androidx.core.view.isVisible import androidx.fragment.app.setFragmentResultListener import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.fragmentViewModel @@ -69,6 +70,7 @@ class LocationSharingFragment @Inject constructor( private var mapView: WeakReference? = null private var hasRenderedUserAvatar = false + private var mapLoadingErrorListener: MapView.OnDidFailLoadingMapListener? = null override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLocationSharingBinding { return FragmentLocationSharingBinding.inflate(inflater, container, false) @@ -87,6 +89,9 @@ class LocationSharingFragment @Inject constructor( super.onViewCreated(view, savedInstanceState) mapView = WeakReference(views.mapView) + mapLoadingErrorListener = MapView.OnDidFailLoadingMapListener { + viewModel.handle(LocationSharingAction.ShowMapLoadingError) + }.also { views.mapView.addOnDidFailLoadingMapListener(it) } views.mapView.onCreate(savedInstanceState) lifecycleScope.launchWhenCreated { @@ -112,6 +117,12 @@ class LocationSharingFragment @Inject constructor( } } + override fun onDestroyView() { + mapLoadingErrorListener?.let { mapView?.get()?.removeOnDidFailLoadingMapListener(it) } + mapLoadingErrorListener = null + super.onDestroyView() + } + override fun onResume() { super.onResume() views.mapView.onResume() @@ -256,20 +267,27 @@ class LocationSharingFragment @Inject constructor( } private fun updateMap(state: LocationSharingViewState) { - // first, update the options view - val options: Set = when (state.areTargetAndUserLocationEqual) { - true -> setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE) - false -> setOf(LocationSharingOption.PINNED) - else -> emptySet() - } - views.shareLocationOptionsPicker.render(options) + if (state.loadingMapHasFailed) { + views.shareLocationOptionsPicker.render(emptySet()) + views.shareLocationMapLoadingError.isVisible = true + } else { + // first, update the options view + val options: Set = when (state.areTargetAndUserLocationEqual) { + true -> setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE) + false -> setOf(LocationSharingOption.PINNED) + else -> emptySet() + } + views.shareLocationOptionsPicker.render(options) - // then, update the map using the height of the options view after it has been rendered - views.shareLocationOptionsPicker.post { - val mapState = state - .toMapState() - .copy(logoMarginBottom = views.shareLocationOptionsPicker.height) - views.mapView.render(mapState) + // then, update the map using the height of the options view after it has been rendered + views.shareLocationOptionsPicker.post { + val mapState = state + .toMapState() + .copy(logoMarginBottom = views.shareLocationOptionsPicker.height) + views.mapView.render(mapState) + } + + views.shareLocationMapLoadingError.isGone = true } } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt index 8056b72d57..28e37a38eb 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt @@ -152,6 +152,7 @@ class LocationSharingViewModel @AssistedInject constructor( LocationSharingAction.ZoomToUserLocation -> handleZoomToUserLocationAction() LocationSharingAction.LiveLocationSharingRequested -> handleLiveLocationSharingRequestedAction() is LocationSharingAction.StartLiveLocationSharing -> handleStartLiveLocationSharingAction(action.durationMillis) + LocationSharingAction.ShowMapLoadingError -> handleShowMapLoadingError() } } @@ -211,6 +212,10 @@ class LocationSharingViewModel @AssistedInject constructor( ) } + private fun handleShowMapLoadingError() { + setState { copy(loadingMapHasFailed = true) } + } + private fun onLocationUpdate(locationData: LocationData) { Timber.d("onLocationUpdate()") setState { diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingViewState.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingViewState.kt index d5226eacfb..c7a2349afa 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingViewState.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingViewState.kt @@ -36,6 +36,7 @@ data class LocationSharingViewState( val lastKnownUserLocation: LocationData? = null, val locationTargetDrawable: Drawable? = null, val canShareLiveLocation: Boolean = false, + val loadingMapHasFailed: Boolean = false ) : MavericksState { constructor(locationSharingArgs: LocationSharingArgs) : this( diff --git a/vector/src/main/res/layout/fragment_location_sharing.xml b/vector/src/main/res/layout/fragment_location_sharing.xml index 7d9241c42b..4f0825b992 100644 --- a/vector/src/main/res/layout/fragment_location_sharing.xml +++ b/vector/src/main/res/layout/fragment_location_sharing.xml @@ -35,16 +35,6 @@ app:layout_constraintStart_toStartOf="@id/mapView" app:layout_constraintTop_toTopOf="@id/mapView" /> - - + + From 6972622bc6a685a2598c8bd9a7cbcd7f4b8c4b72 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 1 Aug 2022 14:45:08 +0200 Subject: [PATCH 48/58] Handling map loading error in timeline --- .../stylable_map_loading_error_view.xml | 8 ++++ .../timeline/item/AbsMessageLocationItem.kt | 12 ++++-- .../features/location/MapLoadingErrorView.kt | 39 +++++++++++++++++-- .../location/MapLoadingErrorViewState.kt | 21 ++++++++++ .../res/drawable/ic_location_pin_failed.xml | 9 ----- .../item_timeline_event_location_stub.xml | 23 +++++------ .../res/layout/view_map_loading_error.xml | 16 ++++++-- 7 files changed, 94 insertions(+), 34 deletions(-) create mode 100644 library/ui-styles/src/main/res/values/stylable_map_loading_error_view.xml create mode 100644 vector/src/main/java/im/vector/app/features/location/MapLoadingErrorViewState.kt delete mode 100644 vector/src/main/res/drawable/ic_location_pin_failed.xml diff --git a/library/ui-styles/src/main/res/values/stylable_map_loading_error_view.xml b/library/ui-styles/src/main/res/values/stylable_map_loading_error_view.xml new file mode 100644 index 0000000000..911167e52a --- /dev/null +++ b/library/ui-styles/src/main/res/values/stylable_map_loading_error_view.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt index b7790b8a30..4903b8c8cf 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt @@ -36,6 +36,8 @@ import im.vector.app.core.utils.DimensionConverter import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout import im.vector.app.features.home.room.detail.timeline.style.granularRoundedCorners +import im.vector.app.features.location.MapLoadingErrorView +import im.vector.app.features.location.MapLoadingErrorViewState abstract class AbsMessageLocationItem( @LayoutRes layoutId: Int = R.layout.item_timeline_event_base @@ -86,8 +88,10 @@ abstract class AbsMessageLocationItem( target: Target?, isFirstResource: Boolean ): Boolean { - holder.staticMapPinImageView.setImageResource(R.drawable.ic_location_pin_failed) - holder.staticMapErrorTextView.isVisible = true + holder.staticMapPinImageView.setImageDrawable(null) + holder.staticMapLoadingErrorView.isVisible = true + val mapErrorViewState = MapLoadingErrorViewState(imageCornerTransformation) + holder.staticMapLoadingErrorView.render(mapErrorViewState) holder.staticMapCopyrightTextView.isVisible = false return false } @@ -103,7 +107,7 @@ abstract class AbsMessageLocationItem( // we are not using Glide since it does not display it correctly when there is no user photo holder.staticMapPinImageView.setImageDrawable(pinDrawable) } - holder.staticMapErrorTextView.isVisible = false + holder.staticMapLoadingErrorView.isVisible = false holder.staticMapCopyrightTextView.isVisible = true return false } @@ -115,7 +119,7 @@ abstract class AbsMessageLocationItem( abstract class Holder(@IdRes stubId: Int) : AbsMessageItem.Holder(stubId) { val staticMapImageView by bind(R.id.staticMapImageView) val staticMapPinImageView by bind(R.id.staticMapPinImageView) - val staticMapErrorTextView by bind(R.id.staticMapErrorTextView) + val staticMapLoadingErrorView by bind(R.id.staticMapLoadingError) val staticMapCopyrightTextView by bind(R.id.staticMapCopyrightTextView) } } diff --git a/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt index 45b7dfd6d6..c82f1eb687 100644 --- a/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt +++ b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt @@ -17,10 +17,16 @@ package im.vector.app.features.location import android.content.Context +import android.content.res.TypedArray +import android.graphics.drawable.ColorDrawable import android.util.AttributeSet import android.view.LayoutInflater import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.res.use +import im.vector.app.R +import im.vector.app.core.glide.GlideApp import im.vector.app.databinding.ViewMapLoadingErrorBinding +import im.vector.app.features.themes.ThemeUtils /** * Custom view to display an error when map fails to load. @@ -29,10 +35,35 @@ class MapLoadingErrorView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { + private val binding = ViewMapLoadingErrorBinding.inflate( + LayoutInflater.from(context), + this + ) + init { - ViewMapLoadingErrorBinding.inflate( - LayoutInflater.from(context), - this - ) + context.obtainStyledAttributes( + attrs, + R.styleable.MapLoadingErrorView, + 0, + 0 + ).use { + setErrorDescription(it) + } + } + + private fun setErrorDescription(typedArray: TypedArray) { + val description = typedArray.getString(R.styleable.MapLoadingErrorView_mapErrorDescription) + if(description.isNullOrEmpty()) { + binding.mapLoadingErrorDescription.setText(R.string.location_share_loading_map_error) + } else { + binding.mapLoadingErrorDescription.text = description + } + } + + fun render(mapLoadingErrorViewState: MapLoadingErrorViewState) { + GlideApp.with(binding.mapLoadingErrorBackground) + .load(ColorDrawable(ThemeUtils.getColor(context, R.attr.vctr_system))) + .transform(mapLoadingErrorViewState.backgroundTransformation) + .into(binding.mapLoadingErrorBackground) } } diff --git a/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorViewState.kt b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorViewState.kt new file mode 100644 index 0000000000..8098d26a12 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorViewState.kt @@ -0,0 +1,21 @@ +/* + * 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.location + +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation + +data class MapLoadingErrorViewState(val backgroundTransformation: BitmapTransformation) diff --git a/vector/src/main/res/drawable/ic_location_pin_failed.xml b/vector/src/main/res/drawable/ic_location_pin_failed.xml deleted file mode 100644 index 250d048836..0000000000 --- a/vector/src/main/res/drawable/ic_location_pin_failed.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/vector/src/main/res/layout/item_timeline_event_location_stub.xml b/vector/src/main/res/layout/item_timeline_event_location_stub.xml index e4c87dab71..3eef4a4084 100644 --- a/vector/src/main/res/layout/item_timeline_event_location_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_location_stub.xml @@ -29,21 +29,16 @@ app:layout_constraintTop_toTopOf="@id/staticMapImageView" app:layout_constraintVertical_bias="1.0" /> - + app:layout_constraintBottom_toTopOf="@id/locationLiveRunningBanner" + app:layout_constraintEnd_toEndOf="@id/staticMapImageView" + app:layout_constraintStart_toStartOf="@id/staticMapImageView" + app:layout_constraintTop_toTopOf="@id/staticMapImageView" + app:mapErrorDescription="@string/location_timeline_failed_to_load_map" /> + + + android:src="@drawable/ic_warning_badge" + tools:ignore="ContentDescription" /> Date: Mon, 1 Aug 2022 14:48:15 +0200 Subject: [PATCH 49/58] Creating location.preview package --- .../src/main/java/im/vector/app/core/di/FragmentModule.kt | 2 +- .../im/vector/app/core/di/MavericksViewModelModule.kt | 2 +- .../app/features/location/LocationSharingActivity.kt | 1 + .../location/{ => preview}/LocationPreviewAction.kt | 4 ++-- .../location/{ => preview}/LocationPreviewFragment.kt | 8 ++++++-- .../location/{ => preview}/LocationPreviewViewModel.kt | 2 +- .../location/{ => preview}/LocationPreviewViewState.kt | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) rename vector/src/main/java/im/vector/app/features/location/{ => preview}/LocationPreviewAction.kt (89%) rename vector/src/main/java/im/vector/app/features/location/{ => preview}/LocationPreviewFragment.kt (94%) rename vector/src/main/java/im/vector/app/features/location/{ => preview}/LocationPreviewViewModel.kt (97%) rename vector/src/main/java/im/vector/app/features/location/{ => preview}/LocationPreviewViewState.kt (93%) diff --git a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt index 3cdc8a1afe..99c4324b00 100644 --- a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt @@ -64,7 +64,7 @@ import im.vector.app.features.home.room.detail.search.SearchFragment import im.vector.app.features.home.room.list.RoomListFragment import im.vector.app.features.home.room.list.home.HomeRoomListFragment import im.vector.app.features.home.room.threads.list.views.ThreadListFragment -import im.vector.app.features.location.LocationPreviewFragment +import im.vector.app.features.location.preview.LocationPreviewFragment import im.vector.app.features.location.LocationSharingFragment import im.vector.app.features.login.LoginCaptchaFragment import im.vector.app.features.login.LoginFragment diff --git a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt index 3936b9eef7..3078d01da9 100644 --- a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt @@ -54,7 +54,7 @@ import im.vector.app.features.home.room.list.RoomListViewModel import im.vector.app.features.home.room.list.home.HomeRoomListViewModel import im.vector.app.features.homeserver.HomeServerCapabilitiesViewModel import im.vector.app.features.invite.InviteUsersToRoomViewModel -import im.vector.app.features.location.LocationPreviewViewModel +import im.vector.app.features.location.preview.LocationPreviewViewModel import im.vector.app.features.location.LocationSharingViewModel import im.vector.app.features.location.live.map.LiveLocationMapViewModel import im.vector.app.features.login.LoginViewModel diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt index 169af4a5a2..9eddcad649 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt @@ -23,6 +23,7 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityLocationSharingBinding +import im.vector.app.features.location.preview.LocationPreviewFragment import kotlinx.parcelize.Parcelize @Parcelize diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewAction.kt similarity index 89% rename from vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt rename to vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewAction.kt index 75474c3f34..38f6952f67 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationPreviewAction.kt +++ b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewAction.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.location +package im.vector.app.features.location.preview import im.vector.app.core.platform.VectorViewModelAction diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewFragment.kt similarity index 94% rename from vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt rename to vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewFragment.kt index e8443afbc3..8285d0156b 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.location +package im.vector.app.features.location.preview import android.os.Bundle import android.view.LayoutInflater @@ -33,6 +33,10 @@ import im.vector.app.core.platform.VectorMenuProvider import im.vector.app.core.utils.openLocation import im.vector.app.databinding.FragmentLocationPreviewBinding import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider +import im.vector.app.features.location.DEFAULT_PIN_ID +import im.vector.app.features.location.LocationSharingArgs +import im.vector.app.features.location.MapState +import im.vector.app.features.location.UrlMapProvider import java.lang.ref.WeakReference import javax.inject.Inject diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt similarity index 97% rename from vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt rename to vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt index 5987bd22f8..f0698249ce 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.location +package im.vector.app.features.location.preview import com.airbnb.mvrx.MavericksViewModelFactory import dagger.assisted.Assisted diff --git a/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewState.kt similarity index 93% rename from vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt rename to vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewState.kt index c3bc86b704..96e8316323 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationPreviewViewState.kt +++ b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewState.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.location +package im.vector.app.features.location.preview import com.airbnb.mvrx.MavericksState From 008e07d03efb3c5989fc7f2c89cc2c3af0b4b03f Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 1 Aug 2022 16:05:42 +0200 Subject: [PATCH 50/58] Handling map loading error in live location maximized map --- .../live/map/LiveLocationMapAction.kt | 1 + .../live/map/LiveLocationMapViewFragment.kt | 24 ++++++++++++++++++- .../live/map/LiveLocationMapViewModel.kt | 5 ++++ .../live/map/LiveLocationMapViewState.kt | 3 ++- .../fragment_live_location_map_view.xml | 7 ++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapAction.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapAction.kt index 2a07934146..295d6b5d41 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapAction.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapAction.kt @@ -22,4 +22,5 @@ sealed class LiveLocationMapAction : VectorViewModelAction { data class AddMapSymbol(val key: String, val value: Long) : LiveLocationMapAction() data class RemoveMapSymbol(val key: String) : LiveLocationMapAction() object StopSharing : LiveLocationMapAction() + object ShowMapLoadingError : LiveLocationMapAction() } diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt index 283774dbc6..9eab20742f 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt @@ -71,11 +71,13 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment? = null + private var mapView: MapView? = null private var symbolManager: SymbolManager? = null private var mapStyle: Style? = null private val pendingLiveLocations = mutableListOf() private var isMapFirstUpdate = true private var onSymbolClickListener: OnSymbolClickListener? = null + private var mapLoadingErrorListener: MapView.OnDidFailLoadingMapListener? = null override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLiveLocationMapViewBinding { return FragmentLiveLocationMapViewBinding.inflate(layoutInflater, container, false) @@ -106,6 +108,13 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment + (mapFragment.view as? MapView)?.let(::listenMapLoadingError) lifecycleScope.launch { mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style -> mapStyle = style @@ -141,6 +151,13 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment - updateMap(viewState.userLocations) + if(viewState.loadingMapHasFailed) { + views.mapPreviewLoadingError.isVisible = true + } else { + views.mapPreviewLoadingError.isGone = true + updateMap(viewState.userLocations) + } updateUserListBottomSheet(viewState.userLocations) } diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt index 280789e4c6..33c584ff85 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt @@ -61,6 +61,7 @@ class LiveLocationMapViewModel @AssistedInject constructor( is LiveLocationMapAction.AddMapSymbol -> handleAddMapSymbol(action) is LiveLocationMapAction.RemoveMapSymbol -> handleRemoveMapSymbol(action) LiveLocationMapAction.StopSharing -> handleStopSharing() + LiveLocationMapAction.ShowMapLoadingError -> handleShowMapLoadingError() } } @@ -87,6 +88,10 @@ class LiveLocationMapViewModel @AssistedInject constructor( } } + private fun handleShowMapLoadingError() { + setState { copy(loadingMapHasFailed = true) } + } + override fun onLocationServiceRunning(roomIds: Set) { // NOOP } diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt index 615b4381e2..459e2797d0 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt @@ -27,7 +27,8 @@ data class LiveLocationMapViewState( /** * Map to keep track of symbol ids associated to each user Id. */ - val mapSymbolIds: Map = emptyMap() + val mapSymbolIds: Map = emptyMap(), + val loadingMapHasFailed: Boolean = false ) : MavericksState { constructor(liveLocationMapViewArgs: LiveLocationMapViewArgs) : this( roomId = liveLocationMapViewArgs.roomId diff --git a/vector/src/main/res/layout/fragment_live_location_map_view.xml b/vector/src/main/res/layout/fragment_live_location_map_view.xml index 81db466dab..369404ddbd 100644 --- a/vector/src/main/res/layout/fragment_live_location_map_view.xml +++ b/vector/src/main/res/layout/fragment_live_location_map_view.xml @@ -17,6 +17,13 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + + Date: Mon, 1 Aug 2022 16:59:29 +0200 Subject: [PATCH 51/58] adding changelog entry --- changelog.d/6711.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6711.feature diff --git a/changelog.d/6711.feature b/changelog.d/6711.feature new file mode 100644 index 0000000000..cff718affd --- /dev/null +++ b/changelog.d/6711.feature @@ -0,0 +1 @@ +[Location Share] Render fallback UI when map fails to load From ec5f874a818acaa94679751e901680f7ec3aeb36 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 1 Aug 2022 17:10:02 +0200 Subject: [PATCH 52/58] Fixing code formatting issues --- vector/src/main/java/im/vector/app/core/di/FragmentModule.kt | 2 +- .../main/java/im/vector/app/core/di/MavericksViewModelModule.kt | 2 +- .../java/im/vector/app/features/location/MapLoadingErrorView.kt | 2 +- .../features/location/live/map/LiveLocationMapViewFragment.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt index 99c4324b00..e86b350534 100644 --- a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt @@ -64,8 +64,8 @@ import im.vector.app.features.home.room.detail.search.SearchFragment import im.vector.app.features.home.room.list.RoomListFragment import im.vector.app.features.home.room.list.home.HomeRoomListFragment import im.vector.app.features.home.room.threads.list.views.ThreadListFragment -import im.vector.app.features.location.preview.LocationPreviewFragment import im.vector.app.features.location.LocationSharingFragment +import im.vector.app.features.location.preview.LocationPreviewFragment import im.vector.app.features.login.LoginCaptchaFragment import im.vector.app.features.login.LoginFragment import im.vector.app.features.login.LoginGenericTextInputFormFragment diff --git a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt index 3078d01da9..331b4afa18 100644 --- a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt @@ -54,9 +54,9 @@ import im.vector.app.features.home.room.list.RoomListViewModel import im.vector.app.features.home.room.list.home.HomeRoomListViewModel import im.vector.app.features.homeserver.HomeServerCapabilitiesViewModel import im.vector.app.features.invite.InviteUsersToRoomViewModel -import im.vector.app.features.location.preview.LocationPreviewViewModel import im.vector.app.features.location.LocationSharingViewModel import im.vector.app.features.location.live.map.LiveLocationMapViewModel +import im.vector.app.features.location.preview.LocationPreviewViewModel import im.vector.app.features.login.LoginViewModel import im.vector.app.features.login2.LoginViewModel2 import im.vector.app.features.login2.created.AccountCreatedViewModel diff --git a/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt index c82f1eb687..8ea4fcac54 100644 --- a/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt +++ b/vector/src/main/java/im/vector/app/features/location/MapLoadingErrorView.kt @@ -53,7 +53,7 @@ class MapLoadingErrorView @JvmOverloads constructor( private fun setErrorDescription(typedArray: TypedArray) { val description = typedArray.getString(R.styleable.MapLoadingErrorView_mapErrorDescription) - if(description.isNullOrEmpty()) { + if (description.isNullOrEmpty()) { binding.mapLoadingErrorDescription.setText(R.string.location_share_loading_map_error) } else { binding.mapLoadingErrorDescription.text = description diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt index 9eab20742f..dfc2fe3ef4 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt @@ -190,7 +190,7 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment - if(viewState.loadingMapHasFailed) { + if (viewState.loadingMapHasFailed) { views.mapPreviewLoadingError.isVisible = true } else { views.mapPreviewLoadingError.isGone = true From 72377c9e7e98781290964a5f369aeb9a03ec44e3 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 3 Aug 2022 09:31:52 +0200 Subject: [PATCH 53/58] Fixing after rebase --- .../live/map/LiveLocationMapViewFragment.kt | 14 +++++--------- .../layout/item_timeline_event_location_stub.xml | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt index dfc2fe3ef4..a866d54a79 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt @@ -109,6 +109,10 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment @@ -154,7 +150,7 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment Date: Wed, 3 Aug 2022 17:00:10 +0200 Subject: [PATCH 54/58] Adding missing trailing comma --- .../app/features/location/live/map/LiveLocationMapViewState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt index 459e2797d0..ddd1cd2369 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewState.kt @@ -28,7 +28,7 @@ data class LiveLocationMapViewState( * Map to keep track of symbol ids associated to each user Id. */ val mapSymbolIds: Map = emptyMap(), - val loadingMapHasFailed: Boolean = false + val loadingMapHasFailed: Boolean = false, ) : MavericksState { constructor(liveLocationMapViewArgs: LiveLocationMapViewArgs) : this( roomId = liveLocationMapViewArgs.roomId From 65c6e578ebea8f14ef445ecc2817a93ac9a1d39f Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 3 Aug 2022 17:14:21 +0200 Subject: [PATCH 55/58] Moving setup of map in onViewCreated + moving reference assignment of MapView --- .../location/live/map/LiveLocationMapViewFragment.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt index a866d54a79..85095e7c9f 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewFragment.kt @@ -86,6 +86,7 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment - (mapFragment.view as? MapView)?.let(::listenMapLoadingError) + (mapFragment.view as? MapView)?.let { + mapView = it + listenMapLoadingError(it) + } lifecycleScope.launch { mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style -> mapStyle = style @@ -148,7 +147,6 @@ class LiveLocationMapViewFragment @Inject constructor() : VectorBaseFragment Date: Thu, 4 Aug 2022 23:10:43 +0000 Subject: [PATCH 56/58] Bump libphonenumber from 8.12.52 to 8.12.53 Bumps [libphonenumber](https://github.com/google/libphonenumber) from 8.12.52 to 8.12.53. - [Release notes](https://github.com/google/libphonenumber/releases) - [Changelog](https://github.com/google/libphonenumber/blob/master/making-metadata-changes.md) - [Commits](https://github.com/google/libphonenumber/compare/v8.12.52...v8.12.53) --- updated-dependencies: - dependency-name: com.googlecode.libphonenumber:libphonenumber dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- matrix-sdk-android/build.gradle | 2 +- vector/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index fdc6a3ed5e..45a962f12c 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -199,7 +199,7 @@ dependencies { implementation libs.apache.commonsImaging // Phone number https://github.com/google/libphonenumber - implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.52' + implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.53' testImplementation libs.tests.junit // Note: version sticks to 1.9.2 due to https://github.com/mockk/mockk/issues/281 diff --git a/vector/build.gradle b/vector/build.gradle index 56a3f0eb80..dc0a2da35d 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -415,7 +415,7 @@ dependencies { implementation 'com.facebook.stetho:stetho:1.6.0' // Phone number https://github.com/google/libphonenumber - implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.52' + implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.53' // FlowBinding implementation libs.github.flowBinding From b375dd14f781c076482c87fa81ebaa54d70db78c Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 5 Aug 2022 11:18:53 +0100 Subject: [PATCH 57/58] removing unused line --- .../main/java/im/vector/app/core/extensions/TextInputLayout.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt b/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt index f1b5f5ce09..909c343a45 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt @@ -83,7 +83,6 @@ fun TextInputLayout.setOnImeDoneListener(action: () -> Unit) { * The listener is only called when the view is in a resumed state to avoid triggers when exiting a screen. */ fun TextInputLayout.setOnFocusLostListener(lifecycleOwner: LifecycleOwner, action: () -> Unit) { - lifecycleOwner.lifecycle editText().setOnFocusChangeListener { _, hasFocus -> when (hasFocus) { false -> lifecycleOwner.lifecycleScope.launchWhenResumed { action() } From 03afd2932c673feb5157002947edf779035580b9 Mon Sep 17 00:00:00 2001 From: Nikita Fedrunov <66663241+fedrunov@users.noreply.github.com> Date: Fri, 5 Aug 2022 14:51:47 +0200 Subject: [PATCH 58/58] NewHomeDetailFragment now shows correct list fragment (#6740) --- .../im/vector/app/features/home/HomeDetailFragment.kt | 11 ++--------- .../vector/app/features/home/NewHomeDetailFragment.kt | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt index d96b44b705..d4c89c1bca 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt @@ -41,7 +41,6 @@ import im.vector.app.core.ui.views.CurrentCallsView import im.vector.app.core.ui.views.CurrentCallsViewPresenter import im.vector.app.core.ui.views.KeysBackupBanner import im.vector.app.databinding.FragmentHomeDetailBinding -import im.vector.app.features.VectorFeatures import im.vector.app.features.call.SharedKnownCallsViewModel import im.vector.app.features.call.VectorCallActivity import im.vector.app.features.call.dialpad.DialPadFragment @@ -49,7 +48,6 @@ import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.home.room.list.RoomListFragment import im.vector.app.features.home.room.list.RoomListParams import im.vector.app.features.home.room.list.UnreadCounterBadgeView -import im.vector.app.features.home.room.list.home.HomeRoomListFragment import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.popup.VerificationVectorAlert import im.vector.app.features.settings.VectorLocale @@ -69,7 +67,6 @@ class HomeDetailFragment @Inject constructor( private val callManager: WebRtcCallManager, private val vectorPreferences: VectorPreferences, private val spaceStateHandler: SpaceStateHandler, - private val vectorFeatures: VectorFeatures, ) : VectorBaseFragment(), KeysBackupBanner.Delegate, CurrentCallsView.Callback, @@ -355,12 +352,8 @@ class HomeDetailFragment @Inject constructor( if (fragmentToShow == null) { when (tab) { is HomeTab.RoomList -> { - if (vectorFeatures.isNewAppLayoutEnabled()) { - add(R.id.roomListContainer, HomeRoomListFragment::class.java, null, fragmentTag) - } else { - val params = RoomListParams(tab.displayMode) - add(R.id.roomListContainer, RoomListFragment::class.java, params.toMvRxBundle(), fragmentTag) - } + val params = RoomListParams(tab.displayMode) + add(R.id.roomListContainer, RoomListFragment::class.java, params.toMvRxBundle(), fragmentTag) } is HomeTab.DialPad -> { add(R.id.roomListContainer, createDialPadFragment(), fragmentTag) diff --git a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt index 7ca42e1338..2e36748069 100644 --- a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt @@ -31,7 +31,6 @@ import com.google.android.material.badge.BadgeDrawable import im.vector.app.R import im.vector.app.SpaceStateHandler import im.vector.app.core.extensions.commitTransaction -import im.vector.app.core.extensions.toMvRxBundle import im.vector.app.core.platform.OnBackPressed import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseFragment @@ -45,8 +44,7 @@ import im.vector.app.features.call.SharedKnownCallsViewModel import im.vector.app.features.call.VectorCallActivity import im.vector.app.features.call.dialpad.DialPadFragment import im.vector.app.features.call.webrtc.WebRtcCallManager -import im.vector.app.features.home.room.list.RoomListFragment -import im.vector.app.features.home.room.list.RoomListParams +import im.vector.app.features.home.room.list.home.HomeRoomListFragment import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.popup.VerificationVectorAlert import im.vector.app.features.settings.VectorLocale @@ -339,8 +337,7 @@ class NewHomeDetailFragment @Inject constructor( if (fragmentToShow == null) { when (tab) { is HomeTab.RoomList -> { - val params = RoomListParams(tab.displayMode) - add(R.id.roomListContainer, RoomListFragment::class.java, params.toMvRxBundle(), fragmentTag) + add(R.id.roomListContainer, HomeRoomListFragment::class.java, null, fragmentTag) } is HomeTab.DialPad -> { add(R.id.roomListContainer, createDialPadFragment(), fragmentTag)