chinwag-android/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt

141 lines
5.3 KiB
Kotlin
Raw Normal View History

/* Copyright 2020 Tusky Contributors
*
* This file is a part of Tusky.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
package com.keylesspalace.tusky
import android.app.Application
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
import android.content.SharedPreferences
import android.util.Log
import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import autodispose2.AutoDisposePlugins
import com.keylesspalace.tusky.components.notifications.NotificationHelper
import com.keylesspalace.tusky.di.AppInjector
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
import com.keylesspalace.tusky.settings.PrefKeys
import com.keylesspalace.tusky.settings.SCHEMA_VERSION
import com.keylesspalace.tusky.util.APP_THEME_DEFAULT
import com.keylesspalace.tusky.util.LocaleManager
import com.keylesspalace.tusky.util.setAppNightMode
import com.keylesspalace.tusky.worker.PruneCacheWorker
import com.keylesspalace.tusky.worker.WorkerFactory
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import de.c1710.filemojicompat_defaults.DefaultEmojiPackList
import de.c1710.filemojicompat_ui.helpers.EmojiPackHelper
import de.c1710.filemojicompat_ui.helpers.EmojiPreference
import io.reactivex.rxjava3.plugins.RxJavaPlugins
import org.conscrypt.Conscrypt
import java.security.Security
import java.util.concurrent.TimeUnit
import javax.inject.Inject
class TuskyApplication : Application(), HasAndroidInjector {
@Inject
lateinit var androidInjector: DispatchingAndroidInjector<Any>
@Inject
lateinit var workerFactory: WorkerFactory
@Inject
lateinit var localeManager: LocaleManager
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
@Inject
lateinit var sharedPreferences: SharedPreferences
override fun onCreate() {
// Uncomment me to get StrictMode violation logs
// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
// StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
// .detectDiskReads()
// .detectDiskWrites()
// .detectNetwork()
// .detectUnbufferedIo()
// .penaltyLog()
// .build())
// }
super.onCreate()
Security.insertProviderAt(Conscrypt.newProvider(), 1)
AutoDisposePlugins.setHideProxies(false) // a small performance optimization
AppInjector.init(this)
// Migrate shared preference keys and defaults from version to version.
val oldVersion = sharedPreferences.getInt(PrefKeys.SCHEMA_VERSION, 0)
if (oldVersion != SCHEMA_VERSION) {
upgradeSharedPreferences(oldVersion, SCHEMA_VERSION)
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
}
// In this case, we want to have the emoji preferences merged with the other ones
// Copied from PreferenceManager.getDefaultSharedPreferenceName
EmojiPreference.sharedPreferenceName = packageName + "_preferences"
EmojiPackHelper.init(this, DefaultEmojiPackList.get(this), allowPackImports = false)
// init night mode
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
val theme = sharedPreferences.getString("appTheme", APP_THEME_DEFAULT)
setAppNightMode(theme)
localeManager.setLocale()
RxJavaPlugins.setErrorHandler {
Log.w("RxJava", "undeliverable exception", it)
}
NotificationHelper.createWorkerNotificationChannel(this)
WorkManager.initialize(
this,
androidx.work.Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
)
// Prune the database every ~ 12 hours when the device is idle.
val pruneCacheWorker = PeriodicWorkRequestBuilder<PruneCacheWorker>(12, TimeUnit.HOURS)
.setConstraints(Constraints.Builder().setRequiresDeviceIdle(true).build())
.build()
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
PruneCacheWorker.PERIODIC_WORK_TAG,
ExistingPeriodicWorkPolicy.KEEP,
pruneCacheWorker
)
}
override fun androidInjector() = androidInjector
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
private fun upgradeSharedPreferences(oldVersion: Int, newVersion: Int) {
Log.d(TAG, "Upgrading shared preferences: $oldVersion -> $newVersion")
val editor = sharedPreferences.edit()
if (oldVersion < 2023022701) {
// These preferences are (now) handled in AccountPreferenceHandler. Remove them from shared for clarity.
editor.remove(PrefKeys.ALWAYS_OPEN_SPOILER)
editor.remove(PrefKeys.ALWAYS_SHOW_SENSITIVE_MEDIA)
editor.remove(PrefKeys.MEDIA_PREVIEW_ENABLED)
}
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-05 06:19:01 +11:00
editor.putInt(PrefKeys.SCHEMA_VERSION, newVersion)
editor.apply()
}
companion object {
private const val TAG = "TuskyApplication"
}
}