mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2025-04-12 04:00:48 +00:00
wip: added multi activity solution
ETLMain Activity will start upon clicking App icon, will download required file / check for existing file then start another ETLActivity so we can start fragging.
This commit is contained in:
parent
94f21f33ad
commit
cbc1b2a069
5 changed files with 87 additions and 90 deletions
|
@ -1,79 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Replace com.test.game with the identifier of your game below, e.g.
|
||||
com.gamemaker.game
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.etlegacy.app"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
android:versionName="1.0" >
|
||||
<!-- OpenGL ES 1.1 -->
|
||||
<uses-feature android:glEsVersion="0x00010001" />
|
||||
<!-- Touchscreen support -->
|
||||
<uses-feature android:glEsVersion="0x00010001" /> <!-- Touchscreen support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Game controller support -->
|
||||
android:required="false" /> <!-- Game controller support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.gamepad"
|
||||
android:required="false" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.usb.host"
|
||||
android:required="false" />
|
||||
|
||||
<!-- External mouse input events -->
|
||||
android:required="false" /> <!-- External mouse input events -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.type.pc"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Allow access to internet -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- Allow writing to external storage and reading from it -->
|
||||
android:required="false" /> <!-- Allow access to internet -->
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- Allow writing to external storage and reading from it -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- Allow access to bluetooth -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- Allow access to bluetooth -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" /> <!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
|
||||
An example Java class can be found in README-android.md
|
||||
-->
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:hardwareAccelerated="true" >
|
||||
|
||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
||||
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
|
||||
-->
|
||||
|
||||
<activity android:name=".ETLActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||
android:largeHeap="true"
|
||||
>
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
<activity
|
||||
android:name=".ETLMain"
|
||||
android:screenOrientation="landscape" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
<!--
|
||||
Example of setting SDL hints from AndroidManifest.xml:
|
||||
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
|
||||
-->
|
||||
<activity
|
||||
android:name=".ETLActivity"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||
android:hardwareAccelerated="true"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:screenOrientation="landscape" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
|
@ -15,19 +15,15 @@ import android.view.ViewGroup;
|
|||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.erz.joysticklibrary.JoyStick;
|
||||
import com.erz.joysticklibrary.JoyStick.JoyStickListener;
|
||||
import com.google.common.io.Files;
|
||||
import com.loopj.android.http.AsyncHttpClient;
|
||||
import com.loopj.android.http.FileAsyncHttpResponseHandler;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
|
||||
public class ETLActivity extends SDLActivity implements JoyStickListener {
|
||||
|
||||
|
@ -40,8 +36,8 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
|
||||
public void runUI() {
|
||||
|
||||
// Use runThread() instead ?
|
||||
// FIXME When you disconnect from server UI is enabled
|
||||
// Use runThread() instead ?
|
||||
// FIXME When you disconnect from server UI is enabled
|
||||
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
|
@ -260,9 +256,6 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static int pxToDp(int px) {
|
||||
return (int) (px / Resources.getSystem().getDisplayMetrics().density);
|
||||
}
|
||||
|
@ -281,31 +274,8 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
/*
|
||||
TODO: Keep it for now. Find a way to download pak0 before ETL lib is launched.
|
||||
AsyncHttpClient client = new AsyncHttpClient();
|
||||
client.get("http://mirror.etlegacy.com/etmain/pak0.pk3", new FileAsyncHttpResponseHandler(this) {
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, File response) {
|
||||
// Do something with the file `response`
|
||||
if (response.exists()) {
|
||||
try {
|
||||
Files.move(response.getAbsoluteFile(), new File(getExternalFilesDir(null), "pak2.pk3"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {
|
||||
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -431,8 +401,8 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
@Override
|
||||
protected String[] getLibraries() {
|
||||
return new String[] {
|
||||
"hidapi",
|
||||
"SDL2",
|
||||
// "hidapi",
|
||||
// "SDL2",
|
||||
"etl"
|
||||
};
|
||||
}
|
||||
|
|
47
app/src/main/java/org/etlegacy/app/ETLMain.java
Normal file
47
app/src/main/java/org/etlegacy/app/ETLMain.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package org.etlegacy.app;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.loopj.android.http.AsyncHttpClient;
|
||||
import com.loopj.android.http.FileAsyncHttpResponseHandler;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
|
||||
public class ETLMain extends SDLActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AsyncHttpClient client = new AsyncHttpClient();
|
||||
client.get("http://mirror.etlegacy.com/etmain/pak2.pk3", new FileAsyncHttpResponseHandler(this) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, File file) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
super.onFinish();
|
||||
try {
|
||||
Files.move(getApplication().getCacheDir().getAbsoluteFile(), new File(getExternalFilesDir(null), "pak2.pk3"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
startActivity(new Intent(getApplicationContext(), ETLActivity.class));
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
BIN
app/src/main/jniLibs/arm64-v8a/libmain.so
Executable file
BIN
app/src/main/jniLibs/arm64-v8a/libmain.so
Executable file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libmain.so
Executable file
BIN
app/src/main/jniLibs/armeabi-v7a/libmain.so
Executable file
Binary file not shown.
Loading…
Reference in a new issue