Skip to content

Commit cf095f3

Browse files
update styles
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 7914bcb commit cf095f3

27 files changed

Lines changed: 1032 additions & 894 deletions

app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import java.util.Properties
88
plugins {
99
// Gradle doesn't allow conditionally enabling/disabling plugins
1010
id("com.android.application")
11-
id("org.gradle.android.cache-fix")
1211
id("com.mikepenz.aboutlibraries.plugin")
1312
kotlin("android")
1413
kotlin("kapt")

app/src/main/java/com/fox2code/mmm/AppUpdateManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import java.nio.charset.StandardCharsets
1515
class AppUpdateManager private constructor() {
1616
private val compatDataId = HashMap<String, Int>()
1717
private val updateLock = Any()
18-
private val compatFile: File = File(MainApplication.getINSTANCE().filesDir, "compat.txt")
18+
private val compatFile: File = File(MainApplication.INSTANCE!!.filesDir, "compat.txt")
1919
private var latestRelease: String?
2020
private var lastChecked: Long
2121

2222
init {
23-
latestRelease = MainApplication.getBootSharedPreferences()
24-
.getString("updater_latest_release", BuildConfig.VERSION_NAME)
23+
latestRelease = MainApplication.bootSharedPreferences
24+
?.getString("updater_latest_release", BuildConfig.VERSION_NAME)
2525
lastChecked = 0
2626
if (compatFile.isFile) {
2727
try {

app/src/main/java/com/fox2code/mmm/CrashHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class CrashHandler : FoxActivity() {
169169
builder.setMessage(R.string.reset_app_confirmation)
170170
builder.setPositiveButton(R.string.reset) { _: DialogInterface?, _: Int ->
171171
// reset the app
172-
MainApplication.getINSTANCE().resetApp()
172+
MainApplication.INSTANCE!!.resetApp()
173173
}
174174
builder.setNegativeButton(R.string.cancel) { _: DialogInterface?, _: Int -> }
175175
builder.show()

app/src/main/java/com/fox2code/mmm/MainActivity.kt

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import android.animation.AnimatorListenerAdapter
55
import android.annotation.SuppressLint
66
import android.content.Context
77
import android.content.Intent
8-
import android.content.SharedPreferences
9-
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
108
import android.content.res.Configuration
119
import android.graphics.Color
1210
import android.os.Build
@@ -99,11 +97,11 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
9997
}
10098
onMainActivityCreate(this)
10199
super.onCreate(savedInstanceState)
102-
TrackHelper.track().screen(this).with(MainApplication.getINSTANCE().tracker)
100+
TrackHelper.track().screen(this).with(MainApplication.INSTANCE!!.tracker)
103101
// track enabled repos
104102
val realmConfig = RealmConfiguration.Builder().name("ReposList.realm")
105-
.encryptionKey(MainApplication.getINSTANCE().key)
106-
.directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1)
103+
.encryptionKey(MainApplication.INSTANCE!!.key)
104+
.directory(MainApplication.INSTANCE!!.getDataDirWithPath("realms")).schemaVersion(1)
107105
.allowQueriesOnUiThread(true).allowWritesOnUiThread(true).build()
108106
val realm = Realm.getInstance(realmConfig)
109107
val enabledRepos = StringBuilder()
@@ -118,7 +116,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
118116
enabledRepos.setLength(enabledRepos.length - 1)
119117
}
120118
TrackHelper.track().event("enabled_repos", enabledRepos.toString())
121-
.with(MainApplication.getINSTANCE().tracker)
119+
.with(MainApplication.INSTANCE!!.tracker)
122120
realm.close()
123121
// hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug
124122
if (BuildConfig.ENABLE_PROTECTION && !MainApplication.o && !BuildConfig.DEBUG) {
@@ -140,7 +138,6 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
140138
// ignore status bar space
141139
this.window.setDecorFitsSystemWindows(false)
142140
} else {
143-
@Suppress("DEPRECATION")
144141
this.window.setFlags(
145142
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
146143
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
@@ -243,14 +240,14 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
243240
when (item.itemId) {
244241
R.id.settings_menu_item -> {
245242
TrackHelper.track().event("view_list", "settings")
246-
.with(MainApplication.getINSTANCE().tracker)
243+
.with(MainApplication.INSTANCE!!.tracker)
247244
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
248245
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
249246
finish()
250247
}
251248
R.id.online_menu_item -> {
252249
TrackHelper.track().event("view_list", "online_modules")
253-
.with(MainApplication.getINSTANCE().tracker)
250+
.with(MainApplication.INSTANCE!!.tracker)
254251
// set module_list_online as visible and module_list as gone. fade in/out
255252
moduleListOnline.alpha = 0f
256253
moduleListOnline.visibility = View.VISIBLE
@@ -267,7 +264,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
267264
}
268265
R.id.installed_menu_item -> {
269266
TrackHelper.track().event("view_list", "installed_modules")
270-
.with(MainApplication.getINSTANCE().tracker)
267+
.with(MainApplication.INSTANCE!!.tracker)
271268
// set module_list_online as gone and module_list as visible. fade in/out
272269
moduleList.alpha = 0f
273270
moduleList.visibility = View.VISIBLE
@@ -304,14 +301,14 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
304301
rootContainer.y = 0f
305302
}
306303
// reset update module and update module count in main application
307-
MainApplication.getINSTANCE().resetUpdateModule()
304+
MainApplication.INSTANCE!!.resetUpdateModule()
308305
tryGetMagiskPathAsync(object : InstallerInitializer.Callback {
309306
override fun onPathReceived(path: String?) {
310307
Timber.i("Got magisk path: %s", path)
311308
if (peekMagiskVersion() < Constants.MAGISK_VER_CODE_INSTALL_COMMAND) moduleViewListBuilder.addNotification(
312309
NotificationType.MAGISK_OUTDATED
313310
)
314-
if (!MainApplication.isShowcaseMode()) moduleViewListBuilder.addNotification(
311+
if (!MainApplication.isShowcaseMode) moduleViewListBuilder.addNotification(
315312
NotificationType.INSTALL_FROM_STORAGE
316313
)
317314
instance!!.scan()
@@ -350,7 +347,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
350347
return
351348
}
352349
swipeRefreshBlocker = System.currentTimeMillis() + 5000L
353-
if (MainApplication.isShowcaseMode()) moduleViewListBuilder.addNotification(
350+
if (MainApplication.isShowcaseMode) moduleViewListBuilder.addNotification(
354351
NotificationType.SHOWCASE_MODE
355352
)
356353
if (!hasWebView()) {
@@ -448,13 +445,13 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
448445
moduleViewListBuilder.applyTo(moduleListOnline, moduleViewAdapterOnline!!)
449446
moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline!!)
450447
// if moduleViewListBuilderOnline has the upgradeable notification, show a badge on the online repo nav item
451-
if (MainApplication.getINSTANCE().modulesHaveUpdates) {
448+
if (MainApplication.INSTANCE!!.modulesHaveUpdates) {
452449
Timber.i("Applying badge")
453450
Handler(Looper.getMainLooper()).post {
454451
val badge = bottomNavigationView.getOrCreateBadge(R.id.online_menu_item)
455452
badge.isVisible = true
456-
badge.number = MainApplication.getINSTANCE().updateModuleCount
457-
badge.applyTheme(MainApplication.getInitialApplication().theme)
453+
badge.number = MainApplication.INSTANCE!!.updateModuleCount
454+
badge.applyTheme(MainApplication.INSTANCE!!.theme)
458455
Timber.i("Badge applied")
459456
}
460457
}
@@ -480,37 +477,12 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
480477
}
481478
ExternalHelper.INSTANCE.refreshHelper(this)
482479
initMode = false
483-
// add preference listener to set isMatomoAllowed
484-
val listener =
485-
OnSharedPreferenceChangeListener { sharedPreferences: SharedPreferences, key: String ->
486-
if (key == "pref_analytics_enabled") {
487-
MainApplication.getINSTANCE().isMatomoAllowed =
488-
sharedPreferences.getBoolean(key, false)
489-
MainApplication.getINSTANCE().tracker.isOptOut =
490-
MainApplication.getINSTANCE().isMatomoAllowed
491-
Timber.d(
492-
"Matomo is allowed change: %s",
493-
MainApplication.getINSTANCE().isMatomoAllowed
494-
)
495-
}
496-
if (MainApplication.getINSTANCE().isMatomoAllowed) {
497-
val value = sharedPreferences.getString(key, null)
498-
// then log
499-
if (value != null) {
500-
TrackHelper.track().event("pref_changed", "$key=$value")
501-
.with(MainApplication.getINSTANCE().tracker)
502-
}
503-
}
504-
Timber.d("Preference changed: %s", key)
505-
}
506-
MainApplication.getSharedPreferences("mmm")
507-
.registerOnSharedPreferenceChangeListener(listener)
508480
}
509481

510482
private fun cardIconifyUpdate() {
511483
val iconified = searchView!!.isIconified
512484
val backgroundAttr =
513-
if (iconified) if (MainApplication.isMonetEnabled()) com.google.android.material.R.attr.colorSecondaryContainer else // Monet is special...
485+
if (iconified) if (MainApplication.isMonetEnabled) com.google.android.material.R.attr.colorSecondaryContainer else // Monet is special...
514486
com.google.android.material.R.attr.colorSecondary else com.google.android.material.R.attr.colorPrimarySurface
515487
val theme = searchCard!!.context.theme
516488
val value = TypedValue()
@@ -546,7 +518,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
546518
}
547519

548520
private fun updateBlurState() {
549-
if (MainApplication.isBlurEnabled()) {
521+
if (MainApplication.isBlurEnabled) {
550522
// set bottom navigation bar color to transparent blur
551523
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottom_navigation)
552524
if (bottomNavigationView != null) {
@@ -590,7 +562,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
590562
if (peekMagiskVersion() < Constants.MAGISK_VER_CODE_INSTALL_COMMAND) moduleViewListBuilder.addNotification(
591563
NotificationType.MAGISK_OUTDATED
592564
)
593-
if (!MainApplication.isShowcaseMode()) moduleViewListBuilder.addNotification(
565+
if (!MainApplication.isShowcaseMode) moduleViewListBuilder.addNotification(
594566
NotificationType.INSTALL_FROM_STORAGE
595567
)
596568
instance!!.scan()
@@ -607,7 +579,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
607579

608580
fun commonNext() {
609581
Timber.i("Common Before")
610-
if (MainApplication.isShowcaseMode()) moduleViewListBuilder.addNotification(
582+
if (MainApplication.isShowcaseMode) moduleViewListBuilder.addNotification(
611583
NotificationType.SHOWCASE_MODE
612584
)
613585
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilderOnline)
@@ -731,7 +703,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
731703
override fun onQueryTextSubmit(query: String): Boolean {
732704
searchView!!.clearFocus()
733705
if (initMode) return false
734-
TrackHelper.track().search(query).with(MainApplication.getINSTANCE().tracker)
706+
TrackHelper.track().search(query).with(MainApplication.INSTANCE!!.tracker)
735707
if (moduleViewListBuilder.setQueryChange(query)) {
736708
Timber.i("Query submit: %s on offline list", query)
737709
Thread(
@@ -754,7 +726,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
754726

755727
override fun onQueryTextChange(query: String): Boolean {
756728
if (initMode) return false
757-
TrackHelper.track().search(query).with(MainApplication.getINSTANCE().tracker)
729+
TrackHelper.track().search(query).with(MainApplication.INSTANCE!!.tracker)
758730
if (moduleViewListBuilder.setQueryChange(query)) {
759731
Timber.i("Query submit: %s on offline list", query)
760732
Thread(

0 commit comments

Comments
 (0)