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

Commit 35e984f

Browse files
author
Michael Klimushyn
authored
[android_intent] Add missing DartDocs (#2268)
Also adds a rule just for `android_intent` that makes sure that there are no undocumented public members. This will prevent the DartDocs from regressing. Also updates the main repo's analysis options to migrate from some deprecated options. If/when all the plugins have their DartDocs updated this package-specific `analysis_options.yaml` should be removed, and the DartDoc rule should be moved up to the top level.
1 parent 7d7be76 commit 35e984f

File tree

7 files changed

+221
-9
lines changed

7 files changed

+221
-9
lines changed

analysis_options.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212

1313
analyzer:
1414
language:
15-
enableStrictCallChecks: true
16-
enableSuperMixins: true
17-
enableAssertInitializer: true
15+
strict-inference: true
16+
strict-raw-types: true
1817
strong-mode:
1918
implicit-dynamic: false
2019
errors:
@@ -117,7 +116,6 @@ linter:
117116
- slash_for_doc_comments
118117
- sort_constructors_first
119118
- sort_unnamed_constructors_first
120-
- super_goes_last
121119
# - type_annotate_public_apis # subset of always_specify_types
122120
- type_init_formals
123121
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793

packages/android_intent/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.4+6
2+
3+
* Add missing DartDocs for public members.
4+
15
## 0.3.4+5
26

37
* Remove AndroidX warning.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This exists to add a lint for missing API docs just on this specific package,
2+
# since not all packages have coverage for all their public members yet and
3+
# adding it in would be non-trivial. `public_member_api_docs` should be applied
4+
# to new packages going forward, and ideally the main `analysis_options.yaml`
5+
# file as soon as possible.
6+
7+
include: ../../analysis_options.yaml
8+
9+
linter:
10+
rules:
11+
- public_member_api_docs

packages/android_intent/example/lib/main.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ void main() {
1111
runApp(MyApp());
1212
}
1313

14+
/// A sample app for launching intents.
1415
class MyApp extends StatelessWidget {
1516
// This widget is the root of your application.
1617
@override
@@ -29,6 +30,7 @@ class MyApp extends StatelessWidget {
2930
}
3031
}
3132

33+
/// Holds the different intent widgets.
3234
class MyHomePage extends StatelessWidget {
3335
void _createAlarm() {
3436
final AndroidIntent intent = const AndroidIntent(
@@ -80,9 +82,11 @@ class MyHomePage extends StatelessWidget {
8082
}
8183
}
8284

85+
/// Launches intents to specific Android activities.
8386
class ExplicitIntentsWidget extends StatelessWidget {
84-
const ExplicitIntentsWidget();
87+
const ExplicitIntentsWidget(); // ignore: public_member_api_docs
8588

89+
// ignore: public_member_api_docs
8690
static const String routeName = "/explicitIntents";
8791

8892
void _openGoogleMapsStreetView() {

packages/android_intent/lib/android_intent.dart

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import 'package:flutter/services.dart';
88
import 'package:meta/meta.dart';
99
import 'package:platform/platform.dart';
1010

11-
const String kChannelName = 'plugins.flutter.io/android_intent';
11+
const String _kChannelName = 'plugins.flutter.io/android_intent';
1212

1313
/// Flutter plugin for launching arbitrary Android Intents.
14+
///
15+
/// See [the official Android
16+
/// documentation](https://developer.android.com/reference/android/content/Intent.html)
17+
/// for more information on how to use Intents.
1418
class AndroidIntent {
1519
/// Builds an Android intent with the following parameters
1620
/// [action] refers to the action parameter of the intent.
@@ -33,9 +37,11 @@ class AndroidIntent {
3337
this.componentName,
3438
Platform platform,
3539
}) : assert(action != null),
36-
_channel = const MethodChannel(kChannelName),
40+
_channel = const MethodChannel(_kChannelName),
3741
_platform = platform ?? const LocalPlatform();
3842

43+
/// This constructor is only exposed for unit testing. Do not rely on this in
44+
/// app code, it may break without warning.
3945
@visibleForTesting
4046
AndroidIntent.private({
4147
@required this.action,
@@ -50,12 +56,43 @@ class AndroidIntent {
5056
}) : _channel = channel,
5157
_platform = platform;
5258

59+
/// This is the general verb that the intent should attempt to do. This
60+
/// includes constants like `ACTION_VIEW`.
61+
///
62+
/// See https://developer.android.com/reference/android/content/Intent.html#intent-structure.
5363
final String action;
64+
65+
/// Constants that can be set on an intent to tweak how it is finally handled.
66+
/// Some of the constants are mirrored to Dart via [Flag].
67+
///
68+
/// See https://developer.android.com/reference/android/content/Intent.html#setFlags(int).
5469
final List<int> flags;
70+
71+
/// An optional additional constant qualifying the given [action].
72+
///
73+
/// See https://developer.android.com/reference/android/content/Intent.html#intent-structure.
5574
final String category;
75+
76+
/// The Uri that the [action] is pointed towards.
77+
///
78+
/// See https://developer.android.com/reference/android/content/Intent.html#intent-structure.
5679
final String data;
80+
81+
/// The equivalent of `extras`, a generic `Bundle` of data that the Intent can
82+
/// carry. This is a slot for extraneous data that the listener may use.
83+
///
84+
/// See https://developer.android.com/reference/android/content/Intent.html#intent-structure.
5785
final Map<String, dynamic> arguments;
86+
87+
/// Sets the [data] to only resolve within this given package.
88+
///
89+
/// See https://developer.android.com/reference/android/content/Intent.html#setPackage(java.lang.String).
5890
final String package;
91+
92+
/// Set the exact `ComponentName` that should handle the intent. If this is
93+
/// set [package] should also be non-null.
94+
///
95+
/// See https://developer.android.com/reference/android/content/Intent.html#setComponent(android.content.ComponentName).
5996
final String componentName;
6097
final MethodChannel _channel;
6198
final Platform _platform;
@@ -65,6 +102,8 @@ class AndroidIntent {
65102
return x != 0 && ((x & (x - 1)) == 0);
66103
}
67104

105+
/// This method is just visible for unit testing and should not be relied on.
106+
/// Its method signature may change at any time.
68107
@visibleForTesting
69108
int convertFlags(List<int> flags) {
70109
int finalValue = 0;

packages/android_intent/lib/flag.dart

Lines changed: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,193 @@
1-
// flag values from https://developer.android.com/reference/android/content/Intent.html
1+
/// Special flags that can be set on an intent to control how it is handled.
2+
///
3+
/// See
4+
/// https://developer.android.com/reference/android/content/Intent.html#setFlags(int)
5+
/// for the official documentation on Intent flags. The constants here mirror
6+
/// the existing [android.content.Intent] ones.
27
class Flag {
8+
/// Specifies how an activity should be launched. Generally set by the system
9+
/// in conjunction with SINGLE_TASK.
10+
///
11+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_BROUGHT_TO_FRONT.
312
static const int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 4194304;
13+
14+
/// Causes any existing tasks associated with the activity to be cleared.
15+
///
16+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TASK
417
static const int FLAG_ACTIVITY_CLEAR_TASK = 32768;
18+
19+
/// Closes any activities on top of this activity and brings it to the front,
20+
/// if it's currently running.
21+
///
22+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP
523
static const int FLAG_ACTIVITY_CLEAR_TOP = 67108864;
24+
25+
/// @deprecated Use [FLAG_ACTIVITY_NEW_DOCUMENT] instead when on API 21 or above.
26+
///
27+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
28+
@deprecated
629
static const int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288;
30+
31+
/// Keeps the activity from being listed with other recently launched
32+
/// activities.
33+
///
34+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
735
static const int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608;
36+
37+
/// Forwards the result from this activity to the existing one.
38+
///
39+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_FORWARD_RESULT
840
static const int FLAG_ACTIVITY_FORWARD_RESULT = 33554432;
41+
42+
/// Generally set by the system if the activity is being launched from
43+
/// history.
44+
///
45+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
946
static const int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576;
47+
48+
/// Used in split-screen mode to set the launched activity adjacent to the
49+
/// launcher.
50+
///
51+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_LAUNCH_ADJACENT
1052
static const int FLAG_ACTIVITY_LAUNCH_ADJACENT = 4096;
53+
54+
/// Used in split-screen mode to set the launched activity adjacent to the
55+
/// launcher.
56+
///
57+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_MATCH_EXTERNAL
1158
static const int FLAG_ACTIVITY_MATCH_EXTERNAL = 2048;
59+
60+
/// Creates and launches the activity into a new task. Should always be
61+
/// combined with [FLAG_ACTIVITY_NEW_DOCUMENT] or [FLAG_ACTIVITY_NEW_TASK].
62+
///
63+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_MULTIPLE_TASK.
1264
static const int FLAG_ACTIVITY_MULTIPLE_TASK = 134217728;
65+
66+
/// Opens a document into a new task rooted in this activity.
67+
///
68+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_DOCUMENT.
1369
static const int FLAG_ACTIVITY_NEW_DOCUMENT = 524288;
70+
71+
/// The launched activity starts a new task on the activity stack.
72+
///
73+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK.
1474
static const int FLAG_ACTIVITY_NEW_TASK = 268435456;
75+
76+
/// Prevents the system from playing an activity transition animation when
77+
/// launching this.
78+
///
79+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_ANIMATION.
1580
static const int FLAG_ACTIVITY_NO_ANIMATION = 65536;
81+
82+
/// Does not keep the launched activity in history.
83+
///
84+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_HISTORY.
1685
static const int FLAG_ACTIVITY_NO_HISTORY = 1073741824;
86+
87+
/// Prevents a typical callback from occuring when the activity is paused.
88+
///
89+
/// https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_USER_ACTION
1790
static const int FLAG_ACTIVITY_NO_USER_ACTION = 262144;
91+
92+
/// Uses the previous activity as top when applicable.
93+
///
94+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_PREVIOUS_IS_TOP.
1895
static const int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 16777216;
96+
97+
/// Brings any already instances of this activity to the front.
98+
///
99+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_REORDER_TO_FRONT.
19100
static const int FLAG_ACTIVITY_REORDER_TO_FRONT = 131072;
101+
102+
/// Launches the activity in a way that resets the task in some cases.
103+
///
104+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED.
20105
static const int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 2097152;
106+
107+
/// Keeps an entry in recent tasks. Used with [FLAG_ACTIVITY_NEW_DOCUMENT].
108+
///
109+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_RETAIN_IN_RECENTS.
21110
static const int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 8192;
111+
112+
/// Will not re-launch the activity if it is already at the top of the history
113+
/// stack.
114+
///
115+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_SINGLE_TOP.
22116
static const int FLAG_ACTIVITY_SINGLE_TOP = 536870912;
117+
118+
/// Places the activity on top of the home task. Must be used with
119+
/// [FLAG_ACTIVITY_NEW_TASK].
120+
///
121+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_TASK_ON_HOME.
23122
static const int FLAG_ACTIVITY_TASK_ON_HOME = 16384;
123+
124+
/// Prints debug logs while the intent is resolving.
125+
///
126+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_DEBUG_LOG_RESOLUTION.
24127
static const int FLAG_DEBUG_LOG_RESOLUTION = 8;
128+
129+
/// Does not match to any stopped components.
130+
///
131+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_EXCLUDE_STOPPED_PACKAGES.
25132
static const int FLAG_EXCLUDE_STOPPED_PACKAGES = 16;
133+
134+
/// Can be set by the caller to flag the intent as not being launched directly
135+
/// by the user.
136+
///
137+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_FROM_BACKGROUND.
26138
static const int FLAG_FROM_BACKGROUND = 4;
139+
140+
/// Will persist the URI permision across device reboots.
141+
///
142+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_PERSISTABLE_URI_PERMISSION.
27143
static const int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 64;
144+
145+
/// Applies the URI permission grant based on prefix matching.
146+
///
147+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_PREFIX_URI_PERMISSION.
28148
static const int FLAG_GRANT_PREFIX_URI_PERMISSION = 128;
149+
150+
/// Grants the intent listener permission to read extra data from the Intent's
151+
/// URI.
152+
///
153+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_READ_URI_PERMISSION.
29154
static const int FLAG_GRANT_READ_URI_PERMISSION = 1;
155+
156+
/// Grants the intent listener permission to write extra data from the
157+
/// Intent's URI.
158+
///
159+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_WRITE_URI_PERMISSION.
30160
static const int FLAG_GRANT_WRITE_URI_PERMISSION = 2;
161+
162+
/// Always matches stopped components. This is the default behavior.
163+
///
164+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_INCLUDE_STOPPED_PACKAGES.
31165
static const int FLAG_INCLUDE_STOPPED_PACKAGES = 32;
166+
167+
/// Allows the listener to run at a high priority.
168+
///
169+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_RECEIVER_FOREGROUND.
32170
static const int FLAG_RECEIVER_FOREGROUND = 268435456;
171+
172+
/// Doesn't allow listeners to cancel the broadcast.
173+
///
174+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_RECEIVER_NO_ABORT.
33175
static const int FLAG_RECEIVER_NO_ABORT = 134217728;
176+
177+
/// Only allows registered receivers to listen for the intent.
178+
///
179+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_RECEIVER_REGISTERED_ONLY.
34180
static const int FLAG_RECEIVER_REGISTERED_ONLY = 1073741824;
181+
182+
/// Will drop any pending broadcasts of this intent in favor of the newest
183+
/// one.
184+
///
185+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_RECEIVER_REPLACE_PENDING.
35186
static const int FLAG_RECEIVER_REPLACE_PENDING = 536870912;
187+
188+
/// Instant Apps will be able to listen for the intent (not the default
189+
/// behavior).
190+
///
191+
/// See https://developer.android.com/reference/android/content/Intent.html#FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS.
36192
static const int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 2097152;
37193
}

packages/android_intent/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: android_intent
22
description: Flutter plugin for launching Android Intents. Not supported on iOS.
33
author: Flutter Team <[email protected]>
44
homepage: https://github.com/flutter/plugins/tree/master/packages/android_intent
5-
version: 0.3.4+5
5+
version: 0.3.4+6
66

77
flutter:
88
plugin:

0 commit comments

Comments
 (0)