Skip to content

Commit

Permalink
Merge pull request #42 from turbolent/turbolent/improve-android
Browse files Browse the repository at this point in the history
Improve Android app
Matt: Tested and working. Thank you!
  • Loading branch information
MatthiasWM authored May 18, 2018
2 parents 4ce3c54 + 5f37711 commit bf8dc69
Show file tree
Hide file tree
Showing 28 changed files with 1,244 additions and 1,424 deletions.
9 changes: 6 additions & 3 deletions _Build_/AndroidStudio/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.newtonforever.einstein"
minSdkVersion 15
targetSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -18,7 +18,6 @@ android {
}
}
ndk {
// abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
abiFilters 'x86', 'armeabi-v7a'
}

Expand All @@ -34,9 +33,13 @@ android {
path "CMakeLists.txt"
}
}
lintOptions{
lintOptions {
disable 'MissingTranslation'
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
Expand Down
7 changes: 4 additions & 3 deletions _Build_/AndroidStudio/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar">
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -36,15 +36,15 @@
android:name="com.newtonforever.einstein.activity.ActionsActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Dialog">
android:theme="@style/Theme.AppCompat.Dialog">
</activity>
<activity android:name="com.newtonforever.einstein.activity.EinsteinPreferencesActivity">
</activity>
<activity
android:name="com.newtonforever.einstein.activity.LoadPackageActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Dialog">
android:theme="@style/Theme.AppCompat.Dialog">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

Expand Down Expand Up @@ -146,6 +146,7 @@
</activity>

<service
android:exported="false"
android:name="com.newtonforever.einstein.EinsteinService"
android:process=":remote">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@

import com.newtonforever.einstein.jni.Native;

/** Class interfacing to the native Einstein emulator.
* @author Matthias Melcher */
public class Einstein
{
/** Load the entire native program as a library at startup. */
static {
System.loadLibrary("native-lib");
}
private boolean pRunning = false;
/**
* Class interfacing to the native Einstein emulator.
*
* @author Matthias Melcher
*/
public class Einstein {
/* Load the entire native program as a library at startup. */
static {
System.loadLibrary("native-lib");
}

public void run(String dataPath, int screenWidth, int screenHeight)
{
Native.runEmulator(dataPath, screenWidth, screenHeight);
this.pRunning = true;
}

/** Returns <code>true</code> if the emulator is currently running. */
public boolean isRunning()
{
return this.pRunning;
}
private boolean isRunning = false;

public void run(String dataPath, int screenWidth, int screenHeight) {
Native.runEmulator(dataPath, screenWidth, screenHeight);
isRunning = true;
}

/**
* Returns <code>true</code> if the emulator is currently running.
*/
public boolean isRunning() {
return isRunning;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,69 +82,64 @@ - interface to Android API

/**
* This class provides resources that must be available for the lifetime of this app.
*
* @author Matthias Melcher
*
* @author Matthias Melcher
*/
public class EinsteinApplication extends Application {

private Einstein pEinstein = null;

/**
* Get a link to the native emulator interface.
*
* @return access to the emulator
*/
public Einstein getEinstein()
{
return pEinstein;
}

/**
* Initialize what we need besides the Activity.
*
* Create the Einstein instance that is shared across Activities.
* Create a Service that will keep this app in the foreground as
* long as possible to avoid lengty emulator reboots.
*/
@Override
public void onCreate()
{
//Log.i("einstein", "--------> App.onCreate()");

super.onCreate();

// create and load the Emulator
pEinstein = new Einstein();

// create the keep-alive Service (will be created asynchronously)
Intent intent = new Intent(getApplicationContext(), EinsteinService.class);
intent.putExtra("task", EinsteinService.TASK_LAUNCH);
ComponentName name = startService(intent);
if (name==null) {
Log.i("einstein", "--------< App.onCreate() - CANT LAUNCH SERVICE");
}
//Log.i("einstein", "--------< App.onCreate()");
}

/**
* Use the Service to keep this application around as long as possible.
*/
public void raisePriority()
{
Intent intent = new Intent(getApplicationContext(), EinsteinService.class);
private Einstein pEinstein = null;

/**
* Get a link to the native emulator interface.
*
* @return access to the emulator
*/
public Einstein getEinstein() {
return pEinstein;
}

/**
* Initialize what we need besides the Activity.
* <p>
* Create the Einstein instance that is shared across Activities.
* Create a Service that will keep this app in the foreground as
* long as possible to avoid lengty emulator reboots.
*/
@Override
public void onCreate() {
//Log.i("einstein", "--------> App.onCreate()");

super.onCreate();

// create and load the Emulator
pEinstein = new Einstein();

// create the keep-alive Service (will be created asynchronously)
Intent intent = new Intent(getApplicationContext(), EinsteinService.class);
intent.putExtra("task", EinsteinService.TASK_LAUNCH);
ComponentName name = startService(intent);
if (name == null) {
Log.i("einstein", "--------< App.onCreate() - CANT LAUNCH SERVICE");
}
//Log.i("einstein", "--------< App.onCreate()");
}

/**
* Use the Service to keep this application around as long as possible.
*/
public void raisePriority() {
Intent intent = new Intent(getApplicationContext(), EinsteinService.class);
intent.putExtra("task", EinsteinService.TASK_RAISE_PRIORITY);
startService(intent);
}

/**
* Return this app to normal priority by sending the service to the background.
*/
public void normalPriority()
{
Intent intent = new Intent(getApplicationContext(), EinsteinService.class);
startService(intent);
}

/**
* Return this app to normal priority by sending the service to the background.
*/
public void normalPriority() {
Intent intent = new Intent(getApplicationContext(), EinsteinService.class);
intent.putExtra("task", EinsteinService.TASK_NORMAL_PRIORITY);
startService(intent);
}
startService(intent);
}

}
Loading

0 comments on commit bf8dc69

Please sign in to comment.