Skip to content

Commit 1351308

Browse files
committed
Update android sample for embedding v2
1 parent e042463 commit 1351308

File tree

17 files changed

+167
-173
lines changed

17 files changed

+167
-173
lines changed

example/android/app/build.gradle

Lines changed: 0 additions & 67 deletions
This file was deleted.
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>

example/android/app/src/main/java/com/pdftron/pdftronflutterexample/MainActivity.java

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.pdftron.pdftronflutterexample
2+
3+
import io.flutter.embedding.android.FlutterFragmentActivity
4+
5+
class MainActivity : FlutterFragmentActivity()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Modify this file to customize your launch splash screen -->
3+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:drawable="?android:colorBackground" />
5+
6+
<!-- You can insert your own image assets here -->
7+
<!-- <item>
8+
<bitmap
9+
android:gravity="center"
10+
android:src="@mipmap/launch_image" />
11+
</item> -->
12+
</layer-list>
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
4-
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
5-
<item name="colorPrimary">#212634</item>
6-
<item name="colorPrimaryDark">#3D4763</item>
7-
<item name="colorAccent">#FFA153</item>
8-
<item name="android:colorBackground">#212634</item>
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
5+
<!-- Show a splash screen on the activity. Automatically removed when
6+
the Flutter engine draws its first frame -->
7+
<item name="android:windowBackground">@drawable/launch_background</item>
98
</style>
9+
<!-- Theme applied to the Android Window as soon as the process has started.
10+
This theme determines the color of the Android Window while your
11+
Flutter UI initializes, as well as behind your Flutter UI while its
12+
running.
1013
14+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
15+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
17+
</style>
1118
</resources>
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<style name="LaunchTheme" parent="AppTheme">
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
45
<!-- Show a splash screen on the activity. Automatically removed when
5-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
67
<item name="android:windowBackground">@drawable/launch_background</item>
78
</style>
8-
9-
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
10-
<item name="colorPrimary">#56607D</item>
11-
<item name="colorPrimaryDark">#3D4763</item>
12-
<item name="colorAccent">#FFA153</item>
13-
</style>
14-
159
<!-- Theme applied to the Android Window as soon as the process has started.
1610
This theme determines the color of the Android Window while your
1711
Flutter UI initializes, as well as behind your Flutter UI while its
@@ -21,5 +15,4 @@
2115
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
2216
<item name="android:windowBackground">?android:colorBackground</item>
2317
</style>
24-
2518
</resources>
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>

0 commit comments

Comments
 (0)