From c9e72dc7b3b8b92b55b7c3157c13ca99c0164de4 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sun, 30 Sep 2018 19:53:03 -0500 Subject: [PATCH] Replace ACRA with Firebase Crashlytics --- .gitignore | 1 + README.md | 10 ++++++++ app/build.gradle | 16 +++++-------- .../simplemarkdown/MarkdownApplication.java | 24 ------------------- .../simplemarkdown/model/MarkdownFile.java | 7 ------ .../presentation/MarkdownPresenterImpl.java | 6 +---- .../view/activity/ExplorerActivity.java | 3 --- .../view/activity/MainActivity.java | 3 --- app/src/main/res/menu/menu_edit.xml | 14 +++++++---- app/src/main/res/values/strings.xml | 1 + build.gradle | 2 ++ 11 files changed, 30 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index 6bc1386..aae4a5d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ app/samsung *~ *.log app/acra.properties +google-services.json diff --git a/README.md b/README.md index e9827de..ee9c02b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,16 @@ creating Android apps and have a little something to put into my portfolio. * [ ] Better insert for tables/images/links * [ ] Quick-insert toolbar for common Markdown syntax characters +## Building + +Using Android Studio is the preferred way to build the project. To build from the command line, you can run + + ./gradlew assembleDebug + +### Firebase + +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. + ## Contributing I'd love any contributions, particularly in improving the existing code. Please just fork the diff --git a/app/build.gradle b/app/build.gradle index 58ad9f1..78a880a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,8 +1,5 @@ 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' @@ -27,9 +24,6 @@ android { versionCode 12 versionName "0.4.6" 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 { @@ -56,7 +50,7 @@ android { } ext { - acraVersion = '5.1.3' + firebase_version = '16.1.0' support_version = "27.1.0" } @@ -89,8 +83,10 @@ dependencies { implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0' implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' implementation 'io.reactivex.rxjava2:rxjava:2.1.0' - - implementation "ch.acra:acra-http:$acraVersion" - + implementation "com.google.firebase:firebase-core:16.0.3" + implementation "com.google.firebase:firebase-perf:$firebase_version" 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 0595fdd..2cac106 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java @@ -1,23 +1,7 @@ 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; @@ -33,12 +17,4 @@ 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 9c0c47e..87debf3 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/model/MarkdownFile.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/model/MarkdownFile.java @@ -2,8 +2,6 @@ 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; @@ -112,7 +110,6 @@ public class MarkdownFile { this.content = sb.toString(); return true; } catch (IOException e) { - ACRA.getErrorReporter().handleException(e, false); return false; } finally { Utils.closeQuietly(reader); @@ -133,7 +130,6 @@ public class MarkdownFile { this.path = markdownFile.getParentFile().getAbsolutePath(); return load(new FileInputStream(markdownFile)); } catch (FileNotFoundException e) { - ACRA.getErrorReporter().handleException(e, false); return false; } } @@ -159,7 +155,6 @@ public class MarkdownFile { return false; } } catch (IOException e) { - ACRA.getErrorReporter().handleException(e, false); return false; } } @@ -175,14 +170,12 @@ 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 6319739..9c16e6a 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java @@ -12,8 +12,6 @@ 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; @@ -53,8 +51,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter { try { InputStream in = new FileInputStream(file); loadMarkdown(file.getName(), in); - } catch (FileNotFoundException e) { - ACRA.getErrorReporter().handleException(e, false); + } catch (FileNotFoundException ignored) { } } @@ -207,7 +204,6 @@ 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 59b2906..c0e1cc6 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,8 +19,6 @@ 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; @@ -119,7 +117,6 @@ 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 1e62ca8..473993b 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,8 +24,6 @@ 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; @@ -167,7 +165,6 @@ 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/app/src/main/res/menu/menu_edit.xml b/app/src/main/res/menu/menu_edit.xml index 8812d16..cc51625 100644 --- a/app/src/main/res/menu/menu_edit.xml +++ b/app/src/main/res/menu/menu_edit.xml @@ -7,17 +7,17 @@ android:title="@string/action_share" app:showAsAction="ifRoom" /> + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 69bc8c9..016c2e0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -41,6 +41,7 @@ Default Root Directory Select \u2191 Go up + Privacy @string/value_edit_view @string/value_explorer_view diff --git a/build.gradle b/build.gradle index 25063b7..20b741a 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,8 @@ buildscript { classpath 'com.android.tools.build:gradle:3.1.4' // 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' } }