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

Unified 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: Add DEPS 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 side-by-side diff with in-line comments
Download patch
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
index 0404827cb0dc86930b90efd2de0197c3e5a7a2d8..efe1f214c704f9002dc7e14d732afd4dce042bf2 100644
--- a/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java
+++ b/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java
@@ -5,23 +5,49 @@
package org.chromium.chromoting;
import android.app.Activity;
+import android.content.ComponentName;
import android.content.Intent;
+import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
import android.net.Uri;
+import android.os.Binder;
import android.os.Bundle;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.RemoteException;
import android.text.TextUtils;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
+import org.chromium.ui.UiUtils;
+
/**
* The Activity for showing the Help screen.
*/
public class HelpActivity extends Activity {
private static final String PLAY_STORE_URL = "market://details?id=";
+ /**
+ * Maximum dimension for the screenshot to be sent to the Send Feedback handler. This size
+ * ensures the size of bitmap < 1MB, which is a requirement of the handler.
+ */
+ private static final int MAX_FEEDBACK_SCREENSHOT_DIMENSION = 600;
+
+ /**
+ * This global variable is used for passing the screenshot from the originating Activity to the
+ * HelpActivity. There seems to be no better way of doing this.
+ */
+ private static Bitmap mScreenshot;
+
+ /** Constant used to send the feedback parcel to the system feedback service. */
+ private static final int SEND_FEEDBACK_INFO = Binder.FIRST_CALL_TRANSACTION;
+
/** Launches an external web browser or application. */
private void openUrl(String url) {
Uri uri = Uri.parse(url);
@@ -34,6 +60,41 @@ public class HelpActivity extends Activity {
}
}
+ private void sendFeedback() {
+ Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
+ ServiceConnection conn = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ try {
+ Parcel parcel = Parcel.obtain();
+ if (mScreenshot != null) {
+ mScreenshot.writeToParcel(parcel, 0);
+ }
+ service.transact(SEND_FEEDBACK_INFO, parcel, null, 0);
+ parcel.recycle();
+ } catch (RemoteException ex) {
+ Log.e("help", "Unexpected error sending feedback: ", ex);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {}
+ };
+
+ bindService(intent, conn, BIND_AUTO_CREATE);
+ }
+
+ /** Launches the Help activity. */
+ public static void launch(Activity activity, String helpUrl) {
+ View rootView = activity.getWindow().getDecorView().getRootView();
+ mScreenshot = UiUtils.generateScaledScreenshot(rootView, MAX_FEEDBACK_SCREENSHOT_DIMENSION,
+ Bitmap.Config.ARGB_8888);
+
+ Intent intent = new Intent(activity, HelpActivity.class);
+ intent.setData(Uri.parse(helpUrl));
+ activity.startActivity(intent);
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -72,6 +133,10 @@ public class HelpActivity extends Activity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
+ case R.id.actionbar_feedback:
+ sendFeedback();
+ return true;
+
case R.id.actionbar_play_store:
openUrl(PLAY_STORE_URL + getPackageName());
return true;
« 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