@@ -5,8 +5,6 @@ import android.animation.AnimatorListenerAdapter
55import android.annotation.SuppressLint
66import android.content.Context
77import android.content.Intent
8- import android.content.SharedPreferences
9- import android.content.SharedPreferences.OnSharedPreferenceChangeListener
108import android.content.res.Configuration
119import android.graphics.Color
1210import 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