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
Android WebView “tel:” links show web page not found - issue fixed #8526
Conversation
By analyzing the blame information on this pull request, we identified @mkonicek and @nicklockwood to be potential reviewers. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
@@ -110,7 +111,18 @@ public void onPageStarted(WebView webView, String url, Bitmap favicon) { | |||
SystemClock.nanoTime(), | |||
createWebViewEvent(webView, url))); | |||
} | |||
|
|||
@Override | |||
public boolean shouldOverrideUrlLoading(WebView view, String url){ |
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: space before {
I don't think checking for I think we should check if the URL is not |
ReactContext reactContext = (ReactContext) view.getContext(); | ||
if(url.startsWith("tel:")) { | ||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); | ||
reactContext.startActivity(intent); |
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.
Does it work without the flag Intent.FLAG_ACTIVITY_NEW_TASK? We should use the current activity to start the intent (which doesn't need the flag) if we can. It provides better UX since most of the time the user can press back to come to the previous screen.
@Override | ||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
ReactContext reactContext = (ReactContext) view.getContext(); | ||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
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 check if it is http or https before handling.
Also does startActivity
work without FLAG_NEW_TASK
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.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url.startsWith("mms:") || url.startsWith("mmsto:")) {
ReactContext reactContext = (ReactContext) view.getContext();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
reactContext.startActivity(intent);
return true;
}
return false;
}
Is this Correct? shall i proceed? |
It should be |
Also, do you need to cast this to |
@@ -113,13 +113,10 @@ public void onPageStarted(WebView webView, String url, Bitmap favicon) { | |||
} | |||
@Override | |||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | |||
ReactContext reactContext = (ReactContext) view.getContext(); | |||
if(url.startsWith("tel:")) { |
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.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url.startsWith("mms:") || url.startsWith("mmsto:")) {
ReactContext reactContext = (ReactContext) view.getContext();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
reactContext.startActivity(intent);
return true;
}
return false;
}
|
||
@Override | ||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
if(url.startsWith("http")|| url.startsWith("https")) { |
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: space after if
and before ||
@@ -112,6 +114,18 @@ public void onPageStarted(WebView webView, String url, Bitmap favicon) { | |||
} | |||
|
|||
@Override | |||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | |||
if (url.startsWith("http") || url.startsWith("https")) { |
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.
better to check for http:// and https://
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
33a1f28
Summary: Submitting PR facebook#6810 - Android WebView “tel:” links show web page not found - issue fixed. 'tel:' link web page not loading: ![screenshot_2016-07-01-19-48-05](https://cloud.githubusercontent.com/assets/11989113/16525364/b3e9f10c-3fc9-11e6-8119-93cdf24d54df.png) After Fixing the issue: ![screenshot_2016-07-01-19-52-00](https://cloud.githubusercontent.com/assets/11989113/16525371/c0d74d92-3fc9-11e6-899b-570a940692f6.png) Closes facebook#8526 Differential Revision: D3554500 fbshipit-source-id: e8cc1ac4c36ddf0c6b261a29b2e038caddc03e75
Summary: Submitting PR facebook#6810 - Android WebView “tel:” links show web page not found - issue fixed. 'tel:' link web page not loading: ![screenshot_2016-07-01-19-48-05](https://cloud.githubusercontent.com/assets/11989113/16525364/b3e9f10c-3fc9-11e6-8119-93cdf24d54df.png) After Fixing the issue: ![screenshot_2016-07-01-19-52-00](https://cloud.githubusercontent.com/assets/11989113/16525371/c0d74d92-3fc9-11e6-899b-570a940692f6.png) Closes facebook#8526 Differential Revision: D3554500 fbshipit-source-id: e8cc1ac4c36ddf0c6b261a29b2e038caddc03e75
Summary: Submitting PR #6810 - Android WebView “tel:” links show web page not found - issue fixed. 'tel:' link web page not loading: ![screenshot_2016-07-01-19-48-05](https://cloud.githubusercontent.com/assets/11989113/16525364/b3e9f10c-3fc9-11e6-8119-93cdf24d54df.png) After Fixing the issue: ![screenshot_2016-07-01-19-52-00](https://cloud.githubusercontent.com/assets/11989113/16525371/c0d74d92-3fc9-11e6-899b-570a940692f6.png) Closes facebook/react-native#8526 Differential Revision: D3554500 fbshipit-source-id: e8cc1ac4c36ddf0c6b261a29b2e038caddc03e75
Submitting PR #6810 - Android WebView “tel:” links show web page not found - issue fixed.
'tel:' link web page not loading:
After Fixing the issue: