diff options
author | lambroslambrou <lambroslambrou@chromium.org> | 2015-06-24 19:38:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-25 02:39:10 +0000 |
commit | 14dadeedcab7275d1bf5b2138d3c4a24215869ad (patch) | |
tree | 8186e07f30ebf8181ae9bbf01e4a0527641c3231 /remoting | |
parent | 9935e0dbf2b5fadd1da588882833cef50fc5cb42 (diff) | |
download | chromium_src-14dadeedcab7275d1bf5b2138d3c4a24215869ad.zip chromium_src-14dadeedcab7275d1bf5b2138d3c4a24215869ad.tar.gz chromium_src-14dadeedcab7275d1bf5b2138d3c4a24215869ad.tar.bz2 |
Chromoting Android: Add Credits screen.
(re-land of https://codereview.chromium.org/1202523007)
This also slightly changes the behavior of the embedded WebView. Now it
only renders content inline if it originates from the initial host that
it was told to use (otherwise it launches an external browser). This
simplifies the code (by using a single explicitly-defined
WebViewClient implementation).
BUG=499478
Review URL: https://codereview.chromium.org/1207073003
Cr-Commit-Position: refs/heads/master@{#336079}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/android/java/res/menu/help_actionbar.xml | 4 | ||||
-rw-r--r-- | remoting/android/java/src/org/chromium/chromoting/HelpActivity.java | 37 | ||||
-rw-r--r-- | remoting/remoting_android.gypi | 19 | ||||
-rw-r--r-- | remoting/remoting_client.gypi | 6 | ||||
-rw-r--r-- | remoting/resources/remoting_strings.grd | 2 | ||||
-rw-r--r-- | remoting/webapp/BUILD.gn | 2 |
6 files changed, 57 insertions, 13 deletions
diff --git a/remoting/android/java/res/menu/help_actionbar.xml b/remoting/android/java/res/menu/help_actionbar.xml index 8b21fd9..736ed1b 100644 --- a/remoting/android/java/res/menu/help_actionbar.xml +++ b/remoting/android/java/res/menu/help_actionbar.xml @@ -15,4 +15,8 @@ android:id="@+id/actionbar_play_store" android:title="@string/actionbar_play_store" app:showAsAction="never"/> + <item + android:id="@+id/actionbar_credits" + android:title="@string/credits" + app:showAsAction="never"/> </menu> diff --git a/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java b/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java index b6132d4..9f92472 100644 --- a/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java +++ b/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java @@ -33,6 +33,7 @@ import org.chromium.ui.UiUtils; */ public class HelpActivity extends ActionBarActivity { private static final String PLAY_STORE_URL = "market://details?id="; + private static final String CREDITS_URL = "file:///android_res/raw/credits.html"; private static final String FEEDBACK_PACKAGE = "com.google.android.gms"; @@ -51,6 +52,9 @@ public class HelpActivity extends ActionBarActivity { */ private static Bitmap sScreenshot; + /** WebView used to display help content and credits. */ + private WebView mWebView; + /** Constant used to send the feedback parcel to the system feedback service. */ private static final int SEND_FEEDBACK_INFO = Binder.FIRST_CALL_TRANSACTION; @@ -111,8 +115,8 @@ public class HelpActivity extends ActionBarActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - WebView webView = new WebView(this); - setContentView(webView); + mWebView = new WebView(this); + setContentView(mWebView); getSupportActionBar().setTitle(getString(R.string.actionbar_help_title)); @@ -128,12 +132,25 @@ public class HelpActivity extends ActionBarActivity { CharSequence subtitle = TextUtils.concat(appName, " ", versionName); getSupportActionBar().setSubtitle(subtitle); - // This line ensures the WebView remains embedded in this activity and doesn't launch an - // external Chrome browser. - webView.setWebViewClient(new WebViewClient()); - webView.getSettings().setJavaScriptEnabled(true); - String url = getIntent().getDataString(); - webView.loadUrl(url); + String initialUrl = getIntent().getDataString(); + final String initialHost = Uri.parse(initialUrl).getHost(); + + mWebView.getSettings().setJavaScriptEnabled(true); + mWebView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + // Make sure any links to other websites open up in an external browser. + String host = Uri.parse(url).getHost(); + + // Note that |host| might be null, so allow for this in the test for equality. + if (initialHost.equals(host)) { + return false; + } + openUrl(url); + return true; + } + }); + mWebView.loadUrl(initialUrl); } @Override @@ -153,6 +170,10 @@ public class HelpActivity extends ActionBarActivity { openUrl(PLAY_STORE_URL + getPackageName()); return true; } + if (id == R.id.actionbar_credits) { + mWebView.loadUrl(CREDITS_URL); + return true; + } return super.onOptionsItemSelected(item); } } diff --git a/remoting/remoting_android.gypi b/remoting/remoting_android.gypi index b6d77c8..5894e92 100644 --- a/remoting/remoting_android.gypi +++ b/remoting/remoting_android.gypi @@ -41,6 +41,24 @@ ], }, # end of target 'remoting_client_jni' { + 'target_name': 'remoting_android_resources', + 'type': 'none', + 'copies': [ + { + 'destination': '<(SHARED_INTERMEDIATE_DIR)/remoting/android/res/raw', + 'files': [ + '<(SHARED_INTERMEDIATE_DIR)/remoting/credits.html', + 'webapp/base/html/credits_css.css', + 'webapp/base/html/main.css', + 'webapp/base/js/credits_js.js', + ], + }, + ], + 'dependencies': [ + 'remoting_client_credits', + ], + }, # end of target 'remoting_android_resources' + { 'target_name': 'remoting_apk_manifest', 'type': 'none', 'sources': [ @@ -79,6 +97,7 @@ ], }, 'dependencies': [ + 'remoting_android_resources', '../base/base.gyp:base_java', '../ui/android/ui_android.gyp:ui_java', '../third_party/android_tools/android_tools.gyp:android_support_v7_appcompat_javalib', diff --git a/remoting/remoting_client.gypi b/remoting/remoting_client.gypi index e36d56b..3d53e39 100644 --- a/remoting/remoting_client.gypi +++ b/remoting/remoting_client.gypi @@ -126,11 +126,11 @@ { # GN version: //remoting/webapp:credits - 'target_name': 'remoting_webapp_credits', + 'target_name': 'remoting_client_credits', 'type': 'none', 'actions': [ { - 'action_name': 'Build remoting webapp credits', + 'action_name': 'Build remoting client credits', 'inputs': [ '../tools/licenses.py', 'webapp/base/html/credits.tmpl', @@ -156,7 +156,7 @@ 'target_name': 'remoting_webapp', 'type': 'none', 'dependencies': [ - 'remoting_webapp_credits', + 'remoting_client_credits', 'remoting_webapp_v1', ], 'conditions': [ diff --git a/remoting/resources/remoting_strings.grd b/remoting/resources/remoting_strings.grd index 926710c..1ef230f 100644 --- a/remoting/resources/remoting_strings.grd +++ b/remoting/resources/remoting_strings.grd @@ -785,7 +785,7 @@ For information about privacy, please see the Google Privacy Policy (http://goo. <message desc="Help link, displayed in the top-left (assuming ltr layout) corner of the main screen. Clicking this takes the user to our FAQ." name="IDS_HELP"> Help </message> - <message desc="Credits link, displayed in the top-left (assuming ltr layout) corner of the main screen. Clicking this takes the user to our acknowledgements screen." name="IDS_CREDITS"> + <message desc="Credits link, displayed in the top-left (assuming ltr layout) corner of the main screen. Clicking this takes the user to our acknowledgements screen." name="IDS_CREDITS" formatter_data="android_java"> Credits </message> <message desc="Clicking this button starts the desktop access process." name="IDS_HOME_ACCESS_BUTTON"> diff --git a/remoting/webapp/BUILD.gn b/remoting/webapp/BUILD.gn index db45bf2..34d90e0 100644 --- a/remoting/webapp/BUILD.gn +++ b/remoting/webapp/BUILD.gn @@ -47,7 +47,7 @@ app_remoting_webapp("ar_sample_app") { manifest_key = "remotingdevbuild" } -# GYP version: remoting/remoting_client:remoting_webapp_credits +# GYP version: remoting/remoting_client:remoting_client_credits action("credits") { about_credits_file = "$target_gen_dir/credits.html" script = "//tools/licenses.py" |