[url_launcher] Add support for setting show title on Chrome Custom Tabs#5166
[url_launcher] Add support for setting show title on Chrome Custom Tabs#5166Alex-Usmanov wants to merge 0 commit intoflutter:mainfrom
Conversation
| required Map<String, String> headers, | ||
| String? webOnlyWindowName, | ||
| }) async { | ||
| final WebViewOptions webViewOptions = WebViewOptions( |
There was a problem hiding this comment.
There is a fair share of code duplication here, but it could only be resolved after flutter/flutter#66721 unfortunately (could not make it a passthrough because there is no way to pass the useWebView parameter to launchUrl).
Did my best to reduce it
|
This cannot be implemented on the web, since the browser controls how tabs/windows are displayed. (Feel free to @ me if I can be of any help with the rest of the PR!) |
There was a problem hiding this comment.
All the packages where the only change is dependency_overrides can be reverted.
There was a problem hiding this comment.
Did not think of that, done ✅
packages/url_launcher/url_launcher_platform_interface/lib/src/types.dart
Show resolved
Hide resolved
*Will update docs once #5155 lands |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Generally looks good, just small comments. Thanks for your patience!
| /// Creates a new InAppBrowserConfiguration with given settings. | ||
| const InAppBrowserConfiguration({this.showTitle = false}); | ||
|
|
||
| /// Whether or not to show the webpage title when using Chrome Custom Tabs. |
There was a problem hiding this comment.
Please remove "when using Chrome Custom Tabs."
|
|
||
| /// Whether or not to show the webpage title when using Chrome Custom Tabs. | ||
| /// | ||
| /// Only works on Android. |
There was a problem hiding this comment.
"May not be supported on all platforms."
There was a problem hiding this comment.
The changes in this file will need a simple test (e.g., testing the default InAppBrowserConfiguration behavior).
There was a problem hiding this comment.
Done. Did not quite think of a lot of testcases, you can find those in packages/url_launcher/url_launcher_platform_interface/test/in_app_browser_configuration_test.dart and packages/url_launcher/url_launcher_platform_interface/test/launch_options_test.dart
There was a problem hiding this comment.
This package will need a version bump and changelog.
There was a problem hiding this comment.
This will need a version change.
| private static boolean openCustomTab( | ||
| @NonNull Context context, @NonNull Uri uri, @NonNull Bundle headersBundle) { | ||
| CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build(); | ||
| @VisibleForTesting |
There was a problem hiding this comment.
Why was this made public for testing? Testing should be done via public interface whenever possible to make tests easier to maintain and less likely to miss important behavior.
There was a problem hiding this comment.
Reverted this change as well
| } | ||
|
|
||
| private static @NonNull Bundle extractBundle(Map<String, String> headersMap) { | ||
| @VisibleForTesting |
There was a problem hiding this comment.
Same question here.
| String url = "https://flutter.dev"; | ||
| HashMap<String, String> headers = new HashMap<>(); | ||
| String headerKey = "Content-Type"; | ||
| headers.put(headerKey, "text/plain"); |
There was a problem hiding this comment.
Headers don't seem relevant to this test, so shouldn't need to be set up.
There was a problem hiding this comment.
Yes, you are right. Removed this
| String url = "https://flutter.dev"; | ||
| HashMap<String, String> headers = new HashMap<>(); | ||
| String headerKey = "Content-Type"; | ||
| headers.put(headerKey, "text/plain"); |
|
|
||
| /// Whether or not to show the webpage title when using Chrome Custom Tabs. | ||
| /// | ||
| /// Only works on Android. |
There was a problem hiding this comment.
Same comments here as on the platform interface; platform details shouldn't be documented at this level.
There was a problem hiding this comment.
Made this comment platform-independent
|
Thank you for your valuable feedback and your time! |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
This looks good with a few minor nits; please feel free to split out the first sub-PR with just the platform interface changes.
| onPressed: () => setState(() { | ||
| _launched = _launchInAppWithBrowserOptions(toLaunch); | ||
| }), | ||
| child: const Text('Launch in app with showTitle'), |
There was a problem hiding this comment.
"[...] with title displayed"
| ## NEXT | ||
| ## 6.3.0 | ||
|
|
||
| * Implement taking in `BrowserConfiguration` parameter |
There was a problem hiding this comment.
These need to follow the CHANGELOG style guide linked from the PR checklist (verb form, punctuation).
|
|
||
| /// Whether or not to show the webpage title. | ||
| /// | ||
| /// May not be supported on all platforms. |
There was a problem hiding this comment.
This file is internal to the Android implementation, so this sentence doesn't make sense here.
| final Map<String, String> headers; | ||
| } | ||
|
|
||
| /// Additional configuration options for [PreferredLaunchMode.inAppBrowserView] |
There was a problem hiding this comment.
Nit: Missing a period.
This is #5166 portion of platform interface changes. Adds `InAppBrowserConfiguration` parameter, as well as `InAppBrowserConfiguration.showTitle` parameter that configures whether to show or not to show webpage title
|
Update from triage: This is blocked on #5759, which is currently in review. |
(Notice title at the top of the page "CyLog Software - HTTP ...")
flutter/flutter#136784
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.