summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornebkat <nebkat@gmail.com>2011-12-26 12:36:32 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-08-13 14:23:50 +0100
commit652dd873e6744ea19d3bb2593e683ca68367e8e8 (patch)
tree45d310dfe8b96fd74cfb13ab1855971d08591a06 /src
parent95abe447a101d2d71a63d2cc5e57f06f4239fe9a (diff)
downloadandroid_packages_apps_Trebuchet-652dd873e6744ea19d3bb2593e683ca68367e8e8.tar.gz
android_packages_apps_Trebuchet-652dd873e6744ea19d3bb2593e683ca68367e8e8.tar.bz2
android_packages_apps_Trebuchet-652dd873e6744ea19d3bb2593e683ca68367e8e8.zip
AppsCustomize: Apps Sorting Mode
Change-Id: I9b376c39da3039b7c9a37f0748a1d6b5dc67a471
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java52
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java9
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java27
3 files changed, 86 insertions, 2 deletions
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index eaa3636bb..e114558ec 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -249,6 +249,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;
@@ -262,6 +270,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Content
private ContentType mContentType;
+ private SortMode mSortMode = SortMode.Title;
private ArrayList<ApplicationInfo> mApps;
private ArrayList<Object> mWidgets;
@@ -1868,10 +1877,44 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ 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();
invalidateOnDataChange();
}
@@ -1880,7 +1923,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 355ac4260..b1e75b37b 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -74,6 +74,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mTabsContainer.setAlpha(1f);
}
};
+
+ mLauncher = (Launcher) context;
+
// Preferences
mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
@@ -138,6 +141,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 = getContext().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 a345df63c..806a0e68c 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -89,6 +89,7 @@ import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.ImageView;
+import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
@@ -1945,6 +1946,32 @@ public final class Launcher extends Activity
}
}
+ 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();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,