Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1dd8325
Moved quickactions to a subfolder
danielroek Mar 17, 2021
b1314ef
Added platform interface with tests
danielroek Mar 19, 2021
bc99e6f
Merge remote-tracking branch 'flutter/master' into quick_actions_fede…
danielroek Mar 19, 2021
7ca0785
Merge remote-tracking branch 'origin/quick_actions_federated' into qu…
danielroek Mar 19, 2021
836bc78
Added exports
danielroek Mar 19, 2021
0f79c71
Formatted, made initialize return Future<void> instead of void
danielroek Mar 19, 2021
357db7e
Fixed formatting
danielroek Mar 19, 2021
d942293
formatting
danielroek Mar 19, 2021
da5f028
Fixed analyze issue with import
danielroek Mar 19, 2021
3727f61
Fixed formatting
danielroek Mar 19, 2021
1e6624d
Fixed formatting
danielroek Mar 19, 2021
f73a1cb
Added license in files
danielroek Mar 19, 2021
c9fbf5a
Removed accidental \\\
danielroek Mar 19, 2021
a3524b9
changed license to Flutter 2017
danielroek Mar 19, 2021
facf6c8
Moved quickactions to a subfolder
danielroek Mar 17, 2021
c2bab45
Added platform interface with tests
danielroek Mar 19, 2021
b136909
Added exports
danielroek Mar 19, 2021
9613b01
Formatted, made initialize return Future<void> instead of void
danielroek Mar 19, 2021
2d5e6dd
Fixed formatting
danielroek Mar 19, 2021
01430d5
formatting
danielroek Mar 19, 2021
619881d
Fixed analyze issue with import
danielroek Mar 19, 2021
6e95017
Fixed formatting
danielroek Mar 19, 2021
a1028bc
Fixed formatting
danielroek Mar 19, 2021
8bfa5d0
Added license in files
danielroek Mar 19, 2021
4ce9b4d
Removed accidental \\\
danielroek Mar 19, 2021
f7cf42d
changed license to Flutter 2017
danielroek Mar 19, 2021
0372457
Merge branch 'quick_actions_federated_platform_interface' of github.c…
danielroek Mar 19, 2021
2b14d21
Merge remote-tracking branch 'flutter/master' into quick_actions_fede…
danielroek Mar 19, 2021
a9fc9ec
Implemented feedback
danielroek Mar 19, 2021
2871948
Changed 2017 to 2013
danielroek Mar 19, 2021
bf0615a
Changed 2017 to 2013
danielroek Mar 19, 2021
8d8cb72
Implemented feedback.
danielroek Mar 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions packages/quick_actions/AUTHORS

This file was deleted.

2 changes: 1 addition & 1 deletion packages/quick_actions/quick_actions/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017 The Flutter Authors. All rights reserved.
Copyright 2013 The Flutter 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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
2 changes: 1 addition & 1 deletion packages/quick_actions/quick_actions/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2017 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter 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:flutter/services.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.0.0

* Initial release of quick_actions_platform_interface
25 changes: 25 additions & 0 deletions packages/quick_actions/quick_actions_platform_interface/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 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/quick_actions/quick_actions_platform_interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# quick_actions_platform_interface

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

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

# Usage

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

# 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]: ../quick_actions
[2]: lib/quick_actions_platform_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2013 The Flutter 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/foundation.dart';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show visibleForTesting;
import 'package:quick_actions_platform_interface/types/types.dart';

import '../platform_interface/quick_actions_platform.dart';

final MethodChannel _channel =
MethodChannel('plugins.flutter.io/quick_actions');

/// An implementation of [QuickActionsPlatform] that uses method channels.
class MethodChannelQuickActions extends QuickActionsPlatform {
/// The MethodChannel that is being used by this implementation of the plugin.
@visibleForTesting
MethodChannel get channel => _channel;

@override
Future<void> initialize(QuickActionHandler handler) async {
channel.setMethodCallHandler((MethodCall call) async {
assert(call.method == 'launch');
handler(call.arguments);
});
final String? action =
await channel.invokeMethod<String?>('getLaunchAction');
if (action != null) {
handler(action);
}
}

@override
Future<void> setShortcutItems(List<ShortcutItem> items) async {
final List<Map<String, String?>> itemsList =
items.map(_serializeItem).toList();
await channel.invokeMethod<void>('setShortcutItems', itemsList);
}

@override
Future<void> clearShortcutItems() =>
channel.invokeMethod<void>('clearShortcutItems');

Map<String, String?> _serializeItem(ShortcutItem item) {
return <String, String?>{
'type': item.type,
'localizedTitle': item.localizedTitle,
'icon': item.icon,
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2013 The Flutter 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:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:quick_actions_platform_interface/types/types.dart';

import '../method_channel/method_channel_quick_actions.dart';

/// The interface that implementations of quick_actions must implement.
///
/// Platform implementations should extend this class rather than implement it as `quick_actions`
/// 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
/// [QuickActionsPlatform] methods.
abstract class QuickActionsPlatform extends PlatformInterface {
/// Constructs a QuickActionsPlatform.
QuickActionsPlatform() : super(token: _token);

static final Object _token = Object();

static QuickActionsPlatform _instance = MethodChannelQuickActions();

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

/// Platform-specific plugins should set this with their own platform-specific
/// class that extends [QuickActionsPlatform] when they register themselves.
// TODO(amirh): Extract common platform interface logic.
// https://github.com/flutter/flutter/issues/43368
static set instance(QuickActionsPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}

/// Initializes this plugin.
///
/// Call this once before any further interaction with the the plugin.
Future<void> initialize(QuickActionHandler handler) async {
throw UnimplementedError("initialize() has not been implemented.");
}

/// Sets the [ShortcutItem]s to become the app's quick actions.
Future<void> setShortcutItems(List<ShortcutItem> items) async {
throw UnimplementedError("setShortcutItems() has not been implemented.");
}

/// Removes all [ShortcutItem]s registered for the app.
Future<void> clearShortcutItems() {
throw UnimplementedError("clearShortcutItems() has not been implemented.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'package:quick_actions_platform_interface/platform_interface/quick_actions_platform.dart';
export 'package:quick_actions_platform_interface/types/types.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Handler for a quick action launch event.
///
/// The argument [type] corresponds to the [ShortcutItem]'s field.
typedef void QuickActionHandler(String type);
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Home screen quick-action shortcut item.
class ShortcutItem {
/// Constructs an instance with the given [type], [localizedTitle], and
/// [icon].
///
/// Only [icon] should be nullable. It will remain `null` if unset.
const ShortcutItem({
required this.type,
required this.localizedTitle,
this.icon,
});

/// The identifier of this item; should be unique within the app.
final String type;

/// Localized title of the item.
final String localizedTitle;

/// Name of native resource (xcassets etc; NOT a Flutter asset) to be
/// displayed as the icon for this item.
final String? icon;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'quick_action_handler.dart';
export 'shortcut_item.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: quick_actions_platform_interface
description: A common platform interface for the quick_actions plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/quick_actions/quick_actions_platform_interface
# 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.3.0
plugin_platform_interface: ^2.0.0

dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.1
pedantic: ^1.11.0

environment:
sdk: ">=2.12.0-259.9.beta <3.0.0"
flutter: ">=1.22.0"
Loading