Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/help/HelpActivity.java

Issue 2769813003: [remoting android] Fix WebView deprecation warnings (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/help/CreditsActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting.help; 5 package org.chromium.chromoting.help;
6 6
7 import android.annotation.TargetApi;
7 import android.app.Activity; 8 import android.app.Activity;
8 import android.content.Intent; 9 import android.content.Intent;
9 import android.content.pm.PackageInfo; 10 import android.content.pm.PackageInfo;
10 import android.content.pm.PackageManager; 11 import android.content.pm.PackageManager;
11 import android.graphics.Bitmap; 12 import android.graphics.Bitmap;
12 import android.net.Uri; 13 import android.net.Uri;
14 import android.os.Build;
13 import android.os.Bundle; 15 import android.os.Bundle;
14 import android.support.v7.app.AppCompatActivity; 16 import android.support.v7.app.AppCompatActivity;
15 import android.support.v7.widget.Toolbar; 17 import android.support.v7.widget.Toolbar;
16 import android.text.TextUtils; 18 import android.text.TextUtils;
17 import android.view.Menu; 19 import android.view.Menu;
18 import android.view.MenuItem; 20 import android.view.MenuItem;
19 import android.view.View; 21 import android.view.View;
22 import android.webkit.WebResourceRequest;
20 import android.webkit.WebView; 23 import android.webkit.WebView;
21 import android.webkit.WebViewClient; 24 import android.webkit.WebViewClient;
22 25
23 import org.chromium.chromoting.ChromotingUtil; 26 import org.chromium.chromoting.ChromotingUtil;
24 import org.chromium.chromoting.R; 27 import org.chromium.chromoting.R;
25 import org.chromium.ui.UiUtils; 28 import org.chromium.ui.UiUtils;
26 29
27 /** 30 /**
28 * The Activity for showing the Help screen. 31 * The Activity for showing the Help screen.
29 */ 32 */
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 82 }
80 83
81 CharSequence subtitle = TextUtils.concat(appName, " ", versionName); 84 CharSequence subtitle = TextUtils.concat(appName, " ", versionName);
82 getSupportActionBar().setSubtitle(subtitle); 85 getSupportActionBar().setSubtitle(subtitle);
83 86
84 String initialUrl = getIntent().getDataString(); 87 String initialUrl = getIntent().getDataString();
85 final String initialHost = Uri.parse(initialUrl).getHost(); 88 final String initialHost = Uri.parse(initialUrl).getHost();
86 89
87 mWebView.getSettings().setJavaScriptEnabled(true); 90 mWebView.getSettings().setJavaScriptEnabled(true);
88 mWebView.setWebViewClient(new WebViewClient() { 91 mWebView.setWebViewClient(new WebViewClient() {
89 @Override 92 private boolean shouldOverrideUrlLoading(final Uri uri) {
90 public boolean shouldOverrideUrlLoading(WebView view, String url) {
91 // Make sure any links to other websites open up in an external browser. 93 // Make sure any links to other websites open up in an external browser.
92 Uri uri = Uri.parse(url);
93 String host = uri.getHost(); 94 String host = uri.getHost();
94 95
95 // Note that |host| might be null, so allow for this in the test for equality. 96 // Note that |host| might be null, so allow for this in the test for equality.
96 if (initialHost.equals(host)) { 97 if (initialHost.equals(host)) {
97 return false; 98 return false;
98 } 99 }
99 ChromotingUtil.openUrl(HelpActivity.this, uri); 100 ChromotingUtil.openUrl(HelpActivity.this, uri);
100 return true; 101 return true;
101 } 102 }
103
104 @TargetApi(Build.VERSION_CODES.N)
105 @Override
106 public boolean shouldOverrideUrlLoading(WebView view, WebResourceReq uest request) {
107 return shouldOverrideUrlLoading(request.getUrl());
108 }
109
110 @SuppressWarnings("deprecation")
111 @Override
112 public boolean shouldOverrideUrlLoading(WebView view, String url) {
113 return shouldOverrideUrlLoading(Uri.parse(url));
114 }
102 }); 115 });
103 mWebView.loadUrl(initialUrl); 116 mWebView.loadUrl(initialUrl);
104 } 117 }
105 118
106 @Override 119 @Override
107 public boolean onCreateOptionsMenu(Menu menu) { 120 public boolean onCreateOptionsMenu(Menu menu) {
108 getMenuInflater().inflate(R.menu.help_actionbar, menu); 121 getMenuInflater().inflate(R.menu.help_actionbar, menu);
109 return super.onCreateOptionsMenu(menu); 122 return super.onCreateOptionsMenu(menu);
110 } 123 }
111 124
(...skipping 12 matching lines...) Expand all
124 ChromotingUtil.openUrl(this, Uri.parse(PLAY_STORE_URL + getPackageNa me())); 137 ChromotingUtil.openUrl(this, Uri.parse(PLAY_STORE_URL + getPackageNa me()));
125 return true; 138 return true;
126 } 139 }
127 if (id == R.id.actionbar_credits) { 140 if (id == R.id.actionbar_credits) {
128 startActivity(new Intent(this, CreditsActivity.class)); 141 startActivity(new Intent(this, CreditsActivity.class));
129 return true; 142 return true;
130 } 143 }
131 return super.onOptionsItemSelected(item); 144 return super.onOptionsItemSelected(item);
132 } 145 }
133 } 146 }
OLDNEW
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/help/CreditsActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698