summaryrefslogtreecommitdiffstats
path: root/remoting/android
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-07 04:18:46 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-07 04:18:46 +0000
commit1cf01308eea59be2e2e24cddeb400a47a1cde899 (patch)
treec66d984c4e58a0acb2246619669d7fd44f5af0f2 /remoting/android
parent66ee84d08dae342eed6461ec6e2800022c6922d9 (diff)
downloadchromium_src-1cf01308eea59be2e2e24cddeb400a47a1cde899.zip
chromium_src-1cf01308eea59be2e2e24cddeb400a47a1cde899.tar.gz
chromium_src-1cf01308eea59be2e2e24cddeb400a47a1cde899.tar.bz2
Implement feedback in Chromoting Help & Feedback screen
BUG=333129 Review URL: https://codereview.chromium.org/187663005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/android')
-rw-r--r--remoting/android/java/DEPS3
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Chromoting.java7
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Desktop.java8
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/HelpActivity.java65
4 files changed, 70 insertions, 13 deletions
diff --git a/remoting/android/java/DEPS b/remoting/android/java/DEPS
new file mode 100644
index 0000000..05f395e
--- /dev/null
+++ b/remoting/android/java/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ui/android/java",
+]
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
index 148ff58b..1abc5b8 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -18,7 +18,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
-import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
@@ -215,11 +214,7 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
return true;
case R.id.actionbar_help:
- {
- Intent intent = new Intent(this, HelpActivity.class);
- intent.setData(Uri.parse(HELP_URL));
- startActivity(intent);
- }
+ HelpActivity.launch(this, HELP_URL);
return true;
default:
diff --git a/remoting/android/java/src/org/chromium/chromoting/Desktop.java b/remoting/android/java/src/org/chromium/chromoting/Desktop.java
index f426ae1..b75d97d 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Desktop.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Desktop.java
@@ -5,9 +5,7 @@
package org.chromium.chromoting;
import android.app.Activity;
-import android.content.Intent;
import android.content.res.Configuration;
-import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
@@ -114,11 +112,7 @@ public class Desktop extends Activity {
return true;
case R.id.actionbar_help:
- {
- Intent intent = new Intent(this, HelpActivity.class);
- intent.setData(Uri.parse(HELP_URL));
- startActivity(intent);
- }
+ HelpActivity.launch(this, HELP_URL);
return true;
default:
diff --git a/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java b/remoting/android/java/src/org/chromium/chromoting/HelpActivity.java
index 0404827..efe1f21 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;