OLD | NEW |
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.ComponentName; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.ServiceConnection; | 10 import android.content.ServiceConnection; |
(...skipping 15 matching lines...) Expand all Loading... |
26 import android.webkit.WebViewClient; | 26 import android.webkit.WebViewClient; |
27 | 27 |
28 import org.chromium.ui.UiUtils; | 28 import org.chromium.ui.UiUtils; |
29 | 29 |
30 /** | 30 /** |
31 * The Activity for showing the Help screen. | 31 * The Activity for showing the Help screen. |
32 */ | 32 */ |
33 public class HelpActivity extends Activity { | 33 public class HelpActivity extends Activity { |
34 private static final String PLAY_STORE_URL = "market://details?id="; | 34 private static final String PLAY_STORE_URL = "market://details?id="; |
35 | 35 |
| 36 private static final String FEEDBACK_PACKAGE = "com.google.android.gms"; |
| 37 |
| 38 private static final String FEEDBACK_CLASS = |
| 39 "com.google.android.gms.feedback.LegacyBugReportService"; |
| 40 |
36 /** | 41 /** |
37 * Maximum dimension for the screenshot to be sent to the Send Feedback hand
ler. This size | 42 * 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. | 43 * ensures the size of bitmap < 1MB, which is a requirement of the handler. |
39 */ | 44 */ |
40 private static final int MAX_FEEDBACK_SCREENSHOT_DIMENSION = 600; | 45 private static final int MAX_FEEDBACK_SCREENSHOT_DIMENSION = 600; |
41 | 46 |
42 /** | 47 /** |
43 * This global variable is used for passing the screenshot from the originat
ing Activity to the | 48 * This global variable is used for passing the screenshot from the originat
ing Activity to the |
44 * HelpActivity. There seems to be no better way of doing this. | 49 * HelpActivity. There seems to be no better way of doing this. |
45 */ | 50 */ |
46 private static Bitmap mScreenshot; | 51 private static Bitmap mScreenshot; |
47 | 52 |
48 /** Constant used to send the feedback parcel to the system feedback service
. */ | 53 /** Constant used to send the feedback parcel to the system feedback service
. */ |
49 private static final int SEND_FEEDBACK_INFO = Binder.FIRST_CALL_TRANSACTION; | 54 private static final int SEND_FEEDBACK_INFO = Binder.FIRST_CALL_TRANSACTION; |
50 | 55 |
51 /** Launches an external web browser or application. */ | 56 /** Launches an external web browser or application. */ |
52 private void openUrl(String url) { | 57 private void openUrl(String url) { |
53 Uri uri = Uri.parse(url); | 58 Uri uri = Uri.parse(url); |
54 Intent intent = new Intent(Intent.ACTION_VIEW, uri); | 59 Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
55 | 60 |
56 // Verify that the device can launch an application for this intent, oth
erwise | 61 // Verify that the device can launch an application for this intent, oth
erwise |
57 // startActivity() may crash the application. | 62 // startActivity() may crash the application. |
58 if (intent.resolveActivity(getPackageManager()) != null) { | 63 if (intent.resolveActivity(getPackageManager()) != null) { |
59 startActivity(intent); | 64 startActivity(intent); |
60 } | 65 } |
61 } | 66 } |
62 | 67 |
63 private void sendFeedback() { | 68 private void sendFeedback() { |
64 Intent intent = new Intent(Intent.ACTION_BUG_REPORT); | 69 Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
| 70 intent.setComponent(new ComponentName(FEEDBACK_PACKAGE, FEEDBACK_CLASS))
; |
| 71 if (getPackageManager().resolveService(intent, 0) == null) { |
| 72 Log.e("help", "Unable to resolve Feedback service."); |
| 73 return; |
| 74 } |
| 75 |
65 ServiceConnection conn = new ServiceConnection() { | 76 ServiceConnection conn = new ServiceConnection() { |
66 @Override | 77 @Override |
67 public void onServiceConnected(ComponentName name, IBinder service)
{ | 78 public void onServiceConnected(ComponentName name, IBinder service)
{ |
68 try { | 79 try { |
69 Parcel parcel = Parcel.obtain(); | 80 Parcel parcel = Parcel.obtain(); |
70 if (mScreenshot != null) { | 81 if (mScreenshot != null) { |
71 mScreenshot.writeToParcel(parcel, 0); | 82 mScreenshot.writeToParcel(parcel, 0); |
72 } | 83 } |
73 service.transact(SEND_FEEDBACK_INFO, parcel, null, 0); | 84 service.transact(SEND_FEEDBACK_INFO, parcel, null, 0); |
74 parcel.recycle(); | 85 parcel.recycle(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 sendFeedback(); | 148 sendFeedback(); |
138 return true; | 149 return true; |
139 } | 150 } |
140 if (id == R.id.actionbar_play_store) { | 151 if (id == R.id.actionbar_play_store) { |
141 openUrl(PLAY_STORE_URL + getPackageName()); | 152 openUrl(PLAY_STORE_URL + getPackageName()); |
142 return true; | 153 return true; |
143 } | 154 } |
144 return super.onOptionsItemSelected(item); | 155 return super.onOptionsItemSelected(item); |
145 } | 156 } |
146 } | 157 } |
OLD | NEW |