am acec6719: Merge "Cleaning up overscroll effect in launcher workspace" into ics-mr1
* commit 'acec6719208a59ccf32bfd4f46e383c9400945d9': Cleaning up overscroll effect in launcher workspace
This commit is contained in:
@@ -64,18 +64,18 @@
|
||||
android:id="@+id/qsb_bar"
|
||||
layout="@layout/qsb_bar" />
|
||||
|
||||
<include layout="@layout/apps_customize_pane"
|
||||
android:id="@+id/apps_customize_pane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<include layout="@layout/hotseat"
|
||||
android:id="@+id/hotseat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/button_bar_height_plus_padding"
|
||||
android:layout_gravity="bottom" />
|
||||
|
||||
<include layout="@layout/apps_customize_pane"
|
||||
android:id="@+id/apps_customize_pane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<include layout="@layout/workspace_cling"
|
||||
android:id="@+id/workspace_cling"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -69,6 +69,8 @@ public class DragLayer extends FrameLayout {
|
||||
private float mDropViewAlpha;
|
||||
private boolean mHoverPointClosesFolder = false;
|
||||
private Rect mHitRect = new Rect();
|
||||
private int mWorkspaceIndex = -1;
|
||||
private int mHotseatIndex = -1;
|
||||
|
||||
/**
|
||||
* Used to create a new DragLayer from XML.
|
||||
@@ -81,6 +83,7 @@ public class DragLayer extends FrameLayout {
|
||||
|
||||
// Disable multitouch across the workspace/all apps/customize tray
|
||||
setMotionEventSplittingEnabled(false);
|
||||
setChildrenDrawingOrderEnabled(true);
|
||||
}
|
||||
|
||||
public void setup(Launcher launcher, DragController controller) {
|
||||
@@ -609,6 +612,44 @@ public class DragLayer extends FrameLayout {
|
||||
mFadeOutAnim.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAdded(View child) {
|
||||
super.onViewAdded(child);
|
||||
updateChildIndices();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewRemoved(View child) {
|
||||
super.onViewRemoved(child);
|
||||
updateChildIndices();
|
||||
}
|
||||
|
||||
private void updateChildIndices() {
|
||||
if (mLauncher != null) {
|
||||
mWorkspaceIndex = indexOfChild(mLauncher.getWorkspace());
|
||||
mHotseatIndex = indexOfChild(mLauncher.getHotseat());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChildDrawingOrder(int childCount, int i) {
|
||||
if (mWorkspaceIndex == -1 || mHotseatIndex == -1 ||
|
||||
mLauncher.getWorkspace().isDrawingBackgroundGradient()) {
|
||||
return i;
|
||||
}
|
||||
|
||||
// This ensures that the workspace is drawn above the hotseat and qsb,
|
||||
// except when the workspace is drawing a background gradient, in which
|
||||
// case we want the workspace to stay behind these elements.
|
||||
if (i == mHotseatIndex) {
|
||||
return mWorkspaceIndex;
|
||||
} else if (i == mWorkspaceIndex) {
|
||||
return mHotseatIndex;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
@@ -1711,7 +1711,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
}
|
||||
}
|
||||
|
||||
private ImageView getScrollingIndicator() {
|
||||
protected ImageView getScrollingIndicator() {
|
||||
// We use mHasScrollIndicator to prevent future lookups if there is no sibling indicator
|
||||
// found
|
||||
if (mHasScrollIndicator && mScrollIndicator == null) {
|
||||
@@ -1750,9 +1750,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
// Fade the indicator in
|
||||
updateScrollingIndicatorPosition();
|
||||
mScrollIndicator.setVisibility(View.VISIBLE);
|
||||
if (mScrollIndicatorAnimator != null) {
|
||||
mScrollIndicatorAnimator.cancel();
|
||||
}
|
||||
cancelScrollingIndicatorAnimations();
|
||||
if (immediately) {
|
||||
mScrollIndicator.setAlpha(1f);
|
||||
} else {
|
||||
@@ -1763,6 +1761,12 @@ public abstract class PagedView extends ViewGroup {
|
||||
}
|
||||
}
|
||||
|
||||
protected void cancelScrollingIndicatorAnimations() {
|
||||
if (mScrollIndicatorAnimator != null) {
|
||||
mScrollIndicatorAnimator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideScrollingIndicator(boolean immediately) {
|
||||
if (getChildCount() <= 1) return;
|
||||
if (!isScrollingIndicatorEnabled()) return;
|
||||
@@ -1771,9 +1775,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
if (mScrollIndicator != null) {
|
||||
// Fade the indicator out
|
||||
updateScrollingIndicatorPosition();
|
||||
if (mScrollIndicatorAnimator != null) {
|
||||
mScrollIndicatorAnimator.cancel();
|
||||
}
|
||||
cancelScrollingIndicatorAnimations();
|
||||
if (immediately) {
|
||||
mScrollIndicator.setVisibility(View.GONE);
|
||||
mScrollIndicator.setAlpha(0f);
|
||||
|
||||
@@ -175,6 +175,7 @@ public class Workspace extends SmoothPagedView
|
||||
private final Rect mTempRect = new Rect();
|
||||
private final int[] mTempXY = new int[2];
|
||||
private int mDragViewMultiplyColor;
|
||||
private float mOverscrollFade = 0;
|
||||
|
||||
// Paint used to draw external drop outline
|
||||
private final Paint mExternalDragOutlinePaint = new Paint();
|
||||
@@ -1152,7 +1153,11 @@ public class Workspace extends SmoothPagedView
|
||||
cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
|
||||
cl.setTranslationX(translationX);
|
||||
cl.setRotationY(rotation);
|
||||
setFadeForOverScroll(Math.abs(scrollProgress));
|
||||
} else {
|
||||
if (mOverscrollFade != 0) {
|
||||
setFadeForOverScroll(0);
|
||||
}
|
||||
// We don't want to mess with the translations during transitions
|
||||
if (!isSwitchingState()) {
|
||||
resetCellLayoutTransforms((CellLayout) getChildAt(0), true);
|
||||
@@ -1230,6 +1235,10 @@ public class Workspace extends SmoothPagedView
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
boolean isDrawingBackgroundGradient() {
|
||||
return (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
@@ -3454,6 +3463,20 @@ public class Workspace extends SmoothPagedView
|
||||
}
|
||||
}
|
||||
|
||||
void setFadeForOverScroll(float fade) {
|
||||
if (!isScrollingIndicatorEnabled()) return;
|
||||
|
||||
mOverscrollFade = fade;
|
||||
float reducedFade = 0.5f + 0.5f * (1 - fade);
|
||||
final ViewGroup parent = (ViewGroup) getParent();
|
||||
final ImageView dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
|
||||
final ImageView scrollIndicator = getScrollingIndicator();
|
||||
|
||||
cancelScrollingIndicatorAnimations();
|
||||
dockDivider.setAlpha(reducedFade);
|
||||
scrollIndicator.setAlpha(1 - fade);
|
||||
}
|
||||
|
||||
void hideDockDivider(boolean immediately) {
|
||||
final ViewGroup parent = (ViewGroup) getParent();
|
||||
final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
|
||||
|
||||
Reference in New Issue
Block a user