Skip to content

Commit 966a6a5

Browse files
committed
fix: Added isNewVersionCode function to the condition
1 parent 4351811 commit 966a6a5

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

owncloudApp/src/main/java/com/owncloud/android/MainApp.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)