Replace ACRA with Firebase Crashlytics

This commit is contained in:
William Brawner 2018-09-30 19:53:03 -05:00 committed by William Brawner
parent 35d077190d
commit c9e72dc7b3
11 changed files with 30 additions and 57 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@ app/samsung
*~ *~
*.log *.log
app/acra.properties app/acra.properties
google-services.json

View file

@ -18,6 +18,16 @@ creating Android apps and have a little something to put into my portfolio.
* [ ] Better insert for tables/images/links * [ ] Better insert for tables/images/links
* [ ] Quick-insert toolbar for common Markdown syntax characters * [ ] 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 ## Contributing
I'd love any contributions, particularly in improving the existing code. Please just fork the I'd love any contributions, particularly in improving the existing code. Please just fork the

View file

@ -1,8 +1,5 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
Properties acra = new Properties()
acra.load(new FileInputStream("app/acra.properties"))
android { android {
configurations.all { configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1' resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
@ -27,9 +24,6 @@ android {
versionCode 12 versionCode 12
versionName "0.4.6" versionName "0.4.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 { buildTypes {
release { release {
@ -56,7 +50,7 @@ android {
} }
ext { ext {
acraVersion = '5.1.3' firebase_version = '16.1.0'
support_version = "27.1.0" support_version = "27.1.0"
} }
@ -89,8 +83,10 @@ dependencies {
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0' implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0' implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
implementation "com.google.firebase:firebase-core:16.0.3"
implementation "ch.acra:acra-http:$acraVersion" implementation "com.google.firebase:firebase-perf:$firebase_version"
samsungImplementation project(":IAP5Helper") samsungImplementation project(":IAP5Helper")
} }
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'

View file

@ -1,23 +1,7 @@
package com.wbrawner.simplemarkdown; package com.wbrawner.simplemarkdown;
import android.app.Application; 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 { public class MarkdownApplication extends Application {
private AppComponent component; private AppComponent component;
@ -33,12 +17,4 @@ public class MarkdownApplication extends Application {
public AppComponent getComponent() { public AppComponent getComponent() {
return component; return component;
} }
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
} }

View file

@ -2,8 +2,6 @@ package com.wbrawner.simplemarkdown.model;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import org.acra.ACRA;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -112,7 +110,6 @@ public class MarkdownFile {
this.content = sb.toString(); this.content = sb.toString();
return true; return true;
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} finally { } finally {
Utils.closeQuietly(reader); Utils.closeQuietly(reader);
@ -133,7 +130,6 @@ public class MarkdownFile {
this.path = markdownFile.getParentFile().getAbsolutePath(); this.path = markdownFile.getParentFile().getAbsolutePath();
return load(new FileInputStream(markdownFile)); return load(new FileInputStream(markdownFile));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} }
} }
@ -159,7 +155,6 @@ public class MarkdownFile {
return false; return false;
} }
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} }
} }
@ -175,14 +170,12 @@ public class MarkdownFile {
); );
writer.write(this.content); writer.write(this.content);
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} finally { } finally {
if (writer != null) { if (writer != null) {
try { try {
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
// closing the reader failed // closing the reader failed
} }
} }

View file

@ -12,8 +12,6 @@ import com.wbrawner.simplemarkdown.utility.Utils;
import com.wbrawner.simplemarkdown.view.MarkdownEditView; import com.wbrawner.simplemarkdown.view.MarkdownEditView;
import com.wbrawner.simplemarkdown.view.MarkdownPreviewView; import com.wbrawner.simplemarkdown.view.MarkdownPreviewView;
import org.acra.ACRA;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -53,8 +51,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
try { try {
InputStream in = new FileInputStream(file); InputStream in = new FileInputStream(file);
loadMarkdown(file.getName(), in); loadMarkdown(file.getName(), in);
} catch (FileNotFoundException e) { } catch (FileNotFoundException ignored) {
ACRA.getErrorReporter().handleException(e, false);
} }
} }
@ -207,7 +204,6 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
} }
loadMarkdown(fileName, in); loadMarkdown(fileName, in);
} catch (Exception e) { } catch (Exception e) {
ACRA.getErrorReporter().handleException(e, false);
if (editView != null) { if (editView != null) {
editView.onFileLoaded(false); editView.onFileLoaded(false);
} }

View file

@ -19,8 +19,6 @@ import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.utility.Constants; import com.wbrawner.simplemarkdown.utility.Constants;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import org.acra.ACRA;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -119,7 +117,6 @@ public class ExplorerActivity extends AppCompatActivity {
try { try {
sdcardSelected = filePath.get().contains(mounts[1].getAbsolutePath()); sdcardSelected = filePath.get().contains(mounts[1].getAbsolutePath());
} catch (NullPointerException e) { } catch (NullPointerException e) {
ACRA.getErrorReporter().handleException(e, false);
updateListView(); updateListView();
menu.findItem(R.id.action_use_sdcard).setVisible(false); menu.findItem(R.id.action_use_sdcard).setVisible(false);
// TODO: Report this? // TODO: Report this?

View file

@ -24,8 +24,6 @@ import com.wbrawner.simplemarkdown.utility.Utils;
import com.wbrawner.simplemarkdown.view.DisableableViewPager; import com.wbrawner.simplemarkdown.view.DisableableViewPager;
import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter; import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter;
import org.acra.ACRA;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
@ -167,7 +165,6 @@ public class MainActivity extends AppCompatActivity
} }
}); });
} catch (Exception e) { } catch (Exception e) {
ACRA.getErrorReporter().handleException(e, false);
Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show(); Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show();
} }
} }

View file

@ -7,17 +7,17 @@
android:title="@string/action_share" android:title="@string/action_share"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_save" android:id="@+id/action_new"
android:icon="@drawable/ic_action_save" android:title="@string/action_new"
android:title="@string/action_save"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_load" android:id="@+id/action_load"
android:title="@string/action_open" android:title="@string/action_open"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_new" android:id="@+id/action_save"
android:title="@string/action_new" android:icon="@drawable/ic_action_save"
android:title="@string/action_save"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_lock_swipe" android:id="@+id/action_lock_swipe"
@ -36,4 +36,8 @@
android:id="@+id/action_libraries" android:id="@+id/action_libraries"
android:title="@string/action_libraries" android:title="@string/action_libraries"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/action_privacy"
android:title="@string/action_privacy"
app:showAsAction="never" />
</menu> </menu>

View file

@ -41,6 +41,7 @@
<string name="pref_description_default_root">Default Root Directory</string> <string name="pref_description_default_root">Default Root Directory</string>
<string name="action_select">Select</string> <string name="action_select">Select</string>
<string name="directory_up">\u2191 Go up</string> <string name="directory_up">\u2191 Go up</string>
<string name="action_privacy">Privacy</string>
<string-array name="pref_entries_default_view"> <string-array name="pref_entries_default_view">
<item>@string/value_edit_view</item> <item>@string/value_edit_view</item>
<item>@string/value_explorer_view</item> <item>@string/value_explorer_view</item>

View file

@ -9,6 +9,8 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.1.4' classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // 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'
} }
} }