Assistive chip: Adjusting chip UI
Change-Id: I2970107f4324a5f01e0df4a6adf21875412582c6
diff --git a/quickstep/recents_ui_overrides/res/values/dimens.xml b/quickstep/recents_ui_overrides/res/values/dimens.xml
index 363840a..9266b06 100644
--- a/quickstep/recents_ui_overrides/res/values/dimens.xml
+++ b/quickstep/recents_ui_overrides/res/values/dimens.xml
@@ -20,6 +20,7 @@
<dimen name="chip_hint_start_padding">10dp</dimen>
<dimen name="chip_hint_end_padding">12dp</dimen>
<dimen name="chip_hint_horizontal_margin">20dp</dimen>
+ <dimen name="chip_hint_vertical_offset">16dp</dimen>
<dimen name="chip_hint_elevation">2dp</dimen>
<dimen name="chip_icon_size">16dp</dimen>
<dimen name="chip_text_height">26dp</dimen>
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
index 470b720..b92a7b1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
@@ -175,11 +175,12 @@
// Order in which the footers appear. Lower order appear below higher order.
public static final int INDEX_DIGITAL_WELLBEING_TOAST = 0;
- public static final int INDEX_PROACTIVE_SUGGEST = 1;
private final FooterWrapper[] mFooters = new FooterWrapper[2];
private float mFooterVerticalOffset = 0;
private float mFooterAlpha = 1;
private int mStackHeight;
+ private View mContextualChipWrapper;
+ private View mContextualChip;
public TaskView(Context context) {
this(context, null);
@@ -262,8 +263,14 @@
footer.animateHide();
}
}
+ if (mContextualChip != null) {
+ mContextualChip.animate().scaleX(0f).scaleY(0f).setDuration(300);
+ }
mIconView.animate().alpha(0.0f);
} else {
+ if (mContextualChip != null) {
+ mContextualChip.animate().scaleX(1f).scaleY(1f).setDuration(300);
+ }
mIconView.animate().alpha(1.0f);
}
@@ -667,6 +674,51 @@
return oldFooter;
}
+ /**
+ * Sets the contextual chip.
+ *
+ * @param view Wrapper view containing contextual chip.
+ */
+ public void setContextualChip(View view) {
+ if (mContextualChipWrapper != null) {
+ removeView(mContextualChipWrapper);
+ }
+ if (view != null) {
+ mContextualChipWrapper = view;
+ LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.WRAP_CONTENT);
+ layoutParams.gravity = BOTTOM | CENTER_HORIZONTAL;
+ layoutParams.bottomMargin = (int)
+ (((MarginLayoutParams) mSnapshotView.getLayoutParams()).bottomMargin
+ - getExpectedViewHeight(view) + getResources().getDimension(
+ R.dimen.chip_hint_vertical_offset));
+ mContextualChip = ((FrameLayout) mContextualChipWrapper).getChildAt(0);
+ mContextualChip.setScaleX(0f);
+ mContextualChip.setScaleY(0f);
+ addView(view, getChildCount(), layoutParams);
+ view.setAlpha(mFooterAlpha);
+ if (mContextualChip != null) {
+ mContextualChip.animate().scaleX(1f).scaleY(1f).setDuration(50);
+ }
+ }
+
+ }
+
+ /**
+ * Clears the contextual chip from TaskView.
+ *
+ * @return The contextual chip wrapper view to be recycled.
+ */
+ public View clearContextualChip() {
+ if (mContextualChipWrapper != null) {
+ removeView(mContextualChipWrapper);
+ }
+ View oldContextualChipWrapper = mContextualChipWrapper;
+ mContextualChipWrapper = null;
+ mContextualChip = null;
+ return oldContextualChipWrapper;
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@@ -767,14 +819,7 @@
mDelegate = mOldOutlineProvider == null
? ViewOutlineProvider.BACKGROUND : mOldOutlineProvider;
- int h = view.getLayoutParams().height;
- if (h > 0) {
- mExpectedHeight = h;
- } else {
- int m = MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY - 1, MeasureSpec.AT_MOST);
- view.measure(m, m);
- mExpectedHeight = view.getMeasuredHeight();
- }
+ mExpectedHeight = getExpectedViewHeight(view);
mOldPaddingBottom = view.getPaddingBottom();
if (mOldOutlineProvider != null) {
@@ -836,6 +881,19 @@
}
}
+ private int getExpectedViewHeight(View view) {
+ int expectedHeight;
+ int h = view.getLayoutParams().height;
+ if (h > 0) {
+ expectedHeight = h;
+ } else {
+ int m = MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY - 1, MeasureSpec.AT_MOST);
+ view.measure(m, m);
+ expectedHeight = view.getMeasuredHeight();
+ }
+ return expectedHeight;
+ }
+
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);