Merge "Update text, colors, and suppression" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-14 12:28:00 +00:00
committed by Android (Google) Code Review
12 changed files with 60 additions and 46 deletions

View File

@@ -47,7 +47,7 @@
android:id="@+id/name"
android:paddingTop="2dp"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp"
android:maxLines="1"
@@ -59,7 +59,7 @@
<TextView
android:text="@string/status_before_loading"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -47,7 +47,7 @@
android:id="@+id/name"
android:paddingTop="2dp"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp"
android:maxLines="1"
@@ -59,7 +59,7 @@
<TextView
android:text="@string/empty_status"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -68,7 +68,7 @@
<TextView
android:id="@+id/name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp"
android:maxLines="1"
@@ -79,7 +79,7 @@
<TextView
android:id="@+id/status"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:paddingVertical="2dp"
android:textSize="12sp"
android:layout_width="wrap_content"

View File

@@ -41,14 +41,14 @@
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/name_text_size_for_large" />
<TextView
android:id="@+id/last_interaction"
android:text="@string/empty_status"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textSize="@dimen/content_text_size_for_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -52,7 +52,7 @@
android:layout_alignParentEnd="true"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?androidprv:attr/textColorOnAccent"
android:background="@drawable/people_space_messages_count_background"
android:textSize="14sp"
@@ -81,9 +81,9 @@
android:singleLine="true"
android:ellipsize="end"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/name_text_size_for_content" />
android:textSize="@dimen/name_text_size_for_large_content" />
<LinearLayout
android:id="@+id/content"
@@ -102,7 +102,7 @@
<ImageView
android:id="@+id/predefined_icon"
android:tint="?android:attr/textColorTertiary"
android:tint="?android:attr/textColorSecondary"
android:gravity="start|center_vertical"
android:layout_width="@dimen/regular_predefined_icon"
android:layout_height="@dimen/regular_predefined_icon" />
@@ -117,11 +117,10 @@
android:ellipsize="end"
android:singleLine="true"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />
</LinearLayout>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
@@ -139,7 +138,7 @@
android:maxLines="2"
android:singleLine="false"
android:text="@string/empty_status"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/content_text_size_for_large" />
</LinearLayout>

View File

@@ -53,7 +53,7 @@
<TextView
android:id="@+id/name"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/empty_name_text_size_for_medium"
android:maxLines="1"
@@ -64,7 +64,7 @@
android:id="@+id/last_interaction"
android:text="@string/empty_status"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textSize="@dimen/content_text_size_for_medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -70,7 +70,7 @@
<TextView
android:id="@+id/subtext"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
android:paddingBottom="8dp"
@@ -90,7 +90,7 @@
<TextView
android:id="@+id/text_content"
android:text="@string/empty_status"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/content_text_size_for_medium"
android:layout_width="match_parent"
@@ -114,9 +114,9 @@
android:layout_gravity="start|center_vertical"
android:gravity="start|center_vertical"
android:text="@string/empty_user_name"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/name_text_size_for_content"
android:textSize="@dimen/name_text_size_for_medium_content"
android:singleLine="true"
android:ellipsize="end"
android:paddingEnd="8dp"
@@ -129,10 +129,9 @@
<TextView
android:id="@+id/messages_count"
android:gravity="end"
android:layout_weight="1"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?androidprv:attr/textColorOnAccent"
android:background="@drawable/people_space_messages_count_background"
android:textSize="14sp"
@@ -144,7 +143,7 @@
/>
<ImageView
android:id="@+id/predefined_icon"
android:tint="?android:attr/textColorTertiary"
android:tint="?android:attr/textColorSecondary"
android:gravity="end|center_vertical"
android:layout_width="@dimen/regular_predefined_icon"
android:layout_height="@dimen/regular_predefined_icon" />

View File

