Skip to content

Commit deb5501

Browse files
committed
refactor(dynamic_links,example): upgrade example to v2 Android embedding
1 parent 2448546 commit deb5501

File tree

6 files changed

+97
-89
lines changed

6 files changed

+97
-89
lines changed
Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,52 @@
11
def localProperties = new Properties()
22
def localPropertiesFile = rootProject.file('local.properties')
33
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
5-
localProperties.load(reader)
6-
}
4+
localPropertiesFile.withReader('UTF-8') { reader ->
5+
localProperties.load(reader)
6+
}
77
}
88

99
def flutterRoot = localProperties.getProperty('flutter.sdk')
1010
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
11+
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
1212
}
1313

1414
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1515
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
16+
flutterVersionCode = '1'
1717
}
1818

1919
def flutterVersionName = localProperties.getProperty('flutter.versionName')
2020
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
21+
flutterVersionName = '1.0'
2222
}
2323

2424
apply plugin: 'com.android.application'
25+
apply plugin: 'com.google.gms.google-services'
2526
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2627

2728
android {
28-
compileSdkVersion 29
29-
30-
lintOptions {
31-
disable 'InvalidPackage'
32-
}
33-
34-
defaultConfig {
35-
applicationId "io.flutter.plugins.firebasedynamiclinksexample"
36-
minSdkVersion 16
37-
targetSdkVersion 28
38-
versionCode flutterVersionCode.toInteger()
39-
versionName flutterVersionName
40-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
41-
}
42-
43-
buildTypes {
44-
release {
45-
signingConfig signingConfigs.debug
46-
}
29+
compileSdkVersion 29
30+
31+
lintOptions {
32+
disable 'InvalidPackage'
33+
}
34+
35+
defaultConfig {
36+
applicationId "io.flutter.plugins.firebasedynamiclinksexample"
37+
minSdkVersion 16
38+
targetSdkVersion 29
39+
versionCode flutterVersionCode.toInteger()
40+
versionName flutterVersionName
41+
}
42+
43+
buildTypes {
44+
release {
45+
signingConfig signingConfigs.debug
4746
}
47+
}
4848
}
4949

5050
flutter {
51-
source '../..'
52-
}
53-
54-
dependencies {
55-
androidTestImplementation 'androidx.test:runner:1.2.0'
56-
androidTestImplementation 'androidx.test:rules:1.2.0'
57-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
51+
source '../..'
5852
}
59-
60-
apply plugin: 'com.google.gms.google-services'
Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="io.flutter.plugins.firebasedynamiclinksexample">
3-
4-
<uses-permission android:name="android.permission.INTERNET"/>
5-
<application>
6-
<activity android:name="io.flutter.embedding.android.FlutterActivity"
7-
android:theme="@android:style/Theme.Black.NoTitleBar"
8-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
9-
android:hardwareAccelerated="true"
10-
android:windowSoftInputMode="adjustResize">
11-
<meta-data
12-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
13-
android:value="true" />
14-
<intent-filter>
15-
<action android:name="android.intent.action.MAIN"/>
16-
<category android:name="android.intent.category.LAUNCHER"/>
17-
</intent-filter>
18-
</activity>
19-
<meta-data android:name="flutterEmbedding" android:value="2"/>
20-
</application>
2+
package="io.flutter.plugins.firebasedynamiclinksexample">
3+
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
4+
calls FlutterMain.startInitialization(this); in its onCreate method.
5+
In most cases you can leave this as-is, but you if you want to provide
6+
additional functionality it is fine to subclass or reimplement
7+
FlutterApplication and put your custom class here. -->
8+
<application
9+
android:name="io.flutter.app.FlutterApplication"
10+
android:label="firebase_dynamic_links_example"
11+
android:icon="@mipmap/ic_launcher">
12+
<activity
13+
android:name="io.flutter.plugins.firebasedynamiclinksexample.MainActivity"
14+
android:launchMode="singleTop"
15+
android:theme="@style/LaunchTheme"
16+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
17+
android:hardwareAccelerated="true"
18+
android:windowSoftInputMode="adjustResize">
19+
<!-- Specifies an Android theme to apply to this Activity as soon as
20+
the Android process has started. This theme is visible to the user
21+
while the Flutter UI initializes. After that, this theme continues
22+
to determine the Window background behind the Flutter UI. -->
23+
<meta-data
24+
android:name="io.flutter.embedding.android.NormalTheme"
25+
android:resource="@style/NormalTheme"
26+
/>
27+
<!-- Displays an Android View that continues showing the launch screen
28+
Drawable until Flutter paints its first frame, then this splash
29+
screen fades out. A splash screen is useful to avoid any visual
30+
gap between the end of Android's launch screen and the painting of
31+
Flutter's first frame. -->
32+
<meta-data
33+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
34+
android:resource="@drawable/launch_background"
35+
/>
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN"/>
38+
<category android:name="android.intent.category.LAUNCHER"/>
39+
</intent-filter>
40+
</activity>
41+
<!-- Don't delete the meta-data below.
42+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
43+
<meta-data
44+
android:name="flutterEmbedding"
45+
android:value="2" />
46+
</application>
2147
</manifest>

packages/firebase_dynamic_links/example/android/app/src/main/java/io/flutter/plugins/firebasedynamiclinksexample/EmbeddingV1Activity.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.flutter.plugins.firebasedynamiclinksexample;
2+
3+
import io.flutter.embedding.android.FlutterActivity;
4+
5+
public class MainActivity extends FlutterActivity {}
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
4-
<!-- Show a splash screen on the activity. Automatically removed when
5-
Flutter draws its first frame -->
6-
<item name="android:windowBackground">@drawable/launch_background</item>
7-
</style>
3+
<!-- Theme applied to the Android Window while the process is starting -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
5+
<!-- Show a splash screen on the activity. Automatically removed when
6+
Flutter draws its first frame -->
7+
<item name="android:windowBackground">@drawable/launch_background</item>
8+
</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.
13+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
14+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
15+
<item name="android:windowBackground">@android:color/white</item>
16+
</style>
817
</resources>
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
include ':app'
22

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
3+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4+
def properties = new Properties()
45

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9-
}
6+
assert localPropertiesFile.exists()
7+
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
108

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
15-
}
9+
def flutterSdkPath = properties.getProperty("flutter.sdk")
10+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11+
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

0 commit comments

Comments
 (0)