Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
bubendorf committed Jun 8, 2024
1 parent eab75b3 commit dca4c7b
Show file tree
Hide file tree
Showing 4 changed files with 419 additions and 8 deletions.
21 changes: 15 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ android {
applicationId "mattecarra.accapp"
minSdkVersion 29
targetSdkVersion 33
versionCode 39
versionName "1.0.35"
versionCode 40
versionName "1.1.${versionCode}-" + getDate()
archivesBaseName = "AccA-${versionName}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand All @@ -25,7 +26,9 @@ android {
debug {
signingConfig null
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
applicationIdSuffix '.debug'
versionNameSuffix "-debug"
}
release {
signingConfig null
Expand All @@ -49,6 +52,10 @@ android {
}
}

static def getDate() {
return new Date().format('yyyyMMdd-HHmm')
}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand All @@ -61,14 +68,14 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.vectordrawable:vectordrawable:1.1.0"
implementation "androidx.preference:preference-ktx:1.2.0"
implementation "androidx.preference:preference-ktx:1.2.1"
implementation "androidx.cardview:cardview:1.0.0"

implementation 'com.afollestad.material-dialogs:core:3.3.0'
implementation 'com.afollestad.material-dialogs:input:3.3.0'
implementation 'com.afollestad.material-dialogs:datetime:3.3.0'

implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.code.gson:gson:2.11.0'

implementation "com.github.topjohnwu.libsu:core:$versions.libsuVersion"

Expand Down Expand Up @@ -112,8 +119,10 @@ dependencies {
implementation 'com.squareup.moshi:moshi-kotlin:1.15.0'
ksp "com.squareup.moshi:moshi-kotlin-codegen:1.15.0"


// Fragment KTX module
implementation "androidx.fragment:fragment-ktx:1.6.0"

implementation "ch.acra:acra-http:5.11.3"
implementation "ch.acra:acra-toast:5.11.3"
implementation "ch.acra:acra-limiter:5.11.3"
}
43 changes: 42 additions & 1 deletion app/src/main/java/mattecarra/accapp/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package mattecarra.accapp

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.widget.Toast
import androidx.multidex.MultiDexApplication
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import com.topjohnwu.superuser.Shell
import mattecarra.accapp.utils.LogExt
import org.acra.ACRA.init
import org.acra.config.CoreConfigurationBuilder
import org.acra.config.HttpSenderConfigurationBuilder
import org.acra.config.LimiterConfigurationBuilder
import org.acra.config.ToastConfigurationBuilder
import org.acra.data.StringFormat
import org.acra.security.TLS
import org.acra.sender.HttpSender

class MainApplication: MultiDexApplication()
{
Expand All @@ -28,4 +37,36 @@ class MainApplication: MultiDexApplication()
mDEBUG = (getDefaultSharedPreferences(applicationContext).getString("appdebug", "0") ?: "0").toInt()
LogExt().s(javaClass.simpleName, "DEBUG=$mDEBUG " +when(mDEBUG) {0->"[NONE]" 1->"[CONSOLE]" 2->"[FILE]" else->"[UNKNOWN]"})
}

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
// if (!BuildConfig.DEBUG) {
init(
this, CoreConfigurationBuilder() //core configuration:
.withBuildConfigClass(BuildConfig::class.java)
.withReportFormat(StringFormat.JSON)
.withPluginConfigurations( //each plugin you chose above can be configured with its builder like this:
ToastConfigurationBuilder()
.withText("AccA crashed. Ein Bericht wurde an Markus verschickt.")
.withLength(Toast.LENGTH_LONG)
.build(),
HttpSenderConfigurationBuilder() //required. Https recommended
.withUri("https://acra.bubendorf.net/report") //optional. Enables http basic auth
.withBasicAuthLogin("KHTsEzvtHFxh8czn") //required if above set
.withBasicAuthPassword("Kh7EOjGiMihWzHBE") // defaults to POST
.withHttpMethod(HttpSender.Method.POST) //defaults to 5000ms
.withConnectionTimeout(5000) //defaults to 20000ms
.withSocketTimeout(20000) // defaults to false
.withDropReportsOnTimeout(false) //defaults to false. Recommended if your backend supports it
.withCompress(true) //defaults to all
.withTlsProtocols(TLS.V1_3, TLS.V1_2)
.build(),
LimiterConfigurationBuilder()
.withDeleteReportsOnAppUpdate(true)
.withEnabled(true)
.build()
)
)
// }
}
}
3 changes: 2 additions & 1 deletion app/src/main/java/mattecarra/accapp/acc/Acc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.net.URL
import kotlin.math.abs

object Acc {
const val bundledVersion = 202108310
const val bundledVersion = 202310160
private val FILES_DIR = "/data/data/mattecarra.accapp/files"

/*
Expand All @@ -28,6 +28,7 @@ object Acc {
* */
private fun getAccInterfaceForversion(v: Int): AccInterface {
return when {
v >= 202310160 -> mattecarra.accapp.acc.v202310160.AccHandler(v)
v >= 202107280 -> mattecarra.accapp.acc.v202107280.AccHandler(v)
v >= 202007220 -> mattecarra.accapp.acc.v202107280.AccHandler(v)
v >= 202007030 -> mattecarra.accapp.acc.v202007030.AccHandler(v)
Expand Down
Loading

0 comments on commit dca4c7b

Please sign in to comment.