@@ -40,7 +40,7 @@
<ImageView
android:id="@+id/predefined_icon"
android:tint="?android:attr/textColorTertiary"
android:tint="?android:attr/textColorSecondary"
android:layout_gravity="center"
android:layout_width="18dp"
android:layout_height="22dp" />
@@ -50,7 +50,7 @@
android:layout_gravity="center"
android:gravity="center"
android:paddingHorizontal="8dp"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?androidprv:attr/textColorOnAccent"
android:background="@drawable/people_space_messages_count_background"
android:textSize="@dimen/name_text_size_for_small"
@@ -69,7 +69,7 @@
android:ellipsize="end"
android:maxLines="1"
android:paddingHorizontal="4dp"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/name_text_size_for_small" />
</LinearLayout>

View File

@@ -1456,7 +1456,8 @@
<dimen name="max_people_avatar_size_for_large_content">64dp</dimen>
<dimen name="max_people_avatar_size">108dp</dimen>
<dimen name="name_text_size_for_small">14sp</dimen>
<dimen name="name_text_size_for_content">12sp</dimen>
<dimen name="name_text_size_for_medium_content">12sp</dimen>
<dimen name="name_text_size_for_large_content">14sp</dimen>
<dimen name="empty_name_text_size_for_medium">12sp</dimen>
<dimen name="max_name_text_size_for_medium">14sp</dimen>
<dimen name="medium_height_for_max_name_text_size">104dp</dimen>

View File

