diff options
author | nebkat <nebkat@gmail.com> | 2011-12-04 16:24:47 +0000 |
---|---|---|
committer | nebkat <nebkat@gmail.com> | 2011-12-05 21:23:17 +0000 |
commit | 44792c9a4c8ece335164f9a1b6e4109583ccebcd (patch) | |
tree | 87ec70eea28efec77564044c0b9c59b874e35569 /src/com | |
parent | e8e44592a790a45c98dc0f320ba0fca1f040fbe5 (diff) | |
download | android_packages_apps_Trebuchet-44792c9a4c8ece335164f9a1b6e4109583ccebcd.tar.gz android_packages_apps_Trebuchet-44792c9a4c8ece335164f9a1b6e4109583ccebcd.tar.bz2 android_packages_apps_Trebuchet-44792c9a4c8ece335164f9a1b6e4109583ccebcd.zip |
Preferences: Separate Apps and Widgets
Reverts "Add ability to swipe from apps to widgets in AllAppsCustomize"
Change-Id: I0727fbe747f2f93c4680bf91fbcbed75af662b29
Diffstat (limited to 'src/com')
3 files changed, 281 insertions, 119 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index bd6128870..94370d572 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -56,6 +56,7 @@ import android.widget.Toast; import com.android.launcher.R; import com.android.launcher2.DropTarget.DragObject; +import com.android.launcher2.preference.PreferencesProvider; import java.util.ArrayList; import java.util.Collections; @@ -133,8 +134,9 @@ class AsyncTaskPageData { * A generic template for an async task used in AppsCustomize. */ class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTaskPageData> { - AppsCustomizeAsyncTask(int p, AsyncTaskPageData.Type ty) { + AppsCustomizeAsyncTask(int p, AppsCustomizePagedView.ContentType t, AsyncTaskPageData.Type ty) { page = p; + pageContentType = t; threadPriority = Process.THREAD_PRIORITY_DEFAULT; dataType = ty; } @@ -161,6 +163,7 @@ class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTas // The page that this async task is associated with AsyncTaskPageData.Type dataType; int page; + AppsCustomizePagedView.ContentType pageContentType; int threadPriority; } @@ -187,8 +190,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Save and Restore private int mSaveInstanceStateItemIndex = -1; + private int mRestorePage = -1; // Content + private ContentType mContentType; private ArrayList<ApplicationInfo> mApps; private ArrayList<Object> mWidgets; @@ -205,13 +210,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Dimens private int mContentWidth; private int mAppIconSize; + private int mMaxWidgetSpan, mMinWidgetSpan; private int mWidgetCountX, mWidgetCountY; private int mWidgetWidthGap, mWidgetHeightGap; private final int mWidgetPreviewIconPaddedDimension; private final float sWidgetPreviewIconPaddingPercentage = 0.25f; private PagedViewCellLayout mWidgetSpacingLayout; - private int mNumAppsPages; - private int mNumWidgetPages; + private int mNumAppsPages = 0; + private int mNumWidgetPages = 0; // Relating to the scroll and overscroll effects Workspace.ZInterpolator mZInterpolator = new Workspace.ZInterpolator(0.5f); @@ -227,10 +233,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private HolographicOutlineHelper mHolographicOutlineHelper; private static final int sPageSleepDelay = 150; + // Preferences + private boolean mJoinWidgetsApps; + public AppsCustomizePagedView(Context context, AttributeSet attrs) { super(context, attrs); mLayoutInflater = LayoutInflater.from(context); mPackageManager = context.getPackageManager(); + mContentType = ContentType.Applications; mApps = new ArrayList<ApplicationInfo>(); mWidgets = new ArrayList<Object>(); mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache(); @@ -238,6 +248,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mCanvas = new Canvas(); mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>(); + // Preferences + mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context); + // Save the default widget preview background Resources resources = context.getResources(); mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview_holo); @@ -261,6 +274,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen a.recycle(); mWidgetSpacingLayout = new PagedViewCellLayout(getContext()); + // The max widget span is the length N, such that NxN is the largest bounds that the widget + // preview can be before applying the widget scaling + mMinWidgetSpan = 1; + mMaxWidgetSpan = 3; + // The padding on the non-matched dimension for the default widget preview icons // (top + bottom) mWidgetPreviewIconPaddedDimension = @@ -292,22 +310,44 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen int i = -1; if (getPageCount() > 0) { int currentPage = getCurrentPage(); - if (currentPage < mNumAppsPages) { - PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage); - PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout(); - int numItemsPerPage = mCellCountX * mCellCountY; - int childCount = childrenLayout.getChildCount(); - if (childCount > 0) { - i = (currentPage * numItemsPerPage) + (childCount / 2); + if (mJoinWidgetsApps) { + if (currentPage < mNumAppsPages) { + PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage); + PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout(); + int numItemsPerPage = mCellCountX * mCellCountY; + int childCount = childrenLayout.getChildCount(); + if (childCount > 0) { + i = (currentPage * numItemsPerPage) + (childCount / 2); + } + } else { + int numApps = mApps.size(); + PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage); + int numItemsPerPage = mWidgetCountX * mWidgetCountY; + int childCount = layout.getChildCount(); + if (childCount > 0) { + i = numApps + + ((currentPage - mNumAppsPages) * numItemsPerPage) + (childCount / 2); + } } } else { - int numApps = mApps.size(); - PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage); - int numItemsPerPage = mWidgetCountX * mWidgetCountY; - int childCount = layout.getChildCount(); - if (childCount > 0) { - i = numApps + - ((currentPage - mNumAppsPages) * numItemsPerPage) + (childCount / 2); + switch (mContentType) { + case Applications: { + PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage); + PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout(); + int numItemsPerPage = mCellCountX * mCellCountY; + int childCount = childrenLayout.getChildCount(); + if (childCount > 0) { + i = (currentPage * numItemsPerPage) + (childCount / 2); + }} + break; + case Widgets: { + PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage); + int numItemsPerPage = mWidgetCountX * mWidgetCountY; + int childCount = layout.getChildCount(); + if (childCount > 0) { + i = (currentPage * numItemsPerPage) + (childCount / 2); + }} + break; } } } @@ -325,14 +365,27 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen /** Returns the page in the current orientation which is expected to contain the specified * item index. */ int getPageForComponent(int index) { - if (index < 0) return 0; + if (mJoinWidgetsApps) { + if (index < 0) return 0; - if (index < mApps.size()) { - int numItemsPerPage = mCellCountX * mCellCountY; - return (index / numItemsPerPage); + if (index < mApps.size()) { + int numItemsPerPage = mCellCountX * mCellCountY; + return (index / numItemsPerPage); + } else { + int numItemsPerPage = mWidgetCountX * mWidgetCountY; + return mNumAppsPages + ((index - mApps.size()) / numItemsPerPage); + } } else { - int numItemsPerPage = mWidgetCountX * mWidgetCountY; - return mNumAppsPages + ((index - mApps.size()) / numItemsPerPage); + switch (mContentType) { + case Applications: { + int numItemsPerPage = mCellCountX * mCellCountY; + return (index / numItemsPerPage); + } + case Widgets: { + int numItemsPerPage = mWidgetCountX * mWidgetCountY; + return (index / numItemsPerPage); + }} + return -1; } } @@ -342,8 +395,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private boolean testDataReady() { // We only do this test once, and we default to the Applications page, so we only really // have to wait for there to be apps. - // TODO: What if one of them is validly empty - return !mApps.isEmpty() && !mWidgets.isEmpty(); + if (mContentType == AppsCustomizePagedView.ContentType.Widgets || mJoinWidgetsApps) { + return !mApps.isEmpty() && !mWidgets.isEmpty(); + } else { + return !mApps.isEmpty(); + } } /** Restores the page for an item at the specified index */ @@ -353,9 +409,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } private void updatePageCounts() { - mNumWidgetPages = (int) Math.ceil(mWidgets.size() / - (float) (mWidgetCountX * mWidgetCountY)); - mNumAppsPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY)); + if (mJoinWidgetsApps) { + mNumWidgetPages = (int) Math.ceil(mWidgets.size() / + (float) (mWidgetCountX * mWidgetCountY)); + mNumAppsPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY)); + } } protected void onDataReady(int width, int height) { @@ -391,7 +449,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen int page = getPageForComponent(mSaveInstanceStateItemIndex); invalidatePageData(Math.max(0, page)); - // Calculate the position for the cling punch through int[] offset = new int[2]; int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY); mLauncher.getDragLayer().getLocationInDragLayer(this, offset); @@ -648,16 +705,23 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } public void setContentType(ContentType type) { - if (type == ContentType.Widgets) { - invalidatePageData(mNumAppsPages, true); - } else if (type == ContentType.Applications) { - invalidatePageData(0, true); + if (mJoinWidgetsApps) { + if (type == ContentType.Widgets) { + invalidatePageData(mNumAppsPages, true); + } else if (type == ContentType.Applications) { + invalidatePageData(0, true); + } + } else { + mContentType = type; + invalidatePageData(0, (type != ContentType.Applications)); } } protected void snapToPage(int whichPage, int delta, int duration) { super.snapToPage(whichPage, delta, duration); - updateCurrentTab(whichPage); + if (mJoinWidgetsApps) { + updateCurrentTab(whichPage); + } } private void updateCurrentTab(int currentPage) { @@ -674,6 +738,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } + public boolean isContentType(ContentType type) { + return (mContentType == type); + } + + public void setCurrentPageToWidgets() { + invalidatePageData(0); + } + /* * Apps PagedView implementation */ @@ -700,7 +772,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen layout.measure(widthSpec, heightSpec); setVisibilityOnChildren(layout, View.VISIBLE); } - + public void syncAppsPages() { + // Ensure that we have the right number of pages + Context context = getContext(); + int numPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY)); + for (int i = 0; i < numPages; ++i) { + PagedViewCellLayout layout = new PagedViewCellLayout(context); + setupPage(layout); + addView(layout); + } + } public void syncAppsPageItems(int page, boolean immediate) { // ensure that we have the right number of items on the pages int numCells = mCellCountX * mCellCountY; @@ -800,6 +881,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen try { mRunningTasks.remove(task); if (task.isCancelled()) return; + if (!mJoinWidgetsApps) { + if (task.page > getPageCount()) return; + if (task.pageContentType != mContentType) return; + } onSyncWidgetPageItems(data); } finally { data.cleanup(task.isCancelled()); @@ -808,7 +893,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen }); // Ensure that the task is appropriately prioritized and runs in parallel - AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page, + AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page, mContentType, AsyncTaskPageData.Type.LoadWidgetPreviewData); t.setThreadPriority(getThreadPriorityForPage(page)); t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageData); @@ -873,6 +958,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen try { mRunningTasks.remove(task); if (task.isCancelled()) return; + if (!mJoinWidgetsApps) { + if (task.page > getPageCount()) return; + if (task.pageContentType != mContentType) return; + } onHolographicPageItemsLoaded(data); } finally { data.cleanup(task.isCancelled()); @@ -882,7 +971,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Ensure that the outline task always runs in the background, serially AppsCustomizeAsyncTask t = - new AppsCustomizeAsyncTask(page, AsyncTaskPageData.Type.LoadHolographicIconsData); + new AppsCustomizeAsyncTask(page, mContentType, + AsyncTaskPageData.Type.LoadHolographicIconsData); t.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); t.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, pageData); mRunningTasks.add(t); @@ -1020,7 +1110,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } return preview; } - + public void syncWidgetPages() { + // Ensure that we have the right number of pages + Context context = getContext(); + int numPages = (int) Math.ceil(mWidgets.size() / + (float) (mWidgetCountX * mWidgetCountY)); + for (int j = 0; j < numPages; ++j) { + PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX, + mWidgetCountY); + setupPage(layout); + addView(layout, new PagedViewGridLayout.LayoutParams(LayoutParams.MATCH_PARENT, + LayoutParams.MATCH_PARENT)); + } + } public void syncWidgetPageItems(int page, boolean immediate) { int numItemsPerPage = mWidgetCountX * mWidgetCountY; int contentWidth = mWidgetSpacingLayout.getContentWidth(); @@ -1185,28 +1287,50 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen removeAllViews(); cancelAllTasks(); - Context context = getContext(); - for (int j = 0; j < mNumWidgetPages; ++j) { - PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX, - mWidgetCountY); - setupPage(layout); - addView(layout, new PagedViewGridLayout.LayoutParams(LayoutParams.MATCH_PARENT, - LayoutParams.MATCH_PARENT)); - } + if (mJoinWidgetsApps) { + Context context = getContext(); + for (int j = 0; j < mNumWidgetPages; ++j) { + PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX, + mWidgetCountY); + setupPage(layout); + addView(layout, new PagedViewGridLayout.LayoutParams(LayoutParams.MATCH_PARENT, + LayoutParams.MATCH_PARENT)); + } - for (int i = 0; i < mNumAppsPages; ++i) { - PagedViewCellLayout layout = new PagedViewCellLayout(context); - setupPage(layout); - addView(layout); + for (int i = 0; i < mNumAppsPages; ++i) { + PagedViewCellLayout layout = new PagedViewCellLayout(context); + setupPage(layout); + addView(layout); + } + } else { + switch (mContentType) { + case Applications: + syncAppsPages(); + break; + case Widgets: + syncWidgetPages(); + break; + } } } @Override public void syncPageItems(int page, boolean immediate) { - if (page < mNumAppsPages) { - syncAppsPageItems(page, immediate); + if (mJoinWidgetsApps) { + if (page < mNumAppsPages) { + syncAppsPageItems(page, immediate); + } else { + syncWidgetPageItems(page - mNumAppsPages, immediate); + } } else { - syncWidgetPageItems(page - mNumAppsPages, immediate); + switch (mContentType) { + case Applications: + syncAppsPageItems(page, immediate); + break; + case Widgets: + syncWidgetPageItems(page, immediate); + break; + } } } @@ -1386,13 +1510,24 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen @Override public void reset() { - AppsCustomizeTabHost tabHost = getTabHost(); - String tag = tabHost.getCurrentTabTag(); - if (tag != null) { - if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) { - tabHost.setCurrentTabFromContent(ContentType.Applications); + if (mJoinWidgetsApps) { + AppsCustomizeTabHost tabHost = getTabHost(); + String tag = tabHost.getCurrentTabTag(); + if (tag != null) { + if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) { + tabHost.setCurrentTabFromContent(ContentType.Applications); + } + } + } else { + if (mContentType != ContentType.Applications) { + // Reset to the first page of the Apps pane + AppsCustomizeTabHost tabs = (AppsCustomizeTabHost) + mLauncher.findViewById(R.id.apps_customize_pane); + tabs.selectAppsTab(); + return; } } + if (mCurrentPage != 0) { invalidatePageData(0); } @@ -1408,6 +1543,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen ApplicationInfo.dumpApplicationInfoList(LOG_TAG, "mApps", mApps); dumpAppWidgetProviderInfoList(LOG_TAG, "mWidgets", mWidgets); } + private void dumpAppWidgetProviderInfoList(String tag, String label, ArrayList<Object> list) { Log.d(tag, label + " size=" + list.size()); @@ -1450,17 +1586,30 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen protected String getCurrentPageDescription() { int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage; int stringId = R.string.default_scroll_format; - int count = 0; - - if (page < mNumAppsPages) { - stringId = R.string.apps_customize_apps_scroll_format; - count = mNumAppsPages; + + if (mJoinWidgetsApps) { + int count = 0; + + if (page < mNumAppsPages) { + stringId = R.string.apps_customize_apps_scroll_format; + count = mNumAppsPages; + } else { + page -= mNumAppsPages; + stringId = R.string.apps_customize_widgets_scroll_format; + count = mNumWidgetPages; + } + + return String.format(mContext.getString(stringId), page + 1, count); } else { - page -= mNumAppsPages; - stringId = R.string.apps_customize_widgets_scroll_format; - count = mNumWidgetPages; + switch (mContentType) { + case Applications: + stringId = R.string.apps_customize_apps_scroll_format; + break; + case Widgets: + stringId = R.string.apps_customize_widgets_scroll_format; + break; + } + return String.format(mContext.getString(stringId), page + 1, getChildCount()); } - - return String.format(mContext.getString(stringId), page + 1, count); } } diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index 688ea152d..41fe4a9ff 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -36,6 +36,7 @@ import android.widget.TabWidget; import android.widget.TextView; import com.android.launcher.R; +import com.android.launcher2.preference.PreferencesProvider; public class AppsCustomizeTabHost extends TabHost implements LauncherTransitionable, TabHost.OnTabChangeListener { @@ -54,9 +55,13 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona private boolean mInTransition; private boolean mResetAfterTransition; + private boolean mJoinWidgetsApps; + public AppsCustomizeTabHost(Context context, AttributeSet attrs) { super(context, attrs); mLayoutInflater = LayoutInflater.from(context); + + mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context); } /** @@ -75,6 +80,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona } void selectWidgetsTab() { setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets); + mAppsCustomizePane.setCurrentPageToWidgets(); + setCurrentTabByTag(WIDGETS_TAB_TAG); } @@ -187,59 +194,62 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona return; } - // Animate the changing of the tab content by fading pages in and out - final Resources res = getResources(); - final int duration = res.getInteger(R.integer.config_tabTransitionDuration); - - // We post a runnable here because there is a delay while the first page is loading and - // the feedback from having changed the tab almost feels better than having it stick - post(new Runnable() { - @Override - public void run() { - if (mAppsCustomizePane.getMeasuredWidth() <= 0 || - mAppsCustomizePane.getMeasuredHeight() <= 0) { - reloadCurrentPage(); - return; - } + if (!mAppsCustomizePane.isContentType(type) || mJoinWidgetsApps) { - // Setup the animation buffer - Bitmap b = Bitmap.createBitmap(mAppsCustomizePane.getMeasuredWidth(), - mAppsCustomizePane.getMeasuredHeight(), Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(b); - mAppsCustomizePane.draw(c); - mAppsCustomizePane.setAlpha(0f); - mAnimationBuffer.setImageBitmap(b); - mAnimationBuffer.setAlpha(1f); - mAnimationBuffer.setVisibility(View.VISIBLE); - c.setBitmap(null); - b = null; - - // Toggle the new content - onTabChangedStart(); - onTabChangedEnd(type); - - // Animate the transition - ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f); - outAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mAnimationBuffer.setVisibility(View.GONE); - mAnimationBuffer.setImageBitmap(null); - } - }); - ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f); - inAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { + // Animate the changing of the tab content by fading pages in and out + final Resources res = getResources(); + final int duration = res.getInteger(R.integer.config_tabTransitionDuration); + + // We post a runnable here because there is a delay while the first page is loading and + // the feedback from having changed the tab almost feels better than having it stick + post(new Runnable() { + @Override + public void run() { + if (mAppsCustomizePane.getMeasuredWidth() <= 0 || + mAppsCustomizePane.getMeasuredHeight() <= 0) { reloadCurrentPage(); + return; } - }); - AnimatorSet animSet = new AnimatorSet(); - animSet.playTogether(outAnim, inAnim); - animSet.setDuration(duration); - animSet.start(); - } - }); + + // Setup the animation buffer + Bitmap b = Bitmap.createBitmap(mAppsCustomizePane.getMeasuredWidth(), + mAppsCustomizePane.getMeasuredHeight(), Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(b); + mAppsCustomizePane.draw(c); + mAppsCustomizePane.setAlpha(0f); + mAnimationBuffer.setImageBitmap(b); + mAnimationBuffer.setAlpha(1f); + mAnimationBuffer.setVisibility(View.VISIBLE); + c.setBitmap(null); + b = null; + + // Toggle the new content + onTabChangedStart(); + onTabChangedEnd(type); + + // Animate the transition + ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f); + outAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mAnimationBuffer.setVisibility(View.GONE); + mAnimationBuffer.setImageBitmap(null); + } + }); + ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f); + inAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + reloadCurrentPage(); + } + }); + AnimatorSet animSet = new AnimatorSet(); + animSet.playTogether(outAnim, inAnim); + animSet.setDuration(duration); + animSet.start(); + } + }); + } } public void setCurrentTabFromContent(AppsCustomizePagedView.ContentType type) { diff --git a/src/com/android/launcher2/preference/PreferencesProvider.java b/src/com/android/launcher2/preference/PreferencesProvider.java index f4579b20c..46fb21f97 100644 --- a/src/com/android/launcher2/preference/PreferencesProvider.java +++ b/src/com/android/launcher2/preference/PreferencesProvider.java @@ -21,7 +21,10 @@ public final class PreferencesProvider { } public static class Drawer { - + public static boolean getJoinWidgetsApps(Context context) { + final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); + return preferences.getBoolean("ui_drawer_widgets_join_apps", true); + } } public static class Dock { |