fix ze crashes

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/89/head
androidacy-user 2 years ago
parent 3fe42f6f3b
commit a9122f572a

@ -130,7 +130,15 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
// check if this build has expired
val buildTime = Timestamp(BuildConfig.BUILD_TIME)
// if the build time is more than 30 days ago, throw an exception
check(ts.time < buildTime.time) { "This build has expired. Please download a stable build or update to the latest version." }
if (BuildConfig.DEBUG) {
check(ts.time < buildTime.time) { getString(R.string.build_expired) }
} else {
// non-debug builds expire after 1 year but only show a toast
val ts2 = Timestamp(System.currentTimeMillis() - 365L * 24 * 60 * 60 * 1000)
if (ts2.time > buildTime.time) {
Toast.makeText(this, R.string.build_expired, Toast.LENGTH_LONG).show()
}
}
setContentView(R.layout.activity_main)
this.setTitle(R.string.app_name)
// set window flags to ignore status bar
@ -245,6 +253,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
finish()
}
R.id.online_menu_item -> {
TrackHelper.track().event("view_list", "online_modules")
.with(MainApplication.INSTANCE!!.tracker)
@ -262,6 +271,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
searchView.setQuery("", false)
searchView.clearFocus()
}
R.id.installed_menu_item -> {
TrackHelper.track().event("view_list", "installed_modules")
.with(MainApplication.INSTANCE!!.tracker)
@ -377,13 +387,11 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
RepoManager.getINSTANCE().update { value: Double ->
runOnUiThread(if (max == 0) Runnable {
progressIndicator.setProgressCompat(
(value * PRECISION).toInt(),
true
(value * PRECISION).toInt(), true
)
} else Runnable {
progressIndicator.setProgressCompat(
(value * PRECISION * 0.75f).toInt(),
true
(value * PRECISION * 0.75f).toInt(), true
)
})
}
@ -597,8 +605,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
RepoManager.getINSTANCE().update { value: Double ->
runOnUiThread {
progressIndicator!!.setProgressCompat(
(value * PRECISION).toInt(),
true
(value * PRECISION).toInt(), true
)
}
}
@ -639,13 +646,11 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
RepoManager.getINSTANCE().update { value: Double ->
runOnUiThread(if (max == 0) Runnable {
progressIndicator!!.setProgressCompat(
(value * PRECISION).toInt(),
true
(value * PRECISION).toInt(), true
)
} else Runnable {
progressIndicator!!.setProgressCompat(
(value * PRECISION * 0.75f).toInt(),
true
(value * PRECISION * 0.75f).toInt(), true
)
})
}
@ -716,8 +721,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
Timber.i("Query submit: %s on online list", query)
Thread({
moduleViewListBuilderOnline.applyTo(
moduleListOnline!!,
moduleViewAdapterOnline!!
moduleListOnline!!, moduleViewAdapterOnline!!
)
}, "Query update thread").start()
}
@ -739,8 +743,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
Timber.i("Query submit: %s on online list", query)
Thread({
moduleViewListBuilderOnline.applyTo(
moduleListOnline!!,
moduleViewAdapterOnline!!
moduleListOnline!!, moduleViewAdapterOnline!!
)
}, "Query update thread").start()
}
@ -759,8 +762,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
if (moduleViewListBuilderOnline.setQueryChange(null)) {
Thread({
moduleViewListBuilderOnline.applyTo(
moduleListOnline!!,
moduleViewAdapterOnline!!
moduleListOnline!!, moduleViewAdapterOnline!!
)
}, "Query update thread").start()
}
@ -789,9 +791,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
}
i++
}
if (AndroidacyRepoData.getInstance()
.isEnabled && AndroidacyRepoData.getInstance().memberLevel == null
) {
if (AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == null) {
Timber.d("Member level is null, waiting for it to be initialized")
i = 0
while (AndroidacyRepoData.getInstance().memberLevel == null && i < 20) {
@ -804,14 +804,10 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
}
}
// if it's still null, but it's enabled, throw an error
if (AndroidacyRepoData.getInstance()
.isEnabled && AndroidacyRepoData.getInstance().memberLevel == null
) {
if (AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == null) {
Timber.e("AndroidacyRepoData is enabled, but member level is null")
}
if (AndroidacyRepoData.getInstance() != null && AndroidacyRepoData.getInstance()
.isEnabled && AndroidacyRepoData.getInstance().memberLevel == "Guest"
) {
if (AndroidacyRepoData.getInstance() != null && AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == "Guest") {
runtimeUtils!!.showUpgradeSnackbar(this, this)
} else {
if (!AndroidacyRepoData.getInstance().isEnabled) {
@ -825,9 +821,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
Timber.i("Unknown error, not showing upgrade snackbar 1")
}
}
} else if (AndroidacyRepoData.getInstance()
.isEnabled && AndroidacyRepoData.getInstance().memberLevel == "Guest"
) {
} else if (AndroidacyRepoData.getInstance().isEnabled && AndroidacyRepoData.getInstance().memberLevel == "Guest") {
runtimeUtils!!.showUpgradeSnackbar(this, this)
} else {
if (!AndroidacyRepoData.getInstance().isEnabled) {
@ -853,6 +847,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
}
private const val PRECISION = 10000
@JvmField
var doSetupNowRunning = true
var doSetupRestarting = false

@ -87,7 +87,7 @@ class MainApplication : FoxApplication(), Configuration.Provider {
private var markwonThemeContext: FoxThemeWrapper? = null
@JvmField
var markwon: Markwon? = null
private var existingKey: ByteArray? = byteArrayOf(0)
private var existingKey: ByteArray? = null
@JvmField
var tracker: Tracker? = null
private var makingNewKey = false
@ -450,7 +450,7 @@ class MainApplication : FoxApplication(), Configuration.Provider {
}
}
// attempt to read the existingKey property
if (existingKey != null) {
if (existingKey != null && existingKey!!.isNotEmpty()) {
return existingKey as ByteArray
}
// check if we have a key already
@ -563,14 +563,17 @@ class MainApplication : FoxApplication(), Configuration.Provider {
).apply()
Timber.d("Saved the encrypted key in shared preferences.")
makingNewKey = false
Timber.d("Returning the new key. Key length: %d", realmKey.size)
return realmKey // pass to a realm configuration via encryptionKey()
}
// Access the encrypted key in the keystore, decrypt it with the secret,
// and use it to open and read from the realm again
fun getExistingKey(): ByteArray {
Timber.v("Getting existing key.")
// attempt to read the existingKey property
if (existingKey != null) {
Timber.v("Existing key found in memory.")
return existingKey as ByteArray
}
// open a connection to the android keystore

@ -127,7 +127,9 @@ enum class PropUtils {
).use { bufferedReader ->
var line: String
var lineNum = 0
while (bufferedReader.readLine().also { line = it } != null) {
val iterator = bufferedReader.lineSequence().iterator()
while (iterator.hasNext()) {
line = iterator.next()
if (lineNum == 0 && line.startsWith("\u0000")) {
while (line.startsWith("\u0000")) line = line.substring(1)
}

@ -282,28 +282,18 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_marginVertical="12dp"
android:text="@string/other_section"
android:text="@string/eula_agree_v2_headline"
android:textAppearance="@android:style/TextAppearance.Material.Headline" />
<com.google.android.material.materialswitch.MaterialSwitch
<com.google.android.material.checkbox.MaterialCheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="false"
android:id="@+id/setup_agree_eula"
android:layout_marginHorizontal="2dp"
android:layout_marginVertical="4dp"
android:text="@string/eula_sum"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:drawableStart="@drawable/baseline_library_add_check_24"
android:drawablePadding="8dp" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:textColorLink="@color/blue"
android:text="@string/eula_agree_v2"
android:textAppearance="@android:style/TextAppearance.Material.Small" />
android:textAppearance="@style/TextAppearance.Material3.LabelSmall" />
</LinearLayout>

@ -429,4 +429,6 @@
<string name="upgrade_now">Upgrade</string>
<string name="crash_details_suggestion">The stacktrace may be found below. However, we <b>strongly</b> recommend you to use the feedback form below to submit feedback instead. This way, instead of manually copying the stacktrace, it will send it to us automatically. It also is deobfuscated that way and additional details are reported automatically.</string>
<string name="reinstall_warning">Most modules should be uninstalled, then reinstalled cleanly. For this reason, AMM does not support reinstalling modules while they are installed on the device.</string>
<string name="build_expired">This build has expired. Please update to the latest version.</string>
<string name="eula_agree_v2_headline">EULA and Terms</string>
</resources>

Loading…
Cancel
Save