Update notification popup UI.

- Update UI to match specs.
- Only shows one notification (removed footer, animation code)

Bug: 175329686
Bug: 190402054
Test: open popup, dismiss notification from shade,
      open popup, click on notification
      checked RTL

Change-Id: I92672f94233d986ae5b5c54979980967308cb156
This commit is contained in:
Jon Miranda
2021-06-17 12:35:43 -07:00
committed by Jonathan Miranda
parent b8ad5cb643
commit 313b2c2d28
11 changed files with 96 additions and 485 deletions
@@ -16,19 +16,15 @@
package com.android.launcher3.notification;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NOTIFICATION_DISMISSED;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -40,19 +36,15 @@ import android.widget.TextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.touch.BaseSwipeDetector;
import com.android.launcher3.touch.OverScroll;
import com.android.launcher3.touch.SingleAxisSwipeDetector;
import com.android.launcher3.util.Themes;
/**
* A {@link android.widget.FrameLayout} that contains a single notification,
* e.g. icon + title + text.
*/
@TargetApi(Build.VERSION_CODES.N)
public class NotificationMainView extends FrameLayout implements SingleAxisSwipeDetector.Listener {
public class NotificationMainView extends FrameLayout {
private static final FloatProperty<NotificationMainView> CONTENT_TRANSLATION =
new FloatProperty<NotificationMainView>("contentTranslation") {
@@ -70,8 +62,6 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
// This is used only to track the notification view, so that it can be properly logged.
public static final ItemInfo NOTIFICATION_ITEM_INFO = new ItemInfo();
private final ObjectAnimator mContentTranslateAnimator;
private NotificationInfo mNotificationInfo;
private ViewGroup mTextAndBackground;
private int mBackgroundColor;
@@ -82,7 +72,6 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
private SingleAxisSwipeDetector mSwipeDetector;
private final ColorDrawable mColorDrawable;
private final RippleDrawable mRippleDrawable;
public NotificationMainView(Context context) {
this(context, null, 0);
@@ -95,11 +84,7 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
public NotificationMainView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContentTranslateAnimator = ObjectAnimator.ofFloat(this, CONTENT_TRANSLATION, 0);
mColorDrawable = new ColorDrawable(Color.TRANSPARENT);
mRippleDrawable = new RippleDrawable(ColorStateList.valueOf(
Themes.getAttrColor(getContext(), android.R.attr.colorControlHighlight)),
mColorDrawable, null);
}
@Override
@@ -118,7 +103,7 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
private void updateBackgroundColor(int color) {
mBackgroundColor = color;
mColorDrawable.setColor(color);
mTextAndBackground.setBackground(mRippleDrawable);
mTextAndBackground.setBackground(mColorDrawable);
if (mNotificationInfo != null) {
mIconView.setBackground(mNotificationInfo.getIconForBackground(getContext(),
mBackgroundColor));
@@ -140,10 +125,6 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
animatorSetOut.play(colors);
}
public void setSwipeDetector(SingleAxisSwipeDetector swipeDetector) {
mSwipeDetector = swipeDetector;
}
/**
* Sets the content of this view, animating it after a new icon shifts up if necessary.
*/
@@ -182,11 +163,6 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
mIconView.setTranslationX(translation);
}
public void setContentVisibility(int visibility) {
mTextAndBackground.setVisibility(visibility);
mIconView.setVisibility(visibility);
}
public NotificationInfo getNotificationInfo() {
return mNotificationInfo;
}
@@ -202,56 +178,4 @@ public class NotificationMainView extends FrameLayout implements SingleAxisSwipe
mNotificationInfo.notificationKey);
launcher.getStatsLogManager().logger().log(LAUNCHER_NOTIFICATION_DISMISSED);
}
// SingleAxisSwipeDetector.Listener's
@Override
public void onDragStart(boolean start, float startDisplacement) { }
@Override
public boolean onDrag(float displacement) {
setContentTranslation(canChildBeDismissed()
? displacement : OverScroll.dampedScroll(displacement, getWidth()));
mContentTranslateAnimator.cancel();
return true;
}
@Override
public void onDragEnd(float velocity) {
final boolean willExit;
final float endTranslation;
final float startTranslation = mTextAndBackground.getTranslationX();
if (!canChildBeDismissed()) {
willExit = false;
endTranslation = 0;
} else if (mSwipeDetector.isFling(velocity)) {
willExit = true;
endTranslation = velocity < 0 ? - getWidth() : getWidth();
} else if (Math.abs(startTranslation) > getWidth() / 2) {
willExit = true;
endTranslation = (startTranslation < 0 ? -getWidth() : getWidth());
} else {
willExit = false;
endTranslation = 0;
}
long duration = BaseSwipeDetector.calculateDuration(velocity,
(endTranslation - startTranslation) / getWidth());
mContentTranslateAnimator.removeAllListeners();
mContentTranslateAnimator.setDuration(duration)
.setInterpolator(scrollInterpolatorForVelocity(velocity));
mContentTranslateAnimator.setFloatValues(startTranslation, endTranslation);
mContentTranslateAnimator.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mSwipeDetector.finishedScrolling();
if (willExit) {
onChildDismissed();
}
}
});
mContentTranslateAnimator.start();
}
}