Add in-app alert to let user know if a new version is available.

This commit is contained in:
Benoit Marty 2022-07-22 16:52:05 +02:00
parent 442180e373
commit 83f3229805
5 changed files with 87 additions and 1 deletions

View File

@ -15,6 +15,7 @@ def gradle = "7.1.3"
def kotlin = "1.6.21"
def kotlinCoroutines = "1.6.4"
def dagger = "2.42"
def appDistribution = "16.0.0-beta03"
def retrofit = "2.9.0"
def arrow = "0.8.2"
def markwon = "4.6.2"
@ -83,7 +84,9 @@ ext.libs = [
'transition' : "androidx.transition:transition:1.2.0",
],
google : [
'material' : "com.google.android.material:material:1.6.1"
'material' : "com.google.android.material:material:1.6.1",
'appdistributionApi' : "com.google.firebase:firebase-appdistribution-api-ktx:$appDistribution",
'appdistribution' : "com.google.firebase:firebase-appdistribution:$appDistribution",
],
dagger : [
'dagger' : "com.google.dagger:dagger:$dagger",

View File

@ -449,6 +449,12 @@ dependencies {
implementation libs.airbnb.epoxyPaging
implementation libs.airbnb.mavericks
// Nightly
// API-only library
gplayImplementation libs.google.appdistributionApi
// Full SDK implementation
gplayImplementation libs.google.appdistribution
// Work
implementation libs.androidx.work

View File

@ -0,0 +1,25 @@
/*
* 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.nightly
import javax.inject.Inject
class NightlyProxy @Inject constructor() {
fun updateIfNewReleaseAvailable() {
// No op
}
}

View File

@ -0,0 +1,47 @@
/*
* 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.nightly
import com.google.firebase.appdistribution.FirebaseAppDistribution
import com.google.firebase.appdistribution.FirebaseAppDistributionException
import timber.log.Timber
import javax.inject.Inject
class NightlyProxy @Inject constructor() {
fun updateIfNewReleaseAvailable() {
val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
firebaseAppDistribution.updateIfNewReleaseAvailable()
.addOnProgressListener { up ->
Timber.d("FirebaseAppDistribution progress: ${up.updateStatus}. ${up.apkBytesDownloaded}/${up.apkFileTotalBytes}")
}
.addOnFailureListener { e ->
if (e is FirebaseAppDistributionException) {
when (e.errorCode) {
FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> {
// SDK did nothing. This is expected when building for Play.
}
else -> {
// Handle other errors.
Timber.e(e, "FirebaseAppDistribution error, status: ${e.errorCode}")
}
}
} else {
Timber.e(e, "FirebaseAppDistribution - other error")
}
}
}
}

View File

@ -78,6 +78,7 @@ import im.vector.app.features.spaces.invite.SpaceInviteBottomSheet
import im.vector.app.features.spaces.share.ShareSpaceBottomSheet
import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import im.vector.app.nightly.NightlyProxy
import im.vector.app.push.fcm.FcmHelper
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@ -132,6 +133,7 @@ class HomeActivity :
@Inject lateinit var appStateHandler: AppStateHandler
@Inject lateinit var unifiedPushHelper: UnifiedPushHelper
@Inject lateinit var fcmHelper: FcmHelper
@Inject lateinit var nightlyProxy: NightlyProxy
private val createSpaceResultLauncher = registerStartForActivityResult { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) {
@ -533,6 +535,9 @@ class HomeActivity :
// Force remote backup state update to update the banner if needed
serverBackupStatusViewModel.refreshRemoteStateIfNeeded()
// Check nightly
nightlyProxy.updateIfNewReleaseAvailable()
}
override fun getMenuRes() = R.menu.home