Skip to content

Commit bfc530f

Browse files
tweaks + improvements
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 8af585e commit bfc530f

4 files changed

Lines changed: 32 additions & 25 deletions

File tree

app/src/main/kotlin/com/fox2code/mmm/MainApplication.kt

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import com.fox2code.foxcompat.app.internal.FoxProcessExt
2828
import com.fox2code.foxcompat.view.FoxThemeWrapper
2929
import com.fox2code.mmm.installer.InstallerInitializer
3030
import com.fox2code.mmm.installer.InstallerInitializer.Companion.peekMagiskVersion
31+
import com.fox2code.mmm.manager.LocalModuleInfo
32+
import com.fox2code.mmm.repo.RepoModule
3133
import com.fox2code.mmm.utils.TimberUtils.configTimber
3234
import com.fox2code.mmm.utils.io.FileUtils
3335
import com.fox2code.mmm.utils.io.GMSProviderInstaller.Companion.installIfNeeded
@@ -79,6 +81,9 @@ class MainApplication : FoxApplication(), Configuration.Provider {
7981
private var makingNewKey = false
8082
private var isCrashHandler = false
8183

84+
var localModules: HashMap<String, LocalModuleInfo> = HashMap()
85+
var repoModules: HashMap<String, RepoModule> = HashMap()
86+
8287
init {
8388
check(!(INSTANCE != null && INSTANCE !== this)) { "Duplicate application instance!" }
8489
INSTANCE = this
@@ -620,25 +625,25 @@ class MainApplication : FoxApplication(), Configuration.Provider {
620625
get() = getSharedPreferences("mmm")!!.getBoolean("pref_dns_over_https", true)
621626
val isMonetEnabled: Boolean
622627
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && getSharedPreferences("mmm")!!.getBoolean(
623-
"pref_enable_monet",
624-
true
625-
)
628+
"pref_enable_monet",
629+
true
630+
)
626631
val isBlurEnabled: Boolean
627632
get() = getSharedPreferences("mmm")!!.getBoolean("pref_enable_blur", false)
628633

629634
@JvmStatic
630635
val isDeveloper: Boolean
631636
get() {
632637
return if (BuildConfig.DEBUG) true else getSharedPreferences("mmm")!!.getBoolean(
633-
"developer",
634-
false
635-
)
638+
"developer",
639+
false
640+
)
636641
}
637642
val isDisableLowQualityModuleFilter: Boolean
638643
get() = getSharedPreferences("mmm")!!.getBoolean(
639-
"pref_disable_low_quality_module_filter",
640-
false
641-
) && isDeveloper
644+
"pref_disable_low_quality_module_filter",
645+
false
646+
) && isDeveloper
642647
val isUsingMagiskCommand: Boolean
643648
get() = (peekMagiskVersion() >= Constants.MAGISK_VER_CODE_INSTALL_COMMAND) && getSharedPreferences(
644649
"mmm"
@@ -652,27 +657,27 @@ class MainApplication : FoxApplication(), Configuration.Provider {
652657
}
653658
val wrapped = isWrapped
654659
val updateCheckBgTemp = !wrapped && getSharedPreferences("mmm")!!.getBoolean(
655-
"pref_background_update_check",
656-
true
657-
)
660+
"pref_background_update_check",
661+
true
662+
)
658663
updateCheckBg = updateCheckBgTemp.toString()
659664
return java.lang.Boolean.parseBoolean(updateCheckBg)
660665
}
661666
val isAndroidacyTestMode: Boolean
662667
get() = isDeveloper && getSharedPreferences("mmm")!!.getBoolean(
663-
"pref_androidacy_test_mode",
664-
false
665-
)
668+
"pref_androidacy_test_mode",
669+
false
670+
)
666671

667672
fun setHasGottenRootAccess(bool: Boolean) {
668673
getSharedPreferences("mmm")!!.edit().putBoolean("has_root_access", bool).apply()
669674
}
670675

671676
val isCrashReportingEnabled: Boolean
672677
get() = SentryMain.IS_SENTRY_INSTALLED && getSharedPreferences("mmm")!!.getBoolean(
673-
"pref_crash_reporting",
674-
BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING
675-
)
678+
"pref_crash_reporting",
679+
BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING
680+
)
676681
val bootSharedPreferences: SharedPreferences?
677682
get() = getSharedPreferences("mmm_boot")
678683

@@ -689,9 +694,9 @@ class MainApplication : FoxApplication(), Configuration.Provider {
689694
@JvmStatic
690695
fun isMatomoAllowed(): Boolean {
691696
return getSharedPreferences("mmm")!!.getBoolean(
692-
"pref_analytics_enabled",
693-
BuildConfig.DEFAULT_ENABLE_ANALYTICS
694-
)
697+
"pref_analytics_enabled",
698+
BuildConfig.DEFAULT_ENABLE_ANALYTICS
699+
)
695700
}
696701
}
697702
}

app/src/main/kotlin/com/fox2code/mmm/manager/ModuleManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ class ModuleManager private constructor() : SyncManager() {
207207

208208
var modules: HashMap<String, LocalModuleInfo> = HashMap()
209209
get() {
210-
Timber.d("getModules")
211210
afterScan()
212211
return moduleInfos
213212
}
214213
set(value) {
215-
Timber.d("setModules")
214+
// add to MainApplication.INSTANCE!!.localModules hashmap
216215
field = value
217216
moduleInfos = value
217+
MainApplication.INSTANCE!!.localModules = value
218218
}
219219

220220
@Suppress("unused")

app/src/main/kotlin/com/fox2code/mmm/repo/RepoData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,12 @@ open class RepoData(url: String, cacheRoot: File) : XRepo() {
342342
readProperties(
343343
moduleInfo,
344344
file.absolutePath,
345-
repoModule.repoName + "/" + moduleInfo.name,
345+
"${repoModule.repoName}/${moduleInfo.name}",
346346
false
347347
)
348348
moduleInfo.flags = moduleInfo.flags and ModuleInfo.FLAG_METADATA_INVALID.inv()
349349
if (moduleInfo.version == null) {
350-
moduleInfo.version = "v" + moduleInfo.versionCode
350+
moduleInfo.version = "v${moduleInfo.versionCode}"
351351
}
352352
return true
353353
} catch (ignored: Exception) {

app/src/main/kotlin/com/fox2code/mmm/repo/RepoUpdater.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class RepoUpdater(repoData2: RepoData) {
9797
toUpdate = repoData.populate(JSONObject(String(indexRaw!!, StandardCharsets.UTF_8)))
9898
// Since we reuse instances this should work
9999
toApply = HashSet(repoData.moduleHashMap.values)
100+
// add toApply to the hashmap MainApplication.INSTANCE!!.repoModules
101+
MainApplication.INSTANCE!!.repoModules.putAll(repoData.moduleHashMap)
100102
(toUpdate as MutableList<RepoModule>?)?.let {
101103
(toApply as HashSet<RepoModule>).removeAll(
102104
it.toSet()

0 commit comments

Comments
 (0)