Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ jobs:
#
# stat app/google-services.json

- name: "Write Secret Properties"
run: |
echo "${{ secrets.SECRET_PROPERTIES }}" | base64 --decode > secret.properties
wc -l secret.properties

- name: "Write Keystore File"
run: |
echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.key_file }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ app/debug
app/release
# App
local.properties
secret.properties
*.keystore
*.logcat
**/google-services.json
Expand Down
16 changes: 16 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import com.android.build.api.dsl.ApplicationExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.util.Properties

// ACRA - Load credentials from secret.properties
val secretProperties = Properties().apply {
val file = rootProject.file("secret.properties")
if (file.exists()) file.inputStream().use { load(it) }
}

plugins {
alias(libs.plugins.android.application)
Expand All @@ -21,6 +28,12 @@ configure<ApplicationExtension> {
versionName = "0.0.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// ACRA - Acrarium backend setup: https://www.acra.ch/docs/Setup
buildConfigField("String", "ACRA_URI", "\"${secretProperties.getProperty("acra.uri") ?: ""}\"")
buildConfigField("String", "ACRA_USER", "\"${secretProperties.getProperty("acra.user") ?: ""}\"")
buildConfigField("String", "ACRA_PASS", "\"${secretProperties.getProperty("acra.pass") ?: ""}\"")

manifestPlaceholders["firebaseAnalyticsDeactivated"] = false // enabled
manifestPlaceholders["firebaseCrashlyticsEnabled"] = true // enabled
}
Expand Down Expand Up @@ -48,6 +61,7 @@ configure<ApplicationExtension> {

buildFeatures {
viewBinding = true
buildConfig = true
}
}

Expand Down Expand Up @@ -77,6 +91,8 @@ dependencies {
implementation(libs.retrofit)
implementation(libs.converter.moshi)
implementation(libs.photoview)
implementation(libs.acra.http)
implementation(libs.acra.toast)
ksp(libs.moshi.kotlin.codegen)
ksp(libs.androidx.room.compiler)
testImplementation(libs.junit)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<application
android:name=".MainApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/org/cssnr/remotewallpaper/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.cssnr.remotewallpaper

import android.app.Application
import android.content.Context
import android.widget.Toast
import org.acra.config.httpSender
import org.acra.config.toast
import org.acra.data.StringFormat
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender

class MainApplication : Application() {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
initAcra {
// core configuration
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.JSON
httpSender {
uri = BuildConfig.ACRA_URI
basicAuthLogin = BuildConfig.ACRA_USER
basicAuthPassword = BuildConfig.ACRA_PASS
httpMethod = HttpSender.Method.POST
}
// toast configuration
toast {
text = base.getString(R.string.acra_toast_text)
length = Toast.LENGTH_LONG
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
ctx.showFeedbackDialog()
false
}

// Crash Reporting - with disable confirmation
val acraEnable = findPreference<SwitchPreferenceCompat>("acra.enable")
acraEnable?.setOnPreferenceChangeListener { _, newValue ->
Log.d("SettingsFragment", "acra.enable: $newValue")
ctx.toggleAcra(acraEnable, newValue)
false
}
}

private fun updateWorkIntervalSettings(selectedValue: String?) {
Expand All @@ -142,6 +150,24 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}

private fun Context.toggleAcra(switchPreference: SwitchPreferenceCompat, newValue: Any) {
Log.d("SettingsFragment", "toggleAcra: $newValue")
if (newValue as Boolean) {
Log.d("SettingsFragment", "ENABLE ACRA")
switchPreference.isChecked = true
} else {
MaterialAlertDialogBuilder(this)
.setTitle("Please Reconsider")
.setMessage("Crash reports help fix bugs and only anonymous data is sent.")
.setPositiveButton("Disable Anyway") { _, _ ->
Log.d("SettingsFragment", "DISABLE ACRA")
switchPreference.isChecked = false
}
.setNegativeButton("Cancel", null)
.show()
}
}

private fun Context.updateWorkManager(newValue: String?, curValue: String? = null): Boolean {
Log.i("updateWorkManager", "newValue: $newValue - curValue: $curValue")
if (newValue.isNullOrEmpty()) {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/md_frame_bug_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M480,760Q546,760 593,713Q640,666 640,600L640,440Q640,374 593,327Q546,280 480,280Q414,280 367,327Q320,374 320,440L320,600Q320,666 367,713Q414,760 480,760ZM400,640L560,640L560,560L400,560L400,640ZM400,480L560,480L560,400L400,400L400,480ZM480,520Q480,520 480,520L480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520L480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520ZM480,840Q415,840 359.5,808Q304,776 272,720L160,720L160,640L244,640Q241,620 240.5,600Q240,580 240,560L160,560L160,480L240,480Q240,460 240.5,440Q241,420 244,400L160,400L160,320L272,320Q286,297 303.5,277Q321,257 344,242L280,176L336,120L422,206Q450,197 479,197Q508,197 536,206L624,120L680,176L614,242Q637,257 655.5,276.5Q674,296 688,320L800,320L800,400L716,400Q719,420 719.5,440Q720,460 720,480L800,480L800,560L720,560Q720,580 719.5,600Q719,620 716,640L800,640L800,720L688,720Q656,776 600.5,808Q545,840 480,840ZM40,240L40,120Q40,87 63.5,63.5Q87,40 120,40L240,40L240,120L120,120Q120,120 120,120Q120,120 120,120L120,240L40,240ZM240,920L120,920Q87,920 63.5,896.5Q40,873 40,840L40,720L120,720L120,840Q120,840 120,840Q120,840 120,840L240,840L240,920ZM720,920L720,840L840,840Q840,840 840,840Q840,840 840,840L840,720L920,720L920,840Q920,873 896.5,896.5Q873,920 840,920L720,920ZM840,240L840,120Q840,120 840,120Q840,120 840,120L720,120L720,40L840,40Q873,40 896.5,63.5Q920,87 920,120L920,240L840,240Z"/>
</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@
<item>black</item>
<item>liberty</item>
</string-array>

<!-- ACRA Toast -->
<string name="acra_toast_text">App crashed and report sent. Disable reporting in Settings.</string>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,16 @@

</PreferenceCategory>

<PreferenceCategory
android:key="debug_settings"
android:title="Debugging">
<SwitchPreferenceCompat
android:key="acra.enable"
android:title="Enable Crash Reporting"
android:summary="Send Crash Reports"
android:icon="@drawable/md_frame_bug_24px"
android:defaultValue="true" />

</PreferenceCategory>

</PreferenceScreen>
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ okhttp = "5.5.0"
retrofit = "3.0.0"
moshiKotlinCodegen = "1.15.2"
photoview = "1.0.3"
acra = "5.13.1"
# taptargetview = "1.15.0"

# googleServices = "4.4.2"
Expand Down Expand Up @@ -59,6 +60,8 @@ retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref =
converter-moshi = { group = "com.squareup.retrofit2", name = "converter-moshi", version.ref = "retrofit" }
moshi-kotlin-codegen = { group = "com.squareup.moshi", name = "moshi-kotlin-codegen", version.ref = "moshiKotlinCodegen" }
photoview = { group = "io.getstream", name = "photoview", version.ref = "photoview" }
acra-http = { group = "ch.acra", name = "acra-http", version.ref = "acra" }
acra-toast = { group = "ch.acra", name = "acra-toast", version.ref = "acra" }
# taptargetview = { group = "com.getkeepsafe.taptargetview", name = "taptargetview", version.ref = "taptargetview" }

# firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
Expand Down
Loading