Commit graph

153 commits

Author SHA1 Message Date
Philipp Wiesemann
30f533b548 Android: Removed three internal functions not used by SDL.
They were not needed internally since the switch to the common EGL backend.

Thanks to the SDL mailing list for pointing out that the functions seem unused.
2015-09-27 20:12:47 +02:00
Philipp Wiesemann
1a31b4723b Android: Improved last error message for failed APK expansion file use. 2015-09-18 21:26:28 +02:00
Philipp Wiesemann
d1ffadbeb6 Android: Added additional error messages for APK expansion file use. 2015-09-17 22:36:11 +02:00
Philipp Wiesemann
8fa156a2f8 Android: Fixed trying to read from APK expansion files without version hint set.
This also fixed overwriting the asset error message which is more useful if no
APK expansion files are available and the requested file was not found.
2015-09-17 22:30:24 +02:00
Philipp Wiesemann
2ab482abc1 Android: Renamed SDLActivity's Java method used for APK expansion files.
The name was not correct.
2015-09-17 22:24:54 +02:00
Philipp Wiesemann
e3768b7fc3 Android: Removed empty onDraw() override method from SDLActivity.
It was redundant because SDLActivity already inherits an empty method from the
base class SurfaceView (which does not implement it but inherits it from View).
Visibility of onDraw() in SDLActivity is now protected again instead of public.
2015-09-17 22:14:37 +02:00
Philipp Wiesemann
36a91d1b09 Android: Fixed unused variable warning. 2015-09-05 20:21:35 +02:00
Philipp Wiesemann
298097bcff Android: Fixed missing break warning. 2015-09-05 20:21:06 +02:00
Sam Lantinga
34a0b04786 Fixed bug 2949 - [Android] Virtual DPAD remote not registered
Sylvain

I have an android device to which I try to connect the google virtual remote application.
https://play.google.com/store/apps/details?id=com.google.android.tv.remote

The java method "pollInputDevices()" detects it as an input source 0x701 which is (SOURCE_KEYBOARD | SOURCE_GAMEPAD | SOURCE_DPAD).

It it not added because it does not AND-bitwise with "SOURCE_CLASS_JOYSTICK".
It's only a virtual DPAD and it works when checking also with SOURCE_CLASS_BUTTON
2015-06-16 23:58:09 -07:00
Sam Lantinga
945a347ea0 Fixed bug 2774 - Android: screen distorted in Landscape after background/foreground
Sylvain

With a Landscape application.
Going to background with Home Key, then foreground.
The screen is distorted.

This has been reported by Samsung. It happens on S5 and Samsung Alpha, see the video attached.

I have captured the following logcat:

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
I/SDL     (20549): SDL_Android_Init()
I/SDL     (20549): SDL_Android_Init() finished!
V/SDL     (20549): SDL audio: opening device
V/SDL     (20549): SDL audio: wanted stereo 16-bit 22.05kHz, 256 frames buffer
V/SDL     (20549): SDL audio: got stereo 16-bit 22.05kHz, 1764 frames buffer
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): onWindowFocusChanged(): false
V/SDL     (20549): onPause()
V/SDL     (20549): nativePause()
V/SDL     (20549): surfaceDestroyed()

Background / Foreground

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1080x1920
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): nativeResume()



This seems to be related to the fact that I have in "AndroidManifest.xml":
android:configChanges="..."
Because of the fields: "orientation" and also "screenSize".


I have looked for another way to solve the issue. Discarding the "surfaceChanged" call, based on the "requestedOrientation" and the new Orientation. It seems to be better.


On my failing test case, the first "surfaceChanged()" is discarded. Sometimes the "focusChanged()" might appear between the two "surfaceChanged()", while the surface is not yet ready. Thus, discarding also the "nativeResume()".

So, for robustness, a call to "nativeResume()" is added at the end of "surfaceChanged()".

Some update:

1/ First I tried, to discard the surface using the current orientation (rather than width / heigh). -> that solve the issue sometimes, but not always.

2/ Samsung Certification now accepts my application that were previously failing.

3/ I personally now owns a Samsung S5, and was able to solve the issue on my side.

4/ I now use the patch and get no complaints from my users. (but I admit, nobody seemed to be complaining before neither...).

5/ I have added a v2 because of a new smart-phone called "Black Berry Passport" that has a square screen of 1440x1440. This screen has a "status bar" so the resolution is in fact : 1440x1308. (as reported by "surfaceChanged").

Problem is: the portrait resolution is in fact a Landscape!

So the "v1" patch is always discarding the "surface" of BlackBerry Passport. Which is terribly bad.


