[UI] android.app.NativeActivity > WindowedAppActivity + code style

This commit is contained in:
Triang3l
2021-09-18 20:32:24 +03:00
parent 347c9f01fd
commit 26a2d814da
10 changed files with 377 additions and 106 deletions

View File

@@ -2,12 +2,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.xenia.emulator">
<uses-feature android:name="android.hardware.vulkan.level" android:version="0" android:required="true" />
<uses-feature android:name="android.hardware.vulkan.version" android:version="0x400000" android:required="true" />
<!-- Granted automatically - guest sockets -->
<uses-feature
android:name="android.hardware.vulkan.level"
android:required="true"
android:version="0" />
<uses-feature
android:name="android.hardware.vulkan.version"
android:required="true"
android:version="0x400000" />
<!-- Granted automatically - guest sockets. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Needs to be requested - loading games from outside the app data directory -->
<!-- WRITE_EXTERNAL_STORAGE is not required to write to the external app data directory since API 19 -->
<!--
Needs to be requested - loading games from outside the app data directory.
WRITE_EXTERNAL_STORAGE is not required to write to the external app data directory since API 19.
-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
@@ -17,12 +28,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light">
<activity android:name="jp.xenia.emulator.DemoActivity">
<activity android:name="jp.xenia.emulator.WindowDemoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -1,12 +0,0 @@
package jp.xenia.emulator;
import android.app.Activity;
import android.os.Bundle;
public class DemoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
}
}

View File

@@ -0,0 +1,8 @@
package jp.xenia.emulator;
public class WindowDemoActivity extends WindowedAppActivity {
@Override
protected String getWindowedAppIdentifier() {
return "xenia_ui_window_vulkan_demo";
}
}

View File

@@ -0,0 +1,45 @@
package jp.xenia.emulator;
import android.app.Activity;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.util.Log;
public abstract class WindowedAppActivity extends Activity {
private static final String TAG = "WindowedAppActivity";
static {
// TODO(Triang3l): Move all demos to libxenia.so.
System.loadLibrary("xenia-ui-window-vulkan-demo");
}
private long mAppContext;
private native long initializeWindowedAppOnCreateNative(
String windowedAppIdentifier, AssetManager assetManager);
private native void onDestroyNative(long appContext);
protected abstract String getWindowedAppIdentifier();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAppContext = initializeWindowedAppOnCreateNative(getWindowedAppIdentifier(), getAssets());
if (mAppContext == 0) {
Log.e(TAG, "Error initializing the windowed app");
finish();
return;
}
}
@Override
protected void onDestroy() {
if (mAppContext != 0) {
onDestroyNative(mAppContext);
}
mAppContext = 0;
super.onDestroy();
}
}

View File

@@ -3,6 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jp.xenia.emulator.DemoActivity">
tools:context="jp.xenia.emulator.WindowDemoActivity">
</RelativeLayout>