Merge pull request #7723 from vector-im/feature/bma/disableNightlyPopup
Disable nightly popup
This commit is contained in:
commit
d0b1a7bfd1
1
changelog.d/7723.misc
Normal file
1
changelog.d/7723.misc
Normal file
@ -0,0 +1 @@
|
||||
Disable nightly popup and add an entry point in the advanced settings instead.
|
@ -2487,6 +2487,9 @@
|
||||
<string name="settings_key_requests">Key Requests</string>
|
||||
<string name="settings_export_trail">Export Audit</string>
|
||||
|
||||
<string name="settings_nightly_build">Nightly build</string>
|
||||
<string name="settings_nightly_build_update">Get the latest build (note: you may have trouble to sign in)</string>
|
||||
|
||||
<string name="e2e_use_keybackup">Unlock encrypted messages history</string>
|
||||
|
||||
<string name="refresh">Refresh</string>
|
||||
|
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +580,9 @@ class HomeActivity :
|
||||
serverBackupStatusViewModel.refreshRemoteStateIfNeeded()
|
||||
|
||||
// Check nightly
|
||||
nightlyProxy.onHomeResumed()
|
||||
if (nightlyProxy.canDisplayPopup()) {
|
||||
nightlyProxy.updateApplication()
|
||||
}
|
||||
|
||||
checkNewAppLayoutFlagChange()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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<VectorPreferenceCategory>("SETTINGS_RAGE_SHAKE_CATEGORY_KEY")!!.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupNightlySection() {
|
||||
findPreference<VectorPreferenceCategory>("SETTINGS_NIGHTLY_BUILD_PREFERENCE_KEY")?.isVisible = nightlyProxy.isNightlyBuild()
|
||||
findPreference<VectorPreference>("SETTINGS_NIGHTLY_BUILD_UPDATE_PREFERENCE_KEY")?.setOnPreferenceClickListener {
|
||||
nightlyProxy.updateApplication()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,4 +95,16 @@
|
||||
|
||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||
|
||||
<im.vector.app.core.preference.VectorPreferenceCategory
|
||||
android:key="SETTINGS_NIGHTLY_BUILD_PREFERENCE_KEY"
|
||||
android:title="@string/settings_nightly_build"
|
||||
app:isPreferenceVisible="true">
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:key="SETTINGS_NIGHTLY_BUILD_UPDATE_PREFERENCE_KEY"
|
||||
android:persistent="false"
|
||||
android:title="@string/settings_nightly_build_update" />
|
||||
|
||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user