Skip to content

Commit 9fb0a9e

Browse files
committed
Sync with core 80247bb and document clipboard_watcher migration
1 parent f0f2f2d commit 9fb0a9e

22 files changed

Lines changed: 624 additions & 12 deletions

File tree

‎bindings/dart/cnativeapi/CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## 0.5.3
22

33
- macOS: add `ShortcutReleasedEvent` for system key-up delivery and accept Fn / CapsLock accelerators (hotkey_manager migration).
4-
- Add desktop clipboard text, HTML, images, file paths, multi-format writes and change notifications.
4+
- Add clipboard text, HTML, images, file paths, multi-format writes and change notifications on macOS, Windows, Linux, Android and iOS (subject to mobile focus, permission and sandbox rules).
55

66
## 0.5.2
77

‎bindings/dart/cnativeapi/hook/build.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ void main(List<String> args) async {
113113
flags: flags,
114114
language: Language.cpp,
115115
std: 'c++17',
116+
// Native assets package this one library; no Gradle CMake target supplies
117+
// libc++_shared.so. Keep the NDK runtime inside our Android library.
118+
cppLinkStdLib: targetOS == OS.android ? 'c++_static' : null,
116119
);
117120
await builder.run(
118121
input: input,

‎bindings/dart/nativeapi/CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## 0.5.3
22

33
- macOS: add `ShortcutReleasedEvent` for system key-up delivery and accept Fn / CapsLock accelerators (hotkey_manager migration).
4-
- Add desktop clipboard text, HTML, images, file paths, multi-format writes and change notifications.
4+
- Add clipboard text, HTML, images, file paths, multi-format writes and change notifications on macOS, Windows, Linux, Android and iOS (subject to mobile focus, permission and sandbox rules).
55
- macOS: the title bar's close button is a cancellable close request again.
66
On macOS 26 it bypassed `WindowCloseRequestedEvent` and closed the window
77
even when a listener cancelled.

‎bindings/dart/nativeapi_flutter/CHANGELOG.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
## 0.5.3
22

3+
- Automatically initialize the Android core from the Flutter engine and activity lifecycle.
4+
35
- macOS: add `ShortcutReleasedEvent` for system key-up delivery and accept Fn / CapsLock accelerators (hotkey_manager migration).
4-
- Add desktop clipboard text, HTML, images, file paths, multi-format writes and change notifications.
6+
- Add clipboard text, HTML, images, file paths, multi-format writes and change notifications on macOS, Windows, Linux, Android and iOS (subject to mobile focus, permission and sandbox rules).
57

68
## 0.5.2
79

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import groovy.json.JsonSlurper
2+
3+
group = 'dev.nativeapi.flutter'
4+
version = '1.0'
5+
6+
buildscript {
7+
repositories { google(); mavenCentral() }
8+
dependencies { classpath 'com.android.tools.build:gradle:8.9.1' }
9+
}
10+
apply plugin: 'com.android.library'
11+
12+
// The core's Java companion travels with cnativeapi's vendored C++ sources.
13+
// Resolve the package through pub's metadata, including local workspace overrides.
14+
def configRoot = rootProject.projectDir.parentFile
15+
while (configRoot != null && !new File(configRoot, '.dart_tool/package_config.json').isFile()) {
16+
configRoot = configRoot.parentFile
17+
}
18+
if (configRoot == null) throw new GradleException('Run flutter pub get before building nativeapi_flutter')
19+
def configFile = new File(configRoot, '.dart_tool/package_config.json')
20+
def packageConfig = new JsonSlurper().parse(configFile)
21+
def rawPackage = packageConfig.packages.find { it.name == 'cnativeapi' }
22+
if (rawPackage == null) throw new GradleException('cnativeapi is missing from package_config.json')
23+
def packageRoot = new File(configFile.toURI().resolve(rawPackage.rootUri))
24+
def candidates = [new File(packageRoot, 'cxx_impl'), new File(packageRoot, '../../../core')]
25+
def coreRoot = candidates.find { new File(it, 'src/platform/android/java').isDirectory() }
26+
if (coreRoot == null) throw new GradleException('nativeapi Android core sources are missing')
27+
28+
android {
29+
namespace = 'dev.nativeapi.flutter'
30+
compileSdk = 36
31+
defaultConfig {
32+
minSdk = 24
33+
consumerProguardFiles 'consumer-rules.pro'
34+
}
35+
compileOptions {
36+
sourceCompatibility = JavaVersion.VERSION_1_8
37+
targetCompatibility = JavaVersion.VERSION_1_8
38+
}
39+
sourceSets.main.java.srcDir new File(coreRoot, 'src/platform/android/java')
40+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# The core locates these entry points and snapshot fields through JNI.
2+
-keep class dev.nativeapi.NativeApi { *; }
3+
-keep class dev.nativeapi.NativeApi$* { *; }
4+
-keep class dev.nativeapi.NativeApiClipboardProvider { *; }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<application>
3+
<provider
4+
android:name="dev.nativeapi.NativeApiClipboardProvider"
5+
android:authorities="${applicationId}.nativeapi.clipboard"
6+
android:exported="false"
7+
android:grantUriPermissions="true" />
8+
</application>
9+
</manifest>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package dev.nativeapi.flutter;
2+
3+
import dev.nativeapi.NativeApi;
4+
import io.flutter.embedding.engine.plugins.FlutterPlugin;
5+
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
6+
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
7+
8+
/** Supplies only Android's Application/activity to the binding-independent core. */
9+
public final class NativeApiPlugin implements FlutterPlugin, ActivityAware {
10+
private android.app.Activity activity;
11+
@Override public void onAttachedToEngine(FlutterPluginBinding binding) {
12+
System.loadLibrary("cnativeapi");
13+
if (!NativeApi.initialize(binding.getApplicationContext())) {
14+
throw new IllegalStateException("nativeapi Android initialization failed");
15+
}
16+
}
17+
@Override public void onDetachedFromEngine(FlutterPluginBinding binding) { detach(); }
18+
@Override public void onAttachedToActivity(ActivityPluginBinding binding) {
19+
activity = binding.getActivity();
20+
NativeApi.attachActivity(activity);
21+
}
22+
private void detach() {
23+
if (activity != null) NativeApi.detachActivity(activity);
24+
activity = null;
25+
}
26+
@Override public void onDetachedFromActivityForConfigChanges() { detach(); }
27+
@Override public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) { onAttachedToActivity(binding); }
28+
@Override public void onDetachedFromActivity() { detach(); }
29+
}

‎bindings/dart/nativeapi_flutter/pubspec.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ dev_dependencies:
1919
flutter_test:
2020
sdk: flutter
2121
flutter_lints: ^5.0.0
22+
23+
flutter:
24+
plugin:
25+
platforms:
26+
android:
27+
package: dev.nativeapi.flutter
28+
pluginClass: NativeApiPlugin

0 commit comments

Comments
 (0)