Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 4d91c96

Browse files
authored
[android_intent] Bump to Flutter stable, remove deprecation warnings (#2586)
* Bumps Flutter & Dart dependencies to stable * Uses spread operator to concisely build arguments * Refactors and cleans up the plugin a bit
1 parent 5287930 commit 4d91c96

File tree

9 files changed

+44
-82
lines changed

9 files changed

+44
-82
lines changed

packages/android_intent/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.3.6+1
2+
3+
* Bump the minimum Flutter version to 1.12.13+hotfix.5.
4+
* Bump the minimum Dart version to 2.3.0.
5+
* Uses Darts spread operator to build plugin arguments internally.
6+
* Remove deprecated API usage warning in AndroidIntentPlugin.java.
7+
* Migrates the Android example to V2 embedding.
8+
19
## 0.3.6
210

311
* Marks the `action` parameter as optional

packages/android_intent/android/build.gradle

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,3 @@ dependencies {
4343
testImplementation 'androidx.test:core:1.0.0'
4444
testImplementation 'org.robolectric:robolectric:4.3'
4545
}
46-
47-
// TODO(mklim): Remove this hack once androidx.lifecycle is included on stable. https://github.com/flutter/flutter/issues/42348
48-
afterEvaluate {
49-
def containsEmbeddingDependencies = false
50-
for (def configuration : configurations.all) {
51-
for (def dependency : configuration.dependencies) {
52-
if (dependency.group == 'io.flutter' &&
53-
dependency.name.startsWith('flutter_embedding') &&
54-
dependency.isTransitive())
55-
{
56-
containsEmbeddingDependencies = true
57-
break
58-
}
59-
}
60-
}
61-
if (!containsEmbeddingDependencies) {
62-
android {
63-
dependencies {
64-
def lifecycle_version = "1.1.1"
65-
compileOnly "android.arch.lifecycle:runtime:$lifecycle_version"
66-
compileOnly "android.arch.lifecycle:common:$lifecycle_version"
67-
compileOnly "android.arch.lifecycle:common-java8:$lifecycle_version"
68-
}
69-
}
70-
}
71-
}

packages/android_intent/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static void registerWith(Registrar registrar) {
4242
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
4343
sender.setApplicationContext(binding.getApplicationContext());
4444
sender.setActivity(null);
45-
impl.startListening(binding.getFlutterEngine().getDartExecutor());
45+
impl.startListening(binding.getBinaryMessenger());
4646
}
4747

4848
@Override

packages/android_intent/example/android/app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@
1111
android:label="android_intent_example"
1212
android:name="io.flutter.app.FlutterApplication">
1313
<activity
14-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
15-
android:exported="true"
16-
android:hardwareAccelerated="true"
17-
android:launchMode="singleTop"
14+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
1815
android:name=".EmbeddingV1Activity"
1916
android:theme="@android:style/Theme.Black.NoTitleBar"
20-
android:windowSoftInputMode="adjustResize"/>
21-
<activity
22-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
2317
android:hardwareAccelerated="true"
24-
android:launchMode="singleTop"
25-
android:name=".MainActivity"
18+
android:windowSoftInputMode="adjustResize">
19+
</activity>
20+
21+
<activity android:name="io.flutter.embedding.android.FlutterActivity"
2622
android:theme="@android:style/Theme.Black.NoTitleBar"
23+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
24+
android:hardwareAccelerated="true"
2725
android:windowSoftInputMode="adjustResize">
26+
<meta-data
27+
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
28+
android:value="true" />
2829
<intent-filter>
2930
<action android:name="android.intent.action.MAIN"/>
3031
<category android:name="android.intent.category.LAUNCHER"/>
3132
</intent-filter>
3233
</activity>
34+
<meta-data android:name="flutterEmbedding" android:value="2"/>
3335
</application>
3436
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
3537

packages/android_intent/example/android/app/src/main/java/io/flutter/plugins/androidintentexample/EmbeddingV1Activity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
import android.os.Bundle;
88
import io.flutter.app.FlutterActivity;
9-
import io.flutter.plugins.GeneratedPluginRegistrant;
9+
import io.flutter.plugins.androidintent.AndroidIntentPlugin;
1010

1111
public class EmbeddingV1Activity extends FlutterActivity {
1212
@Override
1313
protected void onCreate(Bundle savedInstanceState) {
1414
super.onCreate(savedInstanceState);
15-
GeneratedPluginRegistrant.registerWith(this);
15+
AndroidIntentPlugin.registerWith(
16+
registrarFor("io.flutter.plugins.androidintent.AndroidIntentPlugin"));
1617
}
1718
}

packages/android_intent/example/android/app/src/main/java/io/flutter/plugins/androidintentexample/MainActivity.java

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

packages/android_intent/example/pubspec.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ dev_dependencies:
1616
# The following section is specific to Flutter.
1717
flutter:
1818
uses-material-design: true
19-
20-
environment:
21-
flutter: ">=1.9.1+hotfix.2 <2.0.0"

packages/android_intent/lib/android_intent.dart

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -134,31 +134,23 @@ class AndroidIntent {
134134
if (!_platform.isAndroid) {
135135
return;
136136
}
137-
final Map<String, dynamic> args = <String, dynamic>{};
138-
if (action != null) {
139-
args['action'] = action;
140-
}
141-
if (flags != null) {
142-
args['flags'] = convertFlags(flags);
143-
}
144-
if (category != null) {
145-
args['category'] = category;
146-
}
147-
if (data != null) {
148-
args['data'] = data;
149-
}
150-
if (arguments != null) {
151-
args['arguments'] = arguments;
152-
}
153-
if (package != null) {
154-
args['package'] = package;
155-
if (componentName != null) {
156-
args['componentName'] = componentName;
157-
}
158-
}
159-
if (type != null) {
160-
args['type'] = type;
161-
}
162-
await _channel.invokeMethod<void>('launch', args);
137+
138+
await _channel.invokeMethod<void>('launch', _buildArguments());
139+
}
140+
141+
/// Constructs the map of arguments which is passed to the plugin.
142+
Map<String, dynamic> _buildArguments() {
143+
return {
144+
if (action != null) 'action': action,
145+
if (flags != null) 'flags': convertFlags(flags),
146+
if (category != null) 'category': category,
147+
if (data != null) 'data': data,
148+
if (arguments != null) 'arguments': arguments,
149+
if (package != null) ...{
150+
'package': package,
151+
if (componentName != null) 'componentName': componentName,
152+
},
153+
if (type != null) 'type': type,
154+
};
163155
}
164156
}

packages/android_intent/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: android_intent
22
description: Flutter plugin for launching Android Intents. Not supported on iOS.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/android_intent
4-
version: 0.3.6
4+
version: 0.3.6+1
55

66
flutter:
77
plugin:
@@ -23,5 +23,5 @@ dev_dependencies:
2323
pedantic: ^1.8.0
2424

2525
environment:
26-
sdk: ">=2.0.0-dev.28.0 <3.0.0"
27-
flutter: ">=1.10.0 <2.0.0"
26+
sdk: ">=2.3.0 <3.0.0"
27+
flutter: ">=1.12.13+hotfix.5 <2.0.0"

0 commit comments

Comments
 (0)