summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornebkat <nebkat@teamhacksung.org>2011-12-31 13:13:02 +0000
committernebkat <nebkat@teamhacksung.org>2011-12-31 14:11:35 +0000
commit7a61cbce95468ab90ddce01575fbe3f6dc6031f0 (patch)
tree06aa4b9ac25abe672db20c3ac81e3ae8bc2c5599 /src
parent991185b60879af6f84736918f8616e28a67eeeac (diff)
downloadandroid_packages_apps_Trebuchet-7a61cbce95468ab90ddce01575fbe3f6dc6031f0.tar.gz
android_packages_apps_Trebuchet-7a61cbce95468ab90ddce01575fbe3f6dc6031f0.tar.bz2
android_packages_apps_Trebuchet-7a61cbce95468ab90ddce01575fbe3f6dc6031f0.zip
AppsCustomize: Generic Implementation
Preparation for upcoming vertical drawer. Change-Id: I12e9a217bd9172d661d8a397f9a2b64b36d19e3f
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/trebuchet/ApplicationInfo.java2
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java206
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java160
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeView.java (renamed from src/com/cyanogenmod/trebuchet/AllAppsView.java)47
-rw-r--r--src/com/cyanogenmod/trebuchet/DeleteDropTarget.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/InfoDropTarget.java2
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java29
7 files changed, 258 insertions, 192 deletions
diff --git a/src/com/cyanogenmod/trebuchet/ApplicationInfo.java b/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
index 884c34a25..7c506c2a2 100644
--- a/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
@@ -28,7 +28,7 @@ import java.util.ArrayList;
import java.util.HashMap;
/**
- * Represents an app in AllAppsView.
+ * Represents an app in AppsCustomizeView.
*/
class ApplicationInfo extends ItemInfo {
private static final String TAG = "Launcher.ApplicationInfo";
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 82ad7d044..7b39c9f6f 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -16,6 +16,8 @@
package com.cyanogenmod.trebuchet;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
@@ -39,12 +41,16 @@ import android.util.Log;
import android.view.*;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
+import android.widget.FrameLayout;
import android.widget.GridLayout;
import android.widget.ImageView;
import android.widget.Toast;
import com.cyanogenmod.trebuchet.DropTarget.DragObject;
import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
+import static com.cyanogenmod.trebuchet.AppsCustomizeView.ContentType;
+import static com.cyanogenmod.trebuchet.AppsCustomizeView.SortMode;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -119,7 +125,7 @@ class AsyncTaskPageData {
* A generic template for an async task used in AppsCustomize.
*/
class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTaskPageData> {
- AppsCustomizeAsyncTask(int p, AppsCustomizePagedView.ContentType t, AsyncTaskPageData.Type ty) {
+ AppsCustomizeAsyncTask(int p, AppsCustomizeView.ContentType t, AsyncTaskPageData.Type ty) {
page = p;
pageContentType = t;
threadPriority = Process.THREAD_PRIORITY_DEFAULT;
@@ -148,7 +154,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;
+ AppsCustomizeView.ContentType pageContentType;
int threadPriority;
}
@@ -156,25 +162,9 @@ class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTas
* The Apps/Customize page that displays all the applications, widgets, and shortcuts.
*/
public class AppsCustomizePagedView extends PagedViewWithDraggableItems implements
- AllAppsView, View.OnClickListener, View.OnKeyListener, DragSource {
+ AppsCustomizeView, View.OnClickListener, View.OnKeyListener, DragSource {
static final String LOG_TAG = "AppsCustomizePagedView";
- /**
- * The different content types that this paged view can show.
- */
- public enum ContentType {
- Applications,
- Widgets
- }
-
- /**
- * The sorting mode of the apps.
- */
- public enum SortMode {
- Title,
- InstallDate
- }
-
// Refs
private Launcher mLauncher;
private DragController mDragController;
@@ -238,7 +228,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
mPackageManager = context.getPackageManager();
- mContentType = ContentType.Applications;
+ mContentType = ContentType.Apps;
mApps = new ArrayList<ApplicationInfo>();
mWidgets = new ArrayList<Object>();
mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
@@ -330,7 +320,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
} else {
switch (mContentType) {
- case Applications: {
+ case Apps: {
PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage);
PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout();
int numItemsPerPage = mCellCountX * mCellCountY;
@@ -354,7 +344,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
/** Get the index of the item to restore to if we need to restore the current page. */
- int getSaveInstanceStateIndex() {
+ public int getSaveInstanceStateIndex() {
if (mSaveInstanceStateItemIndex == -1) {
mSaveInstanceStateItemIndex = getMiddleComponentIndexOnCurrentPage();
}
@@ -376,7 +366,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
} else {
switch (mContentType) {
- case Applications: {
+ case Apps: {
int numItemsPerPage = mCellCountX * mCellCountY;
return (index / numItemsPerPage);
}
@@ -392,9 +382,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
* This differs from isDataReady as this is the test done if isDataReady is not set.
*/
private boolean testDataReady() {
- // We only do this test once, and we default to the Applications page, so we only really
+ // We only do this test once, and we default to the Apps page, so we only really
// have to wait for there to be apps.
- if (mContentType == AppsCustomizePagedView.ContentType.Widgets || mJoinWidgetsApps) {
+ if (mContentType == ContentType.Widgets || mJoinWidgetsApps) {
return !mApps.isEmpty() && !mWidgets.isEmpty();
} else {
return !mApps.isEmpty();
@@ -402,7 +392,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
/** Restores the page for an item at the specified index */
- void restorePageForIndex(int index) {
+ public void restore(int index) {
+ loadAssociatedPages(mCurrentPage);
if (index < 0) return;
mSaveInstanceStateItemIndex = index;
}
@@ -470,7 +461,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
- void showAllAppsCling() {
+ public void showAllAppsCling() {
Cling allAppsCling = (Cling) getTabHost().findViewById(R.id.all_apps_cling);
if (!mHasShownAllAppsCling && isDataReady() && testDataReady()) {
mHasShownAllAppsCling = true;
@@ -717,7 +708,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
cancelAllTasks();
}
- public void clearAllWidgetPages() {
+ public void clearAllWidgetPreviews() {
cancelAllTasks();
int count = getChildCount();
for (int i = 0; i < count; i++) {
@@ -739,16 +730,20 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ public ContentType getContentType() {
+ return mContentType;
+ }
+
public void setContentType(ContentType type) {
+ mContentType = type;
if (mJoinWidgetsApps) {
if (type == ContentType.Widgets) {
invalidatePageData(mNumAppsPages, true);
- } else if (type == ContentType.Applications) {
+ } else if (type == ContentType.Apps) {
invalidatePageData(0, true);
}
} else {
- mContentType = type;
- invalidatePageData(0, (type != ContentType.Applications));
+ invalidatePageData(0, (type != ContentType.Apps));
}
}
@@ -780,8 +775,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
!tag.equals(tabHost.getTabTagForContentType(ContentType.Widgets))) {
tabHost.setCurrentTabFromContent(ContentType.Widgets);
} else if (currentPage < mNumAppsPages &&
- !tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
- tabHost.setCurrentTabFromContent(ContentType.Applications);
+ !tag.equals(tabHost.getTabTagForContentType(ContentType.Apps))) {
+ tabHost.setCurrentTabFromContent(ContentType.Apps);
}
}
}
@@ -791,10 +786,125 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return (mContentType == type);
}
- public void setCurrentPageToWidgets() {
+ public void setCurrentToApps() {
+ }
+
+ public void setCurrentToWidgets() {
invalidatePageData(0);
}
+ public void reloadCurrentPage() {
+ if (!LauncherApplication.isScreenLarge()) {
+ flashScrollingIndicator(true);
+ }
+ loadAssociatedPages(mCurrentPage);
+ requestFocus();
+ }
+
+ public void loadContent() {
+ loadAssociatedPages(mCurrentPage);
+ }
+
+ public void loadContent(boolean immediately) {
+ loadAssociatedPages(mCurrentPage, immediately);
+ }
+
+ public void onTabChanged(final ContentType type) {
+ if (!isContentType(type) || mJoinWidgetsApps) {
+ // 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 (getMeasuredWidth() <= 0 ||
+ 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];
+ getVisiblePages(visiblePageRange);
+ if (visiblePageRange[0] == -1 && visiblePageRange[1] == -1) {
+ // If we can't get the visible page ranges, then just skip the animation
+ reloadCurrentPage();
+ return;
+ }
+ ArrayList<View> visiblePages = new ArrayList<View>();
+ for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
+ visiblePages.add(getPageAt(i));
+ }
+
+ final FrameLayout animationBuffer =
+ (FrameLayout) getTabHost().findViewById(R.id.animation_buffer);
+ final AppsCustomizePagedView self =
+ (AppsCustomizePagedView) getTabHost().findViewById(R.id.apps_customize_pane_content);
+
+ // 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 animationBuffer
+ // to be exactly the same as mAppsCustomizePane, and below, set the left/top
+ // parameters to be correct for each of the pages
+ animationBuffer.scrollTo(getScrollX(), 0);
+
+ // mAppsCustomizePane renders its children in reverse order, so
+ // add the pages to animationBuffer in reverse order to match that behavior
+ for (int i = visiblePages.size() - 1; i >= 0; i--) {
+ View child = visiblePages.get(i);
+ if (child instanceof PagedViewCellLayout) {
+ ((PagedViewCellLayout) child).resetChildrenOnKeyListeners();
+ } else if (child instanceof PagedViewGridLayout) {
+ ((PagedViewGridLayout) child).resetChildrenOnKeyListeners();
+ }
+ PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false);
+ removeView(child);
+ PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
+ animationBuffer.setAlpha(1f);
+ animationBuffer.setVisibility(View.VISIBLE);
+ FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(child.getWidth(),
+ child.getHeight());
+ p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
+ animationBuffer.addView(child, p);
+ }
+
+ // Toggle the new content
+ hideScrollingIndicator(false);
+ setContentType(type);
+
+ // Animate the transition
+ ObjectAnimator outAnim = ObjectAnimator.ofFloat(animationBuffer, "alpha", 0f);
+ outAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ animationBuffer.setVisibility(View.GONE);
+ animationBuffer.removeAllViews();
+ }
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ animationBuffer.setVisibility(View.GONE);
+ animationBuffer.removeAllViews();
+ }
+ });
+ ObjectAnimator inAnim = ObjectAnimator.ofFloat(self, "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();
+ }
+ });
+ }
+ }
+
/*
* Apps PagedView implementation
*/
@@ -1386,7 +1496,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
} else {
switch (mContentType) {
- case Applications:
+ case Apps:
syncAppsPages();
break;
case Widgets:
@@ -1406,7 +1516,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
} else {
switch (mContentType) {
- case Applications:
+ case Apps:
syncAppsPageItems(page, immediate);
break;
case Widgets:
@@ -1530,7 +1640,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
/*
- * AllAppsView implementation
+ * AppsCustomizeView implementation
*/
@Override
public void setup(Launcher launcher, DragController dragController) {
@@ -1560,7 +1670,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
syncAppsPageItems(i, true);
}
} else {
- if (mContentType == ContentType.Applications) {
+ if (mContentType == ContentType.Apps) {
for (int i = 0; i < getChildCount(); i++) {
syncAppsPageItems(i, true);
}
@@ -1568,6 +1678,18 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ public void showIndicator(boolean immediately) {
+ showScrollingIndicator(immediately);
+ }
+
+ public void hideIndicator(boolean immediately) {
+ hideScrollingIndicator(immediately);
+ }
+
+ public void flashIndicator(boolean immediately) {
+ flashScrollingIndicator(!immediately);
+ }
+
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
@@ -1646,12 +1768,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
AppsCustomizeTabHost tabHost = getTabHost();
String tag = tabHost.getCurrentTabTag();
if (tag != null) {
- if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
- tabHost.setCurrentTabFromContent(ContentType.Applications);
+ if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Apps))) {
+ tabHost.setCurrentTabFromContent(ContentType.Apps);
}
}
} else {
- if (mContentType != ContentType.Applications) {
+ if (mContentType != ContentType.Apps) {
// Reset to the first page of the Apps pane
AppsCustomizeTabHost tabs = (AppsCustomizeTabHost)
mLauncher.findViewById(R.id.apps_customize_pane);
@@ -1744,7 +1866,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return String.format(mContext.getString(stringId), page + 1, count);
} else {
switch (mContentType) {
- case Applications:
+ case Apps:
stringId = R.string.apps_customize_apps_scroll_format;
break;
case Widgets:
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
index 99bcff9df..a7aa1a659 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -42,7 +42,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private final LayoutInflater mLayoutInflater;
private ViewGroup mTabs;
private ViewGroup mTabsContainer;
- private AppsCustomizePagedView mAppsCustomizePane;
+ private AppsCustomizeView mAppsCustomizePane;
private boolean mSuppressContentCallback = false;
private FrameLayout mAnimationBuffer;
private LinearLayout mContent;
@@ -54,7 +54,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private Animator mLauncherTransition;
// Preferences
- private boolean mJoinWidgetsApps;
private boolean mFadeScrollingIndicator;
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
@@ -64,7 +63,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mLauncher = (Launcher) context;
// Preferences
- mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
}
@@ -74,17 +72,17 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
* reflects the new content (but doesn't do the animation and logic associated with changing
* tabs manually).
*/
- private void setContentTypeImmediate(AppsCustomizePagedView.ContentType type) {
- onTabChangedStart();
- onTabChangedEnd(type);
+ private void setContentTypeImmediate(AppsCustomizeView.ContentType type) {
+ mAppsCustomizePane.hideIndicator(false);
+ mAppsCustomizePane.setContentType(type);
}
void selectAppsTab() {
- setContentTypeImmediate(AppsCustomizePagedView.ContentType.Applications);
+ setContentTypeImmediate(AppsCustomizeView.ContentType.Apps);
setCurrentTabByTag(APPS_TAB_TAG);
}
void selectWidgetsTab() {
- setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets);
- mAppsCustomizePane.setCurrentPageToWidgets();
+ setContentTypeImmediate(AppsCustomizeView.ContentType.Widgets);
+ mAppsCustomizePane.setCurrentToWidgets();
setCurrentTabByTag(WIDGETS_TAB_TAG);
}
@@ -99,7 +97,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
final ViewGroup tabsContainer = (ViewGroup) findViewById(R.id.tabs_container);
final TabWidget tabs = (TabWidget) findViewById(com.android.internal.R.id.tabs);
- final AppsCustomizePagedView appsCustomizePane = (AppsCustomizePagedView)
+ final AppsCustomizeView appsCustomizePane = (AppsCustomizeView)
findViewById(R.id.apps_customize_pane_content);
mTabs = tabs;
mTabsContainer = tabsContainer;
@@ -112,7 +110,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// content filter on)
TabContentFactory contentFactory = new TabContentFactory() {
public View createTabContent(String tag) {
- return appsCustomizePane;
+ return (View) appsCustomizePane;
}
};
@@ -159,7 +157,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// Set the width of the tab list to the content width
if (remeasureTabWidth) {
- int contentWidth = mAppsCustomizePane.getPageContentWidth();
+ int contentWidth = ((View) mAppsCustomizePane).getMeasuredWidth();
if (contentWidth > 0 && mTabs.getLayoutParams().width != contentWidth) {
// Set the width and show the tab bar
mTabs.getLayoutParams().width = contentWidth;
@@ -178,127 +176,25 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
public boolean onTouchEvent(MotionEvent event) {
// Intercept all touch events up to the bottom of the AppsCustomizePane so they do not fall
// through to the workspace and trigger showWorkspace()
- if (event.getY() < mAppsCustomizePane.getBottom()) {
+ if (event.getY() < ((View) mAppsCustomizePane).getBottom()) {
return true;
}
return super.onTouchEvent(event);
}
- private void onTabChangedStart() {
- mAppsCustomizePane.hideScrollingIndicator(false);
- }
-
- private void reloadCurrentPage() {
- if (!LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.flashScrollingIndicator(true);
- }
- mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
- mAppsCustomizePane.requestFocus();
- }
-
- private void onTabChangedEnd(AppsCustomizePagedView.ContentType type) {
- mAppsCustomizePane.setContentType(type);
- }
-
@Override
public void onTabChanged(String tabId) {
- final AppsCustomizePagedView.ContentType type = getContentTypeForTabTag(tabId);
+ final AppsCustomizeView.ContentType type = getContentTypeForTabTag(tabId);
if (mSuppressContentCallback) {
mSuppressContentCallback = false;
return;
}
- if (!mAppsCustomizePane.isContentType(type) || mJoinWidgetsApps) {
- // 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;
- }
-
- // 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
- reloadCurrentPage();
- return;
- }
- ArrayList<View> visiblePages = new ArrayList<View>();
- for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
- visiblePages.add(mAppsCustomizePane.getPageAt(i));
- }
+ mAppsCustomizePane.onTabChanged(type);
- // 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
- // parameters to be correct for each of the pages
- mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0);
-
- // 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);
- if (child instanceof PagedViewCellLayout) {
- ((PagedViewCellLayout) child).resetChildrenOnKeyListeners();
- } else if (child instanceof PagedViewGridLayout) {
- ((PagedViewGridLayout) child).resetChildrenOnKeyListeners();
- }
- 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(child.getLeft(), 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();
- }
- });
- }
}
- public void setCurrentTabFromContent(AppsCustomizePagedView.ContentType type) {
+ public void setCurrentTabFromContent(AppsCustomizeView.ContentType type) {
mSuppressContentCallback = true;
setCurrentTabByTag(getTabTagForContentType(type));
}
@@ -306,22 +202,22 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
/**
* Returns the content type for the specified tab tag.
*/
- public AppsCustomizePagedView.ContentType getContentTypeForTabTag(String tag) {
+ public AppsCustomizeView.ContentType getContentTypeForTabTag(String tag) {
if (tag.equals(APPS_TAB_TAG)) {
- return AppsCustomizePagedView.ContentType.Applications;
+ return AppsCustomizeView.ContentType.Apps;
} else if (tag.equals(WIDGETS_TAB_TAG)) {
- return AppsCustomizePagedView.ContentType.Widgets;
+ return AppsCustomizeView.ContentType.Widgets;
}
- return AppsCustomizePagedView.ContentType.Applications;
+ return AppsCustomizeView.ContentType.Apps;
}
/**
* Returns the tab tag for a given content type.
*/
- public String getTabTagForContentType(AppsCustomizePagedView.ContentType type) {
- if (type == AppsCustomizePagedView.ContentType.Applications) {
+ public String getTabTagForContentType(AppsCustomizeView.ContentType type) {
+ if (type == AppsCustomizeView.ContentType.Apps) {
return APPS_TAB_TAG;
- } else if (type == AppsCustomizePagedView.ContentType.Widgets) {
+ } else if (type == AppsCustomizeView.ContentType.Widgets) {
return WIDGETS_TAB_TAG;
}
return APPS_TAB_TAG;
@@ -390,14 +286,14 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
if (!toWorkspace) {
// Make sure the current page is loaded (we start loading the side pages after the
// transition to prevent slowing down the animation)
- mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
+ mAppsCustomizePane.loadContent(true);
}
if (animated && !delayLauncherTransitionUntilLayout) {
enableAndBuildHardwareLayer();
}
if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.showScrollingIndicator(false);
+ mAppsCustomizePane.showIndicator(false);
}
if (mResetAfterTransition) {
mAppsCustomizePane.reset();
@@ -419,10 +315,10 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mAppsCustomizePane.showAllAppsCling();
// Make sure adjacent pages are loaded (we wait until after the transition to
// prevent slowing down the animation)
- mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
+ mAppsCustomizePane.loadContent();
if (!LauncherApplication.isScreenLarge() && mFadeScrollingIndicator) {
- mAppsCustomizePane.hideScrollingIndicator(false);
+ mAppsCustomizePane.hideIndicator(false);
}
}
}
@@ -432,8 +328,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mContent.setVisibility(VISIBLE);
// We unload the widget previews when the UI is hidden, so need to reload pages
// Load the current page synchronously, and the neighboring pages asynchronously
- mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
- mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
+ mAppsCustomizePane.loadContent(true);
+ mAppsCustomizePane.loadContent();
}
}
@@ -441,7 +337,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mContent.setVisibility(GONE);
// Clear the widget pages of all their subviews - this will trigger the widget previews
// to delete their bitmaps
- mAppsCustomizePane.clearAllWidgetPages();
+ mAppsCustomizePane.clearAllWidgetPreviews();
}
boolean isTransitioning() {
diff --git a/src/com/cyanogenmod/trebuchet/AllAppsView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeView.java
index 6065914e0..dfb191713 100644
--- a/src/com/cyanogenmod/trebuchet/AllAppsView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeView.java
@@ -18,9 +18,46 @@ package com.cyanogenmod.trebuchet;
import java.util.ArrayList;
-public interface AllAppsView {
+public interface AppsCustomizeView {
+
+ public enum ContentType {
+ Apps,
+ Widgets
+ }
+
+ public enum SortMode {
+ Title,
+ InstallDate
+ }
+
public void setup(Launcher launcher, DragController dragController);
+ public ContentType getContentType();
+
+ public void setContentType(ContentType type);
+
+ public boolean isContentType(ContentType type);
+
+ public SortMode getSortMode();
+
+ public void showIndicator(boolean immediately);
+
+ public void hideIndicator(boolean immediately);
+
+ public void loadContent();
+
+ public void loadContent(boolean immediately);
+
+ public void onTabChanged(ContentType type);
+
+ public void showAllAppsCling();
+
+ public void setCurrentToApps();
+
+ public void setCurrentToWidgets();
+
+ public void setSortMode(SortMode mode);
+
public void setApps(ArrayList<ApplicationInfo> list);
public void addApps(ArrayList<ApplicationInfo> list);
@@ -29,8 +66,16 @@ public interface AllAppsView {
public void updateApps(ArrayList<ApplicationInfo> list);
+ public void onPackagesUpdated();
+
public void reset();
+ public void clearAllWidgetPreviews();
+
+ public int getSaveInstanceStateIndex();
+
+ public void restore(int restoreIndex);
+
public void dumpState();
public void surrender();
diff --git a/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java b/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java
index 1699c94e9..131882895 100644
--- a/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java
+++ b/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java
@@ -79,10 +79,10 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
private boolean isAllAppsApplication(DragSource source, Object info) {
- return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo);
+ return (source instanceof AppsCustomizeView) && (info instanceof ApplicationInfo);
}
private boolean isAllAppsWidget(DragSource source, Object info) {
- return (source instanceof AppsCustomizePagedView) && (info instanceof PendingAddWidgetInfo);
+ return (source instanceof AppsCustomizeView) && (info instanceof PendingAddWidgetInfo);
}
private boolean isDragSourceWorkspaceOrFolder(DragObject d) {
return (d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder);
diff --git a/src/com/cyanogenmod/trebuchet/InfoDropTarget.java b/src/com/cyanogenmod/trebuchet/InfoDropTarget.java
index 0213f8c63..8420d47e1 100644
--- a/src/com/cyanogenmod/trebuchet/InfoDropTarget.java
+++ b/src/com/cyanogenmod/trebuchet/InfoDropTarget.java
@@ -66,7 +66,7 @@ public class InfoDropTarget extends ButtonDropTarget {
}
private boolean isAllAppsApplication(DragSource source, Object info) {
- return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo);
+ return (source instanceof AppsCustomizeView) && (info instanceof ApplicationInfo);
}
@Override
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 033eaf139..dbfaf7670 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -152,7 +152,7 @@ public final class Launcher extends Activity
private SearchDropTargetBar mSearchDropTargetBar;
private AppsCustomizeTabHost mAppsCustomizeTabHost;
- private AppsCustomizePagedView mAppsCustomizeContent;
+ private AppsCustomizeView mAppsCustomizeContent;
private boolean mAutoAdvanceRunning = false;
private Bundle mSavedState;
@@ -275,7 +275,7 @@ public final class Launcher extends Activity
}
if (!mModel.isAllAppsLoaded()) {
- ViewGroup appsCustomizeContentParent = (ViewGroup) mAppsCustomizeContent.getParent();
+ ViewGroup appsCustomizeContentParent = (ViewGroup) ((View) mAppsCustomizeContent).getParent();
mInflater.inflate(R.layout.apps_customize_progressbar, appsCustomizeContentParent);
}
@@ -703,12 +703,10 @@ public final class Launcher extends Activity
mAppsCustomizeContent.setContentType(
mAppsCustomizeTabHost.getContentTypeForTabTag(curTab));
mAppsCustomizeTabHost.setCurrentTabByTag(curTab);
- mAppsCustomizeContent.loadAssociatedPages(
- mAppsCustomizeContent.getCurrentPage());
}
int currentIndex = savedState.getInt("apps_customize_currentIndex");
- mAppsCustomizeContent.restorePageForIndex(currentIndex);
+ mAppsCustomizeContent.restore(currentIndex);
}
}
@@ -749,7 +747,7 @@ public final class Launcher extends Activity
// Setup AppsCustomize
mAppsCustomizeTabHost = (AppsCustomizeTabHost)
findViewById(R.id.apps_customize_pane);
- mAppsCustomizeContent = (AppsCustomizePagedView)
+ mAppsCustomizeContent = (AppsCustomizeView)
mAppsCustomizeTabHost.findViewById(R.id.apps_customize_pane_content);
mAppsCustomizeContent.setup(this, dragController);
@@ -1739,25 +1737,30 @@ public final class Launcher extends Activity
final Menu menu = popupMenu.getMenu();
dismissAllAppsSortCling(null);
popupMenu.inflate(R.menu.apps_tab);
- AppsCustomizePagedView.SortMode sortMode = mAppsCustomizeContent.getSortMode();
- if (sortMode == AppsCustomizePagedView.SortMode.Title) {
- menu.findItem(R.id.apps_sort_title).setChecked(true);
- } else if (sortMode == AppsCustomizePagedView.SortMode.InstallDate) {
- menu.findItem(R.id.apps_sort_install_date).setChecked(true);
+ AppsCustomizeView.SortMode sortMode = mAppsCustomizeContent.getSortMode();
+ switch (sortMode) {
+ case Title:
+ menu.findItem(R.id.apps_sort_title).setChecked(true);
+ break;
+ case InstallDate:
+ menu.findItem(R.id.apps_sort_install_date).setChecked(true);
+ break;
}
+
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.apps_sort_title:
- mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.Title);
+ mAppsCustomizeContent.setSortMode(AppsCustomizeView.SortMode.Title);
break;
case R.id.apps_sort_install_date:
- mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.InstallDate);
+ mAppsCustomizeContent.setSortMode(AppsCustomizeView.SortMode.InstallDate);
break;
}
return true;
}
});
+
popupMenu.show();
}