Skip to content

Commit

Permalink
Merge branch 'master' into kg-connectivity-ios-permissions
Browse files Browse the repository at this point in the history
* master:
  [url_launcher, url_launcher_web]Added webOnlyWindowName parameter to launch()  (flutter#2979)
  [battery_platform_interface] Introduce package. (flutter#2975)
  [url_launcher_platform_interface] Add webOnlyWindowName parameter to launch() (flutter#2974)
  [share] Add sharing file support (android & ios) (flutter#970)
  [integration_test] add support to get timeline (flutter#2947)
  [battery] Moved battery to its own subdir (flutter#2969)
  [integration_test] Fix channel name for iOS, docs (flutter#2972)
  [integration_test] Show stack trace of widget test errors on the platform side (flutter#2967)
  [video_player] Fix `setWithOthers` test (flutter#2970)
  [video_player_platform_interface] fix `setMixIWithOthers` test channel (flutter#2968)
  Add README instructions for enablePendingPurchases (flutter#2921)
  Rebase previous commits (flutter#2966)
  Avoid walleye 26
  Updating documentation to use isEmpty check. (flutter#2955)
  [integration_test] Minor cleanup (flutter#2956)
  [path_provider, video_player] Tweak pubspecs to pass bulk analysis. (flutter#2959)
  [android_intent] fix platform package dep (flutter#2948)
  [shared_preferences_linux] update `file` package dep version to be compatible with framework (flutter#2950)
  • Loading branch information
KevinTheGray committed Aug 31, 2020
2 parents 1078109 + 7c49361 commit c2732ba
Show file tree
Hide file tree
Showing 134 changed files with 1,294 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ task:
- echo "This user does not have permission to run Firebase Test Lab tests."
- else
- echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json
- ./script/incremental_build.sh firebase-test-lab
- ./script/incremental_build.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26
- fi
- export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt`
- export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt`
Expand Down
4 changes: 4 additions & 0 deletions packages/android_intent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.7+3

* Update the `platform` package dependency to resolve the conflict with the latest flutter.

## 0.3.7+2

* Declare API stability and compatibility with `1.0.0` (more details at: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0).
Expand Down
4 changes: 2 additions & 2 deletions packages/android_intent/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/android_intent
# 0.3.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.3.7+2
version: 0.3.7+3

flutter:
plugin:
Expand All @@ -16,7 +16,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
platform: ^2.0.0
platform: ">=2.0.0 <4.0.0"
meta: ^1.0.5
dev_dependencies:
test: ^1.3.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.4+1

* Moved everything from battery to battery/battery

## 1.0.4

* Updated README.md.

## 1.0.3

* Update package:e2e to use package:integration_test
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ To use this plugin, add `battery` as a [dependency in your pubspec.yaml file](ht
import 'package:battery/battery.dart';
// Instantiate it
var battery = Battery();
var _battery = Battery();
// Access current battery level
print(await battery.batteryLevel);
print(await _battery.batteryLevel);
// Be informed when the state (full, charging, discharging) changes
_battery.onBatteryStateChanged.listen((BatteryState state) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dev_dependencies:
flutter_driver:
sdk: flutter
integration_test:
path: ../../integration_test
path: ../../../integration_test
pedantic: ^1.8.0

flutter:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: battery
description: Flutter plugin for accessing information about the battery state
(full, charging, discharging) on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/battery
version: 1.0.3
homepage: https://github.com/flutter/plugins/tree/master/packages/battery/battery
version: 1.0.4+1

flutter:
plugin:
Expand All @@ -25,7 +25,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
path: ../integration_test
path: ../../integration_test
pedantic: ^1.8.0

environment:
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/battery/battery_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial open-source release.
27 changes: 27 additions & 0 deletions packages/battery/battery_platform_interface/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 changes: 26 additions & 0 deletions packages/battery/battery_platform_interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# battery_platform_interface

A common platform interface for the [`battery`][1] plugin.

This interface allows platform-specific implementations of the `battery`
plugin, as well as the plugin itself, to ensure they are supporting the
same interface.

# Usage

To implement a new platform-specific implementation of `battery`, extend
[`BatteryPlatform`][2] with an implementation that performs the
platform-specific behavior, and when you register your plugin, set the default
`BatteryPlatform` by calling
`BatteryPlatform.instance = MyPlatformBattery()`.

# Note on breaking changes

Strongly prefer non-breaking changes (such as adding a method to the interface)
over breaking changes for this package.

See https://flutter.dev/go/platform-interface-breaking-changes for a discussion
on why a less-clean interface is preferable to a breaking change.

[1]: ../battery
[2]: lib/battery_platform_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'method_channel/method_channel_battery.dart';
import 'enums/battery_state.dart';

export 'enums/battery_state.dart';

/// The interface that implementations of battery must implement.
///
/// Platform implementations should extend this class rather than implement it as `battery`
/// does not consider newly added methods to be breaking changes. Extending this class
/// (using `extends`) ensures that the subclass will get the default implementation, while
/// platform implementations that `implements` this interface will be broken by newly added
/// [BatteryPlatform] methods.
abstract class BatteryPlatform extends PlatformInterface {
/// Constructs a BatteryPlatform.
BatteryPlatform() : super(token: _token);

static final Object _token = Object();

static BatteryPlatform _instance = MethodChannelBattery();

/// The default instance of [BatteryPlatform] to use.
///
/// Defaults to [MethodChannelBattery].
static BatteryPlatform get instance => _instance;

/// Platform-specific plugins should set this with their own platform-specific
/// class that extends [BatteryPlatform] when they register themselves.
static set instance(BatteryPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}

/// Gets the battery level from device.
Future<int> batteryLevel() {
throw UnimplementedError('batteryLevel() has not been implemented.');
}

/// gets battery state from device.
Stream<BatteryState> onBatteryStateChanged() {
throw UnimplementedError(
'onBatteryStateChanged() has not been implemented.');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// Indicates the current battery state.
enum BatteryState {
/// The battery is completely full of energy.
full,

/// The battery is currently storing energy.
charging,

/// The battery is currently losing energy.
discharging
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:meta/meta.dart';

import 'package:battery_platform_interface/battery_platform_interface.dart';

import '../battery_platform_interface.dart';

/// An implementation of [BatteryPlatform] that uses method channels.
class MethodChannelBattery extends BatteryPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
MethodChannel channel = MethodChannel('plugins.flutter.io/battery');

/// The event channel used to interact with the native platform.
@visibleForTesting
EventChannel eventChannel = EventChannel('plugins.flutter.io/charging');

/// Method channel for getting battery level.
Future<int> batteryLevel() async {
return (await channel.invokeMethod('getBatteryLevel')).toInt();
}

/// Stream variable for storing battery state.
Stream<BatteryState> _onBatteryStateChanged;

/// Event channel for getting battery change state.
Stream<BatteryState> onBatteryStateChanged() {
if (_onBatteryStateChanged == null) {
_onBatteryStateChanged = eventChannel
.receiveBroadcastStream()
.map((dynamic event) => _parseBatteryState(event));
}
return _onBatteryStateChanged;
}
}

/// Method for parsing battery state.
BatteryState _parseBatteryState(String state) {
switch (state) {
case 'full':
return BatteryState.full;
case 'charging':
return BatteryState.charging;
case 'discharging':
return BatteryState.discharging;
default:
throw ArgumentError('$state is not a valid BatteryState.');
}
}
22 changes: 22 additions & 0 deletions packages/battery/battery_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: battery_platform_interface
description: A common platform interface for the battery plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/battery
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.0.0

dependencies:
flutter:
sdk: flutter
meta: ^1.1.8
plugin_platform_interface: ^1.0.2

dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^4.1.1
pedantic: ^1.8.0

environment:
sdk: ">=2.7.0 <3.0.0"
flutter: ">=1.9.1+hotfix.4 <2.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:battery_platform_interface/battery_platform_interface.dart';

import 'package:battery_platform_interface/method_channel/method_channel_battery.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

group("$MethodChannelBattery", () {
MethodChannelBattery methodChannelBattery;

setUp(() async {
methodChannelBattery = MethodChannelBattery();

methodChannelBattery.channel
.setMockMethodCallHandler((MethodCall methodCall) async {
switch (methodCall.method) {
case 'getBatteryLevel':
return 90;
default:
return null;
}
});

MethodChannel(methodChannelBattery.eventChannel.name)
.setMockMethodCallHandler((MethodCall methodCall) async {
switch (methodCall.method) {
case 'listen':
await ServicesBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
methodChannelBattery.eventChannel.name,
methodChannelBattery.eventChannel.codec
.encodeSuccessEnvelope('full'),
(_) {},
);
break;
case 'cancel':
default:
return null;
}
});
});

/// Test for batetry level call.
test("getBatteryLevel", () async {
final int result = await methodChannelBattery.batteryLevel();
expect(result, 90);
});

/// Test for battery changed state call.
test("onBatteryChanged", () async {
final BatteryState result =
await methodChannelBattery.onBatteryStateChanged().first;
expect(result, BatteryState.full);
});
});
}
12 changes: 0 additions & 12 deletions packages/battery/example/android.iml

This file was deleted.

15 changes: 0 additions & 15 deletions packages/battery/example/battery_example.iml

This file was deleted.

4 changes: 4 additions & 0 deletions packages/image_picker/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.7+7

* Updating documentation to use isEmpty check.

## 0.6.7+6

* Update package:e2e -> package:integration_test
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Android system -- although very rarely -- sometimes kills the MainActivity after
Future<void> retrieveLostData() async {
final LostData response =
await picker.getLostData();
if (response == null) {
if (response.isEmpty) {
return;
}
if (response.file != null) {
Expand Down

0 comments on commit c2732ba

Please sign in to comment.