mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
android: Changes to add compatibility with pyjnius/plyer
This commit is contained in:
parent
83038146b3
commit
e02a9989fb
5
direct/src/dist/commands.py
vendored
5
direct/src/dist/commands.py
vendored
@ -157,6 +157,9 @@ from android_log import write as android_log_write
|
||||
sys.frozen = True
|
||||
sys.platform = "android"
|
||||
|
||||
# Temporary hack for plyer to detect Android, see kivy/plyer#670
|
||||
os.environ['ANDROID_ARGUMENT'] = ''
|
||||
|
||||
|
||||
# Replace stdout/stderr with something that writes to the Android log.
|
||||
class AndroidLogStream:
|
||||
@ -735,7 +738,7 @@ class build_apps(setuptools.Command):
|
||||
|
||||
for appname in self.gui_apps:
|
||||
activity = ET.SubElement(application, 'activity')
|
||||
activity.set('android:name', 'org.panda3d.android.PandaActivity')
|
||||
activity.set('android:name', 'org.panda3d.android.PythonActivity')
|
||||
activity.set('android:label', appname)
|
||||
activity.set('android:theme', '@android:style/Theme.NoTitleBar')
|
||||
activity.set('android:configChanges', 'orientation|keyboardHidden')
|
||||
|
@ -6136,6 +6136,9 @@ if PkgSkip("PYTHON") == 0:
|
||||
PyTargetAdd('deploy-stubw.exe', input='deploy-stubw.obj')
|
||||
PyTargetAdd('deploy-stubw.exe', opts=['MACOS_APP_BUNDLE', 'DEPLOYSTUB', 'NOICON'])
|
||||
elif GetTarget() == 'android':
|
||||
TargetAdd('org/jnius/NativeInvocationHandler.class', opts=OPTS, input='NativeInvocationHandler.java')
|
||||
TargetAdd('classes.dex', input='org/jnius/NativeInvocationHandler.class')
|
||||
|
||||
PyTargetAdd('deploy-stubw_android_main.obj', opts=OPTS, input='android_main.cxx')
|
||||
PyTargetAdd('deploy-stubw_android_log.obj', opts=OPTS, input='android_log.c')
|
||||
PyTargetAdd('libdeploy-stubw.dll', input='android_native_app_glue.obj')
|
||||
|
@ -16,8 +16,14 @@ package org.panda3d.android;
|
||||
import org.panda3d.android.PandaActivity;
|
||||
|
||||
/**
|
||||
* This is only declared as a separate class from PandaActivity so that we
|
||||
* can have two separate activity definitions in ApplicationManifest.xml.
|
||||
* Extends PandaActivity with some things that are useful in a Python
|
||||
* application.
|
||||
*/
|
||||
public class PythonActivity extends PandaActivity {
|
||||
// This is required by plyer.
|
||||
public static PythonActivity mActivity;
|
||||
|
||||
public PythonActivity() {
|
||||
mActivity = this;
|
||||
}
|
||||
}
|
||||
|
25
pandatool/src/deploy-stub/NativeInvocationHandler.java
Normal file
25
pandatool/src/deploy-stub/NativeInvocationHandler.java
Normal file
@ -0,0 +1,25 @@
|
||||
package org.jnius;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Special support for pyjnius.
|
||||
*/
|
||||
public class NativeInvocationHandler implements InvocationHandler {
|
||||
private long _ptr;
|
||||
|
||||
public NativeInvocationHandler(long ptr) {
|
||||
_ptr = ptr;
|
||||
}
|
||||
|
||||
public long getPythonObjectPointer() {
|
||||
return _ptr;
|
||||
}
|
||||
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
return invoke0(proxy, method, args);
|
||||
}
|
||||
|
||||
native Object invoke0(Object proxy, Method method, Object[] args);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user