Hence, I added the "v2" patch not to discard the surface when aspect ratio is < 1.20. (BB 1440/1308 is : 1.1009). Which seems fair.
2015-06-16 22:16:35 -07:00
Philipp Wiesemann
18be5eb77d Android: Added missing space in three log messages.
Also fixed a typo and changed tag string to constant.
2015-05-31 19:23:16 +02:00
Ryan C. Gordon
ca08bb0d98 Android: Added basic drop file support (thanks, "noxalus"!).
This lets SDL-based apps respond to "Open With" commands properly, as they
can now obtain the requested path via a standard SDL dropfile event.

This is only checked on startup, so apps don't get drop events at any other
time, even if Android supports that, but this is still a definite
improvement.

Fixes Bugzilla #2762.
2015-05-26 20:36:45 -04:00
Philipp Wiesemann
1674b49dc4 Android: Fixed touch pressure being out of range.
According to the documentation of Android's MotionEvent, the getPressure() may
return values higher than 1 on some devices. To prevent passing such values into
SDL they are now corrected to 1 in Java before the JNI call (where it is assumed
to be correct).

Currently SDL only sends SDL_FINGERMOTION events if the touch state (position or
pressure) changed. By correcting pressure down to 1 some events may get dropped
in the rare case that only the pressure was changed but was out of range and the
position did not change.
2015-05-22 22:34:08 +02:00
Philipp Wiesemann
0e132b3325 Android: Replaced logging tag strings with constant. 2015-05-16 21:15:59 +02:00
Reto Schneider
0970b3829d Remove trailing spaces in Android source code. 2015-04-08 12:14:36 +02:00
Philipp Wiesemann
0f74f5f039 Android: Fixed calling a getter method twice. 2015-04-08 22:24:33 +02:00
Ryan C. Gordon
b344c3f2ed Log Android hardware at startup (thanks, rettichschnidi!).
Fixes Bugzilla #2653.
2015-04-08 01:37:17 -04:00
Joseba García Etxebarria
ddad0a1315 Cast the result of calling getButtonState to an Integer 2015-04-02 00:55:45 +02:00
Ryan C. Gordon
bedac6b53a Android: more separate-mouse-and-touch work.
This avoids a hint lookup for each mouse event we get by setting a static Java
variable from native code during our hint watcher callback.

Also attempts to do the right thing with mouse buttons if you happen to be
on an API14 (Ice Cream Sandwich, Android 4.0) or later device. We still
target API12 (Honeycomb MR1, Android 3.1) for SDL 2.0.4 though.

This isn't tested, so I'm pushing to see what the Android buildbot says. Stand
back, I'm a professional!

--HG--
extra : amend_source : 7748c650f37edd47c721e4e7e96cf5995f5ac459
2015-04-01 12:14:56 -04:00
Joseba García Etxebarria
1163b6da1c Renamed SDLGenericMotionListener back to SDLGenericMotionListener_API12 2015-03-27 18:09:51 -04:00
Philipp Wiesemann
8f0ea4bcf7 Android: Removed outdated comment from source. 2015-03-25 22:47:22 +01:00
Joseba García Etxebarria
e997a4144d * More Android patch work 2015-03-24 21:02:28 +01:00
Joseba García Etxebarria
3dcf5c743f * Improve mouse support in Android. These changes require Android API v12 to compile 2015-03-24 20:45:29 +01:00
Philipp Wiesemann
97b6937ee2 Fixed wrong comment in implementation for Android. 2015-01-31 10:32:45 +01:00
Philipp Wiesemann
d2aee7d409 Fixed bug 2816 - [patch] Android: Expose screen refresh rate
Jonas Kulla

Display::getRefreshRate() is available on all API levels.
2015-01-23 20:29:08 +01:00
Philipp Wiesemann
1f37dea55a Added name for second Java Thread on Android. 2014-11-23 20:35:51 +01:00
Philipp Wiesemann
7da09eba59 Fixed bug 2759 - Android findLibrary() returns NULL
Sylvain

