-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[android_intent] add flags parameter #1972
[android_intent] add flags parameter #1972
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
@datvo0110 please bump version & add change log entry. I'm wondering if this should be done explicitly via an extra enum flag in the AndroidIntent class. I can think of those, for example: |
|
@ened I have bumped version from 0.3.2 to 0.3.3 & add change log entry. Is this ok? |
mklim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
I'm wondering if this should be done explicitly via an extra enum flag in the AndroidIntent class.
Can you think of other flags that may be of interest in the future?
I agree. I think the behavior in this PR makes sense in most cases, but not every app would necessarily want external activities to behave in this way. I filed flutter/flutter#38701 to track the feature in general.
I'm following the initial PR review policy. This PR isn't trivial to review so I'm labeling it with "backlog." We'll prioritize according to the issue's priority.
Relevant issues:
flutter/flutter#38701
|
@datvo0110 let’s rewrite this a bit and add the flags argument instead of having app behavior done implicitly using the package name only. L Are you up for changing adding and implementing the ‘flags’ parameter? |
|
ok, let's me do that! I'll try to cover most case :D
…On Sat, Aug 17, 2019 at 3:17 AM Sebastian Roth ***@***.***> wrote:
@datvo0110 <https://github.com/datvo0110> let’s rewrite this a bit and
add the flags argument instead of having app behavior done implicitly using
the package name only. L
Are you up for changing adding and implementing the ‘flags’ parameter?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1972?email_source=notifications&email_token=AIUXZCAISFB742I2XQYGEHDQE4DOXA5CNFSM4ILG2X4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4PTEYI#issuecomment-522138209>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIUXZCDOWYLV75LNWUNMBGLQE4DOXANCNFSM4ILG2X4A>
.
|
|
I added flags parameter as List<String> and prepare some popular flags as
you recommended
Intent.FLAG_ACTIVITY_NEW_TASK
Intent.FLAG_ACTIVITY_NO_HISTORY
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
Intent.FLAG_GRANT_READ_URI_PERMISSION
I also added an example on how to use flags option.
I'm waiting for your opinions :D
@ened @mklim
…On Sat, Aug 17, 2019 at 8:46 AM Thanh Dat Vo ***@***.***> wrote:
ok, let's me do that! I'll try to cover most case :D
On Sat, Aug 17, 2019 at 3:17 AM Sebastian Roth ***@***.***>
wrote:
> @datvo0110 <https://github.com/datvo0110> let’s rewrite this a bit and
> add the flags argument instead of having app behavior done implicitly using
> the package name only. L
>
> Are you up for changing adding and implementing the ‘flags’ parameter?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1972?email_source=notifications&email_token=AIUXZCAISFB742I2XQYGEHDQE4DOXA5CNFSM4ILG2X4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4PTEYI#issuecomment-522138209>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AIUXZCDOWYLV75LNWUNMBGLQE4DOXANCNFSM4ILG2X4A>
> .
>
|
ened
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, nice.
There is some potential to optimise the code (calculate the flags integer in Dart and send that to the platform, instead of a list of strings which needs separate handling).
Also, please add unit and integration tests for this.
| } | ||
| } | ||
|
|
||
| private int convertFlag(String flag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR converts the flags from String to integer using this method.
A better method is to let the Dart side know about the flag names & values and simply push the flag through. You can create a new Flags.dart (or similar) and fill in the constants from https://developer.android.com/reference/android/content/Intent (All the constants from FLAG_).
Please follow the hex numbering (0x00400000) and keep the order as it is listed on the documentation page.
| } | ||
| } | ||
|
|
||
| private int convertFlags(ArrayList<String> flags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said above, this logic should be done in the Dart side.
| /* Begin PBXBuildFile section */ | ||
| 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; | ||
| 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; | ||
| 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in here relate to the iOS example. If possible, please remove them from the commit.
| final AndroidIntent intent = AndroidIntent( | ||
| action: 'action_view', | ||
| data: Uri.encodeFull('https://flutter.io'), | ||
| flags: flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- please add a
,to before the parentheses end - this now becomes simpler as you can do the bit operation in Dart
| RaisedButton( | ||
| child: const Text( | ||
| 'Tap here to open link in browser in a seperated window.'), | ||
| onPressed: _openLinkInDefaultBrowserInSeperatedWindow, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like a close-to-reality example like this one, however I would name it more accurate ("Start Activity in New Task"). What other ways could we use in the example to demonstrate the functionality?
59a9413 to
bd5a534
Compare
|
@ened I already |
|
@datvo0110 ok let's close this one and move to #2000. |
Description
we are launching to a different package we need to set the FLAG_ACTIVITY_NEW_TASK flag
Similar to react native Link.openUrl() : https://github.com/facebook/react-native/blob/3b6f6ca4d5fcee6f1bc6d6242e3e2ef136e4d546/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java#L97
Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?