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

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

Issue 187663005: Implement feedback in Chromoting Help & Feedback screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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; 5 package org.chromium.chromoting;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.ComponentName;
8 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.ServiceConnection;
9 import android.content.pm.PackageInfo; 11 import android.content.pm.PackageInfo;
10 import android.content.pm.PackageManager; 12 import android.content.pm.PackageManager;
13 import android.graphics.Bitmap;
11 import android.net.Uri; 14 import android.net.Uri;
15 import android.os.Binder;
12 import android.os.Bundle; 16 import android.os.Bundle;
17 import android.os.IBinder;
18 import android.os.Parcel;
19 import android.os.RemoteException;
13 import android.text.TextUtils; 20 import android.text.TextUtils;
21 import android.util.Log;
14 import android.view.Menu; 22 import android.view.Menu;
15 import android.view.MenuItem; 23 import android.view.MenuItem;
24 import android.view.View;
16 import android.webkit.WebView; 25 import android.webkit.WebView;
17 import android.webkit.WebViewClient; 26 import android.webkit.WebViewClient;
18 27
28 import org.chromium.ui.UiUtils;
29
19 /** 30 /**
20 * The Activity for showing the Help screen. 31 * The Activity for showing the Help screen.
21 */ 32 */
22 public class HelpActivity extends Activity { 33 public class HelpActivity extends Activity {
23 private static final String PLAY_STORE_URL = "market://details?id="; 34 private static final String PLAY_STORE_URL = "market://details?id=";
24 35
36 /**
37 * Maximum dimension for the screenshot to be sent to the Send Feedback hand ler. This size
38 * ensures the size of bitmap < 1MB, which is a requirement of the handler.
39 */
40 private static final int MAX_FEEDBACK_SCREENSHOT_DIMENSION = 600;
Jamie 2014/03/06 01:52:01 Is this assuming a square screenshot?
Lambros 2014/03/06 02:31:31 I don't know :) Chrome uses this same value.
41
42 private static Bitmap mScreenshot;
Lambros 2014/03/06 00:38:30 Global variables are evil, but there doesn't seem
Jamie 2014/03/06 01:52:01 I think this warrants a comment on the member itse
Lambros 2014/03/06 02:31:31 Done.
43
25 /** Launches an external web browser or application. */ 44 /** Launches an external web browser or application. */
26 private void openUrl(String url) { 45 private void openUrl(String url) {
27 Uri uri = Uri.parse(url); 46 Uri uri = Uri.parse(url);
28 Intent intent = new Intent(Intent.ACTION_VIEW, uri); 47 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
29 48
30 // Verify that the device can launch an application for this intent, oth erwise 49 // Verify that the device can launch an application for this intent, oth erwise
31 // startActivity() may crash the application. 50 // startActivity() may crash the application.
32 if (intent.resolveActivity(getPackageManager()) != null) { 51 if (intent.resolveActivity(getPackageManager()) != null) {
33 startActivity(intent); 52 startActivity(intent);
34 } 53 }
35 } 54 }
36 55
56 private void sendFeedback() {
57 Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
58 ServiceConnection conn = new ServiceConnection() {
59 @Override
60 public void onServiceConnected(ComponentName name, IBinder service) {
61 try {
62 Parcel parcel = Parcel.obtain();
63 if (mScreenshot != null) {
64 mScreenshot.writeToParcel(parcel, 0);
65 }
66 service.transact(Binder.FIRST_CALL_TRANSACTION, parcel, null , 0);
Jamie 2014/03/06 01:52:01 I had to look up FIRST_CALL_TRANSATION. As far as
Lambros 2014/03/06 02:31:31 Done, though I'm not sure I've thought of a good n
67 parcel.recycle();
68 } catch (RemoteException ex) {
69 Log.d("help", "Unexpected error sending feedback: ", ex);
Jamie 2014/03/06 01:52:01 Should this be Log.e?
Lambros 2014/03/06 02:31:31 Done.
70 }
71 }
72
73 @Override
74 public void onServiceDisconnected(ComponentName name) {}
75 };
76
77 bindService(intent, conn, BIND_AUTO_CREATE);
78 }
79
80 /** Launches the Help activity. */
81 public static void launch(Activity activity, String helpUrl) {
82 View rootView = activity.getWindow().getDecorView().getRootView();
83 mScreenshot = UiUtils.generateScaledScreenshot(rootView, MAX_FEEDBACK_SC REENSHOT_DIMENSION,
84 Bitmap.Config.ARGB_8888);
85
86 Intent intent = new Intent(activity, HelpActivity.class);
87 intent.setData(Uri.parse(helpUrl));
88 activity.startActivity(intent);
89 }
90
37 @Override 91 @Override
38 public void onCreate(Bundle savedInstanceState) { 92 public void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState); 93 super.onCreate(savedInstanceState);
40 94
41 WebView webView = new WebView(this); 95 WebView webView = new WebView(this);
42 setContentView(webView); 96 setContentView(webView);
43 97
44 getActionBar().setTitle(getString(R.string.actionbar_help_title)); 98 getActionBar().setTitle(getString(R.string.actionbar_help_title));
45 99
46 CharSequence appName = getTitle(); 100 CharSequence appName = getTitle();
(...skipping 18 matching lines...) Expand all
65 119
66 @Override 120 @Override
67 public boolean onCreateOptionsMenu(Menu menu) { 121 public boolean onCreateOptionsMenu(Menu menu) {
68 getMenuInflater().inflate(R.menu.help_actionbar, menu); 122 getMenuInflater().inflate(R.menu.help_actionbar, menu);
69 return super.onCreateOptionsMenu(menu); 123 return super.onCreateOptionsMenu(menu);
70 } 124 }
71 125
72 @Override 126 @Override
73 public boolean onOptionsItemSelected(MenuItem item) { 127 public boolean onOptionsItemSelected(MenuItem item) {
74 switch (item.getItemId()) { 128 switch (item.getItemId()) {
129 case R.id.actionbar_feedback:
130 sendFeedback();
131 return true;
132
75 case R.id.actionbar_play_store: 133 case R.id.actionbar_play_store:
76 openUrl(PLAY_STORE_URL + getPackageName()); 134 openUrl(PLAY_STORE_URL + getPackageName());
77 return true; 135 return true;
78 136
79 default: 137 default:
80 return super.onOptionsItemSelected(item); 138 return super.onOptionsItemSelected(item);
81 } 139 }
82 } 140 }
83 } 141 }
OLDNEW
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Desktop.java ('k') | remoting/resources/android/menu/help_actionbar.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698