Skip to content

Commit

Permalink
feat(android): support passing intent flags
Browse files Browse the repository at this point in the history
Ti.Android.FLAG_* constants can be used to add intent flags to the Chrome Custom Tab allowing a user to control behaviour such as closing after a redirect has finished with intentFlags: Ti.Android.FLAG_ACTIVITY_NO_HISTORY | Ti.Android.FLAG_ACTIVITY_NEW_TASK

Co-authored-by: Yordan Banev <[email protected]>
  • Loading branch information
ewanharris and ypbnv committed Jan 8, 2020
1 parent 979ca7a commit 953523e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions android/src/ti/webdialog/Params.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public class Params
public static final String ENABLE_SHARING = "enableSharing";
public static final String CLOSE_ICON = "closeIcon";
public static final String BAR_COLLAPSING_ENABLED = "barCollapsingEnabled";
public static final String INTENT_FLAGS = "intentFlags";
}
4 changes: 4 additions & 0 deletions android/src/ti/webdialog/TitaniumWebDialogModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ private void openCustomTab(Context context, List<String> customTabBrowsers, Krol

CustomTabsIntent tabIntent = builder.build();

if (options.containsKeyAndNotNull(Params.INTENT_FLAGS)) {
tabIntent.intent.addFlags(options.getInt(Params.INTENT_FLAGS));
}

for (String s : customTabBrowsers) {
tabIntent.intent.setPackage(s);
}
Expand Down
9 changes: 8 additions & 1 deletion apidoc/WebDialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ events:

---
name: WebDialogOpenParams
summary: Parmaters used in the <Modules.WebDialog.open> method
summary: Parameters used in the <Modules.WebDialog.open> method
properties:
- name: url
summary: The URL to be opened.
Expand Down Expand Up @@ -197,3 +197,10 @@ properties:
default: true
type: Boolean
platforms: [iphone, ipad, android]

- name: intentFlags
summary: Intent flags to be used for the Chrome Custom Tab, specified as a Bitwise-OR
optional: true
type: Number
constants: Titanium.Android.FLAG_*
platform: [android]

0 comments on commit 953523e

Please sign in to comment.