diff --git a/.gitignore b/.gitignore index 5ecda83bd..2596fef8e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ signing.properties amahi-release-key.keystore .DS* + +# Acra +acra.properties diff --git a/.travis.yml b/.travis.yml index bb4eb1c6d..a2d460a82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,13 @@ language: android before_install: + - yes | sdkmanager "platforms;android-29" - yes | sdkmanager "platforms;android-28" + - yes | sdkmanager "platforms;android-19" jdk: - oraclejdk8 -sudo: required android: components: - tools @@ -14,7 +15,6 @@ android: - platform-tools - build-tools-28.0.3 - android-28 - - android-26 - android-19 - extra-android-support - extra-android-m2repository diff --git a/README.md b/README.md index 9a9e7001b..1dad74c1e 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,24 @@ You will need JDK 1.7+ installed to work with it. Gradle, Android SDK, and proje This is something to keep **private** and you obtain it by sending a message to `support at Amahi dot org`. +2. Set ACRA information -2. Build the application using a command line or using GUI. + ``` + $ vim acra.properties + ``` + ``` + mailto.email = myemail@mydomain.com + ``` + +Enter your personal email in place of `myemail@mydomain.com` + +3. Build the application using a command line or using GUI. ``` $ ./gradlew clean assembleDebug - ``` - -3. Once you have built the application, you will be needing credentials to use the application. Go to Amahi website and create your account, once the account is activated, you will see the description on how to set up the Amahi server. However, this is not strictly needed, as we have a set up of a demo server called "Welcome to Amahi" which you should see even without your own server installed. +4. Once you have built the application, you will be needing credentials to use the application. Go to Amahi website and create your account, once the account is activated, you will see the description on how to set up the Amahi server. However, this is not strictly needed, as we have a set up of a demo server called "Welcome to Amahi" which you should see even without your own server installed. ## Code Style Convention diff --git a/acra.properties.sample b/acra.properties.sample new file mode 100644 index 000000000..1cbfc975a --- /dev/null +++ b/acra.properties.sample @@ -0,0 +1,4 @@ +# Set ACRA mailing information in acra.properties. +# This is something to keep private and can be created by following steps in README.md + +mailto.email = myemail@mydomain.com diff --git a/build.gradle b/build.gradle index b7c5f9285..d6f726fd8 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' - classpath 'io.fabric.tools:gradle:1.26.1' + classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'io.fabric.tools:gradle:1.28.1' } } @@ -52,10 +52,13 @@ android { targetSdkVersion 28 def apiFile = file("api.properties") + def acraFile = file("acra.properties") def apiProperties = new Properties() + def acraProperties = new Properties() - // NOTE-cpg: this fake api is here for the tests to pass + // NOTE-cpg: this fakeApi and fakeAcra is here for the tests to pass def fakeApiFile = file("fakeApi.properties") + def fakeAcraFile = file("fakeAcra.properties") if (apiFile.exists()) { apiProperties.load(apiFile.newInputStream()) @@ -63,11 +66,18 @@ android { apiProperties.load(fakeApiFile.newInputStream()) } + if (acraFile.exists()) { + acraProperties.load(acraFile.newInputStream()) + } else { + acraProperties.load(fakeAcraFile.newInputStream()) + } + buildConfigField "String", "API_URL_AMAHI", formatStringField(apiProperties["url.amahi"]) buildConfigField "String", "API_URL_PROXY", formatStringField(apiProperties["url.proxy"]) buildConfigField "String", "API_CLIENT_ID", formatStringField(apiProperties["client.id"]) buildConfigField "String", "API_CLIENT_SECRET", formatStringField(apiProperties["client.secret"]) buildConfigField "String", "CHROMECAST_APP_ID", formatStringField(apiProperties["chromecast.app.id"]) + buildConfigField "String", "ACRA_EMAIL", formatStringField(acraProperties["mailto.email"]) testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -88,8 +98,8 @@ android { } } compileOptions { - targetCompatibility 1.8 - sourceCompatibility 1.8 + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 } } @@ -171,6 +181,12 @@ dependencies { implementation 'android.arch.persistence.room:runtime:' + rootProject.archRoomVersion annotationProcessor 'android.arch.persistence.room:compiler:' + rootProject.archRoomVersion + def acraVersion = '5.6.1' + implementation "ch.acra:acra-mail:$acraVersion" + implementation "ch.acra:acra-dialog:$acraVersion" + implementation "ch.acra:acra-notification:$acraVersion" + implementation "ch.acra:acra-toast:$acraVersion" + // Uncomment the dependencies below to enable Chuck Interceptor for logging /* debugImplementation 'com.readystatesoftware.chuck:library:1.1.0' diff --git a/fakeAcra.properties b/fakeAcra.properties new file mode 100644 index 000000000..eaeda3d7c --- /dev/null +++ b/fakeAcra.properties @@ -0,0 +1,5 @@ +# Set ACRA mailing information in acra.properties. +# This is something to keep private and can be created by following steps in README.md +# Purpose: This file is required for Tests and Travis checks to pass + +mailto.email = myemail@mydomain.com diff --git a/fakeApi.properties b/fakeApi.properties index 5d0473ebe..b0f2d2482 100644 --- a/fakeApi.properties +++ b/fakeApi.properties @@ -1,6 +1,8 @@ # Set API information in api.properties. # This is something to keep private and you obtain it by asking in the Amahi IRC channel or # send a message to support at Amahi dot org +# Purpose: This file is required for Tests and Travis checks to pass + url.amahi=https://amahi.org url.proxy=https://amahi.org client.id=1234567890 diff --git a/fakeSigning.properties b/fakeSigning.properties index 86d6879d8..5bb671b88 100644 --- a/fakeSigning.properties +++ b/fakeSigning.properties @@ -1,6 +1,8 @@ # Set API information in api.properties. # This is something to keep private and you obtain it by asking in the Amahi IRC channel or # send a message to support at Amahi dot org +# Purpose: This file is required for Tests and Travis checks to pass + keystore.file=debug.keystore keystore.password=android key.alias=androiddebugkey diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fe7c2b518..ea4655882 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jun 09 01:34:57 IST 2019 +#Sat Jul 18 05:49:07 IST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index fd718f4bf..d6626655c 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -33,6 +33,7 @@ + diff --git a/src/main/java/org/amahi/anywhere/AmahiApplication.java b/src/main/java/org/amahi/anywhere/AmahiApplication.java index f3446dd94..41e4b3845 100644 --- a/src/main/java/org/amahi/anywhere/AmahiApplication.java +++ b/src/main/java/org/amahi/anywhere/AmahiApplication.java @@ -27,13 +27,21 @@ import android.os.Build; import android.os.StrictMode; import android.preference.PreferenceManager; + import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatDelegate; import com.crashlytics.android.Crashlytics; +import org.acra.ACRA; +import org.acra.ReportField; +import org.acra.config.CoreConfigurationBuilder; +import org.acra.config.MailSenderConfigurationBuilder; +import org.acra.config.ToastConfigurationBuilder; +import org.acra.data.StringFormat; import org.amahi.anywhere.job.NetConnectivityJob; import org.amahi.anywhere.job.PhotosContentJob; +import org.amahi.anywhere.server.Api; import dagger.ObjectGraph; import io.fabric.sdk.android.Fabric; @@ -43,6 +51,7 @@ * Application declaration. Basically sets things up at the startup time, * such as dependency injection, logging, crash reporting and possible ANR detecting. */ + public class AmahiApplication extends Application { private ObjectGraph injector; @@ -162,7 +171,34 @@ private void createNotificationChannel() { NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(uploadChannel); notificationManager.createNotificationChannel(downloadChannel); - } + @Override + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); + if (isDebugging()) { + + CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this) + .setBuildConfigClass(BuildConfig.class) + .setReportFormat(StringFormat.JSON) + .setAlsoReportToAndroidFramework(true) + .setReportContent(ReportField.APP_VERSION_CODE) + .setReportContent(ReportField.APP_VERSION_NAME) + .setReportContent(ReportField.ANDROID_VERSION) + .setReportContent(ReportField.PHONE_MODEL) + .setReportContent(ReportField.CUSTOM_DATA) + .setReportContent(ReportField.STACK_TRACE) + .setReportContent(ReportField.LOGCAT); + + builder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class) + .setMailTo(Api.getAcraEmail()) + .setEnabled(true); + + builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class) + .setResText(R.string.acra_report_toast) + .setEnabled(true); + + ACRA.init(this, builder); + } + } } diff --git a/src/main/java/org/amahi/anywhere/server/Api.java b/src/main/java/org/amahi/anywhere/server/Api.java index 2ef21718d..e25b87b5f 100644 --- a/src/main/java/org/amahi/anywhere/server/Api.java +++ b/src/main/java/org/amahi/anywhere/server/Api.java @@ -43,4 +43,8 @@ public static String getClientId() { public static String getClientSecret() { return BuildConfig.API_CLIENT_SECRET; } + + public static String getAcraEmail() { + return BuildConfig.ACRA_EMAIL; + } } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4137e2cad..769b6ac8b 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -320,4 +320,6 @@ Go back Select the type of connection you want. You can set it as Auto detect, remote or local area network. + ACRA Log Report Sent! +