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

Commit c678af6

Browse files
author
Miguel Ruivo
authored
Merge branch 'master' into image_picker-Fix-#41046
2 parents f7317b8 + da580fc commit c678af6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+691
-236
lines changed

.cirrus.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ task:
1313
activate_script: pub global activate flutter_plugin_tools
1414
matrix:
1515
- name: publishable
16-
script: ./script/check_publish.sh
16+
script:
17+
- flutter channel stable
18+
- ./script/check_publish.sh
1719
- name: format
1820
install_script:
1921
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -

packages/connectivity/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.5+4
2+
3+
* Stability and Maintainability: update documentations.
4+
15
## 0.4.5+3
26

37
* Remove AndroidX warnings.

packages/connectivity/example/README.md

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

packages/connectivity/lib/connectivity.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:meta/meta.dart';
1515
/// None: Device not connected to any network
1616
enum ConnectivityResult { wifi, mobile, none }
1717

18+
/// Discover network connectivity configurations: Distinguish between WI-FI and cellular, check WI-FI status and more.
1819
class Connectivity {
1920
/// Constructs a singleton instance of [Connectivity].
2021
///
@@ -35,11 +36,13 @@ class Connectivity {
3536

3637
Stream<ConnectivityResult> _onConnectivityChanged;
3738

39+
/// Exposed for testing purposes and should not be used by users of the plugin.
3840
@visibleForTesting
3941
static const MethodChannel methodChannel = MethodChannel(
4042
'plugins.flutter.io/connectivity',
4143
);
4244

45+
/// Exposed for testing purposes and should not be used by users of the plugin.
4346
@visibleForTesting
4447
static const EventChannel eventChannel = EventChannel(
4548
'plugins.flutter.io/connectivity_status',

packages/connectivity/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for discovering the state of the network (WiFi &
33
mobile/cellular) connectivity on Android and iOS.
44
author: Flutter Team <[email protected]>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity
6-
version: 0.4.5+3
6+
version: 0.4.5+4
77

88
flutter:
99
plugin:

packages/image_picker/CHANGELOG.md

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

33
* iOS: Fixes an issue where picking conent from Gallery would result in a crash on iOS 13.
44

5+
## 0.6.1+11
6+
7+
* Stability and Maintainability: update documentations, add unit tests.
8+
59
## 0.6.1+10
610

711
* iOS: Fix image orientation problems when scaling images.

packages/image_picker/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
A Flutter plugin for iOS and Android for picking images from the image library,
66
and taking new pictures with the camera.
77

8-
*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback welcome](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome!
9-
108
## Installation
119

1210
First, add `image_picker` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
@@ -67,7 +65,7 @@ class _MyHomePageState extends State<MyHomePage> {
6765

6866
### Handling MainActivity destruction on Android
6967

70-
Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use `retrieveLostData` to retrieve the lost data in this situation. For example:
68+
Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use `retrieveLostData` to retrieve the lost data in this situation. For example:
7169

7270
```dart
7371
Future<void> retrieveLostData() async {

packages/image_picker/lib/image_picker.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ enum ImageSource {
2020
gallery,
2121
}
2222

23+
/// Provides an easy way to pick an image/video from the image library,
24+
/// or to take a picture/video with the camera.
2325
class ImagePicker {
2426
static const MethodChannel _channel =
2527
MethodChannel('plugins.flutter.io/image_picker');

packages/image_picker/test/image_picker_test.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,33 @@ void main() {
143143
});
144144
});
145145

146+
group('#pickVideo', () {
147+
test('passes the image source argument correctly', () async {
148+
await ImagePicker.pickVideo(source: ImageSource.camera);
149+
await ImagePicker.pickVideo(source: ImageSource.gallery);
150+
151+
expect(
152+
log,
153+
<Matcher>[
154+
isMethodCall('pickVideo', arguments: <String, dynamic>{
155+
'source': 0,
156+
}),
157+
isMethodCall('pickVideo', arguments: <String, dynamic>{
158+
'source': 1,
159+
}),
160+
],
161+
);
162+
});
163+
164+
test('handles a null image path response gracefully', () async {
165+
channel.setMockMethodCallHandler((MethodCall methodCall) => null);
166+
167+
expect(
168+
await ImagePicker.pickVideo(source: ImageSource.gallery), isNull);
169+
expect(await ImagePicker.pickVideo(source: ImageSource.camera), isNull);
170+
});
171+
});
172+
146173
group('#retrieveLostData', () {
147174
test('retrieveLostData get success response', () async {
148175
channel.setMockMethodCallHandler((MethodCall methodCall) async {

packages/quick_actions/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.3.3
2+
3+
* Support Android V2 embedding.
4+
* Add e2e tests.
5+
* Migrate to using the new e2e test binding.
6+
17
## 0.3.2+4
28

39
* Remove AndroidX warnings.
@@ -7,6 +13,7 @@
713
* Define clang module for iOS.
814

915
## 0.3.2+2
16+
1017
* Fix bug that would make the shortcut not open on Android.
1118
* Report shortcut used on Android.
1219
* Improves example.
@@ -17,7 +24,7 @@
1724

1825
## 0.3.2
1926

20-
* Fixed the quick actions launch on Android when the app is killed.
27+
* Fixed the quick actions launch on Android when the app is killed.
2128

2229
## 0.3.1
2330

packages/quick_actions/android/build.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,28 @@ android {
3232
disable 'InvalidPackage'
3333
}
3434
}
35+
36+
afterEvaluate {
37+
def containsEmbeddingDependencies = false
38+
for (def configuration : configurations.all) {
39+
for (def dependency : configuration.dependencies) {
40+
if (dependency.group == 'io.flutter' &&
41+
dependency.name.startsWith('flutter_embedding') &&
42+
dependency.isTransitive())
43+
{
44+
containsEmbeddingDependencies = true
45+
break
46+
}
47+
}
48+
}
49+
if (!containsEmbeddingDependencies) {
50+
android {
51+
dependencies {
52+
def lifecycle_version = "1.1.1"
53+
compileOnly "android.arch.lifecycle:runtime:$lifecycle_version"
54+
compileOnly "android.arch.lifecycle:common:$lifecycle_version"
55+
compileOnly "android.arch.lifecycle:common-java8:$lifecycle_version"
56+
}
57+
}
58+
}
59+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// Copyright 2019 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.quickactions;
6+
7+
import android.annotation.TargetApi;
8+
import android.app.Activity;
9+
import android.content.Context;
10+
import android.content.Intent;
11+
import android.content.pm.ShortcutInfo;
12+
import android.content.pm.ShortcutManager;
13+
import android.content.res.Resources;
14+
import android.graphics.drawable.Icon;
15+
import android.os.Build;
16+
import io.flutter.plugin.common.MethodCall;
17+
import io.flutter.plugin.common.MethodChannel;
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
class MethodCallHandlerImpl implements MethodChannel.MethodCallHandler {
23+
24+
private static final String CHANNEL_ID = "plugins.flutter.io/quick_actions";
25+
private static final String EXTRA_ACTION = "some unique action key";
26+
27+
private final Context context;
28+
private Activity activity;
29+
30+
MethodCallHandlerImpl(Context context, Activity activity) {
31+
this.context = context;
32+
this.activity = activity;
33+
}
34+
35+
void setActivity(Activity activity) {
36+
this.activity = activity;
37+
}
38+
39+
@Override
40+
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
41+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
42+
// We already know that this functionality does not work for anything
43+
// lower than API 25 so we chose not to return error. Instead we do nothing.
44+
result.success(null);
45+
return;
46+
}
47+
ShortcutManager shortcutManager =
48+
(ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
49+
switch (call.method) {
50+
case "setShortcutItems":
51+
List<Map<String, String>> serializedShortcuts = call.arguments();
52+
List<ShortcutInfo> shortcuts = deserializeShortcuts(serializedShortcuts);
53+
shortcutManager.setDynamicShortcuts(shortcuts);
54+
break;
55+
case "clearShortcutItems":
56+
shortcutManager.removeAllDynamicShortcuts();
57+
break;
58+
case "getLaunchAction":
59+
if (activity == null) {
60+
result.error(
61+
"quick_action_getlaunchaction_no_activity",
62+
"There is no activity available when launching action",
63+
null);
64+
return;
65+
}
66+
final Intent intent = activity.getIntent();
67+
final String launchAction = intent.getStringExtra(EXTRA_ACTION);
68+
if (launchAction != null && !launchAction.isEmpty()) {
69+
shortcutManager.reportShortcutUsed(launchAction);
70+
intent.removeExtra(EXTRA_ACTION);
71+
}
72+
result.success(launchAction);
73+
return;
74+
default:
75+
result.notImplemented();
76+
return;
77+
}
78+
result.success(null);
79+
}
80+
81+
@TargetApi(Build.VERSION_CODES.N_MR1)
82+
private List<ShortcutInfo> deserializeShortcuts(List<Map<String, String>> shortcuts) {
83+
final List<ShortcutInfo> shortcutInfos = new ArrayList<>();
84+
85+
for (Map<String, String> shortcut : shortcuts) {
86+
final String icon = shortcut.get("icon");
87+
final String type = shortcut.get("type");
88+
final String title = shortcut.get("localizedTitle");
89+
final ShortcutInfo.Builder shortcutBuilder = new ShortcutInfo.Builder(context, type);
90+
91+
final int resourceId = loadResourceId(context, icon);
92+
final Intent intent = getIntentToOpenMainActivity(type);
93+
94+
if (resourceId > 0) {
95+
shortcutBuilder.setIcon(Icon.createWithResource(context, resourceId));
96+
}
97+
98+
final ShortcutInfo shortcutInfo =
99+
shortcutBuilder.setLongLabel(title).setShortLabel(title).setIntent(intent).build();
100+
shortcutInfos.add(shortcutInfo);
101+
}
102+
return shortcutInfos;
103+
}
104+
105+
private int loadResourceId(Context context, String icon) {
106+
if (icon == null) {
107+
return 0;
108+
}
109+
final String packageName = context.getPackageName();
110+
final Resources res = context.getResources();
111+
final int resourceId = res.getIdentifier(icon, "drawable", packageName);
112+
113+
if (resourceId == 0) {
114+
return res.getIdentifier(icon, "mipmap", packageName);
115+
} else {
116+
return resourceId;
117+
}
118+
}
119+
120+
private Intent getIntentToOpenMainActivity(String type) {
121+
final String packageName = context.getPackageName();
122+
123+
return context
124+
.getPackageManager()
125+
.getLaunchIntentForPackage(packageName)
126+
.setAction(Intent.ACTION_RUN)
127+
.putExtra(EXTRA_ACTION, type)
128+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
129+
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
130+
}
131+
}

0 commit comments

Comments
 (0)