NavigationBarTransitionspublic final class NavigationBarTransitions extends BarTransitions
Fields Summary |
---|
private static final int | CONTENT_FADE_DURATION | private final NavigationBarView | mView | private final com.android.internal.statusbar.IStatusBarService | mBarService | private boolean | mLightsOut | private boolean | mVertical | private int | mRequestedMode | private final View.OnTouchListener | mLightsOutListener |
Constructors Summary |
---|
public NavigationBarTransitions(NavigationBarView view)
super(view, R.drawable.nav_background);
mView = view;
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
Methods Summary |
---|
private float | alphaForMode(int mode)
final boolean isOpaque = mode == MODE_OPAQUE || mode == MODE_LIGHTS_OUT;
return isOpaque ? KeyButtonView.DEFAULT_QUIESCENT_ALPHA : 1f;
| public void | applyBackButtonQuiescentAlpha(int mode, boolean animate)
float backAlpha = 0;
backAlpha = maxVisibleQuiescentAlpha(backAlpha, mView.getHomeButton());
backAlpha = maxVisibleQuiescentAlpha(backAlpha, mView.getRecentsButton());
backAlpha = maxVisibleQuiescentAlpha(backAlpha, mView.getMenuButton());
backAlpha = maxVisibleQuiescentAlpha(backAlpha, mView.getImeSwitchButton());
if (backAlpha > 0) {
setKeyButtonViewQuiescentAlpha(mView.getBackButton(), backAlpha, animate);
}
| private void | applyLightsOut(boolean lightsOut, boolean animate, boolean force)
if (!force && lightsOut == mLightsOut) return;
mLightsOut = lightsOut;
final View navButtons = mView.getCurrentView().findViewById(R.id.nav_buttons);
final View lowLights = mView.getCurrentView().findViewById(R.id.lights_out);
// ok, everyone, stop it right there
navButtons.animate().cancel();
lowLights.animate().cancel();
final float navButtonsAlpha = lightsOut ? 0f : 1f;
final float lowLightsAlpha = lightsOut ? 1f : 0f;
if (!animate) {
navButtons.setAlpha(navButtonsAlpha);
lowLights.setAlpha(lowLightsAlpha);
lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE);
} else {
final int duration = lightsOut ? LIGHTS_OUT_DURATION : LIGHTS_IN_DURATION;
navButtons.animate()
.alpha(navButtonsAlpha)
.setDuration(duration)
.start();
lowLights.setOnTouchListener(mLightsOutListener);
if (lowLights.getVisibility() == View.GONE) {
lowLights.setAlpha(0f);
lowLights.setVisibility(View.VISIBLE);
}
lowLights.animate()
.alpha(lowLightsAlpha)
.setDuration(duration)
.setInterpolator(new AccelerateInterpolator(2.0f))
.setListener(lightsOut ? null : new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator _a) {
lowLights.setVisibility(View.GONE);
}
})
.start();
}
| private void | applyMode(int mode, boolean animate, boolean force)
// apply to key buttons
final float alpha = alphaForMode(mode);
setKeyButtonViewQuiescentAlpha(mView.getHomeButton(), alpha, animate);
setKeyButtonViewQuiescentAlpha(mView.getRecentsButton(), alpha, animate);
setKeyButtonViewQuiescentAlpha(mView.getMenuButton(), alpha, animate);
setKeyButtonViewQuiescentAlpha(mView.getImeSwitchButton(), alpha, animate);
applyBackButtonQuiescentAlpha(mode, animate);
// apply to lights out
applyLightsOut(isLightsOut(mode), animate, force);
| public void | init(boolean isVertical)
setVertical(isVertical);
applyModeBackground(-1, getMode(), false /*animate*/);
applyMode(getMode(), false /*animate*/, true /*force*/);
| private static float | maxVisibleQuiescentAlpha(float max, android.view.View v)
if ((v instanceof KeyButtonView) && v.isShown()) {
return Math.max(max, ((KeyButtonView)v).getQuiescentAlpha());
}
return max;
| protected void | onTransition(int oldMode, int newMode, boolean animate)
super.onTransition(oldMode, newMode, animate);
applyMode(newMode, animate, false /*force*/);
| private void | setKeyButtonViewQuiescentAlpha(android.view.View button, float alpha, boolean animate)
if (button instanceof KeyButtonView) {
((KeyButtonView) button).setQuiescentAlpha(alpha, animate);
}
| public void | setVertical(boolean isVertical)
mVertical = isVertical;
transitionTo(mRequestedMode, false /*animate*/);
| public void | transitionTo(int mode, boolean animate)
mRequestedMode = mode;
if (mVertical) {
// translucent mode not allowed when vertical
if (mode == MODE_TRANSLUCENT || mode == MODE_TRANSPARENT) {
mode = MODE_OPAQUE;
} else if (mode == MODE_LIGHTS_OUT_TRANSPARENT) {
mode = MODE_LIGHTS_OUT;
}
}
super.transitionTo(mode, animate);
|
|