mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-05 07:44:43 -04:00
Switch off build variants to build types
Should be much easier to maintain
This commit is contained in:
9
app/src/debug/AndroidManifest.xml
Normal file
9
app/src/debug/AndroidManifest.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name="org.bspeice.minimalbible.test.activity.FragmentTestActivity"
|
||||
android:label="@string/title_activity_fragment_test"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -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());
|
||||
}
|
||||
}
|
20
app/src/debug/java/org/bspeice/minimalbible/Modules.java
Normal file
20
app/src/debug/java/org/bspeice/minimalbible/Modules.java
Normal file
@ -0,0 +1,20 @@
|
||||
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 {
|
||||
|
||||
public static TestModules testModules = new TestModules();
|
||||
|
||||
private Modules() {
|
||||
}
|
||||
|
||||
public static Object[] list(MinimalBible app) {
|
||||
return new Object[]{
|
||||
new MinimalBibleModules(app),
|
||||
testModules
|
||||
};
|
||||
}
|
||||
}
|
54
app/src/debug/java/org/bspeice/minimalbible/TestModules.java
Normal file
54
app/src/debug/java/org/bspeice/minimalbible/TestModules.java
Normal file
@ -0,0 +1,54 @@
|
||||
package org.bspeice.minimalbible;
|
||||
|
||||
|
||||
import org.bspeice.minimalbible.activity.downloader.DownloadActivity;
|
||||
import org.bspeice.minimalbible.service.manager.BookManager;
|
||||
import org.crosswire.jsword.book.BookCategory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Created by Bradlee Speice on 7/5/2014.
|
||||
*/
|
||||
@Module(injects = DownloadActivity.class,
|
||||
overrides = true,
|
||||
library = true)
|
||||
public class TestModules {
|
||||
|
||||
public static CharSequence testActivityTitle = "Test";
|
||||
private BookManager bookManager;
|
||||
|
||||
@Provides
|
||||
CharSequence provideString() {
|
||||
return testActivityTitle;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("ValidCategories")
|
||||
List<BookCategory> provideValidCategories() {
|
||||
return new ArrayList<BookCategory>() {{
|
||||
add(BookCategory.BIBLE);
|
||||
add(BookCategory.COMMENTARY);
|
||||
add(BookCategory.DICTIONARY);
|
||||
add(BookCategory.MAPS);
|
||||
}};
|
||||
}
|
||||
|
||||
public void setBookManager(BookManager bookManager) {
|
||||
this.bookManager = bookManager;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
BookManager provideBookManager() {
|
||||
return bookManager;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package org.bspeice.minimalbible.test.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.bspeice.minimalbible.R;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class FragmentTestActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_fragment_test);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.fragment_test, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void startFragment(Fragment f) {
|
||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.container, f)
|
||||
.commit();
|
||||
|
||||
// Do the ugly work of waiting for the transaction to complete...
|
||||
final CountDownLatch signal = new CountDownLatch(1);
|
||||
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fragmentManager.executePendingTransactions();
|
||||
signal.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
signal.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
7
app/src/debug/res/layout/activity_fragment_test.xml
Normal file
7
app/src/debug/res/layout/activity_fragment_test.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="org.bspeice.minimalbible.test.activity.FragmentTestActivity"
|
||||
tools:ignore="MergeRootFrame" />
|
10
app/src/debug/res/menu/fragment_test.xml
Normal file
10
app/src/debug/res/menu/fragment_test.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="org.bspeice.minimalbible.test.activity.FragmentTestActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
6
app/src/debug/res/values-w820dp/dimens.xml
Normal file
6
app/src/debug/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
5
app/src/debug/res/values/dimens.xml
Normal file
5
app/src/debug/res/values/dimens.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
5
app/src/debug/res/values/strings.xml
Normal file
5
app/src/debug/res/values/strings.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<string name="title_activity_fragment_test">FragmentTestActivity</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
</resources>
|
Reference in New Issue
Block a user