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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/HelpActivity.java

Issue 179003006: Add Help & feedback screens to Android Chromoting client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove whitespace change Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Desktop.java ('k') | remoting/remoting_android.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/HelpActivity.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java b/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..0404827cb0dc86930b90efd2de0197c3e5a7a2d8
--- /dev/null
+++ b/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java
@@ -0,0 +1,83 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chromoting;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+/**
+ * The Activity for showing the Help screen.
+ */
+public class HelpActivity extends Activity {
+ private static final String PLAY_STORE_URL = "market://details?id=";
+
+ /** Launches an external web browser or application. */
+ private void openUrl(String url) {
+ Uri uri = Uri.parse(url);
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+
+ // Verify that the device can launch an application for this intent, otherwise
+ // startActivity() may crash the application.
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ WebView webView = new WebView(this);
+ setContentView(webView);
+
+ getActionBar().setTitle(getString(R.string.actionbar_help_title));
+
+ CharSequence appName = getTitle();
+ CharSequence versionName = null;
+ try {
+ PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
+ versionName = info.versionName;
+ } catch (PackageManager.NameNotFoundException ex) {
+ throw new RuntimeException("Unable to get version: " + ex);
+ }
+
+ CharSequence subtitle = TextUtils.concat(appName, " ", versionName);
+ getActionBar().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);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.help_actionbar, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.actionbar_play_store:
+ openUrl(PLAY_STORE_URL + getPackageName());
+ return true;
+
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Desktop.java ('k') | remoting/remoting_android.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698