Skip to content

Commit 7dc6263

Browse files
conversion or something
idk, im not religious Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 19174c3 commit 7dc6263

23 files changed

Lines changed: 1773 additions & 1667 deletions

app/build.gradle.kts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ androidComponents {
387387
// Assigns the new version code to output.versionCode, which changes the version code
388388
// for only the output APK, not for the variant itself.
389389
val versioCode = output.versionCode.get() as Int
390-
output.versionCode.set(baseAbiCode * 1000 + versioCode)
390+
output.versionCode.set((baseAbiCode * 1000) + versioCode)
391391
}
392392
}
393393
}
@@ -438,7 +438,7 @@ dependencies {
438438
// implementation("com.google.protobuf:protobuf-javalite:3.22.2")
439439

440440
// google guava, maybe fix a bug
441-
implementation("com.google.guava:guava:32.0.0-jre")
441+
implementation("com.google.guava:guava:32.0.1-jre")
442442

443443

444444
val libsuVersion = "5.0.5"
@@ -455,12 +455,12 @@ dependencies {
455455
implementation("com.github.Fox2Code:AndroidANSI:1.2.1")
456456

457457
// sentry
458-
implementation("io.sentry:sentry-android:6.21.0")
459-
implementation("io.sentry:sentry-android-timber:6.21.0")
460-
implementation("io.sentry:sentry-android-fragment:6.21.0")
461-
implementation("io.sentry:sentry-android-okhttp:6.21.0")
462-
implementation("io.sentry:sentry-kotlin-extensions:6.21.0")
463-
implementation("io.sentry:sentry-android-ndk:6.21.0")
458+
implementation("io.sentry:sentry-android:6.22.0")
459+
implementation("io.sentry:sentry-android-timber:6.22.0")
460+
implementation("io.sentry:sentry-android-fragment:6.22.0")
461+
implementation("io.sentry:sentry-android-okhttp:6.22.0")
462+
implementation("io.sentry:sentry-kotlin-extensions:6.22.0")
463+
implementation("io.sentry:sentry-android-ndk:6.22.0")
464464

465465
// Markdown
466466
// TODO: switch to an updated implementation

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class AppUpdateManager private constructor() {
4848
if (lastChecked != this.lastChecked) return peekShouldUpdate()
4949
// make a request to https://production-api.androidacy.com/amm/updates/check with appVersionCode and token/device_id/client_id
5050
var token = AndroidacyRepoData.token
51-
if (!AndroidacyRepoData.getInstance().isValidToken(token)) {
51+
if (!AndroidacyRepoData.instance.isValidToken(token)) {
5252
Timber.w("Invalid token, not checking for updates")
53-
token = AndroidacyRepoData.getInstance().requestNewToken()
53+
token = AndroidacyRepoData.instance.requestNewToken()
5454
}
5555
val deviceId = AndroidacyRepoData.generateDeviceId()
5656
val clientId = BuildConfig.ANDROIDACY_CLIENT_ID

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

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
346346
NotificationType.NO_INTERNET.autoAdd(moduleViewListBuilderOnline)
347347
val progressIndicator = progressIndicator!!
348348
// hide progress bar is repo-manager says we have no internet
349-
if (!RepoManager.getINSTANCE().hasConnectivity()) {
349+
if (!RepoManager.getINSTANCE()!!.hasConnectivity()) {
350350
Timber.i("No connection, hiding progress")
351351
runOnUiThread {
352352
progressIndicator.visibility = View.GONE
@@ -377,9 +377,9 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
377377
Timber.i("Scanning for modules!")
378378
if (BuildConfig.DEBUG) Timber.i("Initialize Update")
379379
val max = instance!!.getUpdatableModuleCount()
380-
if (RepoManager.getINSTANCE().customRepoManager != null && RepoManager.getINSTANCE().customRepoManager.needUpdate()) {
380+
if (RepoManager.getINSTANCE()!!.customRepoManager != null && RepoManager.getINSTANCE()!!.customRepoManager!!.needUpdate()) {
381381
Timber.w("Need update on create")
382-
} else if (RepoManager.getINSTANCE().customRepoManager == null) {
382+
} else if (RepoManager.getINSTANCE()!!.customRepoManager == null) {
383383
Timber.w("CustomRepoManager is null")
384384
}
385385
// update compat metadata
@@ -388,7 +388,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
388388
if (BuildConfig.DEBUG) Timber.i("Check Update")
389389
// update repos
390390
if (hasWebView()) {
391-
RepoManager.getINSTANCE().update { value: Double ->
391+
RepoManager.getINSTANCE()!!.update { value: Double ->
392392
runOnUiThread(if (max == 0) Runnable {
393393
progressIndicator.setProgressCompat(
394394
(value * PRECISION).toInt(), true
@@ -452,7 +452,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
452452
}
453453
if (BuildConfig.DEBUG) Timber.i("Apply")
454454
RepoManager.getINSTANCE()
455-
.runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
455+
?.runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
456456
moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter!!)
457457
moduleViewListBuilder.applyTo(moduleListOnline, moduleViewAdapterOnline!!)
458458
moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline!!)
@@ -599,14 +599,14 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
599599
if (appUpdateManager.checkUpdate(false)) moduleViewListBuilder.addNotification(
600600
NotificationType.UPDATE_AVAILABLE
601601
)
602-
RepoManager.getINSTANCE().updateEnabledStates()
603-
if (RepoManager.getINSTANCE().customRepoManager.needUpdate()) {
602+
RepoManager.getINSTANCE()!!.updateEnabledStates()
603+
if (RepoManager.getINSTANCE()!!.customRepoManager!!.needUpdate()) {
604604
runOnUiThread {
605605
progressIndicator!!.isIndeterminate = false
606606
progressIndicator!!.max = PRECISION
607607
}
608608
if (BuildConfig.DEBUG) Timber.i("Check Update")
609-
RepoManager.getINSTANCE().update { value: Double ->
609+
RepoManager.getINSTANCE()!!.update { value: Double ->
610610
runOnUiThread {
611611
progressIndicator!!.setProgressCompat(
612612
(value * PRECISION).toInt(), true
@@ -620,7 +620,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
620620
}
621621
if (BuildConfig.DEBUG) Timber.i("Apply")
622622
RepoManager.getINSTANCE()
623-
.runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
623+
?.runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
624624
Timber.i("Common Before applyTo")
625625
moduleViewListBuilder.applyTo(moduleList!!, moduleViewAdapter!!)
626626
moduleViewListBuilderOnline.applyTo(moduleListOnline!!, moduleViewAdapterOnline!!)
@@ -647,7 +647,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
647647
Thread({
648648
cleanDnsCache() // Allow DNS reload from network
649649
val max = instance!!.getUpdatableModuleCount()
650-
RepoManager.getINSTANCE().update { value: Double ->
650+
RepoManager.getINSTANCE()!!.update { value: Double ->
651651
runOnUiThread(if (max == 0) Runnable {
652652
progressIndicator!!.setProgressCompat(
653653
(value * PRECISION).toInt(), true
@@ -699,11 +699,11 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
699699
swipeRefreshLayout!!.isRefreshing = false
700700
}
701701
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder)
702-
RepoManager.getINSTANCE().updateEnabledStates()
702+
RepoManager.getINSTANCE()!!.updateEnabledStates()
703703
RepoManager.getINSTANCE()
704-
.runAfterUpdate { moduleViewListBuilder.appendInstalledModules() }
704+
?.runAfterUpdate { moduleViewListBuilder.appendInstalledModules() }
705705
RepoManager.getINSTANCE()
706-
.runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
706+
?.runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
707707
moduleViewListBuilder.applyTo(moduleList!!, moduleViewAdapter!!)
708708
moduleViewListBuilderOnline.applyTo(moduleListOnline!!, moduleViewAdapterOnline!!)
709709
}, "Repo update thread").start()
@@ -784,21 +784,13 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
784784
}
785785

786786
fun maybeShowUpgrade() {
787-
if (AndroidacyRepoData.getInstance() == null || AndroidacyRepoData.getInstance().memberLevel == null) {
787+
if (AndroidacyRepoData.instance.memberLevel == null) {
788788
// wait for up to 10 seconds for AndroidacyRepoData to be initialized
789-
var i = 0
790-
while (AndroidacyRepoData.getInstance() == null && i < 10) {
791-
try {
792-
Thread.sleep(1000)
793-
} catch (e: InterruptedException) {
794-
Timber.e(e)
795-
}
796-
i++
797-
}
798-
if (AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == null) {
789+
var i: Int
790+
if (AndroidacyRepoData.instance.isEnabled && AndroidacyRepoData.instance.memberLevel == null) {
799791
Timber.d("Member level is null, waiting for it to be initialized")
800792
i = 0
801-
while (AndroidacyRepoData.getInstance().memberLevel == null && i < 20) {
793+
while (AndroidacyRepoData.instance.memberLevel == null && i < 20) {
802794
i++
803795
try {
804796
Thread.sleep(500)
@@ -808,32 +800,32 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
808800
}
809801
}
810802
// if it's still null, but it's enabled, throw an error
811-
if (AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == null) {
803+
if (AndroidacyRepoData.instance.isEnabled && AndroidacyRepoData.instance.memberLevel == null) {
812804
Timber.e("AndroidacyRepoData is enabled, but member level is null")
813805
}
814-
if (AndroidacyRepoData.getInstance() != null && AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == "Guest") {
806+
if (AndroidacyRepoData.instance.isEnabled && AndroidacyRepoData.instance.memberLevel == "Guest") {
815807
runtimeUtils!!.showUpgradeSnackbar(this, this)
816808
} else {
817-
if (!AndroidacyRepoData.getInstance().isEnabled) {
809+
if (!AndroidacyRepoData.instance.isEnabled) {
818810
Timber.i("AndroidacyRepoData is disabled, not showing upgrade snackbar 1")
819-
} else if (AndroidacyRepoData.getInstance().memberLevel != "Guest") {
811+
} else if (AndroidacyRepoData.instance.memberLevel != "Guest") {
820812
Timber.i(
821813
"AndroidacyRepoData is not Guest, not showing upgrade snackbar 1. Level: %s",
822-
AndroidacyRepoData.getInstance().memberLevel
814+
AndroidacyRepoData.instance.memberLevel
823815
)
824816
} else {
825817
Timber.i("Unknown error, not showing upgrade snackbar 1")
826818
}
827819
}
828-
} else if (AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == "Guest") {
820+
} else if (AndroidacyRepoData.instance.isEnabled && AndroidacyRepoData.instance.memberLevel == "Guest") {
829821
runtimeUtils!!.showUpgradeSnackbar(this, this)
830822
} else {
831-
if (!AndroidacyRepoData.getInstance().isEnabled) {
823+
if (!AndroidacyRepoData.instance.isEnabled) {
832824
Timber.i("AndroidacyRepoData is disabled, not showing upgrade snackbar 2")
833-
} else if (AndroidacyRepoData.getInstance().memberLevel != "Guest") {
825+
} else if (AndroidacyRepoData.instance.memberLevel != "Guest") {
834826
Timber.i(
835827
"AndroidacyRepoData is not Guest, not showing upgrade snackbar 2. Level: %s",
836-
AndroidacyRepoData.getInstance().memberLevel
828+
AndroidacyRepoData.instance.memberLevel
837829
)
838830
} else {
839831
Timber.i("Unknown error, not showing upgrade snackbar 2")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ enum class NotificationType constructor(
104104
@JvmStatic
105105
NO_INTERNET(R.string.fail_internet, R.drawable.ic_baseline_cloud_off_24) {
106106
override fun shouldRemove(): Boolean {
107-
return RepoManager.getINSTANCE().hasConnectivity()
107+
return RepoManager.getINSTANCE()!!.hasConnectivity()
108108
}
109109
},
110110
@JvmStatic
111111
REPO_UPDATE_FAILED(R.string.repo_update_failed, R.drawable.ic_baseline_cloud_off_24) {
112112
override fun shouldRemove(): Boolean {
113-
return RepoManager.getINSTANCE().isLastUpdateSuccess
113+
return RepoManager.getINSTANCE()!!.isLastUpdateSuccess
114114
}
115115
},
116116
@JvmStatic
@@ -124,7 +124,7 @@ enum class NotificationType constructor(
124124
)
125125
}) {
126126
override fun shouldRemove(): Boolean {
127-
return (!RepoManager.isAndroidacyRepoEnabled()
127+
return (!RepoManager.isAndroidacyRepoEnabled
128128
|| !Http.needCaptchaAndroidacy())
129129
}
130130
},

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ class UpdateActivity : FoxActivity() {
229229
// check for update
230230
val shouldUpdate = AppUpdateManager.appUpdateManager.checkUpdate(true)
231231
var token = AndroidacyRepoData.token
232-
if (!AndroidacyRepoData.getInstance().isValidToken(token)) {
232+
if (!AndroidacyRepoData.instance.isValidToken(token)) {
233233
Timber.w("Invalid token, not checking for updates")
234-
token = AndroidacyRepoData.getInstance().requestNewToken()
234+
token = AndroidacyRepoData.instance.requestNewToken()
235235
}
236236
val deviceId = AndroidacyRepoData.generateDeviceId()
237237
val clientId = BuildConfig.ANDROIDACY_CLIENT_ID
@@ -271,9 +271,9 @@ class UpdateActivity : FoxActivity() {
271271
// get status text view
272272
val statusTextView = findViewById<MaterialTextView>(R.id.update_progress_text)
273273
var token = AndroidacyRepoData.token
274-
if (!AndroidacyRepoData.getInstance().isValidToken(token)) {
274+
if (!AndroidacyRepoData.instance.isValidToken(token)) {
275275
Timber.w("Invalid token, not checking for updates")
276-
token = AndroidacyRepoData.getInstance().requestNewToken()
276+
token = AndroidacyRepoData.instance.requestNewToken()
277277
}
278278
val deviceId = AndroidacyRepoData.generateDeviceId()
279279
val clientId = BuildConfig.ANDROIDACY_CLIENT_ID

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ enum class XHooks {
6565

6666
@Keep
6767
fun addXRepo(url: String?, fallbackName: String?): XRepo {
68-
return RepoManager.getINSTANCE_UNSAFE().addOrGet(url, fallbackName)
68+
return url?.let { RepoManager.iNSTANCE_UNSAFE?.addOrGet(it, fallbackName) }!!
6969
}
7070

7171
@Keep
7272
fun getXRepo(url: String?): XRepo {
73-
return RepoManager.getINSTANCE_UNSAFE()[url]
73+
return RepoManager.iNSTANCE_UNSAFE?.get(url) ?: throw NullPointerException("Repo not found!")
7474
}
7575

7676
@get:Keep
7777
val xRepos: Collection<XRepo>
78-
get() = RepoManager.getINSTANCE_UNSAFE().xRepos
78+
get() = RepoManager.iNSTANCE_UNSAFE!!.xRepos
7979
}
8080
}

0 commit comments

Comments
 (0)