Revert replacing Firebase with ACRA

This commit is contained in:
William Brawner 2018-10-15 20:41:33 -05:00 committed by William Brawner
parent decb4d76ff
commit 306e642d43
10 changed files with 57 additions and 12 deletions

1
.gitignore vendored
View file

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

View file

@ -24,9 +24,9 @@ Using Android Studio is the preferred way to build the project. To build from th
./gradlew assembleDebug ./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 ## Contributing

View file

@ -0,0 +1,3 @@
acraUrl=ACRA_URL
acraUser=ACRA_USER
acraPass=ACRA_PASS

View file

@ -1,5 +1,8 @@
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'
@ -24,6 +27,9 @@ android {
versionCode 14 versionCode 14
versionName "0.4.8" versionName "0.4.8"
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 {
@ -50,7 +56,7 @@ android {
} }
ext { ext {
firebase_version = '16.1.0' acraVersion = '5.1.3'
support_version = "28.0.0" support_version = "28.0.0"
} }
@ -83,10 +89,8 @@ 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.1.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.2' 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") samsungImplementation project(":IAP5Helper")
} }
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'

View file

@ -1,7 +1,23 @@
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;
@ -17,4 +33,12 @@ 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,6 +2,8 @@ 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;
@ -110,6 +112,7 @@ 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);
@ -130,6 +133,7 @@ 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;
} }
} }
@ -155,6 +159,7 @@ public class MarkdownFile {
return false; return false;
} }
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} }
} }
@ -170,12 +175,14 @@ 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,6 +12,8 @@ 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;
@ -51,7 +53,8 @@ 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 ignored) { } catch (FileNotFoundException e) {
ACRA.getErrorReporter().handleException(e, false);
} }
} }
@ -204,6 +207,7 @@ 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,6 +19,8 @@ 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;
@ -117,6 +119,7 @@ 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,6 +24,8 @@ 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;
@ -172,6 +174,7 @@ 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

@ -9,8 +9,6 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.2.0' classpath 'com.android.tools.build:gradle:3.2.0'
// 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'
} }
} }