Merge "Minor UI improvements and code cleanup:" into nyc-dev
This commit is contained in:
@@ -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"/>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user