mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-06-30 21:36:10 -04:00
Remove the build flavors
This is actually a pretty big accomplishment, should be a blog post shortly.
This commit is contained in:
61
app/src/main/java/org/bspeice/minimalbible/MinimalBible.java
Normal file
61
app/src/main/java/org/bspeice/minimalbible/MinimalBible.java
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Created by bspeice on 9/12/14.
|
||||
*/
|
||||
package org.bspeice.minimalbible;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.crosswire.jsword.book.sword.SwordBookPath;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import dagger.ObjectGraph;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
buildObjGraph();
|
||||
setJswordHome();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
17
app/src/main/java/org/bspeice/minimalbible/Modules.java
Normal file
17
app/src/main/java/org/bspeice/minimalbible/Modules.java
Normal file
@ -0,0 +1,17 @@
|
||||
package org.bspeice.minimalbible;
|
||||
|
||||
/**
|
||||
* List modules to be used during testing
|
||||
* Also the entry point for setting whether or not we are using testing mode
|
||||
*/
|
||||
public class Modules {
|
||||
|
||||
private Modules() {
|
||||
}
|
||||
|
||||
public static Object[] list(MinimalBible app) {
|
||||
return new Object[]{
|
||||
new MinimalBibleModules(app),
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user