Skip to content

Commit d1a8f86

Browse files
[Feat|Android] Support for embedding v2 (#342)
* Adds support for embedding v2 * Update android sample for embedding v2 * Updating package version * Update readme * Updating pubspec.yaml * Updating package version * changelog * strange spacing * Updating pubspec.yaml * Updating package version --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent afca8f9 commit d1a8f86

File tree

24 files changed

+193
-216
lines changed

24 files changed

+193
-216
lines changed

.dart_tool/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.2
1+
3.32.0

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.0.1-45 - Jun 10, 2025
2+
- Update Android to embedding v2
3+
14
# 1.0.1-44 - May 28, 2025
25
- Update Android to v11.5.0
36

README.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,44 +80,32 @@ The following instructions are only applicable to Android development; click her
8080
```diff
8181
defaultConfig {
8282
applicationId "com.example.myapp"
83-
- minSdkVersion flutter.minSdkVersion
84-
+ minSdkVersion 21
85-
+ multiDexEnabled true
86-
+ manifestPlaceholders += [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
8783
targetSdkVersion flutter.targetSdkVersion
8884
versionCode flutterVersionCode.toInteger()
8985
versionName flutterVersionName
86+
87+
+ resValue("string", "PDFTRON_LICENSE_KEY", "\"LICENSE_KEY_GOES_HERE\"")
9088
}
9189
```
92-
93-
5. In your `myapp/android/gradle.properties` file, add the following line:
94-
``` diff
95-
# Add the PDFTRON_LICENSE_KEY variable here.
96-
# For trial purposes leave it blank.
97-
# For production add a valid commercial license key.
98-
PDFTRON_LICENSE_KEY=
99-
```
10090

101-
6. In your `myapp/android/app/src/main/AndroidManifest.xml` file, add the following lines:
91+
5. In your `myapp/android/app/src/main/AndroidManifest.xml` file, add the following lines:
10292
```diff
10393
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
10494
package="com.example.myapp">
10595

96+
<!-- Required if you want to work with online documents -->
10697
+ <uses-permission android:name="android.permission.INTERNET" />
107-
<!-- Required to read and write documents from device storage -->
108-
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10998
<!-- Required if you want to record audio annotations -->
11099
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
111100

112101
<application
113102
...
114-
+ android:largeHeap="true"
115-
+ android:usesCleartextTraffic="true">
103+
+ android:largeHeap="true">
116104

117105
<!-- Add license key in meta-data tag here. This should be inside the application tag. -->
118106
+ <meta-data
119107
+ android:name="pdftron_license_key"
120-
+ android:value="${pdftronLicenseKey}"/>
108+
+ android:value="@string/PDFTRON_LICENSE_KEY" />
121109
...
122110
```
123111

@@ -135,9 +123,9 @@ The following instructions are only applicable to Android development; click her
135123
}
136124
```
137125

138-
7. Follow the instructions outlined [in the Usage section](#usage).
139-
8. Check that your Android device is running by running the command `flutter devices`. If none are available, follow the device set up instructions in the [Install](https://flutter.io/docs/get-started/install) guides for your platform.
140-
9. Run the app with the command `flutter run`.
126+
6. Follow the instructions outlined [in the Usage section](#usage).
127+
7. Check that your Android device is running by running the command `flutter devices`. If none are available, follow the device set up instructions in the [Install](https://flutter.io/docs/get-started/install) guides for your platform.
128+
8. Run the app with the command `flutter run`.
141129

142130
### iOS
143131

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.pdftron.pdftronflutter'
2-
version '2.0'
2+
version '3.0.0'
33

44
buildscript {
55
repositories {
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.2.0'
11+
classpath 'com.android.tools.build:gradle:8.0.2'
1212
}
1313
}
1414

@@ -30,7 +30,7 @@ android {
3030
compileSdk 34
3131

3232
defaultConfig {
33-
minSdkVersion 19
33+
minSdk = 21
3434
vectorDrawables.useSupportLibrary = true
3535
}
3636
lintOptions {

android/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
<application>
55

6+
<meta-data
7+
android:name="flutterEmbedding"
8+
android:value="2" />
9+
610
<!-- Document viewer activity declaration-->
711
<activity
812
android:name=".FlutterDocumentActivity"

android/src/main/java/com/pdftron/pdftronflutter/PdftronFlutterPlugin.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.pdftron.pdftronflutter;
22

3-
import android.content.Context;
4-
53
import com.pdftron.pdftronflutter.factories.DocumentViewFactory;
64
import com.pdftron.pdftronflutter.helpers.PluginMethodCallHandler;
75

@@ -10,7 +8,6 @@
108
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
119
import io.flutter.plugin.common.BinaryMessenger;
1210
import io.flutter.plugin.common.MethodChannel;
13-
import io.flutter.plugin.common.PluginRegistry.Registrar;
1411
import io.flutter.plugin.platform.PlatformViewRegistry;
1512

1613
/**
@@ -24,7 +21,8 @@ public class PdftronFlutterPlugin implements FlutterPlugin, ActivityAware {
2421
private BinaryMessenger mMessenger;
2522
private MethodChannel mMethodChannel;
2623

27-
public PdftronFlutterPlugin() { }
24+
public PdftronFlutterPlugin() {
25+
}
2826

2927
@Override
3028
public void onAttachedToEngine(FlutterPluginBinding binding) {
@@ -47,25 +45,15 @@ public void onAttachedToActivity(ActivityPluginBinding binding) {
4745
}
4846

4947
@Override
50-
public void onDetachedFromActivityForConfigChanges() { }
48+
public void onDetachedFromActivityForConfigChanges() {
49+
}
5150

5251
@Override
5352
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
5453
mRegistry.registerViewFactory(viewTypeId, new DocumentViewFactory(mMessenger, binding.getActivity()));
5554
}
5655

5756
@Override
58-
public void onDetachedFromActivity() { }
59-
60-
/**
61-
* Plugin registration using Android embedding v1.
62-
*/
63-
public static void registerWith(Registrar registrar) {
64-
final MethodChannel methodChannel = new MethodChannel(registrar.messenger(), "pdftron_flutter");
65-
methodChannel.setMethodCallHandler(new PluginMethodCallHandler(registrar.messenger(), registrar.activeContext()));
66-
registrar
67-
.platformViewRegistry()
68-
.registerViewFactory(viewTypeId,
69-
new DocumentViewFactory(registrar.messenger(), registrar.activeContext()));
57+
public void onDetachedFromActivity() {
7058
}
7159
}

example/android/app/build.gradle

Lines changed: 0 additions & 67 deletions
This file was deleted.

example/android/app/build.gradle.kts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
plugins {
2+
id("com.android.application")
3+
id("kotlin-android")
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id("dev.flutter.flutter-gradle-plugin")
6+
}
7+
8+
android {
9+
namespace = "com.pdftron.pdftronflutterexample"
10+
compileSdk = flutter.compileSdkVersion
11+
ndkVersion = flutter.ndkVersion
12+
13+
compileOptions {
14+
sourceCompatibility = JavaVersion.VERSION_11
15+
targetCompatibility = JavaVersion.VERSION_11
16+
}
17+
18+
kotlinOptions {
19+
jvmTarget = JavaVersion.VERSION_11.toString()
20+
}
21+
22+
defaultConfig {
23+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
24+
applicationId = "com.pdftron.pdftronflutterexample"
25+
// You can update the following values to match your application needs.
26+
// For more information, see: https://flutter.dev/to/review-gradle-config.
27+
minSdk = flutter.minSdkVersion
28+
targetSdk = flutter.targetSdkVersion
29+
versionCode = flutter.versionCode
30+
versionName = flutter.versionName
31+
32+
resValue("string", "PDFTRON_LICENSE_KEY", "\"LICENSE_KEY_GOES_HERE\"")
33+
}
34+
35+
buildTypes {
36+
release {
37+
// TODO: Add your own signing config for the release build.
38+
// Signing with the debug keys for now, so `flutter run --release` works.
39+
signingConfig = signingConfigs.getByName("debug")
40+
}
41+
}
42+
}
43+
44+
flutter {
45+
source = "../.."
46+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<!-- The INTERNET permission is required for development. Specifically,
3+
the Flutter tool needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.pdftron.pdftronflutterexample">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

43
<uses-permission android:name="android.permission.INTERNET" />
5-
<!-- Required to read and write documents from device storage -->
6-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
74
<!-- Required if you want to record audio annotations -->
85
<uses-permission android:name="android.permission.RECORD_AUDIO" />
96

107
<application
118
android:label="pdftron_flutter_example"
129
android:name="${applicationName}"
13-
android:icon="@mipmap/ic_launcher"
1410
android:largeHeap="true"
15-
android:requestLegacyExternalStorage="true"
16-
android:usesCleartextTraffic="true">
11+
android:icon="@mipmap/ic_launcher">
1712

18-
<!-- Add license key in meta-data tag here. This should be inside the application tag. -->
1913
<meta-data
2014
android:name="pdftron_license_key"
21-
android:value="${pdftronLicenseKey}" />
15+
android:value="@string/PDFTRON_LICENSE_KEY" />
2216

2317
<activity
2418
android:name=".MainActivity"
2519
android:exported="true"
2620
android:launchMode="singleTop"
27-
android:theme="@style/PDFTronAppTheme"
21+
android:taskAffinity=""
22+
android:theme="@style/LaunchTheme"
2823
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
2924
android:hardwareAccelerated="true"
3025
android:windowSoftInputMode="adjustPan">
@@ -33,20 +28,29 @@
3328
while the Flutter UI initializes. After that, this theme continues
3429
to determine the Window background behind the Flutter UI. -->
3530
<meta-data
36-
android:name="io.flutter.embedding.android.NormalTheme"
37-
android:resource="@style/NormalTheme"
38-
/>
31+
android:name="io.flutter.embedding.android.NormalTheme"
32+
android:resource="@style/NormalTheme"
33+
/>
3934
<intent-filter>
40-
<action android:name="android.intent.action.MAIN" />
41-
<category android:name="android.intent.category.LAUNCHER" />
35+
<action android:name="android.intent.action.MAIN"/>
36+
<category android:name="android.intent.category.LAUNCHER"/>
4237
</intent-filter>
4338
</activity>
44-
4539
<!-- Don't delete the meta-data below.
4640
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
4741
<meta-data
4842
android:name="flutterEmbedding"
4943
android:value="2" />
50-
5144
</application>
45+
<!-- Required to query activities that can process text, see:
46+
https://developer.android.com/training/package-visibility and
47+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
48+
49+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
50+
<queries>
51+
<intent>
52+
<action android:name="android.intent.action.PROCESS_TEXT"/>
53+
<data android:mimeType="text/plain"/>
54+
</intent>
55+
</queries>
5256
</manifest>

0 commit comments

Comments
 (0)