proguard bs

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/89/head
androidacy-user 2 years ago
parent 60d284d885
commit ae7c807e44

@ -821,7 +821,7 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
}
})
// update last feedback time
MainApplication.getSharedPreferences("mmm")?.edit()
MainApplication.getPreferences("mmm")?.edit()
?.putLong("last_feedback", System.currentTimeMillis())?.apply()
}
} else {

@ -143,7 +143,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
@StyleRes val themeResId: Int
var theme: String?
val monet = isMonetEnabled
when (getSharedPreferences("mmm")!!.getString("pref_theme", "system").also { theme = it }) {
when (getPreferences("mmm")!!.getString("pref_theme", "system").also { theme = it }) {
"system" -> themeResId =
if (monet) R.style.Theme_MagiskModuleManager_Monet else R.style.Theme_MagiskModuleManager
@ -327,9 +327,9 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
o = listOf(*osh).contains(oosh)
} catch (ignored: PackageManager.NameNotFoundException) {
}
val sharedPreferences = getSharedPreferences("mmm")
val sharedPreferences = getPreferences("mmm")
// We are only one process so it's ok to do this
val bootPrefs = getSharedPreferences("mmm_boot")
val bootPrefs = getPreferences("mmm_boot")
val lastBoot = System.currentTimeMillis() - SystemClock.elapsedRealtime()
val lastBootPrefs = bootPrefs!!.getLong("last_boot", 0)
isFirstBoot = if (lastBootPrefs == 0L || abs(lastBoot - lastBootPrefs) > 100) {
@ -499,7 +499,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
companion object {
var forceDebugLogging: Boolean =
BuildConfig.DEBUG || getSharedPreferences("mmm")?.getBoolean(
BuildConfig.DEBUG || getPreferences("mmm")?.getBoolean(
"pref_force_debug_logging",
false
) ?: false
@ -577,10 +577,11 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
}
@Suppress("NAME_SHADOWING")
fun getSharedPreferences(name: String): SharedPreferences? {
fun getPreferences(name: String): SharedPreferences? {
// encryptedSharedPreferences is used
return try {
var name = name
val mContext: Context? = INSTANCE
val mContext: Context? = INSTANCE!!.applicationContext
name += "x"
if (mSharedPrefs == null) {
mSharedPrefs = HashMap()
@ -588,7 +589,6 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
if (mSharedPrefs!!.containsKey(name)) {
return mSharedPrefs!![name] as SharedPreferences?
}
return try {
val masterKey =
MasterKey.Builder(mContext!!).setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
@ -604,6 +604,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
} catch (e: Exception) {
// try again five times, with a 250ms delay between each try. if we still can't get the shared preferences, throw an exception
var i = 0
var s = false
while (i < 5) {
try {
Thread.sleep(250)
@ -611,24 +612,25 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
}
try {
val masterKey =
MasterKey.Builder(mContext!!)
MasterKey.Builder(INSTANCE!!.applicationContext)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
val sharedPreferences = EncryptedSharedPreferences.create(
mContext,
INSTANCE!!.applicationContext,
name,
masterKey,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
mSharedPrefs!![name] = sharedPreferences
s = true
return sharedPreferences
} catch (e: Exception) {
Timber.e(e, "Failed to get shared preferences")
}
i++
}
throw IllegalStateException("Failed to get shared preferences")
return null
}
}
@ -648,42 +650,42 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
return java.lang.Boolean.parseBoolean(SHOWCASE_MODE_TRUE)
}
val showcaseMode =
getSharedPreferences("mmm")!!.getBoolean("pref_showcase_mode", false)
getPreferences("mmm")!!.getBoolean("pref_showcase_mode", false)
SHOWCASE_MODE_TRUE = showcaseMode.toString()
return showcaseMode
}
fun shouldPreventReboot(): Boolean {
return getSharedPreferences("mmm")!!.getBoolean("pref_prevent_reboot", true)
return getPreferences("mmm")!!.getBoolean("pref_prevent_reboot", true)
}
val isShowIncompatibleModules: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean("pref_show_incompatible", false)
get() = getPreferences("mmm")!!.getBoolean("pref_show_incompatible", false)
val isForceDarkTerminal: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean("pref_force_dark_terminal", false)
get() = getPreferences("mmm")!!.getBoolean("pref_force_dark_terminal", false)
val isTextWrapEnabled: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean("pref_wrap_text", false)
get() = getPreferences("mmm")!!.getBoolean("pref_wrap_text", false)
val isDohEnabled: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean("pref_dns_over_https", true)
get() = getPreferences("mmm")!!.getBoolean("pref_dns_over_https", true)
val isMonetEnabled: Boolean
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && getSharedPreferences("mmm")!!.getBoolean(
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && getPreferences("mmm")!!.getBoolean(
"pref_enable_monet", true
)
val isBlurEnabled: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean("pref_enable_blur", false)
get() = getPreferences("mmm")!!.getBoolean("pref_enable_blur", false)
val isDeveloper: Boolean
get() {
return if (BuildConfig.DEBUG) true else getSharedPreferences("mmm")!!.getBoolean(
return if (BuildConfig.DEBUG) true else getPreferences("mmm")!!.getBoolean(
"developer", false
)
}
val isDisableLowQualityModuleFilter: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean(
get() = getPreferences("mmm")!!.getBoolean(
"pref_disable_low_quality_module_filter", false
) && isDeveloper
val isUsingMagiskCommand: Boolean
get() = (peekMagiskVersion() >= Constants.MAGISK_VER_CODE_INSTALL_COMMAND) && getSharedPreferences(
get() = (peekMagiskVersion() >= Constants.MAGISK_VER_CODE_INSTALL_COMMAND) && getPreferences(
"mmm"
)!!.getBoolean(
"pref_use_magisk_install_command",
@ -696,27 +698,27 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
return java.lang.Boolean.parseBoolean(updateCheckBg)
}
val wrapped = isWrapped
val updateCheckBgTemp = !wrapped && getSharedPreferences("mmm")!!.getBoolean(
val updateCheckBgTemp = !wrapped && getPreferences("mmm")!!.getBoolean(
"pref_background_update_check", true
)
updateCheckBg = updateCheckBgTemp.toString()
return java.lang.Boolean.parseBoolean(updateCheckBg)
}
val isAndroidacyTestMode: Boolean
get() = isDeveloper && getSharedPreferences("mmm")!!.getBoolean(
get() = isDeveloper && getPreferences("mmm")!!.getBoolean(
"pref_androidacy_test_mode", false
)
fun setHasGottenRootAccess(bool: Boolean) {
getSharedPreferences("mmm")!!.edit().putBoolean("has_root_access", bool).apply()
getPreferences("mmm")!!.edit().putBoolean("has_root_access", bool).apply()
}
val isCrashReportingEnabled: Boolean
get() = getSharedPreferences("mmm")!!.getBoolean(
get() = getPreferences("mmm")!!.getBoolean(
"pref_crash_reporting", BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING
)
val bootSharedPreferences: SharedPreferences?
get() = getSharedPreferences("mmm_boot")
get() = getPreferences("mmm_boot")
fun formatTime(timeStamp: Long): String {
// new Date(x) also get the local timestamp for format
@ -727,7 +729,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
get() = NotificationManagerCompat.from((INSTANCE)!!).areNotificationsEnabled()
fun analyticsAllowed(): Boolean {
return getSharedPreferences("mmm")!!.getBoolean(
return getPreferences("mmm")!!.getBoolean(
"pref_analytics_enabled", BuildConfig.DEFAULT_ENABLE_ANALYTICS
)
}
@ -735,7 +737,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
fun shouldShowFeedback(): Boolean {
// should not have been shown in 14 days and only 1 in 5 chance
val randChance = Random().nextInt(5)
val lastShown = getSharedPreferences("mmm")!!.getLong("last_feedback", 0)
val lastShown = getPreferences("mmm")!!.getLong("last_feedback", 0)
if (forceDebugLogging) Timber.d(
"Last feedback shown: %d, randChance: %d",
lastShown,

@ -192,7 +192,7 @@ enum class NotificationType(
androidx.appcompat.R.attr.colorBackgroundFloating,
com.google.android.material.R.attr.colorOnBackground,
View.OnClickListener { v: View? ->
if (MainApplication.getSharedPreferences("mmm")
if (MainApplication.getPreferences("mmm")
?.getBoolean("pref_require_security", false) == true
) {
// block local install for safety

@ -55,7 +55,7 @@ class SetupActivity : AppCompatActivity(), LanguageActivity {
createFiles()
disableUpdateActivityForFdroidFlavor()
// Set theme
val prefs = MainApplication.getSharedPreferences("mmm")!!
val prefs = MainApplication.getPreferences("mmm")!!
when (prefs.getString("theme", "system")) {
"light" -> setTheme(R.style.Theme_MagiskModuleManager_Monet_Light)
"dark" -> setTheme(R.style.Theme_MagiskModuleManager_Monet_Dark)
@ -405,7 +405,7 @@ class SetupActivity : AppCompatActivity(), LanguageActivity {
return theme
}
// Set the theme
val prefs = MainApplication.getSharedPreferences("mmm")!!
val prefs = MainApplication.getPreferences("mmm")!!
when (prefs.getString("pref_theme", "system")) {
"light" -> {
theme.applyStyle(R.style.Theme_MagiskModuleManager_Monet_Light, true)

@ -15,7 +15,7 @@ import com.fingerprintjs.android.fingerprint.FingerprinterFactory.create
import com.fox2code.mmm.BuildConfig
import com.fox2code.mmm.MainApplication
import com.fox2code.mmm.MainApplication.Companion.INSTANCE
import com.fox2code.mmm.MainApplication.Companion.getSharedPreferences
import com.fox2code.mmm.MainApplication.Companion.getPreferences
import com.fox2code.mmm.R
import com.fox2code.mmm.androidacy.AndroidacyUtil.Companion.hideToken
import com.fox2code.mmm.androidacy.AndroidacyUtil.Companion.isAndroidacyLink
@ -97,7 +97,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
if (e.errorCode == 401) {
Timber.w("Invalid token, resetting...")
// Remove saved preference
val editor = getSharedPreferences("androidacy")!!.edit()
val editor = getPreferences("androidacy")!!.edit()
editor.remove("pref_androidacy_api_token")
editor.apply()
return false
@ -118,12 +118,12 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
Timber.w("Invalid token, resetting...")
Timber.w(e)
// Remove saved preference
val editor = getSharedPreferences("androidacy")!!.edit()
val editor = getPreferences("androidacy")!!.edit()
editor.remove("pref_androidacy_api_token")
editor.apply()
requestNewToken()
isValidToken(
getSharedPreferences("androidacy")!!.getString(
getPreferences("androidacy")!!.getString(
"pref_androidacy_api_token",
null
))
@ -152,7 +152,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
}
}
// Save the token to the shared preferences
val editor = getSharedPreferences("androidacy")!!.edit()
val editor = getPreferences("androidacy")!!.edit()
editor.putString("pref_androidacy_api_token", token)
editor.apply()
return token
@ -163,7 +163,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
// If ANDROIDACY_CLIENT_ID is not set or is empty, disable this repo and return
@Suppress("KotlinConstantConditions")
if (BuildConfig.ANDROIDACY_CLIENT_ID == "") {
val editor = getSharedPreferences("mmm")!!.edit()
val editor = getPreferences("mmm")!!.edit()
editor.putBoolean("pref_androidacy_repo_enabled", false)
editor.apply()
Timber.w("ANDROIDACY_CLIENT_ID is empty, disabling AndroidacyRepoData 2")
@ -208,7 +208,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
try {
if (token == null) {
token =
getSharedPreferences("androidacy")?.getString("pref_androidacy_api_token", null)
getPreferences("androidacy")?.getString("pref_androidacy_api_token", null)
if (token != null && !isValidToken(token)) {
if (MainApplication.forceDebugLogging) Timber.i("Token expired or invalid, requesting new one...")
token = null
@ -250,7 +250,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
return false
} else {
// Save token to shared preference
val editor = getSharedPreferences("androidacy")!!.edit()
val editor = getPreferences("androidacy")!!.edit()
editor.putString("pref_androidacy_api_token", token)
editor.apply()
if (MainApplication.forceDebugLogging) Timber.i("Token saved to shared preference")
@ -468,7 +468,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
companion object {
private var ANDROIDACY_DEVICE_ID: String? = null
var token =
getSharedPreferences("androidacy")!!.getString("pref_androidacy_api_token", null)
getPreferences("androidacy")!!.getString("pref_androidacy_api_token", null)
init {
@Suppress("LocalVariableName") val OK_HTTP_URL_BUILDER: Builder =
@ -495,7 +495,7 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
return ANDROIDACY_DEVICE_ID
}
// Try to get the device ID from the shared preferences
val sharedPreferences = getSharedPreferences("androidacy")
val sharedPreferences = getPreferences("androidacy")
val deviceIdPref =
sharedPreferences!!.getString("device_id_v2", null)
return if (deviceIdPref != null) {

@ -114,7 +114,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
@Suppress("NAME_SHADOWING", "KotlinConstantConditions")
fun doCheck(context: Context) {
// first, check if the user has enabled background update checking
if (!MainApplication.getSharedPreferences("mmm")!!
if (!MainApplication.getPreferences("mmm")!!
.getBoolean("pref_background_update_check", false)
) {
return
@ -124,7 +124,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
return
}
// next, check if user requires wifi
if (MainApplication.getSharedPreferences("mmm")!!
if (MainApplication.getPreferences("mmm")!!
.getBoolean("pref_background_update_check_wifi", true)
) {
// check if wifi is connected
@ -192,7 +192,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
// exclude all modules with id's stored in the pref pref_background_update_check_excludes
try {
if (Objects.requireNonNull(
MainApplication.getSharedPreferences("mmm")!!.getStringSet(
MainApplication.getPreferences("mmm")!!.getStringSet(
"pref_background_update_check_excludes",
HashSet()
)
@ -203,7 +203,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
// now, we just had to make it more fucking complicated, didn't we?
// we now have pref_background_update_check_excludes_version, which is a id:version stringset of versions the user may want to "skip"
// oh, and because i hate myself, i made ^ at the beginning match that version and newer, and $ at the end match that version and older
val stringSet = MainApplication.getSharedPreferences("mmm")!!.getStringSet(
val stringSet = MainApplication.getPreferences("mmm")!!.getStringSet(
"pref_background_update_check_excludes_version",
HashSet()
)
@ -277,7 +277,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
}
}
// check for app updates
if (MainApplication.getSharedPreferences("mmm")!!
if (MainApplication.getPreferences("mmm")!!
.getBoolean("pref_background_update_check_app", false)
) {
@ -308,9 +308,9 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
}
}
// increment or create counter in shared preferences
MainApplication.getSharedPreferences("mmm")!!.edit().putInt(
MainApplication.getPreferences("mmm")!!.edit().putInt(
"pref_background_update_counter",
MainApplication.getSharedPreferences("mmm")!!
MainApplication.getPreferences("mmm")!!
.getInt("pref_background_update_counter", 0) + 1
).apply()
}
@ -377,7 +377,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
fun onMainActivityCreate(context: Context) {
// Refuse to run if first_launch pref is not false
if (MainApplication.getSharedPreferences("mmm")!!
if (MainApplication.getPreferences("mmm")!!
.getString("last_shown_setup", null) != "v5"
) return
// create notification channel group
@ -417,7 +417,7 @@ class BackgroundUpdateChecker(context: Context, workerParams: WorkerParameters)
notificationManagerCompat.cancel(NOTIFICATION_ID_ONGOING)
if (MainApplication.forceDebugLogging) Timber.d("Scheduling periodic background check")
// use pref_background_update_check_frequency to set frequency. value is in minutes
val frequency = MainApplication.getSharedPreferences("mmm")!!
val frequency = MainApplication.getPreferences("mmm")!!
.getInt("pref_background_update_check_frequency", 60).toLong()
if (MainApplication.forceDebugLogging) Timber.d("Frequency: $frequency minutes")
WorkManager.getInstance(context).enqueueUniquePeriodicWork(

@ -30,7 +30,7 @@ class ModuleManager private constructor() : SyncManager() {
override fun scanInternal(updateListener: UpdateListener) {
// if last_shown_setup is not "v5", then refuse to continue
if (MainApplication.getSharedPreferences("mmm")!!
if (MainApplication.getPreferences("mmm")!!
.getString("last_shown_setup", "") != "v5"
) {
return

@ -124,7 +124,7 @@ enum class ActionButtonType {
}
override fun doAction(button: Chip, moduleHolder: ModuleHolder) {
if (MainApplication.getSharedPreferences("mmm")?.getBoolean("pref_require_security", false) == true) {
if (MainApplication.getPreferences("mmm")?.getBoolean("pref_require_security", false) == true) {
// get safe status from either mainmoduleinfo or repo module
val safe = moduleHolder.mainModuleInfo.safe || moduleHolder.repoModule?.moduleInfo?.safe ?: false
if (!safe) {

@ -10,7 +10,7 @@ import androidx.annotation.StringRes
import com.fox2code.mmm.MainApplication
import com.fox2code.mmm.MainApplication.Companion.INSTANCE
import com.fox2code.mmm.MainApplication.Companion.formatTime
import com.fox2code.mmm.MainApplication.Companion.getSharedPreferences
import com.fox2code.mmm.MainApplication.Companion.getPreferences
import com.fox2code.mmm.MainApplication.Companion.isDisableLowQualityModuleFilter
import com.fox2code.mmm.NotificationType
import com.fox2code.mmm.R
@ -120,7 +120,7 @@ class ModuleHolder : Comparable<ModuleHolder?> {
if (MainApplication.forceDebugLogging) Timber.i("Module %s is updateable", moduleId)
var ignoreUpdate = false
try {
if (getSharedPreferences("mmm")?.getStringSet(
if (getPreferences("mmm")?.getStringSet(
"pref_background_update_check_excludes",
HashSet()
)!!
@ -133,7 +133,7 @@ class ModuleHolder : Comparable<ModuleHolder?> {
// now, we just had to make it more fucking complicated, didn't we?
// we now have pref_background_update_check_excludes_version, which is a id:version stringset of versions the user may want to "skip"
// oh, and because i hate myself, i made ^ at the beginning match that version and newer, and $ at the end match that version and older
val stringSetT = getSharedPreferences("mmm")?.getStringSet(
val stringSetT = getPreferences("mmm")?.getStringSet(
"pref_background_update_check_excludes_version",
HashSet()
)

@ -6,7 +6,7 @@ package com.fox2code.mmm.repo
import androidx.room.Room
import com.fox2code.mmm.MainApplication
import com.fox2code.mmm.MainApplication.Companion.INSTANCE
import com.fox2code.mmm.MainApplication.Companion.getSharedPreferences
import com.fox2code.mmm.MainApplication.Companion.getPreferences
import com.fox2code.mmm.utils.io.Hashes.Companion.hashSha256
import com.fox2code.mmm.utils.io.PropUtils.Companion.isNullString
import com.fox2code.mmm.utils.io.net.Http.Companion.doHttpGet
@ -29,7 +29,7 @@ class CustomRepoManager internal constructor(
init {
repoCount = 0
// refuse to load if setup is not complete
if (getSharedPreferences("mmm")!!.getString("last_shown_setup", "") == "v5") {
if (getPreferences("mmm")!!.getString("last_shown_setup", "") == "v5") {
val i = 0
val lastFilled = intArrayOf(0)
// now the same as above but for room database

@ -11,7 +11,7 @@ import android.os.Looper
import android.widget.Toast
import com.fox2code.mmm.MainActivity
import com.fox2code.mmm.MainApplication
import com.fox2code.mmm.MainApplication.Companion.getSharedPreferences
import com.fox2code.mmm.MainApplication.Companion.getPreferences
import com.fox2code.mmm.MainApplication.Companion.isAndroidacyTestMode
import com.fox2code.mmm.MainApplication.Companion.isDisableLowQualityModuleFilter
import com.fox2code.mmm.R
@ -55,7 +55,7 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
repoData = LinkedHashMap()
modules = HashMap()
// refuse to load if setup is not complete
if (getSharedPreferences("mmm")!!.getString("last_shown_setup", "") == "v5") {
if (getPreferences("mmm")!!.getString("last_shown_setup", "") == "v5") {
// We do not have repo list config yet.
androidacyRepoData = addAndroidacyRepoData()
val altRepo = addRepoData(MAGISK_ALT_REPO, "Magisk Modules Alt Repo")
@ -82,7 +82,7 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
private fun populateDefaultCache(repoData: RepoData?) {
// if last_shown_setup is not "v5", them=n refuse to continue
if (getSharedPreferences("mmm")!!.getString("last_shown_setup", "") != "v5") {
if (getPreferences("mmm")!!.getString("last_shown_setup", "") != "v5") {
return
}
// make sure repodata is not null
@ -256,7 +256,7 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
builder.setPositiveButton(android.R.string.ok, null)
if (repoUpdaters[i]!!.repoData is AndroidacyRepoData) {
builder.setNeutralButton(R.string.reset_api_key) { _: DialogInterface?, _: Int ->
val editor = getSharedPreferences("androidacy")!!
val editor = getPreferences("androidacy")!!
.edit()
editor.putString("androidacy_api_key", "")
editor.apply()

@ -69,7 +69,7 @@ class RepoFragment : PreferenceFragmentCompat() {
)
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
// User clicked OK button
MainApplication.getSharedPreferences("mmm")!!
MainApplication.getPreferences("mmm")!!
.edit().putBoolean("androidacy_test_mode", true).apply()
// Check the switch
val mStartActivity =
@ -101,11 +101,11 @@ class RepoFragment : PreferenceFragmentCompat() {
androidacyTestMode as SwitchPreferenceCompat
switchPreferenceCompat.isChecked = false
// There's probably a better way to do this than duplicate code but I'm too lazy to figure it out
MainApplication.getSharedPreferences("mmm")!!
MainApplication.getPreferences("mmm")!!
.edit().putBoolean("androidacy_test_mode", false).apply()
}.show()
} else {
MainApplication.getSharedPreferences("mmm")!!
MainApplication.getPreferences("mmm")!!
.edit().putBoolean("androidacy_test_mode", false).apply()
// Show dialog to restart app with ok button
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
@ -221,7 +221,7 @@ class RepoFragment : PreferenceFragmentCompat() {
}
}
val originalApiKeyRef = arrayOf(
MainApplication.getSharedPreferences("androidacy")!!
MainApplication.getPreferences("androidacy")!!
.getString("pref_androidacy_api_token", "")
)
// Get the dummy pref_androidacy_repo_api_token preference with id pref_androidacy_repo_api_token
@ -281,7 +281,7 @@ class RepoFragment : PreferenceFragmentCompat() {
Thread(Runnable {
// If key is empty, just remove it and change the text of the snack bar
if (apiKey.isEmpty()) {
MainApplication.getSharedPreferences("androidacy")!!.edit()
MainApplication.getPreferences("androidacy")!!.edit()
.remove("pref_androidacy_api_token").apply()
Handler(Looper.getMainLooper()).post {
Snackbar.make(
@ -332,7 +332,7 @@ class RepoFragment : PreferenceFragmentCompat() {
BaseTransientBottomBar.LENGTH_SHORT
).show()
// Save the original key
MainApplication.getSharedPreferences("androidacy")!!
MainApplication.getPreferences("androidacy")!!
.edit().putString(
"pref_androidacy_api_token",
originalApiKeyRef[0]
@ -366,7 +366,7 @@ class RepoFragment : PreferenceFragmentCompat() {
RepoManager.getINSTANCE()!!.androidacyRepoData!!.setToken(
apiKey
)
MainApplication.getSharedPreferences("androidacy")!!
MainApplication.getPreferences("androidacy")!!
.edit()
.putString("pref_androidacy_api_token", apiKey)
.apply()
@ -420,11 +420,9 @@ class RepoFragment : PreferenceFragmentCompat() {
BaseTransientBottomBar.LENGTH_SHORT
).show()
// Save the original key
MainApplication.INSTANCE!!.getSharedPreferences(
MainApplication.getPreferences(
"androidacy",
0
)
.edit().putString(
)!!.edit().putString(
"pref_androidacy_api_token",
originalApiKeyRef[0]
).apply()

@ -104,7 +104,7 @@ class UpdateFragment : PreferenceFragmentCompat() {
// set the box to unchecked
(backgroundUpdateCheck as SwitchPreferenceCompat?)!!.isChecked = false
// ensure that the preference is false
MainApplication.getSharedPreferences("mmm")!!.edit()
MainApplication.getPreferences("mmm")!!.edit()
.putBoolean("pref_background_update_check", false).apply()
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.permission_notification_title)
.setMessage(

@ -137,7 +137,7 @@ class RuntimeUtils {
}
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
// Set pref_background_update_check to false and dismiss dialog
val prefs = MainApplication.getSharedPreferences("mmm")!!
val prefs = MainApplication.getPreferences("mmm")!!
prefs.edit().putBoolean("pref_background_update_check", false).apply()
dialog.dismiss()
MainActivity.doSetupNowRunning = false
@ -161,7 +161,7 @@ class RuntimeUtils {
fun checkShowInitialSetup(context: Context, activity: MainActivity) {
if (MainApplication.forceDebugLogging) Timber.i("Checking if we need to run setup")
// Check if context is the first launch using prefs and if doSetupRestarting was passed in the intent
val prefs = MainApplication.getSharedPreferences("mmm")!!
val prefs = MainApplication.getPreferences("mmm")!!
var firstLaunch = prefs.getString("last_shown_setup", null) != "v5"
// First launch
// context is intentionally separate from the above if statement, because it needs to be checked even if the first launch check is true due to some weird edge cases
@ -218,7 +218,7 @@ class RuntimeUtils {
) {
MainActivity.isShowingWeblateSb = true
// if we haven't shown context snackbar for context version yet
val prefs = MainApplication.getSharedPreferences("mmm")!!
val prefs = MainApplication.getPreferences("mmm")!!
if (prefs.getInt("weblate_snackbar_shown", 0) == BuildConfig.VERSION_CODE) return
val snackbar: Snackbar = Snackbar.make(
activity.findViewById(R.id.root_container),
@ -255,7 +255,7 @@ class RuntimeUtils {
}, 4500)
return
}
val prefs = MainApplication.getSharedPreferences("mmm")!!
val prefs = MainApplication.getPreferences("mmm")!!
// if last shown < 7 days ago
if (prefs.getLong("ugsns4", 0) > System.currentTimeMillis() - 604800000) return
val snackbar: Snackbar = Snackbar.make(

@ -83,7 +83,7 @@ enum class Http {;
private val fallbackCache: HashMap<String, List<InetAddress>>
init {
sharedPreferences = context.getSharedPreferences("mmm_dns", Context.MODE_PRIVATE)
sharedPreferences = MainApplication.getPreferences("mmm_dns")!!
this.parent = parent
this.fallbacks =
HashSet(listOf(*fallbacks)).toString().replaceAfter("]", "").replace("[", "")

@ -0,0 +1,23 @@
FATAL EXCEPTION: main
Process: com.fox2code.mmm, PID: 13896
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(Unknown Source:0)
at android.app.Instrumentation.newApplication(Instrumentation.java:1244)
at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1458)
at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1395)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6780)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2137)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7933)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
Caused by: java.lang.NullPointerException
at bm0.f(Unknown Source:4)
at com.fox2code.mmm.MainApplication.<clinit>(Unknown Source:2)
... 16 more
Loading…
Cancel
Save