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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chromoting;
6
7 import android.app.Activity;
8 import android.content.Intent;
9 import android.content.pm.PackageInfo;
10 import android.content.pm.PackageManager;
11 import android.net.Uri;
12 import android.os.Bundle;
13 import android.text.TextUtils;
14 import android.view.Menu;
15 import android.view.MenuItem;
16 import android.webkit.WebView;
17 import android.webkit.WebViewClient;
18
19 /**
20 * The Activity for showing the Help screen.
21 */
22 public class HelpActivity extends Activity {
23 private static final String PLAY_STORE_URL = "market://details?id=";
24
25 /** Launches an external web browser or application. */
26 private void openUrl(String url) {
27 Uri uri = Uri.parse(url);
28 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
29
30 // Verify that the device can launch an application for this intent, oth erwise
31 // startActivity() may crash the application.
32 if (intent.resolveActivity(getPackageManager()) != null) {
33 startActivity(intent);
34 }
35 }
36
37 @Override
38 public void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState);
40
41 WebView webView = new WebView(this);
42 setContentView(webView);
43
44 getActionBar().setTitle(getString(R.string.actionbar_help_title));
45
46 CharSequence appName = getTitle();
47 CharSequence versionName = null;
48 try {
49 PackageInfo info = getPackageManager().getPackageInfo(getPackageName (), 0);
50 versionName = info.versionName;
51 } catch (PackageManager.NameNotFoundException ex) {
52 throw new RuntimeException("Unable to get version: " + ex);
53 }
54
55 CharSequence subtitle = TextUtils.concat(appName, " ", versionName);
56 getActionBar().setSubtitle(subtitle);
57
58 // This line ensures the WebView remains embedded in this activity and d oesn't launch an
59 // external Chrome browser.
60 webView.setWebViewClient(new WebViewClient());
61 webView.getSettings().setJavaScriptEnabled(true);
62 String url = getIntent().getDataString();
63 webView.loadUrl(url);
64 }
65
66 @Override
67 public boolean onCreateOptionsMenu(Menu menu) {
68 getMenuInflater().inflate(R.menu.help_actionbar, menu);
69 return super.onCreateOptionsMenu(menu);
70 }
71
72 @Override
73 public boolean onOptionsItemSelected(MenuItem item) {
74 switch (item.getItemId()) {
75 case R.id.actionbar_play_store:
76 openUrl(PLAY_STORE_URL + getPackageName());
77 return true;
78
79 default:
80 return super.onOptionsItemSelected(item);
81 }
82 }
83 }
OLDNEW
« 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