Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,20 @@ class CommonsApplication : MultiDexApplication() {
defaultPrefs.putStringSet(Prefs.MANAGED_EXIF_TAGS, defaultExifTagsSet)
}

// Set DownsampleEnabled to True to downsample the image in case it's heavy
// Set DownsampleEnabled to True to downsample the image in case it's heavy
val config = ImagePipelineConfig.newBuilder(this)
.setNetworkFetcher(customOkHttpNetworkFetcher)
.setDownsampleEnabled(true)
.build()
try {
Fresco.initialize(this, config)
} catch (e: Exception) {
Timber.e(e)
// TODO: Remove when we're able to initialize Fresco in test builds.

if ("robolectric" != android.os.Build.FINGERPRINT) {
try {
Fresco.initialize(this, config)
} catch (e: Exception) {
Timber.e(e)
}
} else {
Timber.d("Skipping Fresco initialization in Robolectric test builds.")
}

createNotificationChannel(this)
Expand Down Expand Up @@ -215,8 +219,22 @@ class CommonsApplication : MultiDexApplication() {
.andThen(Completable.fromAction {
Timber.d("All accounts have been removed")
clearImageCache()
//TODO: fix preference manager

//fix:capture the preferences that should survive a logout/data clear
val currentTheme = defaultPrefs.getString(Prefs.KEY_THEME_VALUE)
val currentLanguage = defaultPrefs.getString(Prefs.APP_UI_LANGUAGE)

// Clear the preference manager
defaultPrefs.clearAll()

//restore non-account-specific ui settings
if (currentTheme != null) {
defaultPrefs.putString(Prefs.KEY_THEME_VALUE, currentTheme)
}
if (currentLanguage != null) {
defaultPrefs.putString(Prefs.APP_UI_LANGUAGE, currentLanguage)
}

defaultPrefs.putBoolean("firstrun", false)
updateAllDatabases()
})
Expand Down