extra patch with minor modifications:
- typo
- cancel-able set to false
- add the error message, so that the user can report it.
2014-10-24 11:53:34 +02:00
Philipp Wiesemann
2b40ad3b10 Added an option to define libraries to be loaded on Android in a derived class.
This way it is no more needed to modify SDLActivity.java to add own libraries.
2014-10-23 16:45:18 +02:00
Philipp Wiesemann
1e55e039ec Fixed alert dialog for not loaded libraries on Android being cancelable.
If the alert dialog could be canceled the Activity would not be finished here.
Also setting the property to "true" would be redundant because that is default.
2014-10-23 16:41:01 +02:00
Philipp Wiesemann
1d8143941f Fixed missing @Override annotation warning in source for Android. 2014-10-23 16:39:15 +02:00
Philipp Wiesemann
5767c4b5a3 Fixed upper case button in alert dialog for not loaded libraries on Android.
This is more consistent with the buttons of other dialogs on Android.
2014-10-23 16:38:03 +02:00
Philipp Wiesemann
25e97e03c9 Fixed typo in message of alert dialog for not loaded libraries on Android. 2014-10-23 16:34:48 +02:00
Philipp Wiesemann
db76896e79 Fixed writing new errors to standard output instead of error output on Android. 2014-10-23 16:33:27 +02:00
Philipp Wiesemann
8b744670c3 Fixed documentation in source for Android. 2014-10-23 16:31:02 +02:00
Gabriel Jacobo
c77c91bb2a [Android] #2759: Show a message on failure to load a .so library (by Sylvain) 2014-10-21 11:44:35 -03:00
Philipp Wiesemann
69e989c667 Fixed setting of screen saver state crashing on some version of Android.
Setting Window flags seems to affect Views and must be handled on UI thread.
2014-10-20 22:19:09 +02:00
Gabriel Jacobo
0ec4fc6589 Bug 2739 - [Android] No support for SDL_DisableScreenSaver by Martin Gerhardy 2014-10-20 10:10:39 -03:00
Philipp Wiesemann
a32480ef1f Fixed bug 2476 - Allow custom main() arguments
rettichschnidi

I would like to pass custom arguments from my Java code (subclass of SDLActivity) to the native SDL2 binary.
2014-10-17 23:36:45 +02:00
Philipp Wiesemann
21af0c2d68 Fixed broken layout for buttons with configured color in messagebox on Android. 2014-09-25 20:56:27 +02:00
Philipp Wiesemann
00a37f9098 Added setting configured color to button texts for messagebox on Android. 2014-09-24 23:46:46 +02:00
Gabriel Jacobo
b70d45cec5 [Android] Fixes #2679 - Crash resuming from screen off
Before destroying the static Java-side data, wait for the SDL native thread,
*and* the listener thread that waits on it to trigger a clean up.
2014-09-17 08:59:43 -03:00
Philipp Wiesemann
946ca79670 Fixed key down closing messagebox dialog instead of key up on Android.
This fixed sending key up event to SDL a dialog closed by down did not consume.
2014-09-14 19:44:53 +02:00
Sam Lantinga
56f86cc81f Fixed bug 2415 - Message Boxes aren't implemented on Android
Philipp Wiesemann

I attached a patch for an incomplete implementation of the messagebox parts.

It was not tested on lots of devices yet and features a very fragile workaround to block the calling SDL thread while the dialog is handled on Android's UI thread. Although it works for testmessage.c I assume there are lot of situations were it may fail (standby, device rotation and other changes). Also not all flags and colors are implemented.

On the other hand most uses of the messagebox are to show an error on start and fragility (or working at all) may not matter there.
2014-09-13 02:15:18 -07:00
Philipp Wiesemann
69487c41dd Fixed warning about implicit boxing to Java Object. 2014-08-12 23:33:16 +02:00
Philipp Wiesemann
36341cbc34 Added javadoc comment for consistency. 2014-08-11 23:16:47 +02:00
Sam Lantinga
f5054661e6 Merged changes from Alexey Petruchik to support Android obb files
http://developer.android.com/google/play/expansion-files.html
2014-06-21 20:35:36 -07:00
Sam Lantinga
424dd9d921 Fixed bug 2558 - Missing FINGERUP in Android
Sylvain

If you play with the TouchScreen with +3 fingers randomly / pressing simultaneously all fingers.

You triggers FINGER DOWN events, but not always all the associated FINGER UP events.

So, after a while SDL_GetNumFingers() can report a wrong number of fingers pressed !


The explanation is hidden there : http://developer.android.com/reference/android/view/MotionEvent.html

Each pointer has a unique id that is assigned when it first goes down (indicated by ACTION_DOWN or ACTION_POINTER_DOWN).
A pointer id remains valid until the pointer eventually goes up (indicated by ACTION_UP or ACTION_POINTER_UP) or when the gesture is canceled (indicated by ACTION_CANCEL).

in ACTION_CANCEL :

The current gesture has been aborted. You will not receive any more points in it. You should treat this as an up event, but not perform any action that you normally would.
Constant Value: 3 (0x00000003)
2014-06-15 19:32:39 -07:00
Philipp Wiesemann
9024566f68 Changed two Java nested classes into static nested classes.
Both do not need an implicitly created reference to enclosing class.
2014-06-08 13:14:20 +02:00
Philipp Wiesemann
822b690cac Added javadoc comments to document methods used by JNI. 2014-05-29 23:05:18 +02:00
Philipp Wiesemann
272e4b090a Added javadoc comments to prevent unused parameter warning. 2014-05-29 22:58:06 +02:00