@@ -282,13 +282,18 @@ public class PeopleTileViewHelper {
}
private void setMaxLines(RemoteViews views, boolean showSender) {
int nameHeight = getLineHeightFromResource(R.dimen.name_text_size_for_content);
int textSizeResId;
int nameHeight;
if (mLayoutSize == LAYOUT_LARGE) {
textSizeResId = R.dimen.content_text_size_for_large;
nameHeight = getLineHeightFromResource(R.dimen.name_text_size_for_large_content);
} else {
textSizeResId = R.dimen.content_text_size_for_medium;
nameHeight = getLineHeightFromResource(R.dimen.name_text_size_for_medium_content);
}
boolean isStatusLayout =
views.getLayoutId() == R.layout.people_tile_large_with_status_content;
int contentHeight = getContentHeightForLayout(nameHeight, isStatusLayout);
int textSizeResId = mLayoutSize == LAYOUT_LARGE
? R.dimen.content_text_size_for_large
: R.dimen.content_text_size_for_medium;
int lineHeight = getLineHeightFromResource(textSizeResId);
int maxAdaptiveLines = Math.floorDiv(contentHeight, lineHeight);
int maxLines = Math.max(MIN_CONTENT_MAX_LINES, maxAdaptiveLines);
@@ -349,7 +354,7 @@ public class PeopleTileViewHelper {
int spaceAvailableForPadding =
mHeight - (getSizeInDp(R.dimen.avatar_size_for_medium)
+ 4 + getLineHeightFromResource(
R.dimen.name_text_size_for_content));
R.dimen.name_text_size_for_medium_content));
if (DEBUG) {
Log.d(TAG, "Medium view for mWidth: " + mWidth + " mHeight: " + mHeight
+ " with padding space: " + spaceAvailableForPadding);

View File

@@ -183,6 +183,7 @@ public class PeopleSpaceWidgetManager {
filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE);
filter.addAction(Intent.ACTION_USER_UNLOCKED);
mBroadcastDispatcher.registerReceiver(mBaseBroadcastReceiver, filter,
null /* executor */, UserHandle.ALL);
mRegisteredReceivers = true;
}
@@ -235,6 +236,10 @@ public class PeopleSpaceWidgetManager {
* Updates People Space widgets.
*/
public void updateWidgets(int[] widgetIds) {
mBgExecutor.execute(() -> updateWidgetsInBackground(widgetIds));
}
private void updateWidgetsInBackground(int[] widgetIds) {
try {
if (DEBUG) Log.d(TAG, "updateWidgets called");
if (widgetIds.length == 0) {
@@ -675,7 +680,7 @@ public class PeopleSpaceWidgetManager {
if (icon != null) {
updatedTile.setUserIcon(icon);
}
if (DEBUG) Log.d(TAG, "Statuses: " + conversation.getStatuses().toString());
if (DEBUG) Log.d(TAG, "Statuses: " + conversation.getStatuses());
NotificationChannel channel = conversation.getNotificationChannel();
if (channel != null) {
if (DEBUG) Log.d(TAG, "Important:" + channel.isImportantConversation());
@@ -1095,17 +1100,18 @@ public class PeopleSpaceWidgetManager {
NotificationManager.Policy.areAllVisualEffectsSuppressed(
policy.suppressedVisualEffects);
int notificationPolicyState = 0;
// If the user sees notifications in DND, we do not need to evaluate the current DND
// state, just always show notifications.
if (!suppressVisualEffects) {
if (DEBUG) Log.d(TAG, "Visual effects not suppressed.");
return PeopleSpaceTile.SHOW_CONVERSATIONS;
}
switch (mNotificationManager.getCurrentInterruptionFilter()) {
case INTERRUPTION_FILTER_ALL:
if (DEBUG) Log.d(TAG, "All interruptions allowed");
return PeopleSpaceTile.SHOW_CONVERSATIONS;
case INTERRUPTION_FILTER_PRIORITY:
if (policy.allowConversations()) {
// If the user sees notifications in DND, show notifications in tiles in DND.
if (!suppressVisualEffects) {
if (DEBUG) Log.d(TAG, "Visual effects not suppressed.");
return PeopleSpaceTile.SHOW_CONVERSATIONS;
}
if (policy.priorityConversationSenders == CONVERSATION_SENDERS_ANYONE) {
if (DEBUG) Log.d(TAG, "All conversations allowed");
// We only show conversations, so we can show everything.
@@ -1140,11 +1146,6 @@ public class PeopleSpaceWidgetManager {
case INTERRUPTION_FILTER_NONE:
case INTERRUPTION_FILTER_ALARMS:
default:
// If the user sees notifications in DND, show notifications in tiles in DND.
if (!suppressVisualEffects) {
if (DEBUG) Log.d(TAG, "Visual effects not suppressed.");
return PeopleSpaceTile.SHOW_CONVERSATIONS;
}
if (DEBUG) Log.d(TAG, "Block conversations");
return PeopleSpaceTile.BLOCK_CONVERSATIONS;
}

View File

@@ -991,8 +991,9 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
addSecondWidgetForPersonTile();
mManager.updateWidgets(new int[]{WIDGET_ID_WITH_SHORTCUT, SECOND_WIDGET_ID_WITH_SHORTCUT});
// Delete only one widget for the conversation.
// Delete only one widget for the conversation in background.
mManager.deleteWidgets(new int[]{WIDGET_ID_WITH_SHORTCUT});
mClock.advanceTime(MIN_LINGER_DURATION);
// Check deleted storage.
SharedPreferences widgetSp = mContext.getSharedPreferences(
@@ -1010,8 +1011,9 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
eq(Arrays.asList(SHORTCUT_ID)), eq(UserHandle.of(0)),
eq(LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS));
// Delete all widgets for the conversation.
// Delete all widgets for the conversation in background.
mManager.deleteWidgets(new int[]{SECOND_WIDGET_ID_WITH_SHORTCUT});
mClock.advanceTime(MIN_LINGER_DURATION);
// Check deleted storage.
SharedPreferences secondWidgetSp = mContext.getSharedPreferences(
@@ -1341,6 +1343,13 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
PeopleSpaceTile tile = mManager.mTiles.get(WIDGET_ID_WITH_SHORTCUT);
assertThat(tile.getNotificationPolicyState()).isEqualTo(expected | SHOW_STARRED_CONTACTS);
setFinalField("suppressedVisualEffects", SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
| SUPPRESSED_EFFECT_AMBIENT);
mManager.updateWidgetsOnStateChange(ACTION_BOOT_COMPLETED);
tile = mManager.mTiles.get(WIDGET_ID_WITH_SHORTCUT);
assertThat(tile.getNotificationPolicyState()).isEqualTo(expected | SHOW_CONVERSATIONS);
}
@Test