Use view layouts rather than compositing an image
Which works better for apps with adaptive icons Test: manual, and atest SystemUITests Fixes: 177332447 Change-Id: Ib4948336fa174694e7c23098a0cfd92c4de62e32
This commit is contained in:
@@ -36,13 +36,62 @@
|
||||
android:clipChildren="false"
|
||||
android:paddingTop="@dimen/notification_guts_header_top_padding"
|
||||
android:clipToPadding="true">
|
||||
<ImageView
|
||||
android:id="@+id/conversation_icon"
|
||||
android:layout_width="@dimen/notification_guts_conversation_icon_size"
|
||||
android:layout_height="@dimen/notification_guts_conversation_icon_size"
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:layout_centerVertical="false"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginEnd="12dp" />
|
||||
android:layout_marginEnd="12dp"
|
||||
>
|
||||
|
||||
<!-- Big icon: 52x52, 12dp padding left + top, 16dp padding right -->
|
||||
<ImageView
|
||||
android:id="@+id/conversation_icon"
|
||||
android:layout_width="@*android:dimen/conversation_avatar_size"
|
||||
android:layout_height="@*android:dimen/conversation_avatar_size"
|
||||
android:scaleType="centerCrop"
|
||||
android:importantForAccessibility="no"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/conversation_icon_badge"
|
||||
android:layout_width="@*android:dimen/conversation_icon_size_badged"
|
||||
android:layout_height="@*android:dimen/conversation_icon_size_badged"
|
||||
android:layout_marginLeft="@*android:dimen/conversation_badge_side_margin"
|
||||
android:layout_marginTop="@*android:dimen/conversation_badge_side_margin"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/conversation_icon_badge_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:src="@*android:drawable/conversation_badge_background"
|
||||
android:forceHasOverlappingRendering="false"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/conversation_icon_badge_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="4dp"
|
||||
android:layout_gravity="center"
|
||||
android:forceHasOverlappingRendering="false"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/conversation_icon_badge_ring"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@*android:drawable/conversation_badge_ring"
|
||||
android:forceHasOverlappingRendering="false"
|
||||
android:clipToPadding="false"
|
||||
android:scaleType="center"
|
||||
/>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/names"
|
||||
android:layout_weight="1"
|
||||
|
||||
@@ -243,7 +243,7 @@
|
||||
<dimen name="notification_guts_conversation_action_text_padding_start">32dp</dimen>
|
||||
<dimen name="conversation_onboarding_bullet_gap_width">6dp</dimen>
|
||||
|
||||
<dimen name="notification_guts_header_top_padding">11dp</dimen>
|
||||
<dimen name="notification_guts_header_top_padding">12dp</dimen>
|
||||
|
||||
<!-- The height of the header in inline settings -->
|
||||
<dimen name="notification_guts_header_height">24dp</dimen>
|
||||
|
||||
@@ -346,9 +346,22 @@ public class NotificationConversationInfo extends LinearLayout implements
|
||||
}
|
||||
|
||||
private void bindIcon(boolean important) {
|
||||
Drawable person = mIconFactory.getBaseIconDrawable(mShortcutInfo);
|
||||
if (person == null) {
|
||||
person = mContext.getDrawable(R.drawable.ic_person).mutate();
|
||||
TypedArray ta = mContext.obtainStyledAttributes(new int[]{android.R.attr.colorAccent});
|
||||
int colorAccent = ta.getColor(0, 0);
|
||||
ta.recycle();
|
||||
person.setTint(colorAccent);
|
||||
}
|
||||
ImageView image = findViewById(R.id.conversation_icon);
|
||||
image.setImageDrawable(mIconFactory.getConversationDrawable(
|
||||
mShortcutInfo, mPackageName, mAppUid, important));
|
||||
image.setImageDrawable(person);
|
||||
|
||||
ImageView app = findViewById(R.id.conversation_icon_badge_icon);
|
||||
app.setImageDrawable(mIconFactory.getAppBadge(
|
||||
mPackageName, UserHandle.getUserId(mSbn.getUid())));
|
||||
|
||||
findViewById(R.id.conversation_icon_badge_ring).setVisibility(important ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
private void bindPackage() {
|
||||
|
||||
@@ -199,8 +199,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
|
||||
when(mShortcutInfo.getLabel()).thenReturn("Convo name");
|
||||
List<ShortcutInfo> shortcuts = Arrays.asList(mShortcutInfo);
|
||||
when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcuts);
|
||||
when(mIconFactory.getConversationDrawable(
|
||||
any(ShortcutInfo.class), anyString(), anyInt(), anyBoolean()))
|
||||
when(mIconFactory.getBaseIconDrawable(any(ShortcutInfo.class)))
|
||||
.thenReturn(mIconDrawable);
|
||||
|
||||
mNotificationChannel = new NotificationChannel(
|
||||
|
||||
Reference in New Issue
Block a user