summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Felipe Leme <felipeal@google.com> 2016-03-16 16:29:55 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-03-16 16:29:57 +0000
commitf3a65fd31798f8c7ecfa0f3db292d115c10c3dbc (patch)
treeed9b8ba3f40545cca99025e4dc7284f773a89b30
parent8a2d1d9c3dec5d7dc16d46ca2b453c9bfa957ec1 (diff)
parent208b1881ae924cd0c2bed326555e4aa18424d927 (diff)
Merge "Minor UI improvements and code cleanup:" into nyc-dev
-rw-r--r--packages/Shell/res/layout/dialog_bugreport_info.xml2
-rw-r--r--packages/Shell/src/com/android/shell/BugreportProgressService.java36
-rw-r--r--packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java31
3 files changed, 33 insertions, 36 deletions
diff --git a/packages/Shell/res/layout/dialog_bugreport_info.xml b/packages/Shell/res/layout/dialog_bugreport_info.xml
index b6b8d6bcf2b2..bb3084f5c10a 100644
--- a/packages/Shell/res/layout/dialog_bugreport_info.xml
+++ b/packages/Shell/res/layout/dialog_bugreport_info.xml
@@ -19,6 +19,7 @@
android:paddingTop="15dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
+ android:focusableInTouchMode="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
@@ -30,7 +31,6 @@
android:id="@+id/name"
android:maxLength="30"
android:singleLine="true"
- android:selectAllOnFocus="true"
android:inputType="textNoSuggestions"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index 89ebcd1b3fe6..7fae0ee6b660 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -454,21 +454,15 @@ public class BugreportProgressService extends Service {
final String name =
info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed);
- final Notification notification = new Notification.Builder(mContext)
- .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
+ final Notification notification = newBaseNotification(mContext)
.setContentTitle(title)
.setTicker(title)
.setContentText(name)
.setContentInfo(percentText)
.setProgress(info.max, info.progress, false)
.setOngoing(true)
- .setLocalOnly(true)
- .setColor(mContext.getColor(
- com.android.internal.R.color.system_notification_accent_color))
.setContentIntent(infoPendingIntent)
- .addAction(infoAction)
- .addAction(screenshotAction)
- .addAction(cancelAction)
+ .setActions(infoAction, screenshotAction, cancelAction)
.build();
if (info.finished) {
@@ -928,17 +922,13 @@ public class BugreportProgressService extends Service {
title = context.getString(R.string.bugreport_finished_title, info.id);
content = context.getString(R.string.bugreport_finished_text);
}
- final Notification.Builder builder = new Notification.Builder(context)
- .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
+ final Notification.Builder builder = newBaseNotification(context)
.setContentTitle(title)
.setTicker(title)
.setContentText(content)
.setContentIntent(PendingIntent.getService(context, info.id, shareIntent,
PendingIntent.FLAG_UPDATE_CURRENT))
- .setDeleteIntent(newCancelIntent(context, info))
- .setLocalOnly(true)
- .setColor(context.getColor(
- com.android.internal.R.color.system_notification_accent_color));
+ .setDeleteIntent(newCancelIntent(context, info));
if (!TextUtils.isEmpty(info.name)) {
builder.setContentInfo(info.name);
@@ -955,16 +945,21 @@ public class BugreportProgressService extends Service {
*/
private static void sendBugreportBeingUpdatedNotification(Context context, int id) {
final String title = context.getString(R.string.bugreport_updating_title);
- final Notification.Builder builder = new Notification.Builder(context)
- .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
+ final Notification.Builder builder = newBaseNotification(context)
.setContentTitle(title)
.setTicker(title)
- .setContentText(context.getString(R.string.bugreport_updating_wait))
+ .setContentText(context.getString(R.string.bugreport_updating_wait));
+ Log.v(TAG, "Sending 'Updating zip' notification for ID " + id + ": " + title);
+ NotificationManager.from(context).notify(TAG, id, builder.build());
+ }
+
+ private static Notification.Builder newBaseNotification(Context context) {
+ return new Notification.Builder(context)
+ .setCategory(Notification.CATEGORY_SYSTEM)
+ .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
.setLocalOnly(true)
.setColor(context.getColor(
com.android.internal.R.color.system_notification_accent_color));
- Log.v(TAG, "Sending 'Updating zip' notification for ID " + id + ": " + title);
- NotificationManager.from(context).notify(TAG, id, builder.build());
}
/**
@@ -1288,9 +1283,6 @@ public class BugreportProgressService extends Service {
if (hasFocus) {
return;
}
- // Select-all is useful just initially, since the date-based filename is
- // full of hyphens.
- mInfoName.setSelectAllOnFocus(false);
sanitizeName();
}
});
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index 47e3b3b8f8f3..17f6f6b5ac89 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -291,6 +291,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
detailsUi.assertName(NAME);
// Change name - it should have changed system property once focus is changed.
+ detailsUi.focusOnName();
detailsUi.nameField.setText(NEW_NAME);
detailsUi.focusAwayFromName();
assertPropertyValue(NAME_PROPERTY, NEW_NAME);
@@ -966,40 +967,44 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
cancelButton = mUiBot.getObjectById("android:id/button2");
}
- private void assertField(String name, UiObject field, String expected) {
- try {
- String actual = field.getText().toString();
- assertEquals("Wrong value on field '" + name + "'", expected, actual);
- } catch (UiObjectNotFoundException e) {
- // Should not happen...
- throw new IllegalStateException("field not found: " + name, e);
- }
+ private void assertField(String name, UiObject field, String expected)
+ throws UiObjectNotFoundException {
+ String actual = field.getText().toString();
+ assertEquals("Wrong value on field '" + name + "'", expected, actual);
}
- void assertName(String expected) {
+ void assertName(String expected) throws UiObjectNotFoundException {
assertField("name", nameField, expected);
}
- void assertTitle(String expected) {
+ void assertTitle(String expected) throws UiObjectNotFoundException {
assertField("title", titleField, expected);
}
- void assertDescription(String expected) {
+ void assertDescription(String expected) throws UiObjectNotFoundException {
assertField("description", descField, expected);
}
/**
+ * Set focus on the name field so it can be validated once focus is lost.
+ */
+ void focusOnName() throws UiObjectNotFoundException {
+ mUiBot.click(nameField, "name_field");
+ assertTrue("name_field not focused", nameField.isFocused());
+ }
+
+ /**
* Takes focus away from the name field so it can be validated.
*/
- void focusAwayFromName() {
+ void focusAwayFromName() throws UiObjectNotFoundException {
mUiBot.click(titleField, "title_field"); // Change focus.
mUiBot.pressBack(); // Dismiss keyboard.
+ assertFalse("name_field is focused", nameField.isFocused());
}
void reOpen() {
openProgressNotification(ID);
mUiBot.click(detailsButton, "details_button");
-
}
void clickOk() {