From cbb4b5fd145a0b3d23896699fb0862e6eb07d16b Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 12 Sep 2014 22:23:48 -0400 Subject: [PATCH] Add a whole lot of debug goodies --- app/build.gradle | 9 ++- .../bspeice/minimalbible/MinimalBible.java | 15 +++-- .../bspeice/minimalbible/MinimalBible.java | 66 +++++++++++++++++++ 3 files changed, 82 insertions(+), 8 deletions(-) rename app/src/{main => mainConfig}/java/org/bspeice/minimalbible/MinimalBible.java (91%) create mode 100644 app/src/testConfig/java/org/bspeice/minimalbible/MinimalBible.java diff --git a/app/build.gradle b/app/build.gradle index 99f175f..4a79309 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,12 +7,14 @@ buildscript { dependencies { classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.jakewharton.hugo:hugo-plugin:+' } } apply plugin: 'android-sdk-manager' apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'hugo' android { compileSdkVersion 20 @@ -42,14 +44,15 @@ android { exclude 'NOTICE' exclude 'asm-license.txt' } + // TODO: Remove Hugo and support SDK 8? productFlavors { testConfig { - minSdkVersion 8 + minSdkVersion 9 applicationId 'org.bspeice.minimalbible' targetSdkVersion 20 } mainConfig { - minSdkVersion 8 + minSdkVersion 9 applicationId 'org.bspeice.minimalbible' targetSdkVersion 20 } @@ -82,4 +85,6 @@ dependencies { androidTestCompile 'com.google.dexmaker:dexmaker:+' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:+' + // Email debug reports if I crash... + testConfigCompile 'ch.acra:acra:+' } \ No newline at end of file diff --git a/app/src/main/java/org/bspeice/minimalbible/MinimalBible.java b/app/src/mainConfig/java/org/bspeice/minimalbible/MinimalBible.java similarity index 91% rename from app/src/main/java/org/bspeice/minimalbible/MinimalBible.java rename to app/src/mainConfig/java/org/bspeice/minimalbible/MinimalBible.java index 3fcca64..177bb46 100644 --- a/app/src/main/java/org/bspeice/minimalbible/MinimalBible.java +++ b/app/src/mainConfig/java/org/bspeice/minimalbible/MinimalBible.java @@ -1,3 +1,6 @@ +/** + * Created by bspeice on 9/12/14. + */ package org.bspeice.minimalbible; import android.app.Application; @@ -11,12 +14,16 @@ import java.io.File; import dagger.ObjectGraph; /** - * Created by Bradlee Speice on 7/5/2014. + * Created by bspeice on 9/12/14. */ public class MinimalBible extends Application implements Injector { private String TAG = "MinimalBible"; private ObjectGraph mObjectGraph; + public static MinimalBible get(Context ctx) { + return (MinimalBible) ctx.getApplicationContext(); + } + @Override public void onCreate() { super.onCreate(); @@ -36,10 +43,6 @@ public class MinimalBible extends Application implements Injector { return mObjectGraph.plus(modules); } - public static MinimalBible get(Context ctx) { - return (MinimalBible)ctx.getApplicationContext(); - } - /** * Notify jSword that it needs to store files in the Android internal directory * NOTE: Android will uninstall these files if you uninstall MinimalBible. @@ -55,4 +58,4 @@ public class MinimalBible extends Application implements Injector { SwordBookPath.setDownloadDir(new File(home)); Log.d(TAG, "Sword download path: " + SwordBookPath.getSwordDownloadDir()); } -} +} \ No newline at end of file diff --git a/app/src/testConfig/java/org/bspeice/minimalbible/MinimalBible.java b/app/src/testConfig/java/org/bspeice/minimalbible/MinimalBible.java new file mode 100644 index 0000000..21f701b --- /dev/null +++ b/app/src/testConfig/java/org/bspeice/minimalbible/MinimalBible.java @@ -0,0 +1,66 @@ +package org.bspeice.minimalbible; + +import android.app.Application; +import android.content.Context; +import android.util.Log; + +import org.acra.ACRA; +import org.acra.ReportingInteractionMode; +import org.acra.annotation.ReportsCrashes; +import org.crosswire.jsword.book.sword.SwordBookPath; + +import java.io.File; + +import dagger.ObjectGraph; + +/** + * Created by bspeice on 9/12/14. + */ +@ReportsCrashes(formKey = "", + mailTo = "bspeice.nc@gmail.com", + mode = ReportingInteractionMode.SILENT +) +public class MinimalBible extends Application implements Injector { + private String TAG = "MinimalBible"; + private ObjectGraph mObjectGraph; + + public static MinimalBible get(Context ctx) { + return (MinimalBible) ctx.getApplicationContext(); + } + + @Override + public void onCreate() { + super.onCreate(); + buildObjGraph(); + setJswordHome(); + ACRA.init(this); + } + + public void buildObjGraph() { + mObjectGraph = ObjectGraph.create(Modules.list(this)); + } + + public void inject(Object o) { + mObjectGraph.inject(o); + } + + public ObjectGraph plus(Object... modules) { + return mObjectGraph.plus(modules); + } + + /** + * Notify jSword that it needs to store files in the Android internal directory + * NOTE: Android will uninstall these files if you uninstall MinimalBible. + */ + @SuppressWarnings("null") + private void setJswordHome() { + // We need to set the download directory for jSword to stick with + // Android. + String home = this.getFilesDir().toString(); + Log.d(TAG, "Setting jsword.home to: " + home); + System.setProperty("jsword.home", home); + System.setProperty("sword.home", home); + SwordBookPath.setDownloadDir(new File(home)); + Log.d(TAG, "Sword download path: " + SwordBookPath.getSwordDownloadDir()); + } +} \ No newline at end of file