* commit 'c013477567cd023e87c7b9213c6563ac272a016a': Improve Apps/Widgets transition
This commit is contained in:
commit
dafe7fe96a
3 files changed
+58
-29
No files matched your search
@@ -65,10 +65,11 @@
|
|||||||
launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
|
launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
|
||||||
launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
|
launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
|
||||||
launcher:maxGap="@dimen/workspace_max_gap" />
|
launcher:maxGap="@dimen/workspace_max_gap" />
|
||||||
<ImageView
|
<FrameLayout
|
||||||
android:id="@+id/animation_buffer"
|
android:id="@+id/animation_buffer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="#FF000000"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
|||||||
@@ -22,21 +22,20 @@ import android.animation.AnimatorSet;
|
|||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabWidget;
|
import android.widget.TabWidget;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.launcher.R;
|
import com.android.launcher.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class AppsCustomizeTabHost extends TabHost implements LauncherTransitionable,
|
public class AppsCustomizeTabHost extends TabHost implements LauncherTransitionable,
|
||||||
TabHost.OnTabChangeListener {
|
TabHost.OnTabChangeListener {
|
||||||
static final String LOG_TAG = "AppsCustomizeTabHost";
|
static final String LOG_TAG = "AppsCustomizeTabHost";
|
||||||
@@ -49,7 +48,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
private ViewGroup mTabsContainer;
|
private ViewGroup mTabsContainer;
|
||||||
private AppsCustomizePagedView mAppsCustomizePane;
|
private AppsCustomizePagedView mAppsCustomizePane;
|
||||||
private boolean mSuppressContentCallback = false;
|
private boolean mSuppressContentCallback = false;
|
||||||
private ImageView mAnimationBuffer;
|
private FrameLayout mAnimationBuffer;
|
||||||
|
|
||||||
private boolean mInTransition;
|
private boolean mInTransition;
|
||||||
private boolean mResetAfterTransition;
|
private boolean mResetAfterTransition;
|
||||||
@@ -93,7 +92,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
mTabs = tabs;
|
mTabs = tabs;
|
||||||
mTabsContainer = tabsContainer;
|
mTabsContainer = tabsContainer;
|
||||||
mAppsCustomizePane = appsCustomizePane;
|
mAppsCustomizePane = appsCustomizePane;
|
||||||
mAnimationBuffer = (ImageView) findViewById(R.id.animation_buffer);
|
mAnimationBuffer = (FrameLayout) findViewById(R.id.animation_buffer);
|
||||||
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
|
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
|
||||||
|
|
||||||
// Configure the tabs content factory to return the same paged view (that we change the
|
// Configure the tabs content factory to return the same paged view (that we change the
|
||||||
@@ -138,9 +137,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
// Set the width of the tab list to the content width
|
// Set the width of the tab list to the content width
|
||||||
if (remeasureTabWidth) {
|
if (remeasureTabWidth) {
|
||||||
int contentWidth = mAppsCustomizePane.getPageContentWidth();
|
int contentWidth = mAppsCustomizePane.getPageContentWidth();
|
||||||
if (contentWidth > 0) {
|
if (contentWidth > 0 && mTabs.getLayoutParams().width != contentWidth) {
|
||||||
// Set the width and show the tab bar (if we have a loading graphic, we can switch
|
// Set the width and show the tab bar
|
||||||
// it off here)
|
|
||||||
mTabs.getLayoutParams().width = contentWidth;
|
mTabs.getLayoutParams().width = contentWidth;
|
||||||
post(new Runnable() {
|
post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -202,17 +200,35 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the animation buffer
|
// Take the visible pages and re-parent them temporarily to mAnimatorBuffer
|
||||||
Bitmap b = Bitmap.createBitmap(mAppsCustomizePane.getMeasuredWidth(),
|
// and then cross fade to the new pages
|
||||||
mAppsCustomizePane.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
|
|
||||||
Canvas c = new Canvas(b);
|
// We want the pages to be rendered in exactly the same way as they were when
|
||||||
mAppsCustomizePane.draw(c);
|
// their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
|
||||||
mAppsCustomizePane.setAlpha(0f);
|
// to be exactly the same as mAppsCustomizePane, and below, set the left/top
|
||||||
mAnimationBuffer.setImageBitmap(b);
|
// parameters to be correct for each of the pages
|
||||||
mAnimationBuffer.setAlpha(1f);
|
mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0);
|
||||||
mAnimationBuffer.setVisibility(View.VISIBLE);
|
|
||||||
c.setBitmap(null);
|
int[] visiblePageRange = new int[2];
|
||||||
b = null;
|
mAppsCustomizePane.getVisiblePages(visiblePageRange);
|
||||||
|
ArrayList<View> visiblePages = new ArrayList<View>();
|
||||||
|
for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
|
||||||
|
visiblePages.add(mAppsCustomizePane.getPageAt(i));
|
||||||
|
}
|
||||||
|
// mAppsCustomizePane renders its children in reverse order, so
|
||||||
|
// add the pages to mAnimationBuffer in reverse order to match that behavior
|
||||||
|
for (int i = visiblePages.size() - 1; i >= 0; i--) {
|
||||||
|
View child = visiblePages.get(i);
|
||||||
|
PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false);
|
||||||
|
mAppsCustomizePane.removeView(child);
|
||||||
|
PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
|
||||||
|
mAnimationBuffer.setAlpha(1f);
|
||||||
|
mAnimationBuffer.setVisibility(View.VISIBLE);
|
||||||
|
LayoutParams p = new FrameLayout.LayoutParams(child.getWidth(),
|
||||||
|
child.getHeight());
|
||||||
|
p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
|
||||||
|
mAnimationBuffer.addView(child, p);
|
||||||
|
}
|
||||||
|
|
||||||
// Toggle the new content
|
// Toggle the new content
|
||||||
onTabChangedStart();
|
onTabChangedStart();
|
||||||
@@ -224,7 +240,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
mAnimationBuffer.setVisibility(View.GONE);
|
mAnimationBuffer.setVisibility(View.GONE);
|
||||||
mAnimationBuffer.setImageBitmap(null);
|
mAnimationBuffer.removeAllViews();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
mAnimationBuffer.setVisibility(View.GONE);
|
||||||
|
mAnimationBuffer.removeAllViews();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
|
ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
|||||||
|
|
||||||
private static final int sPreviewFadeInDuration = 80;
|
private static final int sPreviewFadeInDuration = 80;
|
||||||
private static final int sPreviewFadeInStaggerDuration = 20;
|
private static final int sPreviewFadeInStaggerDuration = 20;
|
||||||
|
private static boolean sDeletePreviewsWhenDetachedFromWindow = true;
|
||||||
|
|
||||||
private final Paint mPaint = new Paint();
|
private final Paint mPaint = new Paint();
|
||||||
private Bitmap mHolographicOutline;
|
private Bitmap mHolographicOutline;
|
||||||
@@ -89,17 +90,23 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
|||||||
setClipToPadding(false);
|
setClipToPadding(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setDeletePreviewsWhenDetachedFromWindow(boolean value) {
|
||||||
|
sDeletePreviewsWhenDetachedFromWindow = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
|
|
||||||
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
|
if (sDeletePreviewsWhenDetachedFromWindow) {
|
||||||
if (image != null) {
|
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
|
||||||
FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable();
|
if (image != null) {
|
||||||
if (preview != null && preview.getBitmap() != null) {
|
FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable();
|
||||||
preview.getBitmap().recycle();
|
if (preview != null && preview.getBitmap() != null) {
|
||||||
}
|
preview.getBitmap().recycle();
|
||||||
image.setImageDrawable(null);
|
}
|
||||||
|
image.setImageDrawable(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user