File tree Expand file tree Collapse file tree
owncloudApp/src/main/java/com/owncloud/android Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ class MainApp : Application() {
136136
137137 val pref = PreferenceManager .getDefaultSharedPreferences(appContext)
138138 val clearDataAlreadyTriggered = pref.contains(PREFERENCE_CLEAR_DATA_ALREADY_TRIGGERED )
139- if (clearDataAlreadyTriggered) {
139+ if (clearDataAlreadyTriggered || isNewVersionCode() ) {
140140 val dontShowAgainDialogPref = pref.getBoolean(PREFERENCE_KEY_DONT_SHOW_OCIS_ACCOUNT_WARNING_DIALOG , false )
141141 if (! dontShowAgainDialogPref && shouldShowDialog(activity)) {
142142 val checkboxDialog = activity.layoutInflater.inflate(R .layout.checkbox_dialog, null )
@@ -389,5 +389,13 @@ class MainApp : Application() {
389389 val pref = PreferenceManager .getDefaultSharedPreferences(appContext)
390390 return pref.getInt(PREFERENCE_KEY_LAST_SEEN_VERSION_CODE , 0 )
391391 }
392+
393+ private fun isNewVersionCode (): Boolean {
394+ val lastSeenVersionCode = getLastSeenVersionCode()
395+ if (lastSeenVersionCode == 0 ) { // The preferences have been deleted, so we can delete the accounts and navigate to login
396+ return false
397+ }
398+ return lastSeenVersionCode != versionCode // The version has changed and the accounts must not be deleted
399+ }
392400 }
393401}
Original file line number Diff line number Diff line change @@ -188,6 +188,10 @@ class FileDisplayActivity : FileActivity(),
188188 super .onCreate(savedInstanceState) // this calls onAccountChanged() when ownCloud Account is valid
189189
190190 checkPasscodeEnforced(this )
191+
192+ if (BuildConfig .DEBUG ) {
193+ sharedPreferences.putInt(MainApp .PREFERENCE_KEY_LAST_SEEN_VERSION_CODE , MainApp .versionCode)
194+ }
191195 sharedPreferences.putBoolean(PREFERENCE_CLEAR_DATA_ALREADY_TRIGGERED , true )
192196 localBroadcastManager = LocalBroadcastManager .getInstance(this )
193197
You can’t perform that action at this time.
0 commit comments