Do not display the name change popup for a new installation
This commit is contained in:
parent
bbbd45efcd
commit
0e28214b63
|
@ -20,6 +20,7 @@ interface LegacySessionImporter {
|
|||
|
||||
/**
|
||||
* Will eventually import a session created by the legacy app.
|
||||
* @return true if a session has been imported
|
||||
*/
|
||||
fun process()
|
||||
fun process(): Boolean
|
||||
}
|
||||
|
|
|
@ -53,14 +53,14 @@ internal class DefaultLegacySessionImporter @Inject constructor(
|
|||
private var DELETE_PREVIOUS_DATA = true
|
||||
}
|
||||
|
||||
override fun process() {
|
||||
override fun process(): Boolean {
|
||||
Timber.d("Migration: Importing legacy session")
|
||||
|
||||
val list = loginStorage.credentialsList
|
||||
|
||||
Timber.d("Migration: found ${list.size} session(s).")
|
||||
|
||||
val legacyConfig = list.firstOrNull() ?: return
|
||||
val legacyConfig = list.firstOrNull() ?: return false
|
||||
|
||||
runBlocking {
|
||||
Timber.d("Migration: importing a session")
|
||||
|
@ -97,6 +97,9 @@ internal class DefaultLegacySessionImporter @Inject constructor(
|
|||
Timber.d("Migration: clear shared prefs - DEACTIVATED")
|
||||
}
|
||||
}
|
||||
|
||||
// A session has been imported
|
||||
return true
|
||||
}
|
||||
|
||||
private suspend fun importCredentials(legacyConfig: LegacyHomeServerConnectionConfig) {
|
||||
|
|
|
@ -46,6 +46,7 @@ import im.vector.riotx.core.extensions.configureAndStart
|
|||
import im.vector.riotx.core.rx.RxConfig
|
||||
import im.vector.riotx.features.call.WebRtcPeerConnectionManager
|
||||
import im.vector.riotx.features.configuration.VectorConfiguration
|
||||
import im.vector.riotx.features.disclaimer.doNotShowDisclaimerDialog
|
||||
import im.vector.riotx.features.lifecycle.VectorActivityLifecycleCallbacks
|
||||
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
||||
import im.vector.riotx.features.notifications.NotificationUtils
|
||||
|
@ -132,7 +133,11 @@ class VectorApplication :
|
|||
notificationUtils.createNotificationChannels()
|
||||
|
||||
// It can takes time, but do we care?
|
||||
legacySessionImporter.process()
|
||||
val sessionImported = legacySessionImporter.process()
|
||||
if (!sessionImported) {
|
||||
// Do not display the name change popup
|
||||
doNotShowDisclaimerDialog(this)
|
||||
}
|
||||
|
||||
if (authenticationService.hasAuthenticatedSessions() && !activeSessionHolder.hasActiveSession()) {
|
||||
val lastAuthenticatedSession = authenticationService.getLastAuthenticatedSession()!!
|
||||
|
|
|
@ -17,20 +17,14 @@
|
|||
package im.vector.riotx.features.disclaimer
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import androidx.preference.PreferenceManager
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import im.vector.riotx.BuildConfig
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.dialogs.withColoredButton
|
||||
import im.vector.riotx.core.extensions.setTextWithColoredPart
|
||||
import im.vector.riotx.core.utils.displayInWebView
|
||||
import im.vector.riotx.core.utils.openPlayStore
|
||||
import im.vector.riotx.features.settings.VectorSettingsUrls
|
||||
import im.vector.riotx.features.themes.ThemeUtils
|
||||
|
||||
// Increase this value to show again the disclaimer dialog after an upgrade of the application
|
||||
private const val CURRENT_DISCLAIMER_VALUE = 2
|
||||
|
@ -57,3 +51,11 @@ fun showDisclaimerDialog(activity: Activity) {
|
|||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
fun doNotShowDisclaimerDialog(context: Context) {
|
||||
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
sharedPrefs.edit {
|
||||
putInt(SHARED_PREF_KEY, CURRENT_DISCLAIMER_VALUE)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue