|
|
@@ -37,7 +37,8 @@ import android.content.pm.ApplicationInfo;
|
|
|
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
|
|
|
private static final String TAG = "SDL";
|
|
|
|
|
|
- public static boolean mIsResumedCalled, mIsSurfaceReady, mHasFocus;
|
|
|
+ public static boolean mIsResumedCalled, mHasFocus;
|
|
|
+ public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24);
|
|
|
|
|
|
// Cursor types
|
|
|
private static final int SDL_SYSTEM_CURSOR_NONE = -1;
|
|
|
@@ -70,15 +71,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
public static NativeState mNextNativeState;
|
|
|
public static NativeState mCurrentNativeState;
|
|
|
|
|
|
- public static boolean mExitCalledFromJava;
|
|
|
-
|
|
|
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
|
|
|
public static boolean mBrokenLibraries;
|
|
|
|
|
|
- // If we want to separate mouse and touch events.
|
|
|
- // This is only toggled in native code when a hint is set!
|
|
|
- public static boolean mSeparateMouseAndTouch;
|
|
|
-
|
|
|
// Main components
|
|
|
protected static SDLActivity mSingleton;
|
|
|
protected static SDLSurface mSurface;
|
|
|
@@ -98,7 +93,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
if (mMotionListener == null) {
|
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
|
mMotionListener = new SDLGenericMotionListener_API26();
|
|
|
- } else
|
|
|
+ } else
|
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
|
mMotionListener = new SDLGenericMotionListener_API24();
|
|
|
} else {
|
|
|
@@ -142,6 +137,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
*/
|
|
|
protected String[] getLibraries() {
|
|
|
return new String[] {
|
|
|
+ "hidapi",
|
|
|
"SDL2",
|
|
|
// "SDL2_image",
|
|
|
// "SDL2_mixer",
|
|
|
@@ -179,10 +175,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
mCursors = new Hashtable<Integer, PointerIcon>();
|
|
|
mLastCursorID = 0;
|
|
|
mSDLThread = null;
|
|
|
- mExitCalledFromJava = false;
|
|
|
mBrokenLibraries = false;
|
|
|
mIsResumedCalled = false;
|
|
|
- mIsSurfaceReady = false;
|
|
|
mHasFocus = true;
|
|
|
mNextNativeState = NativeState.INIT;
|
|
|
mCurrentNativeState = NativeState.INIT;
|
|
|
@@ -196,6 +190,12 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
Log.v(TAG, "onCreate()");
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
+ try {
|
|
|
+ Thread.currentThread().setName("SDLActivity");
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.v(TAG, "modify thread properties failed " + e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
// Load shared libraries
|
|
|
String errorMsgBrokenLib = "";
|
|
|
try {
|
|
|
@@ -243,12 +243,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
mSingleton = this;
|
|
|
SDL.setContext(this);
|
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= 11) {
|
|
|
- mClipboardHandler = new SDLClipboardHandler_API11();
|
|
|
- } else {
|
|
|
- /* Before API 11, no clipboard notification (eg no SDL_CLIPBOARDUPDATE) */
|
|
|
- mClipboardHandler = new SDLClipboardHandler_Old();
|
|
|
- }
|
|
|
+ mClipboardHandler = new SDLClipboardHandler_API11();
|
|
|
|
|
|
mHIDDeviceManager = HIDDeviceManager.acquire(this);
|
|
|
|
|
|
@@ -260,6 +255,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
|
|
|
// Get our current screen orientation and pass it down.
|
|
|
mCurrentOrientation = SDLActivity.getCurrentOrientation();
|
|
|
+ // Only record current orientation
|
|
|
SDLActivity.onNativeOrientationChanged(mCurrentOrientation);
|
|
|
|
|
|
setContentView(mLayout);
|
|
|
@@ -279,16 +275,12 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Events
|
|
|
- @Override
|
|
|
- protected void onPause() {
|
|
|
- Log.v(TAG, "onPause()");
|
|
|
- super.onPause();
|
|
|
+ protected void pauseNativeThread() {
|
|
|
mNextNativeState = NativeState.PAUSED;
|
|
|
mIsResumedCalled = false;
|
|
|
|
|
|
if (SDLActivity.mBrokenLibraries) {
|
|
|
- return;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if (mHIDDeviceManager != null) {
|
|
|
@@ -298,10 +290,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
SDLActivity.handleNativeState();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onResume() {
|
|
|
- Log.v(TAG, "onResume()");
|
|
|
- super.onResume();
|
|
|
+ protected void resumeNativeThread() {
|
|
|
mNextNativeState = NativeState.RESUMED;
|
|
|
mIsResumedCalled = true;
|
|
|
|
|
|
@@ -316,6 +305,43 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
SDLActivity.handleNativeState();
|
|
|
}
|
|
|
|
|
|
+ // Events
|
|
|
+ @Override
|
|
|
+ protected void onPause() {
|
|
|
+ Log.v(TAG, "onPause()");
|
|
|
+ super.onPause();
|
|
|
+ if (!mHasMultiWindow) {
|
|
|
+ pauseNativeThread();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ Log.v(TAG, "onResume()");
|
|
|
+ super.onResume();
|
|
|
+ if (!mHasMultiWindow) {
|
|
|
+ resumeNativeThread();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onStop() {
|
|
|
+ Log.v(TAG, "onStop()");
|
|
|
+ super.onStop();
|
|
|
+ if (mHasMultiWindow) {
|
|
|
+ pauseNativeThread();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onStart() {
|
|
|
+ Log.v(TAG, "onStart()");
|
|
|
+ super.onStart();
|
|
|
+ if (mHasMultiWindow) {
|
|
|
+ resumeNativeThread();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static int getCurrentOrientation() {
|
|
|
final Context context = SDLActivity.getContext();
|
|
|
final Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
|
|
@@ -326,15 +352,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
case Surface.ROTATION_0:
|
|
|
result = SDL_ORIENTATION_PORTRAIT;
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case Surface.ROTATION_90:
|
|
|
result = SDL_ORIENTATION_LANDSCAPE;
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case Surface.ROTATION_180:
|
|
|
result = SDL_ORIENTATION_PORTRAIT_FLIPPED;
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case Surface.ROTATION_270:
|
|
|
result = SDL_ORIENTATION_LANDSCAPE_FLIPPED;
|
|
|
break;
|
|
|
@@ -352,15 +378,21 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- SDLActivity.mHasFocus = hasFocus;
|
|
|
+ mHasFocus = hasFocus;
|
|
|
if (hasFocus) {
|
|
|
mNextNativeState = NativeState.RESUMED;
|
|
|
SDLActivity.getMotionListener().reclaimRelativeMouseModeIfNeeded();
|
|
|
+
|
|
|
+ SDLActivity.handleNativeState();
|
|
|
+ nativeFocusChanged(true);
|
|
|
+
|
|
|
} else {
|
|
|
- mNextNativeState = NativeState.PAUSED;
|
|
|
+ nativeFocusChanged(false);
|
|
|
+ if (!mHasMultiWindow) {
|
|
|
+ mNextNativeState = NativeState.PAUSED;
|
|
|
+ SDLActivity.handleNativeState();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- SDLActivity.handleNativeState();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -386,34 +418,25 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
|
|
|
if (SDLActivity.mBrokenLibraries) {
|
|
|
super.onDestroy();
|
|
|
- // Reset everything in case the user re opens the app
|
|
|
- SDLActivity.initialize();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- mNextNativeState = NativeState.PAUSED;
|
|
|
- SDLActivity.handleNativeState();
|
|
|
+ if (SDLActivity.mSDLThread != null) {
|
|
|
|
|
|
- // Send a quit message to the application
|
|
|
- SDLActivity.mExitCalledFromJava = true;
|
|
|
- SDLActivity.nativeQuit();
|
|
|
+ // Send Quit event to "SDLThread" thread
|
|
|
+ SDLActivity.nativeSendQuit();
|
|
|
|
|
|
- // Now wait for the SDL thread to quit
|
|
|
- if (SDLActivity.mSDLThread != null) {
|
|
|
+ // Wait for "SDLThread" thread to end
|
|
|
try {
|
|
|
SDLActivity.mSDLThread.join();
|
|
|
} catch(Exception e) {
|
|
|
- Log.v(TAG, "Problem stopping thread: " + e);
|
|
|
+ Log.v(TAG, "Problem stopping SDLThread: " + e);
|
|
|
}
|
|
|
- SDLActivity.mSDLThread = null;
|
|
|
-
|
|
|
- //Log.v(TAG, "Finished waiting for SDL thread");
|
|
|
}
|
|
|
|
|
|
- super.onDestroy();
|
|
|
+ SDLActivity.nativeQuit();
|
|
|
|
|
|
- // Reset everything in case the user re opens the app
|
|
|
- SDLActivity.initialize();
|
|
|
+ super.onDestroy();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -490,16 +513,19 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
|
|
|
// Try a transition to paused state
|
|
|
if (mNextNativeState == NativeState.PAUSED) {
|
|
|
- nativePause();
|
|
|
- if (mSurface != null)
|
|
|
+ if (mSDLThread != null) {
|
|
|
+ nativePause();
|
|
|
+ }
|
|
|
+ if (mSurface != null) {
|
|
|
mSurface.handlePause();
|
|
|
+ }
|
|
|
mCurrentNativeState = mNextNativeState;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Try a transition to resumed state
|
|
|
if (mNextNativeState == NativeState.RESUMED) {
|
|
|
- if (mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
|
|
|
+ if (mSurface.mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
|
|
|
if (mSDLThread == null) {
|
|
|
// This is the entry point to the C app.
|
|
|
// Start up the C app thread and enable sensor input for the first time
|
|
|
@@ -508,28 +534,24 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
mSDLThread = new Thread(new SDLMain(), "SDLThread");
|
|
|
mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
|
|
|
mSDLThread.start();
|
|
|
+
|
|
|
+ // No nativeResume(), don't signal Android_ResumeSem
|
|
|
+ mSurface.handleResume();
|
|
|
+ } else {
|
|
|
+ nativeResume();
|
|
|
+ mSurface.handleResume();
|
|
|
}
|
|
|
|
|
|
- nativeResume();
|
|
|
- mSurface.handleResume();
|
|
|
mCurrentNativeState = mNextNativeState;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /* The native thread has finished */
|
|
|
- public static void handleNativeExit() {
|
|
|
- SDLActivity.mSDLThread = null;
|
|
|
- if (mSingleton != null) {
|
|
|
- mSingleton.finish();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
// Messages from the SDLMain thread
|
|
|
static final int COMMAND_CHANGE_TITLE = 1;
|
|
|
static final int COMMAND_CHANGE_WINDOW_STYLE = 2;
|
|
|
static final int COMMAND_TEXTEDIT_HIDE = 3;
|
|
|
+ static final int COMMAND_CHANGE_SURFACEVIEW_FORMAT = 4;
|
|
|
static final int COMMAND_SET_KEEP_SCREEN_ON = 5;
|
|
|
|
|
|
protected static final int COMMAND_USER = 0x8000;
|
|
|
@@ -584,7 +606,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
|
|
|
- window.getDecorView().setSystemUiVisibility(flags);
|
|
|
+ window.getDecorView().setSystemUiVisibility(flags);
|
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
|
|
SDLActivity.mFullscreenModeActive = true;
|
|
|
@@ -609,7 +631,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
|
|
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
|
|
|
-
|
|
|
+
|
|
|
mScreenKeyboardShown = false;
|
|
|
}
|
|
|
break;
|
|
|
@@ -627,6 +649,32 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
+ case COMMAND_CHANGE_SURFACEVIEW_FORMAT:
|
|
|
+ {
|
|
|
+ int format = (Integer) msg.obj;
|
|
|
+ int pf;
|
|
|
+
|
|
|
+ if (SDLActivity.mSurface == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SurfaceHolder holder = SDLActivity.mSurface.getHolder();
|
|
|
+ if (holder == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (format == 1) {
|
|
|
+ pf = PixelFormat.RGBA_8888;
|
|
|
+ } else if (format == 2) {
|
|
|
+ pf = PixelFormat.RGBX_8888;
|
|
|
+ } else {
|
|
|
+ pf = PixelFormat.RGB_565;
|
|
|
+ }
|
|
|
+
|
|
|
+ holder.setFormat(pf);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
default:
|
|
|
if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
|
|
|
Log.e(TAG, "error handling message, command is " + msg.arg1);
|
|
|
@@ -650,14 +698,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
// or 500ms have passed.
|
|
|
|
|
|
boolean bShouldWait = false;
|
|
|
-
|
|
|
+
|
|
|
if (data instanceof Integer) {
|
|
|
// Let's figure out if we're already laid out fullscreen or not.
|
|
|
Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
|
|
android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
|
|
|
display.getRealMetrics( realMetrics );
|
|
|
-
|
|
|
- boolean bFullscreenLayout = ((realMetrics.widthPixels == mSurface.getWidth()) &&
|
|
|
+
|
|
|
+ boolean bFullscreenLayout = ((realMetrics.widthPixels == mSurface.getWidth()) &&
|
|
|
(realMetrics.heightPixels == mSurface.getHeight()));
|
|
|
|
|
|
if (((Integer)data).intValue() == 1) {
|
|
|
@@ -682,7 +730,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
// size we need, instead of grabbing a size that's still got
|
|
|
// the navigation and/or status bars before they're hidden.
|
|
|
//
|
|
|
- // We'll wait for up to half a second, because some devices
|
|
|
+ // We'll wait for up to half a second, because some devices
|
|
|
// take a surprisingly long time for the surface resize, but
|
|
|
// then we'll just give up and return.
|
|
|
//
|
|
|
@@ -704,13 +752,17 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
public static native int nativeSetupJNI();
|
|
|
public static native int nativeRunMain(String library, String function, Object arguments);
|
|
|
public static native void nativeLowMemory();
|
|
|
+ public static native void nativeSendQuit();
|
|
|
public static native void nativeQuit();
|
|
|
public static native void nativePause();
|
|
|
public static native void nativeResume();
|
|
|
+ public static native void nativeFocusChanged(boolean hasFocus);
|
|
|
public static native void onNativeDropFile(String filename);
|
|
|
- public static native void onNativeResize(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, int format, float rate);
|
|
|
+ public static native void nativeSetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, int format, float rate);
|
|
|
+ public static native void onNativeResize();
|
|
|
public static native void onNativeKeyDown(int keycode);
|
|
|
public static native void onNativeKeyUp(int keycode);
|
|
|
+ public static native boolean onNativeSoftReturnKey();
|
|
|
public static native void onNativeKeyboardFocusLost();
|
|
|
public static native void onNativeMouse(int button, int action, float x, float y, boolean relative);
|
|
|
public static native void onNativeTouch(int touchDevId, int pointerFingerId,
|
|
|
@@ -718,11 +770,13 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
float y, float p);
|
|
|
public static native void onNativeAccel(float x, float y, float z);
|
|
|
public static native void onNativeClipboardChanged();
|
|
|
+ public static native void onNativeSurfaceCreated();
|
|
|
public static native void onNativeSurfaceChanged();
|
|
|
public static native void onNativeSurfaceDestroyed();
|
|
|
public static native String nativeGetHint(String name);
|
|
|
public static native void nativeSetenv(String name, String value);
|
|
|
public static native void onNativeOrientationChanged(int orientation);
|
|
|
+ public static native void nativeAddTouch(int touchId, String name);
|
|
|
|
|
|
/**
|
|
|
* This method is called by SDL using JNI.
|
|
|
@@ -743,7 +797,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
/**
|
|
|
* This method is called by SDL using JNI.
|
|
|
* This is a static method for JNI convenience, it calls a non-static method
|
|
|
- * so that is can be overridden
|
|
|
+ * so that is can be overridden
|
|
|
*/
|
|
|
public static void setOrientation(int w, int h, boolean resizable, String hint)
|
|
|
{
|
|
|
@@ -751,11 +805,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
mSingleton.setOrientationBis(w, h, resizable, hint);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* This can be overridden
|
|
|
*/
|
|
|
- public void setOrientationBis(int w, int h, boolean resizable, String hint)
|
|
|
+ public void setOrientationBis(int w, int h, boolean resizable, String hint)
|
|
|
{
|
|
|
int orientation = -1;
|
|
|
|
|
|
@@ -795,7 +849,46 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
/**
|
|
|
* This method is called by SDL using JNI.
|
|
|
*/
|
|
|
- public static boolean isScreenKeyboardShown()
|
|
|
+ public static void minimizeWindow() {
|
|
|
+
|
|
|
+ if (mSingleton == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Intent startMain = new Intent(Intent.ACTION_MAIN);
|
|
|
+ startMain.addCategory(Intent.CATEGORY_HOME);
|
|
|
+ startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
+ mSingleton.startActivity(startMain);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This method is called by SDL using JNI.
|
|
|
+ */
|
|
|
+ public static boolean shouldMinimizeOnFocusLoss() {
|
|
|
+/*
|
|
|
+ if (Build.VERSION.SDK_INT >= 24) {
|
|
|
+ if (mSingleton == null) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mSingleton.isInMultiWindowMode()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mSingleton.isInPictureInPictureMode()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+*/
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This method is called by SDL using JNI.
|
|
|
+ */
|
|
|
+ public static boolean isScreenKeyboardShown()
|
|
|
{
|
|
|
if (mTextEdit == null) {
|
|
|
return false;
|
|
|
@@ -820,7 +913,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // DeX mode in Samsung Experience 9.0 and earlier doesn't support relative mice properly under
|
|
|
+ // DeX mode in Samsung Experience 9.0 and earlier doesn't support relative mice properly under
|
|
|
// Android 7 APIs, and simply returns no data under Android 8 APIs.
|
|
|
//
|
|
|
// This is fixed in Samsung Experience 9.5, which corresponds to Android 8.1.0, and
|
|
|
@@ -902,7 +995,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
*/
|
|
|
public static boolean isChromebook() {
|
|
|
return getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* This method is called by SDL using JNI.
|
|
|
@@ -948,7 +1041,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
}
|
|
|
}
|
|
|
/* environment variables set! */
|
|
|
- return true;
|
|
|
+ return true;
|
|
|
} catch (Exception e) {
|
|
|
Log.v("SDL", "exception " + e.toString());
|
|
|
}
|
|
|
@@ -956,7 +1049,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
}
|
|
|
|
|
|
// This method is called by SDLControllerManager's API 26 Generic Motion Handler.
|
|
|
- public static View getContentView()
|
|
|
+ public static View getContentView()
|
|
|
{
|
|
|
return mSingleton.mLayout;
|
|
|
}
|
|
|
@@ -976,6 +1069,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
this.y = y;
|
|
|
this.w = w;
|
|
|
this.h = h;
|
|
|
+
|
|
|
+ /* Minimum size of 1 pixel, so it takes focus. */
|
|
|
+ if (this.w <= 0) {
|
|
|
+ this.w = 1;
|
|
|
+ }
|
|
|
+ if (this.h + HEIGHT_PADDING <= 0) {
|
|
|
+ this.h = 1 - HEIGHT_PADDING;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1011,12 +1112,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
}
|
|
|
|
|
|
public static boolean isTextInputEvent(KeyEvent event) {
|
|
|
-
|
|
|
+
|
|
|
// Key pressed with Ctrl should be sent as SDL_KEYDOWN/SDL_KEYUP and not SDL_TEXTINPUT
|
|
|
- if (Build.VERSION.SDK_INT >= 11) {
|
|
|
- if (event.isCtrlPressed()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (event.isCtrlPressed()) {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return event.isPrintingKey() || event.getKeyCode() == KeyEvent.KEYCODE_SPACE;
|
|
|
@@ -1032,23 +1131,28 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
return SDLActivity.mSurface.getNativeSurface();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * This method is called by SDL using JNI.
|
|
|
+ */
|
|
|
+ public static void setSurfaceViewFormat(int format) {
|
|
|
+ mSingleton.sendCommand(COMMAND_CHANGE_SURFACEVIEW_FORMAT, format);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// Input
|
|
|
|
|
|
/**
|
|
|
* This method is called by SDL using JNI.
|
|
|
- * @return an array which may be empty but is never null.
|
|
|
*/
|
|
|
- public static int[] inputGetInputDeviceIds(int sources) {
|
|
|
+ public static void initTouch() {
|
|
|
int[] ids = InputDevice.getDeviceIds();
|
|
|
- int[] filtered = new int[ids.length];
|
|
|
- int used = 0;
|
|
|
+
|
|
|
for (int i = 0; i < ids.length; ++i) {
|
|
|
InputDevice device = InputDevice.getDevice(ids[i]);
|
|
|
- if ((device != null) && ((device.getSources() & sources) != 0)) {
|
|
|
- filtered[used++] = device.getId();
|
|
|
+ if (device != null && (device.getSources() & InputDevice.SOURCE_TOUCHSCREEN) != 0) {
|
|
|
+ nativeAddTouch(device.getId(), device.getName());
|
|
|
}
|
|
|
}
|
|
|
- return Arrays.copyOf(filtered, used);
|
|
|
}
|
|
|
|
|
|
// APK expansion files support
|
|
|
@@ -1341,7 +1445,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
};
|
|
|
|
|
|
public void onSystemUiVisibilityChange(int visibility) {
|
|
|
- if (SDLActivity.mFullscreenModeActive && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
|
|
|
+ if (SDLActivity.mFullscreenModeActive && ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0)) {
|
|
|
|
|
|
Handler handler = getWindow().getDecorView().getHandler();
|
|
|
if (handler != null) {
|
|
|
@@ -1350,7 +1454,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* This method is called by SDL using JNI.
|
|
|
@@ -1474,14 +1578,24 @@ class SDLMain implements Runnable {
|
|
|
String function = SDLActivity.mSingleton.getMainFunction();
|
|
|
String[] arguments = SDLActivity.mSingleton.getArguments();
|
|
|
|
|
|
+ try {
|
|
|
+ android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.v("SDL", "modify thread properties failed " + e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
Log.v("SDL", "Running main function " + function + " from library " + library);
|
|
|
+
|
|
|
SDLActivity.nativeRunMain(library, function, arguments);
|
|
|
|
|
|
Log.v("SDL", "Finished main function");
|
|
|
|
|
|
- // Native thread has finished, let's finish the Activity
|
|
|
- if (!SDLActivity.mExitCalledFromJava) {
|
|
|
- SDLActivity.handleNativeExit();
|
|
|
+ if (SDLActivity.mSingleton.isFinishing()) {
|
|
|
+ // Activity is already being destroyed
|
|
|
+ } else {
|
|
|
+ // Let's finish the Activity
|
|
|
+ SDLActivity.mSDLThread = null;
|
|
|
+ SDLActivity.mSingleton.finish();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1497,11 +1611,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
View.OnKeyListener, View.OnTouchListener, SensorEventListener {
|
|
|
|
|
|
// Sensors
|
|
|
- protected static SensorManager mSensorManager;
|
|
|
- protected static Display mDisplay;
|
|
|
+ protected SensorManager mSensorManager;
|
|
|
+ protected Display mDisplay;
|
|
|
|
|
|
// Keep track of the surface size to normalize touch events
|
|
|
- protected static float mWidth, mHeight;
|
|
|
+ protected float mWidth, mHeight;
|
|
|
+
|
|
|
+ // Is SurfaceView ready for rendering
|
|
|
+ public boolean mIsSurfaceReady;
|
|
|
|
|
|
// Startup
|
|
|
public SDLSurface(Context context) {
|
|
|
@@ -1517,13 +1634,13 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
|
|
mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
|
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= 12) {
|
|
|
- setOnGenericMotionListener(SDLActivity.getMotionListener());
|
|
|
- }
|
|
|
+ setOnGenericMotionListener(SDLActivity.getMotionListener());
|
|
|
|
|
|
// Some arbitrary defaults to avoid a potential division by zero
|
|
|
mWidth = 1.0f;
|
|
|
mHeight = 1.0f;
|
|
|
+
|
|
|
+ mIsSurfaceReady = false;
|
|
|
}
|
|
|
|
|
|
public void handlePause() {
|
|
|
@@ -1547,7 +1664,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
@Override
|
|
|
public void surfaceCreated(SurfaceHolder holder) {
|
|
|
Log.v("SDL", "surfaceCreated()");
|
|
|
- holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
|
|
|
+ SDLActivity.onNativeSurfaceCreated();
|
|
|
}
|
|
|
|
|
|
// Called when we lose the surface
|
|
|
@@ -1559,7 +1676,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
SDLActivity.mNextNativeState = SDLActivity.NativeState.PAUSED;
|
|
|
SDLActivity.handleNativeState();
|
|
|
|
|
|
- SDLActivity.mIsSurfaceReady = false;
|
|
|
+ mIsSurfaceReady = false;
|
|
|
SDLActivity.onNativeSurfaceDestroyed();
|
|
|
}
|
|
|
|
|
|
@@ -1575,23 +1692,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
|
|
|
int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default
|
|
|
switch (format) {
|
|
|
- case PixelFormat.A_8:
|
|
|
- Log.v("SDL", "pixel format A_8");
|
|
|
- break;
|
|
|
- case PixelFormat.LA_88:
|
|
|
- Log.v("SDL", "pixel format LA_88");
|
|
|
- break;
|
|
|
- case PixelFormat.L_8:
|
|
|
- Log.v("SDL", "pixel format L_8");
|
|
|
- break;
|
|
|
- case PixelFormat.RGBA_4444:
|
|
|
- Log.v("SDL", "pixel format RGBA_4444");
|
|
|
- sdlFormat = 0x15421002; // SDL_PIXELFORMAT_RGBA4444
|
|
|
- break;
|
|
|
- case PixelFormat.RGBA_5551:
|
|
|
- Log.v("SDL", "pixel format RGBA_5551");
|
|
|
- sdlFormat = 0x15441002; // SDL_PIXELFORMAT_RGBA5551
|
|
|
- break;
|
|
|
case PixelFormat.RGBA_8888:
|
|
|
Log.v("SDL", "pixel format RGBA_8888");
|
|
|
sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888
|
|
|
@@ -1600,10 +1700,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
Log.v("SDL", "pixel format RGBX_8888");
|
|
|
sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888
|
|
|
break;
|
|
|
- case PixelFormat.RGB_332:
|
|
|
- Log.v("SDL", "pixel format RGB_332");
|
|
|
- sdlFormat = 0x14110801; // SDL_PIXELFORMAT_RGB332
|
|
|
- break;
|
|
|
case PixelFormat.RGB_565:
|
|
|
Log.v("SDL", "pixel format RGB_565");
|
|
|
sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565
|
|
|
@@ -1640,8 +1736,11 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
|
|
|
Log.v("SDL", "Window size: " + width + "x" + height);
|
|
|
Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
|
|
|
- SDLActivity.onNativeResize(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
|
|
|
+ SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
|
|
|
+ SDLActivity.onNativeResize();
|
|
|
|
|
|
+ // Prevent a screen distortion glitch,
|
|
|
+ // for instance when the device is in Landscape and a Portrait App is resumed.
|
|
|
boolean skip = false;
|
|
|
int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();
|
|
|
|
|
|
@@ -1671,24 +1770,39 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Don't skip in MultiWindow.
|
|
|
+ if (skip) {
|
|
|
+ if (Build.VERSION.SDK_INT >= 24) {
|
|
|
+ if (SDLActivity.mSingleton.isInMultiWindowMode()) {
|
|
|
+ Log.v("SDL", "Don't skip in Multi-Window");
|
|
|
+ skip = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (skip) {
|
|
|
Log.v("SDL", "Skip .. Surface is not ready.");
|
|
|
- SDLActivity.mIsSurfaceReady = false;
|
|
|
+ mIsSurfaceReady = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- /* Surface is ready */
|
|
|
- SDLActivity.mIsSurfaceReady = true;
|
|
|
-
|
|
|
/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
|
|
|
SDLActivity.onNativeSurfaceChanged();
|
|
|
|
|
|
+ /* Surface is ready */
|
|
|
+ mIsSurfaceReady = true;
|
|
|
+
|
|
|
+ SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED;
|
|
|
SDLActivity.handleNativeState();
|
|
|
}
|
|
|
|
|
|
// Key events
|
|
|
@Override
|
|
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
+
|
|
|
+ int deviceId = event.getDeviceId();
|
|
|
+ int source = event.getSource();
|
|
|
+
|
|
|
// Dispatch the different events depending on where they come from
|
|
|
// Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
|
|
|
// So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD
|
|
|
@@ -1696,20 +1810,25 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
// Furthermore, it's possible a game controller has SOURCE_KEYBOARD and
|
|
|
// SOURCE_JOYSTICK, while its key events arrive from the keyboard source
|
|
|
// So, retrieve the device itself and check all of its sources
|
|
|
- if (SDLControllerManager.isDeviceSDLJoystick(event.getDeviceId())) {
|
|
|
+ if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) {
|
|
|
// Note that we process events with specific key codes here
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
- if (SDLControllerManager.onNativePadDown(event.getDeviceId(), keyCode) == 0) {
|
|
|
+ if (SDLControllerManager.onNativePadDown(deviceId, keyCode) == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
|
|
- if (SDLControllerManager.onNativePadUp(event.getDeviceId(), keyCode) == 0) {
|
|
|
+ if (SDLControllerManager.onNativePadUp(deviceId, keyCode) == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ((event.getSource() & InputDevice.SOURCE_KEYBOARD) != 0) {
|
|
|
+ if (source == InputDevice.SOURCE_UNKNOWN) {
|
|
|
+ InputDevice device = InputDevice.getDevice(deviceId);
|
|
|
+ source = device.getSources();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((source & InputDevice.SOURCE_KEYBOARD) != 0) {
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
//Log.v("SDL", "key down: " + keyCode);
|
|
|
if (SDLActivity.isTextInputEvent(event)) {
|
|
|
@@ -1725,7 +1844,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ((event.getSource() & InputDevice.SOURCE_MOUSE) != 0) {
|
|
|
+ if ((source & InputDevice.SOURCE_MOUSE) != 0) {
|
|
|
// on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
|
|
|
// they are ignored here because sending them as mouse input to SDL is messy
|
|
|
if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
|
|
|
@@ -1754,17 +1873,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
int i = -1;
|
|
|
float x,y,p;
|
|
|
|
|
|
- // !!! FIXME: dump this SDK check after 2.0.4 ships and require API14.
|
|
|
// 12290 = Samsung DeX mode desktop mouse
|
|
|
- if ((event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == 12290) && SDLActivity.mSeparateMouseAndTouch) {
|
|
|
- if (Build.VERSION.SDK_INT < 14) {
|
|
|
- mouseButton = 1; // all mouse buttons are the left button
|
|
|
- } else {
|
|
|
- try {
|
|
|
- mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
|
|
|
- } catch(Exception e) {
|
|
|
- mouseButton = 1; // oh well.
|
|
|
- }
|
|
|
+ // 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN
|
|
|
+ // 0x2 = SOURCE_CLASS_POINTER
|
|
|
+ if (event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == (InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN)) {
|
|
|
+ try {
|
|
|
+ mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
|
|
|
+ } catch(Exception e) {
|
|
|
+ mouseButton = 1; // oh well.
|
|
|
}
|
|
|
|
|
|
// We need to check if we're in relative mouse mode and get the axis offset rather than the x/y values
|
|
|
@@ -1862,7 +1978,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
// Since we may have an orientation set, we won't receive onConfigurationChanged events.
|
|
|
// We thus should check here.
|
|
|
int newOrientation = SDLActivity.SDL_ORIENTATION_UNKNOWN;
|
|
|
-
|
|
|
+
|
|
|
float x, y;
|
|
|
switch (mDisplay.getRotation()) {
|
|
|
case Surface.ROTATION_90:
|
|
|
@@ -1876,8 +1992,8 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE_FLIPPED;
|
|
|
break;
|
|
|
case Surface.ROTATION_180:
|
|
|
- x = -event.values[1];
|
|
|
- y = -event.values[0];
|
|
|
+ x = -event.values[0];
|
|
|
+ y = -event.values[1];
|
|
|
newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT_FLIPPED;
|
|
|
break;
|
|
|
default:
|
|
|
@@ -1896,7 +2012,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|
|
y / SensorManager.GRAVITY_EARTH,
|
|
|
event.values[2] / SensorManager.GRAVITY_EARTH);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1964,7 +2080,7 @@ class DummyEdit extends View implements View.OnKeyListener {
|
|
|
|
|
|
@Override
|
|
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
- /*
|
|
|
+ /*
|
|
|
* This handles the hardware keyboard input
|
|
|
*/
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
@@ -2032,14 +2148,8 @@ class SDLInputConnection extends BaseInputConnection {
|
|
|
*/
|
|
|
|
|
|
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
|
|
- String imeHide = SDLActivity.nativeGetHint("SDL_RETURN_KEY_HIDES_IME");
|
|
|
- if ((imeHide != null) && imeHide.equals("1")) {
|
|
|
- Context c = SDL.getContext();
|
|
|
- if (c instanceof SDLActivity) {
|
|
|
- SDLActivity activity = (SDLActivity)c;
|
|
|
- activity.sendCommand(SDLActivity.COMMAND_TEXTEDIT_HIDE, null);
|
|
|
- return true;
|
|
|
- }
|
|
|
+ if (SDLActivity.onNativeSoftReturnKey()) {
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2052,6 +2162,11 @@ class SDLInputConnection extends BaseInputConnection {
|
|
|
|
|
|
for (int i = 0; i < text.length(); i++) {
|
|
|
char c = text.charAt(i);
|
|
|
+ if (c == '\n') {
|
|
|
+ if (SDLActivity.onNativeSoftReturnKey()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
nativeGenerateScancodeForUnichar(c);
|
|
|
}
|
|
|
|
|
|
@@ -2084,7 +2199,7 @@ class SDLInputConnection extends BaseInputConnection {
|
|
|
while (beforeLength-- > 0) {
|
|
|
boolean ret_key = sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
|
|
|
&& sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
|
|
|
- ret = ret && ret_key;
|
|
|
+ ret = ret && ret_key;
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
@@ -2103,7 +2218,7 @@ interface SDLClipboardHandler {
|
|
|
|
|
|
|
|
|
class SDLClipboardHandler_API11 implements
|
|
|
- SDLClipboardHandler,
|
|
|
+ SDLClipboardHandler,
|
|
|
android.content.ClipboardManager.OnPrimaryClipChangedListener {
|
|
|
|
|
|
protected android.content.ClipboardManager mClipMgr;
|
|
|
@@ -2134,7 +2249,7 @@ class SDLClipboardHandler_API11 implements
|
|
|
mClipMgr.setText(string);
|
|
|
mClipMgr.addPrimaryClipChangedListener(this);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void onPrimaryClipChanged() {
|
|
|
SDLActivity.onNativeClipboardChanged();
|
|
|
@@ -2142,33 +2257,3 @@ class SDLClipboardHandler_API11 implements
|
|
|
|
|
|
}
|
|
|
|
|
|
-class SDLClipboardHandler_Old implements
|
|
|
- SDLClipboardHandler {
|
|
|
-
|
|
|
- protected android.text.ClipboardManager mClipMgrOld;
|
|
|
-
|
|
|
- SDLClipboardHandler_Old() {
|
|
|
- mClipMgrOld = (android.text.ClipboardManager) SDL.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean clipboardHasText() {
|
|
|
- return mClipMgrOld.hasText();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String clipboardGetText() {
|
|
|
- CharSequence text;
|
|
|
- text = mClipMgrOld.getText();
|
|
|
- if (text != null) {
|
|
|
- return text.toString();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void clipboardSetText(String string) {
|
|
|
- mClipMgrOld.setText(string);
|
|
|
- }
|
|
|
-}
|
|
|
-
|