summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornebkat <nebkat@gmail.com>2011-12-04 16:24:47 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-08-13 14:23:50 +0100
commita9d9e3918b5c2cd3a8d0580022471272eed867f4 (patch)
treeb36effcdee3448c7d310856b899e74306b0ccdca
parent581ab43494c1ff7bc0ef7562e66475744190ec07 (diff)
downloadandroid_packages_apps_Trebuchet-a9d9e3918b5c2cd3a8d0580022471272eed867f4.tar.gz
android_packages_apps_Trebuchet-a9d9e3918b5c2cd3a8d0580022471272eed867f4.tar.bz2
android_packages_apps_Trebuchet-a9d9e3918b5c2cd3a8d0580022471272eed867f4.zip
Preferences: Separate Apps and Widgets
Reverts "Add ability to swipe from apps to widgets in AllAppsCustomize" Change-Id: I0727fbe747f2f93c4680bf91fbcbed75af662b29
-rw-r--r--res/values/strings.xml3
-rw-r--r--res/xml/preferences.xml7
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java296
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java95
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java5
5 files changed, 286 insertions, 120 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d01b6e76c..669016b80 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -313,6 +313,9 @@ s -->
<!-- Drawer -->
<string name="preferences_interface_drawer_title">Drawer</string>
+ <string name="preferences_interface_drawer_widgets_category">Widgets</string>
+ <string name="preferences_interface_drawer_widgets_join_apps_title">Join with Apps</string>
+ <string name="preferences_interface_drawer_widgets_join_apps_summary">Swipe from apps drawer to widgets drawer without changing tabs</string>
<!-- Dock -->
<string name="preferences_interface_dock_title">Dock</string>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index a81209b80..d1585e2cd 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -71,7 +71,12 @@
<!-- Drawer -->
<PreferenceScreen android:key="ui_drawer"
android:title="@string/preferences_interface_drawer_title">
-
+ <PreferenceCategory android:title="@string/preferences_interface_drawer_widgets_category">
+ <CheckBoxPreference android:key="ui_drawer_widgets_join_apps"
+ android:title="@string/preferences_interface_drawer_widgets_join_apps_title"
+ android:summary="@string/preferences_interface_drawer_widgets_join_apps_summary"
+ android:defaultValue="true" />
+ </PreferenceCategory>
</PreferenceScreen>
<!-- Dock -->
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 5a58a9a95..46d9e948f 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -65,6 +65,7 @@ import android.widget.Toast;
import com.cyanogenmod.trebuchet.R;
import com.cyanogenmod.trebuchet.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
import java.util.Collections;
@@ -140,8 +141,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;
}
@@ -168,6 +170,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;
}
@@ -255,8 +258,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Save and Restore
private int mSaveInstanceStateItemIndex = -1;
private PagedViewIcon mPressedIcon;
+ private int mRestorePage = -1;
// Content
+ private ContentType mContentType;
private ArrayList<ApplicationInfo> mApps;
private ArrayList<Object> mWidgets;
@@ -274,12 +279,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private int mContentWidth;
private int mAppIconSize;
private int mMaxAppCellCountX, mMaxAppCellCountY;
+ private int mMaxWidgetSpan, mMinWidgetSpan;
private int mWidgetCountX, mWidgetCountY;
private int mWidgetWidthGap, mWidgetHeightGap;
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);
@@ -324,16 +330,23 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
RectCache mCachedAppWidgetPreviewDestRect = new RectCache();
PaintCache mCachedAppWidgetPreviewPaint = new PaintCache();
+ // 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();
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);
@@ -353,6 +366,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)
mFadeInAdjacentScreens = false;
@@ -387,22 +405,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;
}
}
}
@@ -420,14 +460,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;
}
}
@@ -438,9 +491,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) {
@@ -518,7 +573,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (!isDataReady()) {
- if (!mApps.isEmpty() && !mWidgets.isEmpty()) {
+ boolean isReady = false;
+ if (mContentType == AppsCustomizePagedView.ContentType.Widgets || mJoinWidgetsApps) {
+ isReady = (!mApps.isEmpty() && !mWidgets.isEmpty());
+ } else {
+ isReady = !mApps.isEmpty();
+ }
+
+ if (isReady) {
setDataIsReady();
setMeasuredDimension(width, height);
onDataReady(width, height);
@@ -986,27 +1048,34 @@ 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);
- // Update the thread priorities given the direction lookahead
- Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
- while (iter.hasNext()) {
- AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
- int pageIndex = task.page;
- if ((mNextPage > mCurrentPage && pageIndex >= mCurrentPage) ||
- (mNextPage < mCurrentPage && pageIndex <= mCurrentPage)) {
- task.setThreadPriority(getThreadPriorityForPage(pageIndex));
- } else {
- task.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
+ // Update the thread priorities given the direction lookahead
+ Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
+ while (iter.hasNext()) {
+ AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
+ int pageIndex = task.page;
+ if ((mNextPage > mCurrentPage && pageIndex >= mCurrentPage) ||
+ (mNextPage < mCurrentPage && pageIndex <= mCurrentPage)) {
+ task.setThreadPriority(getThreadPriorityForPage(pageIndex));
+ } else {
+ task.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
+ }
}
}
}
@@ -1027,6 +1096,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ public boolean isContentType(ContentType type) {
+ return (mContentType == type);
+ }
+
+ public void setCurrentPageToWidgets() {
+ invalidatePageData(0);
+ }
+
/*
* Apps PagedView implementation
*/
@@ -1053,7 +1130,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;
@@ -1171,13 +1257,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
mRunningTasks.remove(task);
if (task.isCancelled()) return;
+ if (!mJoinWidgetsApps) {
+ if (task.page > getPageCount()) return;
+ if (task.pageContentType != mContentType) return;
+ }
// do cleanup inside onSyncWidgetPageItems
onSyncWidgetPageItems(data);
}
});
// 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);
@@ -1375,6 +1465,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(final int page, final boolean immediate) {
int numItemsPerPage = mWidgetCountX * mWidgetCountY;
@@ -1558,28 +1661,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 PagedView.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 PagedView.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, immediate);
+ }
} else {
- syncWidgetPageItems(page, immediate);
+ switch (mContentType) {
+ case Applications:
+ syncAppsPageItems(page, immediate);
+ break;
+ case Widgets:
+ syncWidgetPageItems(page, immediate);
+ break;
+ }
}
}
@@ -1791,11 +1916,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// If we have reset, then we should not continue to restore the previous state
mSaveInstanceStateItemIndex = -1;
- 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;
}
}
@@ -1883,17 +2018,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(getContext().getString(stringId), page + 1, count);
}
}
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
index 917f62ed0..9aa1a9e4e 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -35,6 +35,7 @@ import android.widget.TabWidget;
import android.widget.TextView;
import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
@@ -60,6 +61,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private Launcher mLauncher;
+ private boolean mJoinWidgetsApps;
+
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
@@ -69,6 +72,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mTabsContainer.setAlpha(1f);
}
};
+ mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
}
public void setup(Launcher launcher) {
@@ -91,6 +95,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
}
void selectWidgetsTab() {
setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets);
+ mAppsCustomizePane.setCurrentPageToWidgets();
+
setCurrentTabByTag(WIDGETS_TAB_TAG);
}
@@ -212,27 +218,28 @@ 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);
+ if (!mAppsCustomizePane.isContentType(type) || mJoinWidgetsApps) {
- // 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() {
+ // 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) {
+ mAppsCustomizePane.getMeasuredHeight() <= 0) {
reloadCurrentPage();
return;
}
-
// Take the visible pages and re-parent them temporarily to mAnimatorBuffer
// and then cross fade to the new pages
int[] visiblePageRange = new int[2];
mAppsCustomizePane.getVisiblePages(visiblePageRange);
if (visiblePageRange[0] == -1 && visiblePageRange[1] == -1) {
- // If we can't get the visible page ranges, then just skip the animation
+ // If we can't get the visible page ranges, then just skip the animation
reloadCurrentPage();
return;
}
@@ -240,7 +247,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
visiblePages.add(mAppsCustomizePane.getPageAt(i));
}
-
// We want the pages to be rendered in exactly the same way as they were when
// their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
// to be exactly the same as mAppsCustomizePane, and below, set the left/top
@@ -265,39 +271,40 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
child.getMeasuredHeight());
p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
mAnimationBuffer.addView(child, p);
- }
- // 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.removeAllViews();
- }
- @Override
- public void onAnimationCancel(Animator animation) {
- mAnimationBuffer.setVisibility(View.GONE);
- mAnimationBuffer.removeAllViews();
- }
- });
- 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();
- }
- });
+ // 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.removeAllViews();
+ }
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mAnimationBuffer.setVisibility(View.GONE);
+ mAnimationBuffer.removeAllViews();
+ }
+ });
+ 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/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 2e745e2fe..f08929f39 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -70,7 +70,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 {