diff --git a/.gitignore b/.gitignore index aae4a5d..6bc1386 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,3 @@ app/samsung *~ *.log app/acra.properties -google-services.json diff --git a/README.md b/README.md index ee9c02b..30ee6f4 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ Using Android Studio is the preferred way to build the project. To build from th ./gradlew assembleDebug -### Firebase +### ACRA -SimpleMarkdown makes use of Firebase for crash reports. To integrate with your own project, create a project from the [Firebase Console](https://console.firebase.google.com/) and enable Crashlytics support. Download the `google-services.json` file and place it in the `app/` directory. Additionally, you'll need another `google-services.json` file enabled for the `app.package.name.samsung` version of the app, placed in the `app/src/samsung/` directory. +SimpleMarkdown makes use of [ACRA](https://github.com/ACRA/acra) for crash reports. This requires the presence of the `app/acra.properties` file for building. For your convenience, a `app/acra.properties.sample` file has been provided. ## Contributing diff --git a/app/acra.properties.sample b/app/acra.properties.sample new file mode 100644 index 0000000..bc9f4f5 --- /dev/null +++ b/app/acra.properties.sample @@ -0,0 +1,3 @@ +acraUrl=ACRA_URL +acraUser=ACRA_USER +acraPass=ACRA_PASS diff --git a/app/build.gradle b/app/build.gradle index 9c586d3..5eba941 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,8 @@ apply plugin: 'com.android.application' +Properties acra = new Properties() +acra.load(new FileInputStream("app/acra.properties")) + android { configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1' @@ -24,6 +27,9 @@ android { versionCode 14 versionName "0.4.8" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + buildConfigField "String", "ACRA_URL", "\"${acra.getProperty("url")}\"" + buildConfigField "String", "ACRA_USER", "\"${acra.getProperty("user")}\"" + buildConfigField "String", "ACRA_PASS", "\"${acra.getProperty("pass")}\"" } buildTypes { release { @@ -50,7 +56,7 @@ android { } ext { - firebase_version = '16.1.0' + acraVersion = '5.1.3' support_version = "28.0.0" } @@ -83,10 +89,8 @@ dependencies { implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'io.reactivex.rxjava2:rxjava:2.2.2' - implementation "com.google.firebase:firebase-core:16.0.3" - implementation "com.google.firebase:firebase-perf:$firebase_version" + + implementation "ch.acra:acra-http:$acraVersion" + samsungImplementation project(":IAP5Helper") } - -apply plugin: 'com.google.gms.google-services' -apply plugin: 'com.google.firebase.firebase-perf' diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java b/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java index 2cac106..0595fdd 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java @@ -1,7 +1,23 @@ package com.wbrawner.simplemarkdown; import android.app.Application; +import android.content.Context; +import org.acra.ACRA; +import org.acra.annotation.AcraCore; +import org.acra.annotation.AcraHttpSender; +import org.acra.data.StringFormat; +import org.acra.sender.HttpSender; + +import static com.wbrawner.simplemarkdown.BuildConfig.ACRA_PASS; +import static com.wbrawner.simplemarkdown.BuildConfig.ACRA_URL; +import static com.wbrawner.simplemarkdown.BuildConfig.ACRA_USER; + +@AcraCore(buildConfigClass = BuildConfig.class, reportFormat = StringFormat.JSON) +@AcraHttpSender(uri = ACRA_URL, + basicAuthLogin = ACRA_USER, + basicAuthPassword = ACRA_PASS, + httpMethod = HttpSender.Method.POST) public class MarkdownApplication extends Application { private AppComponent component; @@ -17,4 +33,12 @@ public class MarkdownApplication extends Application { public AppComponent getComponent() { return component; } + + @Override + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); + + // The following line triggers the initialization of ACRA + ACRA.init(this); + } } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/model/MarkdownFile.java b/app/src/main/java/com/wbrawner/simplemarkdown/model/MarkdownFile.java index 87debf3..9c0c47e 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/model/MarkdownFile.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/model/MarkdownFile.java @@ -2,6 +2,8 @@ package com.wbrawner.simplemarkdown.model; import com.wbrawner.simplemarkdown.utility.Utils; +import org.acra.ACRA; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -110,6 +112,7 @@ public class MarkdownFile { this.content = sb.toString(); return true; } catch (IOException e) { + ACRA.getErrorReporter().handleException(e, false); return false; } finally { Utils.closeQuietly(reader); @@ -130,6 +133,7 @@ public class MarkdownFile { this.path = markdownFile.getParentFile().getAbsolutePath(); return load(new FileInputStream(markdownFile)); } catch (FileNotFoundException e) { + ACRA.getErrorReporter().handleException(e, false); return false; } } @@ -155,6 +159,7 @@ public class MarkdownFile { return false; } } catch (IOException e) { + ACRA.getErrorReporter().handleException(e, false); return false; } } @@ -170,12 +175,14 @@ public class MarkdownFile { ); writer.write(this.content); } catch (IOException e) { + ACRA.getErrorReporter().handleException(e, false); return false; } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { + ACRA.getErrorReporter().handleException(e, false); // closing the reader failed } } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java index 9c16e6a..6319739 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java @@ -12,6 +12,8 @@ import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.view.MarkdownEditView; import com.wbrawner.simplemarkdown.view.MarkdownPreviewView; +import org.acra.ACRA; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -51,7 +53,8 @@ public class MarkdownPresenterImpl implements MarkdownPresenter { try { InputStream in = new FileInputStream(file); loadMarkdown(file.getName(), in); - } catch (FileNotFoundException ignored) { + } catch (FileNotFoundException e) { + ACRA.getErrorReporter().handleException(e, false); } } @@ -204,6 +207,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter { } loadMarkdown(fileName, in); } catch (Exception e) { + ACRA.getErrorReporter().handleException(e, false); if (editView != null) { editView.onFileLoaded(false); } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java index c0e1cc6..59b2906 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java @@ -19,6 +19,8 @@ import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.utility.Constants; import com.wbrawner.simplemarkdown.utility.Utils; +import org.acra.ACRA; + import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -117,6 +119,7 @@ public class ExplorerActivity extends AppCompatActivity { try { sdcardSelected = filePath.get().contains(mounts[1].getAbsolutePath()); } catch (NullPointerException e) { + ACRA.getErrorReporter().handleException(e, false); updateListView(); menu.findItem(R.id.action_use_sdcard).setVisible(false); // TODO: Report this? diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java index 8e69be7..7cb50ac 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java @@ -24,6 +24,8 @@ import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.view.DisableableViewPager; import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter; +import org.acra.ACRA; + import java.io.File; import java.io.InputStream; @@ -172,6 +174,7 @@ public class MainActivity extends AppCompatActivity } }); } catch (Exception e) { + ACRA.getErrorReporter().handleException(e, false); Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show(); } } diff --git a/build.gradle b/build.gradle index 130b95c..1a292b3 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,6 @@ buildscript { classpath 'com.android.tools.build:gradle:3.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files - classpath 'com.google.gms:google-services:4.0.1' - classpath 'com.google.firebase:firebase-plugins:1.1.5' } }