summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/trebuchet
diff options
context:
space:
mode:
authornebkat <nebkat@gmail.com>2011-12-26 12:36:32 +0000
committernebkat <nebkat@teamhacksung.org>2011-12-29 12:25:31 +0000
commit51480b8f3978c2c464c493ba39caec840228786c (patch)
tree1383b90c35d93a31fee29959c8e13fc7eb93bc7e /src/com/cyanogenmod/trebuchet
parentcd3ed5a32ac51aef267b0b70f325da7118d77317 (diff)
downloadandroid_packages_apps_Trebuchet-51480b8f3978c2c464c493ba39caec840228786c.tar.gz
android_packages_apps_Trebuchet-51480b8f3978c2c464c493ba39caec840228786c.tar.bz2
android_packages_apps_Trebuchet-51480b8f3978c2c464c493ba39caec840228786c.zip
AppsCustomize: Apps Sorting Mode
Change-Id: I9b376c39da3039b7c9a37f0748a1d6b5dc67a471
Diffstat (limited to 'src/com/cyanogenmod/trebuchet')
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java53
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java12
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java25
3 files changed, 87 insertions, 3 deletions
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index c2ad80580..c4274bdd7 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -181,6 +181,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Widgets
}
+ /**
+ * The sorting mode of the apps.
+ */
+ public enum SortMode {
+ Title,
+ InstallDate
+ }
+
// Refs
private Launcher mLauncher;
private DragController mDragController;
@@ -193,6 +201,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Content
private ContentType mContentType;
+ private SortMode mSortMode = SortMode.Title;
private ArrayList<ApplicationInfo> mApps;
private ArrayList<Object> mWidgets;
@@ -1565,10 +1574,45 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public boolean isAnimating() {
return false;
}
+
+ public SortMode getSortMode() {
+ return mSortMode;
+ }
+
+ public void setSortMode(SortMode sortMode) {
+ if (mSortMode == sortMode) {
+ return;
+ }
+
+ mSortMode = sortMode;
+
+ if (mSortMode == SortMode.Title) {
+ Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
+ } else if (mSortMode == SortMode.InstallDate) {
+ Collections.sort(mApps, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
+ }
+
+ if (mJoinWidgetsApps) {
+ for (int i = 0; i < mNumAppsPages; i++) {
+ syncAppsPageItems(i, true);
+ }
+ } else {
+ if (mContentType == ContentType.Applications) {
+ for (int i = 0; i < getChildCount(); i++) {
+ syncAppsPageItems(i, true);
+ }
+ }
+ }
+ }
+
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
- Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
+ if (mSortMode == SortMode.Title) {
+ Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
+ } else if (mSortMode == SortMode.InstallDate) {
+ Collections.sort(mApps, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
+ }
updatePageCounts();
// The next layout pass will trigger data-ready if both widgets and apps are set, so
@@ -1580,7 +1624,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int count = list.size();
for (int i = 0; i < count; ++i) {
ApplicationInfo info = list.get(i);
- int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
+ int index = 0;
+ if (mSortMode == SortMode.Title) {
+ index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
+ } else if (mSortMode == SortMode.InstallDate) {
+ index = Collections.binarySearch(mApps, info, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
+ }
if (index < 0) {
mApps.add(-(index + 1), info);
}
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
index ad02a305a..6a97ea052 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -39,7 +39,7 @@ import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
public class AppsCustomizeTabHost extends TabHost implements LauncherTransitionable,
- TabHost.OnTabChangeListener {
+ TabHost.OnTabChangeListener {
static final String LOG_TAG = "AppsCustomizeTabHost";
private static final String APPS_TAB_TAG = "APPS";
@@ -53,6 +53,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private FrameLayout mAnimationBuffer;
private LinearLayout mContent;
+ private Launcher mLauncher;
+
private boolean mInTransition;
private boolean mResetAfterTransition;
private Animator mLauncherTransition;
@@ -65,6 +67,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
+ mLauncher = (Launcher) context;
+
// Preferences
mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
@@ -125,6 +129,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
tabView.setText(label);
tabView.setContentDescription(label);
+ tabView.setOnLongClickListener(new View.OnLongClickListener() {
+ public boolean onLongClick(View v) {
+ mLauncher.onLongClickAppsTab(v);
+ return true;
+ }
+ });
addTab(newTabSpec(APPS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
label = mContext.getString(R.string.widgets_tab_label);
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 84a798e02..0df98045e 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -1786,6 +1786,31 @@ public final class Launcher extends Activity
popupMenu.show();
}
+ public void onLongClickAppsTab(View v) {
+ final PopupMenu popupMenu = new PopupMenu(this, v);
+ final Menu menu = popupMenu.getMenu();
+ 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);
+ }
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ public boolean onMenuItemClick(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.apps_sort_title:
+ mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.Title);
+ break;
+ case R.id.apps_sort_install_date:
+ mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.InstallDate);
+ break;
+ }
+ return true;
+ }
+ });
+ popupMenu.show();
+ }
void startApplicationDetailsActivity(ComponentName componentName) {
String packageName = componentName.getPackageName();