This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[android_intent] add flags option #2000
Merged
mklim
merged 4 commits into
flutter:master
from
thanhdatvo:feature/android_intent_add_flag
Aug 28, 2019
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // flag values from https://developer.android.com/reference/android/content/Intent.html | ||
| class Flag { | ||
| static const int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 4194304; | ||
| static const int FLAG_ACTIVITY_CLEAR_TASK = 32768; | ||
| static const int FLAG_ACTIVITY_CLEAR_TOP = 67108864; | ||
| static const int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288; | ||
| static const int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608; | ||
| static const int FLAG_ACTIVITY_FORWARD_RESULT = 33554432; | ||
| static const int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576; | ||
| static const int FLAG_ACTIVITY_LAUNCH_ADJACENT = 4096; | ||
| static const int FLAG_ACTIVITY_MATCH_EXTERNAL = 2048; | ||
| static const int FLAG_ACTIVITY_MULTIPLE_TASK = 134217728; | ||
| static const int FLAG_ACTIVITY_NEW_DOCUMENT = 524288; | ||
| static const int FLAG_ACTIVITY_NEW_TASK = 268435456; | ||
| static const int FLAG_ACTIVITY_NO_ANIMATION = 65536; | ||
| static const int FLAG_ACTIVITY_NO_HISTORY = 1073741824; | ||
| static const int FLAG_ACTIVITY_NO_USER_ACTION = 262144; | ||
| static const int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 16777216; | ||
| static const int FLAG_ACTIVITY_REORDER_TO_FRONT = 131072; | ||
| static const int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 2097152; | ||
| static const int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 8192; | ||
| static const int FLAG_ACTIVITY_SINGLE_TOP = 536870912; | ||
| static const int FLAG_ACTIVITY_TASK_ON_HOME = 16384; | ||
| static const int FLAG_DEBUG_LOG_RESOLUTION = 8; | ||
| static const int FLAG_EXCLUDE_STOPPED_PACKAGES = 16; | ||
| static const int FLAG_FROM_BACKGROUND = 4; | ||
| static const int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 64; | ||
| static const int FLAG_GRANT_PREFIX_URI_PERMISSION = 128; | ||
| static const int FLAG_GRANT_READ_URI_PERMISSION = 1; | ||
| static const int FLAG_GRANT_WRITE_URI_PERMISSION = 2; | ||
| static const int FLAG_INCLUDE_STOPPED_PACKAGES = 32; | ||
| static const int FLAG_RECEIVER_FOREGROUND = 268435456; | ||
| static const int FLAG_RECEIVER_NO_ABORT = 134217728; | ||
| static const int FLAG_RECEIVER_REGISTERED_ONLY = 1073741824; | ||
| static const int FLAG_RECEIVER_REPLACE_PENDING = 536870912; | ||
| static const int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 2097152; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ name: android_intent | |
| description: Flutter plugin for launching Android Intents. Not supported on iOS. | ||
| author: Flutter Team <[email protected]> | ||
| homepage: https://github.com/flutter/plugins/tree/master/packages/android_intent | ||
| version: 0.3.2 | ||
| version: 0.3.3 | ||
|
|
||
| flutter: | ||
| plugin: | ||
|
|
@@ -15,7 +15,11 @@ dependencies: | |
| sdk: flutter | ||
| platform: ^2.0.0 | ||
| meta: ^1.0.5 | ||
|
|
||
| dev_dependencies: | ||
| test: ^1.3.0 | ||
| mockito: ^3.0.0 | ||
| flutter_test: | ||
| sdk: flutter | ||
| environment: | ||
| sdk: ">=2.0.0-dev.28.0 <3.0.0" | ||
| flutter: ">=1.2.0 <2.0.0" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // Copyright 2019 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:android_intent/flag.dart'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:android_intent/android_intent.dart'; | ||
| import 'package:mockito/mockito.dart'; | ||
| import 'package:platform/platform.dart'; | ||
|
|
||
| void main() { | ||
| AndroidIntent androidIntent; | ||
| MockMethodChannel mockChannel; | ||
| setUp(() { | ||
| mockChannel = MockMethodChannel(); | ||
| }); | ||
| group('AndroidIntent', () { | ||
| test('pass right params', () async { | ||
| androidIntent = AndroidIntent.private( | ||
| action: 'action_view', | ||
| data: Uri.encodeFull('https://flutter.io'), | ||
| flags: <int>[Flag.FLAG_ACTIVITY_NEW_TASK], | ||
| channel: mockChannel, | ||
| platform: FakePlatform(operatingSystem: 'android')); | ||
| androidIntent.launch(); | ||
| verify(mockChannel.invokeMethod<void>('launch', <String, Object>{ | ||
| 'action': 'action_view', | ||
| 'data': Uri.encodeFull('https://flutter.io'), | ||
| 'flags': androidIntent.convertFlags(<int>[Flag.FLAG_ACTIVITY_NEW_TASK]), | ||
| })); | ||
| }); | ||
| test('pass null value to action param', () async { | ||
| androidIntent = AndroidIntent.private( | ||
| action: null, | ||
| channel: mockChannel, | ||
| platform: FakePlatform(operatingSystem: 'android')); | ||
| androidIntent.launch(); | ||
| verify(mockChannel.invokeMethod<void>('launch', <String, Object>{ | ||
| 'action': null, | ||
| })); | ||
| }); | ||
|
|
||
| test('call in ios platform', () async { | ||
| androidIntent = AndroidIntent.private( | ||
| action: null, | ||
| channel: mockChannel, | ||
| platform: FakePlatform(operatingSystem: 'ios')); | ||
| androidIntent.launch(); | ||
| verifyZeroInteractions(mockChannel); | ||
| }); | ||
| }); | ||
| group('convertFlags ', () { | ||
| androidIntent = const AndroidIntent( | ||
| action: 'action_view', | ||
| ); | ||
| test('add filled flag list', () async { | ||
| final List<int> flags = <int>[]; | ||
| flags.add(Flag.FLAG_ACTIVITY_NEW_TASK); | ||
| flags.add(Flag.FLAG_ACTIVITY_NEW_DOCUMENT); | ||
| expect( | ||
| androidIntent.convertFlags(flags), | ||
| 268959744, | ||
| ); | ||
| }); | ||
| test('add flags whose values are not power of 2', () async { | ||
| final List<int> flags = <int>[]; | ||
| flags.add(100); | ||
| flags.add(10); | ||
| expect( | ||
| () => androidIntent.convertFlags(flags), | ||
| throwsArgumentError, | ||
| ); | ||
| }); | ||
| test('add empty flag list', () async { | ||
| final List<int> flags = <int>[]; | ||
| expect( | ||
| androidIntent.convertFlags(flags), | ||
| 0, | ||
| ); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| class MockMethodChannel extends Mock implements MethodChannel {} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.