Moving the QSB out of the cell layout to the Drag layer

This allows better edge matching for the QSB. The QSB position
is kept synchronized with the page scroll and all-apps transition.
But its not visible in spring loaded and overview mode

Change-Id: I4e6723607ea966ee672273a9ca67c792fd6b5661
This commit is contained in:
Sunny Goyal
2016-07-11 17:30:03 -07:00
parent ba162aa7d2
commit 6178f13e2d
16 changed files with 234 additions and 69 deletions
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.util;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import java.util.Arrays;
/**
* A utility class which divides the alpha for a view across multiple states.
*/
public class MultiStateAlphaController {
private final View mTargetView;
private final float[] mAlphas;
private final AccessibilityManager mAm;
public MultiStateAlphaController(View view, int stateCount) {
mTargetView = view;
mAlphas = new float[stateCount];
Arrays.fill(mAlphas, 1);
mAm = (AccessibilityManager) view.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
}
public void setAlphaAtIndex(float alpha, int index) {
mAlphas[index] = alpha;
float finalAlpha = 1;
for (float a : mAlphas) {
finalAlpha = finalAlpha * a;
}
mTargetView.setAlpha(finalAlpha);
mTargetView.setVisibility(alpha > 0 ? View.VISIBLE
: (mAm.isEnabled() ? View.GONE : View.INVISIBLE));
}
public Animator animateAlphaAtIndex(float finalAlpha, final int index) {
if (Float.compare(finalAlpha, mAlphas[index]) == 0) {
// Return a dummy animator to avoid null checks.
return ValueAnimator.ofFloat(0, 0);
} else {
ValueAnimator animator = ValueAnimator.ofFloat(mAlphas[index], finalAlpha);
animator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = (Float) valueAnimator.getAnimatedValue();
setAlphaAtIndex(value, index);
}
});
return animator;
}
}
}