-
Notifications
You must be signed in to change notification settings - Fork 305
Support setting browser preference #1400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/widgets/settings.dart
Outdated
final openLinksWithInAppBrowser = | ||
GlobalStoreWidget.of(context).globalSettings.urlLaunchMode | ||
== UrlLaunchMode.platformDefault; |
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.
Given that we'll be presenting the setting as either "in-app: yes" or "in-app: no", let's make the semantics of our default match that presentation. IOW on Android let's adjust our default behavior so that it's the same as the behavior we end up with if the database says inApp
.
That'd be good to do as a prep commit, before introducing the setting.
3ec51af
to
85c0d5b
Compare
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.platformDefault)); | ||
.single.equals((url: Uri.parse('https://a/'), mode: LaunchMode.inAppBrowserView)); |
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.
setting: Make in-app explicitly the default browser preference on Android
This way, the default behavior when opening links on Android is
equivalent as if the browser preference is set to in-app.
I think both these two commits:
d1242a2 content [nfc]: Follow browser preference setting when opening links
f2a8d6a setting: Make in-app explicitly the default browser preference on Android
will be clearer to understand if the "explicitly in-app" commit comes first, as I suggested at #1400 (comment) .
Let's save making that revision for our call tomorrow. I can demonstrate how I'd go about re-splitting these changes (I think this is a case where that will be easier than trying to treat it as a rebase), and I think it'll be a good example.
Thanks for the help! I have updated the PR. |
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!
This is quite close now — a handful of nits below, following the revision I just pushed which expands some of the explanation in this commit:
f06b14c setting [nfc]: Make in-app explicitly the browser preference on Android
lib/model/settings.dart
Outdated
|
||
/// What browser the user has set to use for opening links in messages. | ||
/// | ||
/// See https://chat.zulip.org/#narrow/stream/48-mobile/topic/in-app.20browser |
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.
nit: always use a permalink (so for Zulip topics, either /near/ or /with/)
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.
Removed the link because I think the dartdoc on the individual enum options explain them well enough, and that we have links to this conversation from effectiveBrowserPreference
.
This line was originally from zulip/zulip-mobile#4679 (comment), where the code that interprets the enum values live elsewhere.
lib/model/settings.dart
Outdated
BrowserPreference.inApp => url.scheme == 'http' || url.scheme == 'https' | ||
? UrlLaunchMode.inAppBrowserView : UrlLaunchMode.platformDefault, |
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 condition calls for a comment to explain why we need this (and why it takes the particular shape it does).
Much of the needed information is in the commit message, so just needs to be moved from there. I also had some changes I wanted to make to the framing of that, so I made a revision which I'll push along with this review.
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.
Ah I see! It makes sense that the upstream behavior needs to change.
test/model/settings_test.dart
Outdated
defaultTargetPlatform == TargetPlatform.iOS | ||
? UrlLaunchMode.externalApplication : UrlLaunchMode.inAppBrowserView); |
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.
nit: the conditions in these two tests are confusing because they go opposite ways (so the expected values come in opposite orders) — either way seems fine, just make them consistent
final globalStore = eg.globalStore(globalSettings: eg.globalSettings( | ||
browserPreference: null)); |
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.
nit: this bit of setup should arrive in the "follow setting" commit, rather than the preceding commit where the setting isn't yet involved
@@ -811,6 +811,10 @@ | |||
"@themeSettingSystem": { | |||
"description": "Label for system theme setting." | |||
}, | |||
"openLinksWithInAppBrowser": "Open links with in-app browser", |
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 translation for the label is taken from zulip-mobile. The user
facing string refers to "in in-app browser" when the actual value is
`UrlLaunchMode.platformDefault`. This is consistent with the behavior
the user sees when the link is a HTTP URL on Android and iOS, which
should cover the majority of use cases of this setting (and probably
what the user would expect).
This apologetic paragraph can get a lot simpler now 🙂 — I think really can just be cut.
The exact semantics are now "Open links with in-app browser where possible", and the implementation code now makes clear that those are the semantics. And having a "where possible" qualifier be implicit is pretty normal for UI text (outside of UIs for quite technical domains).
Thanks! Updated the PR. |
Thanks! Looks good; merging. |
Signed-off-by: Zixuan James Li <[email protected]>
The url_launcher documentation warns that the meaning of platformDefault may change at any time. We've chosen particular behaviors we want on different platforms, so express those choices explicitly. This change is NFC given the current behavior of url_launcher, which appears to be that platformDefault means an in-app browser for at least HTTP links. Co-authored-by: Greg Price <[email protected]> Signed-off-by: Zixuan James Li <[email protected]>
This preserves the previous behavior (external application on iOS, and in-app browser on Android) when browserPreference is `null`. There is no way for the client to update the setting for now, hence the NFC. The helper could have been a static method instead of an extension, similar to ThemeSetting.displayName, but that will be a lot more verbose for the caller. Signed-off-by: Zixuan James Li <[email protected]>
The UI currently does not have a design, and is made to be as simple as possible to implement for now. Fixes: zulip#1228 Signed-off-by: Zixuan James Li <[email protected]>
Fixes #1228.
This is taken from #1167, addressing the reviews there.