fix known bugs

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

@ -353,15 +353,15 @@ configurations {
dependencies { dependencies {
// UI // UI
implementation("androidx.appcompat:appcompat:1.6.1") implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.activity:activity-ktx:1.7.2") implementation("androidx.activity:activity-ktx:1.8.0")
implementation("androidx.emoji2:emoji2:1.4.0") implementation("androidx.emoji2:emoji2:1.4.0")
implementation("androidx.emoji2:emoji2-views-helper:1.4.0") implementation("androidx.emoji2:emoji2-views-helper:1.4.0")
implementation("androidx.preference:preference-ktx:1.2.1") implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.recyclerview:recyclerview:1.3.1") implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.webkit:webkit:1.8.0") implementation("androidx.webkit:webkit:1.8.0")
implementation("com.google.android.material:material:1.9.0") implementation("com.google.android.material:material:1.10.0")
implementation("com.mikepenz:aboutlibraries:10.9.1") implementation("com.mikepenz:aboutlibraries:10.9.1")
@ -405,11 +405,11 @@ dependencies {
implementation("androidx.security:security-crypto:1.1.0-alpha06") implementation("androidx.security:security-crypto:1.1.0-alpha06")
// some utils // some utils
implementation("commons-io:commons-io:2.14.0") implementation("commons-io:commons-io:2.15.0")
implementation("org.apache.commons:commons-compress:1.24.0") implementation("org.apache.commons:commons-compress:1.24.0")
// analytics // analytics
implementation("ly.count.android:sdk:23.8.2") implementation("ly.count.android:sdk:23.8.4")
// annotations // annotations
implementation("org.jetbrains:annotations-java5:24.0.1") implementation("org.jetbrains:annotations-java5:24.0.1")
@ -418,19 +418,19 @@ dependencies {
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12") debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
// desugaring // desugaring
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
// yes // yes
implementation("com.github.fingerprintjs:fingerprint-android:2.0.2") implementation("com.github.fingerprintjs:fingerprint-android:2.0.2")
// room // room
implementation("androidx.room:room-runtime:2.5.2") implementation("androidx.room:room-runtime:2.6.0")
// To use Kotlin Symbol Processing (KSP) // To use Kotlin Symbol Processing (KSP)
ksp("androidx.room:room-compiler:2.5.2") ksp("androidx.room:room-compiler:2.6.0")
// optional - Kotlin Extensions and Coroutines support for Room // optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:2.5.2") implementation("androidx.room:room-ktx:2.6.0")
implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.28") implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.28")

@ -110,7 +110,7 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
@SuppressLint("SdCardPath") @SuppressLint("SdCardPath")
val getContent = this.registerForActivityResult( val getContent = this.registerForActivityResult(
ActivityResultContracts.GetContent() ActivityResultContracts.GetContent(),
) { uri: Uri? -> ) { uri: Uri? ->
if (uri == null) { if (uri == null) {
Timber.d("invalid uri received") Timber.d("invalid uri received")
@ -157,46 +157,28 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
) )
return@registerForActivityResult return@registerForActivityResult
} }
// check if the file is a zip by reading the first 4 bytes run {
val bytes = ByteArray(4) outputStream = FileOutputStream(destination)
inputStream.read(bytes, 0, 4) Files.copy(inputStream, outputStream as FileOutputStream)
if (!(bytes[0] == 0x50.toByte() && bytes[1] == 0x4B.toByte() && bytes[2] == 0x03.toByte() && bytes[3] == 0x04.toByte())) { if (MainApplication.forceDebugLogging) Timber.i("File saved at %s", destination)
Toast.makeText( success = true
this@MainActivity, R.string.file_picker_not_zip, Toast.LENGTH_SHORT
).show()
Timber.e(
"File is not a zip! Expected 0x504B0304, got %02X%02X%02X%02X",
bytes[0],
bytes[1],
bytes[2],
bytes[3]
)
callback?.onReceived( callback?.onReceived(
destination, destination,
uri, uri,
IntentHelper.RESPONSE_ERROR IntentHelper.RESPONSE_FILE
) )
return@registerForActivityResult
} }
outputStream = FileOutputStream(destination)
Files.copy(inputStream, outputStream)
if (MainApplication.forceDebugLogging) Timber.i("File saved at %s", destination)
success = true
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Timber.e(e)
Toast.makeText( Toast.makeText(
this@MainActivity, R.string.file_picker_failure, Toast.LENGTH_SHORT this@MainActivity, R.string.file_picker_failure, Toast.LENGTH_SHORT
).show() ).show()
callback?.onReceived(destination, uri, IntentHelper.RESPONSE_ERROR)
} finally { } finally {
Files.closeSilently(inputStream) Files.closeSilently(inputStream)
Files.closeSilently(outputStream) Files.closeSilently(outputStream)
if (!success && destination?.exists() == true && !destination!!.delete()) Timber.e("Failed to delete artifact!") if (!success && destination?.exists() == true && !destination!!.delete()) Timber.e("Failed to delete artifact!")
} }
callback?.onReceived(
destination,
uri,
if (success) IntentHelper.RESPONSE_FILE else IntentHelper.RESPONSE_ERROR
)
} }
init { init {

@ -489,7 +489,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
BuildConfig.DEBUG || getPreferences("mmm")?.getBoolean( BuildConfig.DEBUG || getPreferences("mmm")?.getBoolean(
"pref_force_debug_logging", "pref_force_debug_logging",
false false
) ?: false ) ?: BuildConfig.DEBUG
// Warning! Locales that don't exist will crash the app // Warning! Locales that don't exist will crash the app
// Anything that is commented out is supported but the translation is not complete to at least 60% // Anything that is commented out is supported but the translation is not complete to at least 60%
@ -641,7 +641,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
} }
fun shouldPreventReboot(): Boolean { fun shouldPreventReboot(): Boolean {
return getPreferences("mmm")!!.getBoolean("pref_prevent_reboot", true) return getPreferences("mmm")!!.getBoolean("pref_prevent_reboot", false)
} }
val isShowIncompatibleModules: Boolean val isShowIncompatibleModules: Boolean
@ -738,8 +738,12 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
} }
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
try {
lastActivity = activity as AppCompatActivity lastActivity = activity as AppCompatActivity
activity.setTheme(managerThemeResId) activity.setTheme(managerThemeResId)
} catch (e: Exception) {
Timber.e(e, "Failed to set theme")
}
} }
override fun onActivityStarted(activity: Activity) { override fun onActivityStarted(activity: Activity) {
@ -747,8 +751,12 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
} }
override fun onActivityResumed(activity: Activity) { override fun onActivityResumed(activity: Activity) {
try {
lastActivity = activity as AppCompatActivity lastActivity = activity as AppCompatActivity
activity.setTheme(managerThemeResId) activity.setTheme(managerThemeResId)
} catch (e: Exception) {
Timber.e(e, "Failed to set theme")
}
} }
override fun onActivityPaused(activity: Activity) { override fun onActivityPaused(activity: Activity) {

@ -11,6 +11,7 @@ import android.text.Spanned
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import com.fox2code.mmm.BuildConfig
import com.fox2code.mmm.MainApplication import com.fox2code.mmm.MainApplication
import com.fox2code.mmm.MainApplication.Companion.INSTANCE import com.fox2code.mmm.MainApplication.Companion.INSTANCE
import com.fox2code.mmm.MainApplication.Companion.isShowcaseMode import com.fox2code.mmm.MainApplication.Companion.isShowcaseMode
@ -159,6 +160,7 @@ enum class ActionButtonType {
}) })
// if text is reinstall, we need to uninstall first - warn the user but don't proceed // if text is reinstall, we need to uninstall first - warn the user but don't proceed
if (moduleHolder.moduleInfo != null && moduleHolder.repoModule == null && button.text == button.context.getString(R.string.reinstall)) { if (moduleHolder.moduleInfo != null && moduleHolder.repoModule == null && button.text == button.context.getString(R.string.reinstall)) {
if (!BuildConfig.DEBUG) {
val builder = MaterialAlertDialogBuilder(button.context) val builder = MaterialAlertDialogBuilder(button.context)
builder.setTitle(R.string.reinstall) builder.setTitle(R.string.reinstall)
.setMessage(R.string.reinstall_warning_v2) .setMessage(R.string.reinstall_warning_v2)
@ -168,6 +170,7 @@ enum class ActionButtonType {
.show() .show()
return return
} }
}
// prefer repomodule if possible // prefer repomodule if possible
var updateZipUrl = "" var updateZipUrl = ""
if (moduleHolder.repoModule != null && moduleHolder.repoModule!!.zipUrl != null) { if (moduleHolder.repoModule != null && moduleHolder.repoModule!!.zipUrl != null) {

@ -418,7 +418,8 @@ enum class IntentHelper {;
} }
MainActivity.INSTANCE?.callback = callback MainActivity.INSTANCE?.callback = callback
MainActivity.INSTANCE?.destination = destination MainActivity.INSTANCE?.destination = destination
MainActivity.INSTANCE?.getContent?.launch("*/*") // select zip file
MainActivity.INSTANCE?.getContent?.launch("application/zip")
} }
} }
} }

