Commit graph

60 commits

Author SHA1 Message Date
Olivier Goffart
cbc28b1f1b Android: handle properly the Destroy event
Destroy means we need to exit the event loop.
And android_main will be called again from another thread, so we need to
support reseting the proxy

There is also a bug in the timer when exiting the app that this worked
around

Fix #6626
2024-10-23 14:30:55 +02:00
Ian Hattendorf
ac9b85049a Add PlatformBuilder API to allow selecting OpenGL API
Right now this just allows selecting between OpenGL and OpenGL ES.
2024-10-23 11:13:49 +02:00
wu bobo
a590883a48
Fixes for older Android versions (6.0 to 9.0) (#6622)
Fixes #4936

ChangeLog: Support older android
2024-10-22 22:26:35 +02:00
crai0
3f3ac7e347
common: add support for back and forward pointing-device buttons (#6149)
Closes #6043

ChangeLog: add support for back and forward pointing-device buttons
2024-09-18 07:48:30 +02:00
Simon Hausmann
d74e49e71f Skia renderer: Remove unnecessary scale factor argument / function 2024-09-10 10:24:07 +02:00
Olivier Goffart
fae774c821 Android: workaround PollEvent::Wake not being recieved
We observe, in issue #5699 that the call to `AndroidAppWaker::wake`
doesn't always result in a `PollEvent::Wake` event.
So to work around that, always process event from any event we recieve
so that any timeout or input event would make sure event gets processed.

Closes #5699
2024-08-07 14:53:50 +02:00
Olivier Goffart
8eb1543832 Android: create output directory for .class
According to https://github.com/slint-ui/slint/discussions/5662 , this might be necessary
2024-07-22 15:23:46 +02:00
Olivier Goffart
b9dc73bc6a Android: Print a warning when there is an error from the build script JDK 21
It doesn't compile:
```
Dex conversion failed: Error in ...\out\java\dev\slint\android-activity\SlintAndroidJavaHelper$1.class:
java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null
```

I don't know how to solve the error, but i can giv an informative
message telling them to downgrade Java

CC: #4973
2024-07-11 13:30:13 +02:00
Olivier Goffart
fe6f845ca0 Android: port to rwh 0.6 2024-06-18 17:48:17 +02:00
Simon Hausmann
0e67654431 Fix jitter when resizing a window on macOS
Commit 1e450abc9c originally fixed this. Meanwhile, after many refactorings, this doesn't work anymore for the FemtoVG renderer. That's because the contents placement (or layer's contents gravity) is set before the hidden layer NSOpenGLContext creates is associated with the view.

For the Skia GL surface that already works, but for clarify the code is moved into the same location.

For Skia Metal rendering, apply the same on the metal layer (through the view). For this to work the contents scale also needs to be applied. To avoid further visual effects, the scale needs to be applied as early as possible, so apply it right after creating the
surface and latest at rendering time.

Fixes #5258
2024-06-06 08:34:58 -07:00
Olivier Goffart
dea51f2055 Android: fix content positioning
The getWindowVisibleDisplayFrame seems to return a rectangle in the screen coordinate and cut the room for the camera.
The problem is that the Window is somehow already displaced.
The insets seems to be a better way to get that value.

Fixes #5242
2024-06-03 16:53:29 +02:00
Olivier Goffart
b3181b05a2 Android: clear the native focus when the keyboard hides
Otherwise the keyboard will popup again when the app is switched to the
background and back.

Fixes #5235
2024-06-03 16:27:47 +02:00
Olivier Goffart
a1e7f85892 Android: Always hide cursor/selection handle when the keyboard hides
Fixes #5233
2024-06-03 16:21:47 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Olivier Goffart
ebc4a14602 Update the android-activity crate by adding a new feature
The android-activity 0.5 no longer works with Rust 1.78 because it
asserts with
> slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

Note that the documentation is build with the 05 feature because it also
build the winit backend crate in the same command that still depends on
android-activity 0.5 via winit
2024-05-07 12:48:49 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Tobias Hunger
8a19e13dec android: Support Android 12
Make the code by @matthewjrichey found in issue #5031 into a PR:

> [...] discovered that `AMotionEvent_getActionButton` is only available on
> Android NDK 33 (Android 13) or higher. I came up with a working fix for the
> problem, which is tested and working on Android 12.

Done-by: @matthewjrichey
2024-04-12 14:46:50 +02:00
Simon Hausmann
68083243b2
Add an in-out boolean color-scheme property to Palette (#4701)
This allows applications to force dark/light mode, as well as determine
which mode is active.
2024-03-26 15:44:22 +01:00
Olivier Goffart
1f961a997b android: add the menu with cut/copy/paste when there is a selection
Also implement clipboard in the backend (Fixes #4865)
2024-03-26 14:50:55 +01:00
Olivier Goffart
8c2a798630 Android: long press select word 2024-03-26 14:50:55 +01:00
Olivier Goffart
2b7834e7c9 android: attempt to fix build if the locale is not UTF-8
Reported in https://fosstodon.org/@Karcsesz@equestria.social/112141146083141613

The build would fail with
```
error: unmappable character (0xC2) for encoding US-ASCII
```
Because of the © in the comment
2024-03-24 10:12:08 +01:00
Olivier Goffart
a61cf5239d Android: support for Java8
Older version of java used stderr for the version.
(As seen in https://github.com/slint-ui/slint/issues/4904#issuecomment-2014798778)
2024-03-22 14:23:10 +01:00
Olivier Goffart
fb0046c231 android: show a proper error when the version is java is too old
Also support Java 8 that did not support the --release argument yet.

Fix #4904
2024-03-22 09:20:13 +01:00
Olivier Goffart
b46effe65c Android: selection handle
Have two selection handle when there is selected text
2024-03-22 09:19:53 +01:00
Olivier Goffart
9f6b837f7d android: fix cursor and handle color
On android, the handle is the same as the cursor color and the cursor
color is usually the "accent" color.
We can't know the accent color from the native code, but we know the
selection color which is the accent color with a lesser opacity.
2024-03-20 15:06:34 +01:00
Olivier Goffart
504fbed476 android: only show cursor handle when we click 2024-03-20 12:46:10 +01:00
Olivier Goffart
528f85509b android: Moving cursor handle 2024-03-20 12:46:10 +01:00
Olivier Goffart
291a0bdc66 WIP: android cursor handle 2024-03-20 12:46:10 +01:00
Olivier Goffart
a77c8d4397 Update internal documentation of the android backend
The backend is now exposed through the Slint crate. No need to document
how to use the private API anymore
2024-03-18 13:44:14 +01:00
Olivier Goffart
3969e09d5b Remove debug output 2024-02-29 11:11:59 +01:00
Olivier Goffart
c4e0f4a265 Android: support for preedit
(Tested with the typewise keyboard)
2024-02-27 18:29:36 +01:00
Olivier Goffart
1fb162936e Android: simplify the text input with SpannableStringBuilder
Also needed some change on the Text item to avoid sending ime callback
for intermediate states
2024-02-27 18:29:36 +01:00
Olivier Goffart
b8f302464c Android: fix first frame not being translated after a rotation 2024-02-26 15:51:23 +01:00
Ralph Minderhoud
9cb1a4a4e0
Add API for minimize/maximize on Window component (#4581)
Closes #4400
2024-02-22 10:40:36 +01:00
Olivier Goffart
0db6e96f67 Update version number in android docs 2024-02-04 13:03:37 +01:00
Simon Hausmann
858ed639ec
Fix Android build on Windows (#4530)
- Use Path/OsStr to avoid directory separator mismatches
- Call d8.bat

Fixes #4524
2024-02-02 14:56:00 +01:00
Olivier Goffart
fadcbdf726 Android: send the input type to the input method
Also avoid flickering of the input method when inserting text by
preventing sending an imput method event right after deleting the
selection
2024-02-02 11:54:47 +01:00
Olivier Goffart
46dd8b1060 Android: refactor the JavaHelper to avoid that each function has unsafe 2024-01-31 14:56:42 +01:00
Olivier Goffart
d76631431e Android: Split the backend into modules
lib.rs started to be a bit big
2024-01-31 14:56:42 +01:00
Olivier Goffart
fb78bbd702 Android: Don't draw the UI under the system bars or the keyboard 2024-01-31 09:20:19 +01:00
Olivier Goffart
0f14b24cc6 janitor: android: fix warnings and group args together 2024-01-30 18:08:06 +01:00
Olivier Goffart
a9641a2d11 Update version number in the android readme 2024-01-30 15:26:02 +01:00
Olivier Goffart
25925b55fd android: detect dark or light style 2024-01-26 15:26:21 +01:00
Olivier Goffart
168654fa29 Android: Implement InputConnection
So that we can use text prediction and other input method features
2024-01-21 09:21:41 +01:00
Olivier Goffart
daa40f43cd Android: Use java code to show or hide the keyboard
instead of coding it all in JNI

This uses build.rs to compile the java code into bytecode that is then
embedded in the binary and loaded at runtime
2024-01-21 09:21:41 +01:00
Olivier Goffart
926c313493
Android docs: Fix warning in the documentation 2024-01-10 10:45:28 +01:00
Olivier Goffart
0725bb1b61
Android docs: mention the todo example 2024-01-10 10:06:15 +01:00
Olivier Goffart
b90047599e Android: Fix delete and backspace being inverted 2024-01-05 17:35:49 +01:00
Olivier Goffart
950ffb0041 Android: make the show/hide keyboard work with native-activity 2024-01-05 16:11:28 +01:00