diff --git a/changelog.d/7723.misc b/changelog.d/7723.misc
new file mode 100644
index 0000000000..36869d1efb
--- /dev/null
+++ b/changelog.d/7723.misc
@@ -0,0 +1 @@
+Disable nightly popup and add an entry point in the advanced settings instead.
diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml
index 609cdac233..7f11e63469 100644
--- a/library/ui-strings/src/main/res/values/strings.xml
+++ b/library/ui-strings/src/main/res/values/strings.xml
@@ -2487,6 +2487,9 @@
Key Requests
Export Audit
+ Nightly build
+ Get the latest build (note: you may have trouble to sign in)
+
Unlock encrypted messages history
Refresh
diff --git a/vector-app/build.gradle b/vector-app/build.gradle
index fa6aa5f0fd..6ebb08600b 100644
--- a/vector-app/build.gradle
+++ b/vector-app/build.gradle
@@ -374,7 +374,7 @@ dependencies {
// API-only library
gplayImplementation libs.google.appdistributionApi
// Full SDK implementation
- gplayImplementation libs.google.appdistribution
+ nightlyImplementation libs.google.appdistribution
// OSS License, gplay flavor only
gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
diff --git a/vector-app/src/fdroid/java/im/vector/app/di/FlavorModule.kt b/vector-app/src/fdroid/java/im/vector/app/di/FlavorModule.kt
index 63b4c2a3cd..e7d9598b65 100644
--- a/vector-app/src/fdroid/java/im/vector/app/di/FlavorModule.kt
+++ b/vector-app/src/fdroid/java/im/vector/app/di/FlavorModule.kt
@@ -46,9 +46,9 @@ abstract class FlavorModule {
@Provides
fun provideNightlyProxy() = object : NightlyProxy {
- override fun onHomeResumed() {
- // no op
- }
+ override fun canDisplayPopup() = false
+ override fun isNightlyBuild() = false
+ override fun updateApplication() = Unit
}
@Provides
diff --git a/vector-app/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt b/vector-app/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt
index 94a36036b6..71ffda7c36 100644
--- a/vector-app/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt
+++ b/vector-app/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt
@@ -34,8 +34,11 @@ class FirebaseNightlyProxy @Inject constructor(
private val buildMeta: BuildMeta,
) : NightlyProxy {
- override fun onHomeResumed() {
- if (!canDisplayPopup()) return
+ override fun isNightlyBuild(): Boolean {
+ return buildMeta.applicationId in nightlyPackages
+ }
+
+ override fun updateApplication() {
val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
firebaseAppDistribution.updateIfNewReleaseAvailable()
.addOnProgressListener { up ->
@@ -46,6 +49,7 @@ class FirebaseNightlyProxy @Inject constructor(
when (e.errorCode) {
FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> {
// SDK did nothing. This is expected when building for Play.
+ Timber.d("FirebaseAppDistribution NOT_IMPLEMENTED error")
}
else -> {
// Handle other errors.
@@ -56,10 +60,14 @@ class FirebaseNightlyProxy @Inject constructor(
Timber.e(e, "FirebaseAppDistribution - other error")
}
}
+ .addOnSuccessListener {
+ Timber.d("FirebaseAppDistribution Success!")
+ }
}
- private fun canDisplayPopup(): Boolean {
- if (buildMeta.applicationId != "im.vector.app.nightly") return false
+ override fun canDisplayPopup(): Boolean {
+ if (!POPUP_IS_ENABLED) return false
+ if (!isNightlyBuild()) return false
val today = clock.epochMillis() / A_DAY_IN_MILLIS
val lastDisplayPopupDay = sharedPreferences.getLong(SHARED_PREF_KEY, 0)
return (today > lastDisplayPopupDay)
@@ -73,7 +81,12 @@ class FirebaseNightlyProxy @Inject constructor(
}
companion object {
+ private const val POPUP_IS_ENABLED = false
private const val A_DAY_IN_MILLIS = 8_600_000L
private const val SHARED_PREF_KEY = "LAST_NIGHTLY_POPUP_DAY"
+
+ private val nightlyPackages = listOf(
+ "im.vector.app.nightly"
+ )
}
}
diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt
index 8c6daae95a..2a3d8d094c 100644
--- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt
+++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt
@@ -580,7 +580,9 @@ class HomeActivity :
serverBackupStatusViewModel.refreshRemoteStateIfNeeded()
// Check nightly
- nightlyProxy.onHomeResumed()
+ if (nightlyProxy.canDisplayPopup()) {
+ nightlyProxy.updateApplication()
+ }
checkNewAppLayoutFlagChange()
}
diff --git a/vector/src/main/java/im/vector/app/features/home/NightlyProxy.kt b/vector/src/main/java/im/vector/app/features/home/NightlyProxy.kt
index b25add2ac9..42b93bf1a5 100644
--- a/vector/src/main/java/im/vector/app/features/home/NightlyProxy.kt
+++ b/vector/src/main/java/im/vector/app/features/home/NightlyProxy.kt
@@ -17,5 +17,18 @@
package im.vector.app.features.home
interface NightlyProxy {
- fun onHomeResumed()
+ /**
+ * Return true if this is a nightly build (checking the package of the app), and only once a day.
+ */
+ fun canDisplayPopup(): Boolean
+
+ /**
+ * Return true if this is a nightly build (checking the package of the app).
+ */
+ fun isNightlyBuild(): Boolean
+
+ /**
+ * Try to update the application, if update is available. Will also take care of the user sign in.
+ */
+ fun updateApplication()
}
diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt
index 9c08d446f4..b6fa997f41 100644
--- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt
@@ -22,10 +22,13 @@ import androidx.preference.SeekBarPreference
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity
+import im.vector.app.core.preference.VectorPreference
import im.vector.app.core.preference.VectorPreferenceCategory
import im.vector.app.core.preference.VectorSwitchPreference
import im.vector.app.features.analytics.plan.MobileScreen
+import im.vector.app.features.home.NightlyProxy
import im.vector.app.features.rageshake.RageShake
+import javax.inject.Inject
@AndroidEntryPoint
class VectorSettingsAdvancedSettingsFragment :
@@ -34,6 +37,8 @@ class VectorSettingsAdvancedSettingsFragment :
override var titleRes = R.string.settings_advanced_settings
override val preferenceXmlRes = R.xml.vector_settings_advanced_settings
+ @Inject lateinit var nightlyProxy: NightlyProxy
+
private var rageshake: RageShake? = null
override fun onCreate(savedInstanceState: Bundle?) {
@@ -57,6 +62,11 @@ class VectorSettingsAdvancedSettingsFragment :
}
override fun bindPref() {
+ setupRageShakeSection()
+ setupNightlySection()
+ }
+
+ private fun setupRageShakeSection() {
val isRageShakeAvailable = RageShake.isAvailable(requireContext())
if (isRageShakeAvailable) {
@@ -86,4 +96,12 @@ class VectorSettingsAdvancedSettingsFragment :
findPreference("SETTINGS_RAGE_SHAKE_CATEGORY_KEY")!!.isVisible = false
}
}
+
+ private fun setupNightlySection() {
+ findPreference("SETTINGS_NIGHTLY_BUILD_PREFERENCE_KEY")?.isVisible = nightlyProxy.isNightlyBuild()
+ findPreference("SETTINGS_NIGHTLY_BUILD_UPDATE_PREFERENCE_KEY")?.setOnPreferenceClickListener {
+ nightlyProxy.updateApplication()
+ true
+ }
+ }
}
diff --git a/vector/src/main/res/xml/vector_settings_advanced_settings.xml b/vector/src/main/res/xml/vector_settings_advanced_settings.xml
index 29d8051583..9260b33162 100644
--- a/vector/src/main/res/xml/vector_settings_advanced_settings.xml
+++ b/vector/src/main/res/xml/vector_settings_advanced_settings.xml
@@ -95,4 +95,16 @@
+
+
+
+
+
+