@ -76,14 +76,13 @@ enum class Http {;
* *
* Note: DNS Cache is stored in user data. * Note: DNS Cache is stored in user data.
*/ */
private class FallBackDNS(context: Context, parent: Dns, vararg fallbacks: String?) : Dns { private class FallBackDNS(parent: Dns, vararg fallbacks: String?) : Dns {
private val parent: Dns private val parent: Dns
private val sharedPreferences: SharedPreferences private val sharedPreferences: SharedPreferences = MainApplication.getPreferences("mmm_dns")!!
private val fallbacks: HashSet<String> private val fallbacks: HashSet<String>
private val fallbackCache: HashMap<String, List<InetAddress>> private val fallbackCache: HashMap<String, List<InetAddress>>
init { init {
sharedPreferences = MainApplication.getPreferences("mmm_dns")!!
this.parent = parent this.parent = parent
this.fallbacks = this.fallbacks =
HashSet(listOf(*fallbacks)).toString().replaceAfter("]", "").replace("[", "") HashSet(listOf(*fallbacks)).toString().replaceAfter("]", "").replace("[", "")
@ -291,11 +290,11 @@ enum class Http {;
} }
// User-Agent format was agreed on telegram // User-Agent format was agreed on telegram
androidacyUA = if (hasWebView) { androidacyUA = if (hasWebView) {
WebSettings.getDefaultUserAgent(mainApplication) WebSettings.getDefaultUserAgent(mainApplication).replaceFirst("(; )?wv".toRegex(), "").replaceFirst(" Version/[^ ]*".toRegex(), "") + " AMM/" + BuildConfig.VERSION_CODE
.replace("wv", "") + " AMMM/" + BuildConfig.VERSION_CODE
} else { } else {
"Mozilla/5.0 (Linux; Android " + Build.VERSION.RELEASE + "; " + Build.DEVICE + ")" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Mobile Safari/537.36" + " AMMM/" + BuildConfig.VERSION_CODE "Mozilla/5.0 (Linux; Android " + Build.VERSION.RELEASE + "; " + Build.DEVICE + ")" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Mobile Safari/537.36" + " AMMM/" + BuildConfig.VERSION_CODE
} }
Timber.i("User-Agent: %s", androidacyUA)
httpclientBuilder.addInterceptor(Interceptor { chain: Interceptor.Chain? -> httpclientBuilder.addInterceptor(Interceptor { chain: Interceptor.Chain? ->
val request: Request.Builder = chain!!.request().newBuilder() val request: Request.Builder = chain!!.request().newBuilder()
request.header("Upgrade-Insecure-Requests", "1") request.header("Upgrade-Insecure-Requests", "1")
@ -383,7 +382,6 @@ enum class Http {;
} }
// Fallback DNS cache responses in case request fail but already succeeded once in the past // Fallback DNS cache responses in case request fail but already succeeded once in the past
fallbackDNS = FallBackDNS( fallbackDNS = FallBackDNS(
mainApplication,
dns, dns,
"github.com", "github.com",
"api.github.com", "api.github.com",

@ -26,7 +26,7 @@
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:widgetLayout="@layout/preference_material_switch" android:widgetLayout="@layout/preference_material_switch"
app:defaultValue="true" app:defaultValue="false"
app:icon="@drawable/ic_reboot_24" app:icon="@drawable/ic_reboot_24"
app:key="pref_prevent_reboot" app:key="pref_prevent_reboot"
app:singleLineTitle="false" app:singleLineTitle="false"

Loading…
Cancel
Save