Merge "Fix inline controls from being swipeable" into nyc-dev
am: c2b4957625
* commit 'c2b495762515c6976014ef7bb05dd06a51316f3c':
Fix inline controls from being swipeable
This commit is contained in:
@@ -144,7 +144,9 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
protected Animator getViewTranslationAnimator(View v, float target,
|
||||
AnimatorUpdateListener listener) {
|
||||
ObjectAnimator anim = createTranslationAnimation(v, target);
|
||||
anim.addUpdateListener(listener);
|
||||
if (listener != null) {
|
||||
anim.addUpdateListener(listener);
|
||||
}
|
||||
return anim;
|
||||
}
|
||||
|
||||
@@ -370,6 +372,9 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
};
|
||||
|
||||
Animator anim = getViewTranslationAnimator(animView, newPos, updateListener);
|
||||
if (anim == null) {
|
||||
return;
|
||||
}
|
||||
if (useAccelerateInterpolator) {
|
||||
anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
|
||||
} else {
|
||||
@@ -411,6 +416,9 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
};
|
||||
|
||||
Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
|
||||
if (anim == null) {
|
||||
return;
|
||||
}
|
||||
int duration = SNAP_ANIM_LEN;
|
||||
anim.setDuration(duration);
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
|
||||
@@ -684,7 +684,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
mTranslateableViews.remove(mGutsStub);
|
||||
}
|
||||
|
||||
public void setTranslationForOutline(float translationX) {
|
||||
private void setTranslationForOutline(float translationX) {
|
||||
setOutlineRect(false, translationX, getTop(), getRight() + translationX, getBottom());
|
||||
}
|
||||
|
||||
@@ -704,6 +704,46 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
if (mTranslateAnim != null) {
|
||||
mTranslateAnim.cancel();
|
||||
}
|
||||
mTranslateAnim = (AnimatorSet) getTranslateViewAnimator(leftTarget,
|
||||
null /* updateListener */);
|
||||
if (mTranslateAnim != null) {
|
||||
mTranslateAnim.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTranslation(float translationX) {
|
||||
if (areGutsExposed()) {
|
||||
// Don't translate if guts are showing.
|
||||
return;
|
||||
}
|
||||
// Translate the group of views
|
||||
for (int i = 0; i < mTranslateableViews.size(); i++) {
|
||||
if (mTranslateableViews.get(i) != null) {
|
||||
mTranslateableViews.get(i).setTranslationX(translationX);
|
||||
}
|
||||
}
|
||||
setTranslationForOutline(translationX);
|
||||
if (mSettingsIconRow != null) {
|
||||
mSettingsIconRow.updateSettingsIcons(translationX, getMeasuredWidth());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTranslation() {
|
||||
if (mTranslateableViews != null && mTranslateableViews.size() > 0) {
|
||||
// All of the views in the list should have same translation, just use first one.
|
||||
return mTranslateableViews.get(0).getTranslationX();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Animator getTranslateViewAnimator(final float leftTarget,
|
||||
AnimatorUpdateListener listener) {
|
||||
if (areGutsExposed()) {
|
||||
// No translation if guts are exposed.
|
||||
return null;
|
||||
}
|
||||
AnimatorSet set = new AnimatorSet();
|
||||
if (mTranslateableViews != null) {
|
||||
for (int i = 0; i < mTranslateableViews.size(); i++) {
|
||||
@@ -715,8 +755,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
setTranslationForOutline((float) animation.getAnimatedValue());
|
||||
if (mSettingsIconRow != null) {
|
||||
mSettingsIconRow.updateSettingsIcons(
|
||||
(float) animation.getAnimatedValue(), getMeasuredWidth());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (listener != null) {
|
||||
translateAnim.addUpdateListener(listener);
|
||||
}
|
||||
}
|
||||
translateAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -730,8 +777,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
set.play(translateAnim);
|
||||
}
|
||||
}
|
||||
mTranslateAnim = set;
|
||||
set.start();
|
||||
return set;
|
||||
}
|
||||
|
||||
public float getSpaceForGear() {
|
||||
@@ -748,10 +794,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
return mSettingsIconRow;
|
||||
}
|
||||
|
||||
public ArrayList<View> getContentViews() {
|
||||
return mTranslateableViews;
|
||||
}
|
||||
|
||||
public void inflateGuts() {
|
||||
if (mGuts == null) {
|
||||
mGutsStub.inflate();
|
||||
@@ -1169,6 +1211,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
return mMaxExpandHeight;
|
||||
}
|
||||
|
||||
public boolean areGutsExposed() {
|
||||
return (mGuts != null && mGuts.areGutsExposed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContentExpandable() {
|
||||
NotificationContentView showingLayout = getShowingLayout();
|
||||
|
||||
@@ -283,6 +283,20 @@ public abstract class ExpandableView extends FrameLayout {
|
||||
public void setBelowSpeedBump(boolean below) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the translation of the view.
|
||||
*/
|
||||
public void setTranslation(float translation) {
|
||||
setTranslationX(translation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the translation of the view.
|
||||
*/
|
||||
public float getTranslation() {
|
||||
return getTranslationX();
|
||||
}
|
||||
|
||||
public void onHeightReset() {
|
||||
if (mOnHeightChangedListener != null) {
|
||||
mOnHeightChangedListener.onReset(this);
|
||||
|
||||
@@ -714,6 +714,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
|
||||
if (targetLeft == 0 && mCurrIconRow != null) {
|
||||
mCurrIconRow.resetState();
|
||||
mCurrIconRow = null;
|
||||
if (mGearExposedView != null && mGearExposedView == mTranslatingParentView) {
|
||||
mGearExposedView = null;
|
||||
}
|
||||
@@ -3367,7 +3368,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
|
||||
private static final long GEAR_SHOW_DELAY = 60;
|
||||
|
||||
private ArrayList<View> mTranslatingViews = new ArrayList<>();
|
||||
private CheckForDrag mCheckForDrag;
|
||||
private Handler mHandler;
|
||||
private int mMoveState = MOVE_STATE_UNDEFINED;
|
||||
@@ -3384,6 +3384,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
|
||||
// Reset check for drag gesture
|
||||
mCheckForDrag = null;
|
||||
mCurrIconRow = null;
|
||||
|
||||
// Slide back any notifications that might be showing a gear
|
||||
resetExposedGearView();
|
||||
@@ -3392,9 +3393,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
// Set the listener for the current row's gear
|
||||
mCurrIconRow = ((ExpandableNotificationRow) currView).getSettingsRow();
|
||||
mCurrIconRow.setGearListener(NotificationStackScrollLayout.this);
|
||||
|
||||
// And the translating children
|
||||
mTranslatingViews = ((ExpandableNotificationRow) currView).getContentViews();
|
||||
}
|
||||
mMoveState = MOVE_STATE_UNDEFINED;
|
||||
}
|
||||
@@ -3408,15 +3406,12 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
}
|
||||
mMoveState = newMoveState;
|
||||
|
||||
if (view instanceof ExpandableNotificationRow) {
|
||||
((ExpandableNotificationRow) view).setTranslationForOutline(translation);
|
||||
if (!isPinnedHeadsUp(view)) {
|
||||
// Only show the gear if we're not a heads up view.
|
||||
checkForDrag();
|
||||
if (mCurrIconRow != null) {
|
||||
mCurrIconRow.updateSettingsIcons(translation, getSize(view));
|
||||
}
|
||||
}
|
||||
final boolean gutsExposed = (view instanceof ExpandableNotificationRow)
|
||||
&& ((ExpandableNotificationRow) view).areGutsExposed();
|
||||
|
||||
if (!isPinnedHeadsUp(view) && !gutsExposed) {
|
||||
// Only show the gear if we're not a heads up view and guts aren't exposed.
|
||||
checkForDrag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3439,12 +3434,12 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
(!fromLeft && absTrans >= snapBackThreshold * 0.4f
|
||||
&& absTrans <= notiThreshold);
|
||||
|
||||
if (pastGear && !isPinnedHeadsUp(animView)) {
|
||||
if (pastGear && !isPinnedHeadsUp(animView)
|
||||
&& (animView instanceof ExpandableNotificationRow)) {
|
||||
// bouncity
|
||||
final float target = fromLeft ? snapBackThreshold : -snapBackThreshold;
|
||||
mGearExposedView = mTranslatingParentView;
|
||||
if (mGearDisplayedListener != null
|
||||
&& (animView instanceof ExpandableNotificationRow)) {
|
||||
if (mGearDisplayedListener != null) {
|
||||
mGearDisplayedListener.onGearDisplayed((ExpandableNotificationRow) animView);
|
||||
}
|
||||
super.snapChild(animView, target, velocity);
|
||||
@@ -3453,39 +3448,17 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTranslationUpdate(View animView, float value, boolean canBeDismissed) {
|
||||
if (mDismissAllInProgress) {
|
||||
// When dismissing all, we translate the entire view instead.
|
||||
super.onTranslationUpdate(animView, value, canBeDismissed);
|
||||
return;
|
||||
}
|
||||
if (animView instanceof ExpandableNotificationRow) {
|
||||
((ExpandableNotificationRow) animView).setTranslationForOutline(value);
|
||||
}
|
||||
if (mCurrIconRow != null) {
|
||||
mCurrIconRow.updateSettingsIcons(value, getSize(animView));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator getViewTranslationAnimator(View v, float target,
|
||||
AnimatorUpdateListener listener) {
|
||||
if (mDismissAllInProgress) {
|
||||
// When dismissing all, we translate the entire view instead.
|
||||
return super.getViewTranslationAnimator(v, target, listener);
|
||||
} else if (v instanceof ExpandableNotificationRow) {
|
||||
return ((ExpandableNotificationRow) v).getTranslateViewAnimator(target, listener);
|
||||
} else {
|
||||
return super.getViewTranslationAnimator(v, target, listener);
|
||||
}
|
||||
ArrayList<Animator> animators = new ArrayList<Animator>();
|
||||
for (int i = 0; i < mTranslatingViews.size(); i++) {
|
||||
ObjectAnimator anim = createTranslationAnimation(mTranslatingViews.get(i), target);
|
||||
animators.add(anim);
|
||||
if (i == 0 && listener != null) {
|
||||
anim.addUpdateListener(listener);
|
||||
}
|
||||
}
|
||||
AnimatorSet set = new AnimatorSet();
|
||||
set.playTogether(animators);
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3493,13 +3466,8 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
if (mDismissAllInProgress) {
|
||||
// When dismissing all, we translate the entire view instead.
|
||||
super.setTranslation(v, translate);
|
||||
return;
|
||||
}
|
||||
// Translate the group of views
|
||||
for (int i = 0; i < mTranslatingViews.size(); i++) {
|
||||
if (mTranslatingViews.get(i) != null) {
|
||||
super.setTranslation(mTranslatingViews.get(i), translate);
|
||||
}
|
||||
} else {
|
||||
((ExpandableView) v).setTranslation(translate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3508,15 +3476,11 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
if (mDismissAllInProgress) {
|
||||
// When dismissing all, we translate the entire view instead.
|
||||
return super.getTranslation(v);
|
||||
} else {
|
||||
return ((ExpandableView) v).getTranslation();
|
||||
}
|
||||
// All of the views in the list should have same translation, just use first one.
|
||||
if (mTranslatingViews.size() > 0) {
|
||||
return super.getTranslation(mTranslatingViews.get(0));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the horizontal space in pixels required to display the gear behind a
|
||||
* notification.
|
||||
@@ -3571,26 +3535,11 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
final View prevGearExposedView = mGearExposedView;
|
||||
mGearExposedView = null;
|
||||
|
||||
AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (prevGearExposedView instanceof ExpandableNotificationRow) {
|
||||
((ExpandableNotificationRow) prevGearExposedView).getSettingsRow()
|
||||
.resetState();
|
||||
}
|
||||
}
|
||||
};
|
||||
AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
if (prevGearExposedView instanceof ExpandableNotificationRow) {
|
||||
((ExpandableNotificationRow) prevGearExposedView)
|
||||
.setTranslationForOutline((float) animation.getAnimatedValue());
|
||||
}
|
||||
}
|
||||
};
|
||||
Animator set = getViewTranslationAnimator(prevGearExposedView, 0, updateListener);
|
||||
set.addListener(listener);
|
||||
set.start();
|
||||
Animator anim = getViewTranslationAnimator(prevGearExposedView,
|
||||
0 /* leftTarget */, null /* updateListener */);
|
||||
if (anim != null) {
|
||||
anim.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user