Merge "Code cleanup and visual polish for hybrid views" into tm-qpr-dev am: 12f23952ed
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18922156 Change-Id: Ice21a81cba9a0156b9d1e7a33feb8bc1cf6c2b49 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -57,7 +57,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
style="?attr/hybridNotificationTextStyle"
|
android:paddingEnd="4dp"
|
||||||
|
style="@*android:style/Widget.DeviceDefault.Notification.Text"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -65,6 +66,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
style="?attr/hybridNotificationTextStyle"
|
android:paddingEnd="4dp"
|
||||||
|
style="@*android:style/Widget.DeviceDefault.Notification.Text"
|
||||||
/>
|
/>
|
||||||
</com.android.systemui.statusbar.notification.row.HybridConversationNotificationView>
|
</com.android.systemui.statusbar.notification.row.HybridConversationNotificationView>
|
||||||
|
|||||||
@@ -20,19 +20,22 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="bottom|start"
|
android:gravity="bottom|start"
|
||||||
style="?attr/hybridNotificationStyle">
|
android:paddingStart="@*android:dimen/notification_content_margin_start"
|
||||||
|
android:paddingEnd="12dp">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/notification_title"
|
android:id="@+id/notification_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
style="?attr/hybridNotificationTitleStyle"
|
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
/>
|
/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/notification_text"
|
android:id="@+id/notification_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
style="?attr/hybridNotificationTextStyle"
|
android:paddingEnd="4dp"
|
||||||
|
style="@*android:style/Widget.DeviceDefault.Notification.Text"
|
||||||
/>
|
/>
|
||||||
</com.android.systemui.statusbar.notification.row.HybridNotificationView>
|
</com.android.systemui.statusbar.notification.row.HybridNotificationView>
|
||||||
@@ -108,12 +108,6 @@
|
|||||||
<attr name="android:layout" />
|
<attr name="android:layout" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="HybridNotificationTheme">
|
|
||||||
<attr name="hybridNotificationStyle" format="reference" />
|
|
||||||
<attr name="hybridNotificationTitleStyle" format="reference" />
|
|
||||||
<attr name="hybridNotificationTextStyle" format="reference" />
|
|
||||||
</declare-styleable>
|
|
||||||
|
|
||||||
<declare-styleable name="PluginInflateContainer">
|
<declare-styleable name="PluginInflateContainer">
|
||||||
<attr name="viewType" format="string" />
|
<attr name="viewType" format="string" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|||||||
@@ -17,30 +17,6 @@
|
|||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
|
|
||||||
<!-- HybridNotification themes and styles -->
|
|
||||||
|
|
||||||
<style name="HybridNotification">
|
|
||||||
<item name="hybridNotificationStyle">@style/hybrid_notification</item>
|
|
||||||
<item name="hybridNotificationTitleStyle">@style/hybrid_notification_title</item>
|
|
||||||
<item name="hybridNotificationTextStyle">@style/hybrid_notification_text</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="hybrid_notification">
|
|
||||||
<item name="android:paddingStart">@*android:dimen/notification_content_margin_start</item>
|
|
||||||
<item name="android:paddingEnd">12dp</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="hybrid_notification_title">
|
|
||||||
<item name="android:paddingEnd">4dp</item>
|
|
||||||
<item name="android:textAppearance">@*android:style/TextAppearance.DeviceDefault.Notification.Title</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="hybrid_notification_text"
|
|
||||||
parent="@*android:style/Widget.DeviceDefault.Notification.Text">
|
|
||||||
<item name="android:paddingEnd">4dp</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
<style name="TextAppearance.StatusBar.Clock" parent="@*android:style/TextAppearance.StatusBar.Icon">
|
<style name="TextAppearance.StatusBar.Clock" parent="@*android:style/TextAppearance.StatusBar.Icon">
|
||||||
<item name="android:textSize">@dimen/status_bar_clock_size</item>
|
<item name="android:textSize">@dimen/status_bar_clock_size</item>
|
||||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
|
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class HybridConversationNotificationView extends HybridNotificationView {
|
|||||||
mConversationIconView = requireViewById(com.android.internal.R.id.conversation_icon);
|
mConversationIconView = requireViewById(com.android.internal.R.id.conversation_icon);
|
||||||
mConversationFacePile = requireViewById(com.android.internal.R.id.conversation_face_pile);
|
mConversationFacePile = requireViewById(com.android.internal.R.id.conversation_face_pile);
|
||||||
mConversationSenderName = requireViewById(R.id.conversation_notification_sender);
|
mConversationSenderName = requireViewById(R.id.conversation_notification_sender);
|
||||||
|
applyTextColor(mConversationSenderName, mSecondaryTextColor);
|
||||||
mFacePileSize = getResources()
|
mFacePileSize = getResources()
|
||||||
.getDimensionPixelSize(R.dimen.conversation_single_line_face_pile_size);
|
.getDimensionPixelSize(R.dimen.conversation_single_line_face_pile_size);
|
||||||
mFacePileAvatarSize = getResources()
|
mFacePileAvatarSize = getResources()
|
||||||
@@ -75,6 +76,9 @@ public class HybridConversationNotificationView extends HybridNotificationView {
|
|||||||
.getDimensionPixelSize(R.dimen.conversation_single_line_avatar_size);
|
.getDimensionPixelSize(R.dimen.conversation_single_line_avatar_size);
|
||||||
mFacePileProtectionWidth = getResources().getDimensionPixelSize(
|
mFacePileProtectionWidth = getResources().getDimensionPixelSize(
|
||||||
R.dimen.conversation_single_line_face_pile_protection_width);
|
R.dimen.conversation_single_line_face_pile_protection_width);
|
||||||
|
mTransformationHelper.setCustomTransformation(
|
||||||
|
new FadeOutAndDownWithTitleTransformation(mConversationSenderName),
|
||||||
|
mConversationSenderName.getId());
|
||||||
mTransformationHelper.addViewTransformingToSimilar(mConversationIconView);
|
mTransformationHelper.addViewTransformingToSimilar(mConversationIconView);
|
||||||
mTransformationHelper.addTransformedView(mConversationSenderName);
|
mTransformationHelper.addTransformedView(mConversationSenderName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.content.Context;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.ContextThemeWrapper;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -57,10 +56,8 @@ public class HybridGroupManager {
|
|||||||
mOverflowNumberPadding = res.getDimensionPixelSize(R.dimen.group_overflow_number_padding);
|
mOverflowNumberPadding = res.getDimensionPixelSize(R.dimen.group_overflow_number_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HybridNotificationView inflateHybridViewWithStyle(int style,
|
private HybridNotificationView inflateHybridView(View contentView, ViewGroup parent) {
|
||||||
View contentView, ViewGroup parent) {
|
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||||
LayoutInflater inflater = new ContextThemeWrapper(mContext, style)
|
|
||||||
.getSystemService(LayoutInflater.class);
|
|
||||||
int layout = contentView instanceof ConversationLayout
|
int layout = contentView instanceof ConversationLayout
|
||||||
? R.layout.hybrid_conversation_notification
|
? R.layout.hybrid_conversation_notification
|
||||||
: R.layout.hybrid_notification;
|
: R.layout.hybrid_notification;
|
||||||
@@ -93,16 +90,8 @@ public class HybridGroupManager {
|
|||||||
public HybridNotificationView bindFromNotification(HybridNotificationView reusableView,
|
public HybridNotificationView bindFromNotification(HybridNotificationView reusableView,
|
||||||
View contentView, StatusBarNotification notification,
|
View contentView, StatusBarNotification notification,
|
||||||
ViewGroup parent) {
|
ViewGroup parent) {
|
||||||
return bindFromNotificationWithStyle(reusableView, contentView, notification,
|
|
||||||
R.style.HybridNotification, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HybridNotificationView bindFromNotificationWithStyle(
|
|
||||||
HybridNotificationView reusableView, View contentView,
|
|
||||||
StatusBarNotification notification,
|
|
||||||
int style, ViewGroup parent) {
|
|
||||||
if (reusableView == null) {
|
if (reusableView == null) {
|
||||||
reusableView = inflateHybridViewWithStyle(style, contentView, parent);
|
reusableView = inflateHybridView(contentView, parent);
|
||||||
}
|
}
|
||||||
CharSequence titleText = resolveTitle(notification.getNotification());
|
CharSequence titleText = resolveTitle(notification.getNotification());
|
||||||
CharSequence contentText = resolveText(notification.getNotification());
|
CharSequence contentText = resolveText(notification.getNotification());
|
||||||
|
|||||||
@@ -16,13 +16,18 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification.row;
|
package com.android.systemui.statusbar.notification.row;
|
||||||
|
|
||||||
|
import static android.app.Notification.COLOR_INVALID;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
|
|
||||||
import com.android.keyguard.AlphaOptimizedLinearLayout;
|
import com.android.keyguard.AlphaOptimizedLinearLayout;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.statusbar.CrossFadeHelper;
|
import com.android.systemui.statusbar.CrossFadeHelper;
|
||||||
@@ -40,6 +45,8 @@ public class HybridNotificationView extends AlphaOptimizedLinearLayout
|
|||||||
protected final ViewTransformationHelper mTransformationHelper = new ViewTransformationHelper();
|
protected final ViewTransformationHelper mTransformationHelper = new ViewTransformationHelper();
|
||||||
protected TextView mTitleView;
|
protected TextView mTitleView;
|
||||||
protected TextView mTextView;
|
protected TextView mTextView;
|
||||||
|
protected int mPrimaryTextColor = COLOR_INVALID;
|
||||||
|
protected int mSecondaryTextColor = COLOR_INVALID;
|
||||||
|
|
||||||
public HybridNotificationView(Context context) {
|
public HybridNotificationView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -69,42 +76,37 @@ public class HybridNotificationView extends AlphaOptimizedLinearLayout
|
|||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
resolveThemeTextColors();
|
||||||
mTitleView = findViewById(R.id.notification_title);
|
mTitleView = findViewById(R.id.notification_title);
|
||||||
mTextView = findViewById(R.id.notification_text);
|
mTextView = findViewById(R.id.notification_text);
|
||||||
|
applyTextColor(mTitleView, mPrimaryTextColor);
|
||||||
|
applyTextColor(mTextView, mSecondaryTextColor);
|
||||||
mTransformationHelper.setCustomTransformation(
|
mTransformationHelper.setCustomTransformation(
|
||||||
new ViewTransformationHelper.CustomTransformation() {
|
new FadeOutAndDownWithTitleTransformation(mTextView),
|
||||||
@Override
|
TRANSFORMING_VIEW_TEXT);
|
||||||
public boolean transformTo(TransformState ownState, TransformableView notification,
|
|
||||||
float transformationAmount) {
|
|
||||||
// We want to transform to the same y location as the title
|
|
||||||
TransformState otherState = notification.getCurrentState(
|
|
||||||
TRANSFORMING_VIEW_TITLE);
|
|
||||||
CrossFadeHelper.fadeOut(mTextView, transformationAmount);
|
|
||||||
if (otherState != null) {
|
|
||||||
ownState.transformViewVerticalTo(otherState, transformationAmount);
|
|
||||||
otherState.recycle();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean transformFrom(TransformState ownState,
|
|
||||||
TransformableView notification, float transformationAmount) {
|
|
||||||
// We want to transform from the same y location as the title
|
|
||||||
TransformState otherState = notification.getCurrentState(
|
|
||||||
TRANSFORMING_VIEW_TITLE);
|
|
||||||
CrossFadeHelper.fadeIn(mTextView, transformationAmount, true /* remap */);
|
|
||||||
if (otherState != null) {
|
|
||||||
ownState.transformViewVerticalFrom(otherState, transformationAmount);
|
|
||||||
otherState.recycle();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}, TRANSFORMING_VIEW_TEXT);
|
|
||||||
mTransformationHelper.addTransformedView(TRANSFORMING_VIEW_TITLE, mTitleView);
|
mTransformationHelper.addTransformedView(TRANSFORMING_VIEW_TITLE, mTitleView);
|
||||||
mTransformationHelper.addTransformedView(TRANSFORMING_VIEW_TEXT, mTextView);
|
mTransformationHelper.addTransformedView(TRANSFORMING_VIEW_TEXT, mTextView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void applyTextColor(TextView textView, @ColorInt int textColor) {
|
||||||
|
if (textColor != COLOR_INVALID) {
|
||||||
|
textView.setTextColor(textColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resolveThemeTextColors() {
|
||||||
|
try (TypedArray ta = mContext.getTheme().obtainStyledAttributes(
|
||||||
|
android.R.style.Theme_DeviceDefault_DayNight, new int[]{
|
||||||
|
android.R.attr.textColorPrimary,
|
||||||
|
android.R.attr.textColorSecondary
|
||||||
|
})) {
|
||||||
|
if (ta != null) {
|
||||||
|
mPrimaryTextColor = ta.getColor(0, mPrimaryTextColor);
|
||||||
|
mSecondaryTextColor = ta.getColor(1, mSecondaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void bind(@Nullable CharSequence title, @Nullable CharSequence text,
|
public void bind(@Nullable CharSequence title, @Nullable CharSequence text,
|
||||||
@Nullable View contentView) {
|
@Nullable View contentView) {
|
||||||
mTitleView.setText(title);
|
mTitleView.setText(title);
|
||||||
@@ -152,4 +154,40 @@ public class HybridNotificationView extends AlphaOptimizedLinearLayout
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNotificationFaded(boolean faded) {}
|
public void setNotificationFaded(boolean faded) {}
|
||||||
|
|
||||||
|
protected static class FadeOutAndDownWithTitleTransformation extends
|
||||||
|
ViewTransformationHelper.CustomTransformation {
|
||||||
|
|
||||||
|
private final View mView;
|
||||||
|
|
||||||
|
public FadeOutAndDownWithTitleTransformation(View view) {
|
||||||
|
mView = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformTo(TransformState ownState, TransformableView notification,
|
||||||
|
float transformationAmount) {
|
||||||
|
// We want to transform to the same y location as the title
|
||||||
|
TransformState otherState = notification.getCurrentState(TRANSFORMING_VIEW_TITLE);
|
||||||
|
CrossFadeHelper.fadeOut(mView, transformationAmount);
|
||||||
|
if (otherState != null) {
|
||||||
|
ownState.transformViewVerticalTo(otherState, transformationAmount);
|
||||||
|
otherState.recycle();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformFrom(TransformState ownState,
|
||||||
|
TransformableView notification, float transformationAmount) {
|
||||||
|
// We want to transform from the same y location as the title
|
||||||
|
TransformState otherState = notification.getCurrentState(TRANSFORMING_VIEW_TITLE);
|
||||||
|
CrossFadeHelper.fadeIn(mView, transformationAmount, true /* remap */);
|
||||||
|
if (otherState != null) {
|
||||||
|
ownState.transformViewVerticalFrom(otherState, transformationAmount);
|
||||||
|
otherState.recycle();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user