summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Folder.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-03-10 13:14:47 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-03-17 14:49:38 -0700
commit5d85c44fd873c740dc191b28424c2ee367d730a2 (patch)
tree293001622c1888852f148a138b542563c6131dd4 /src/com/android/launcher3/Folder.java
parentce53e6dd12f5fa9e16ea77fbdafed3f8c2f448ac (diff)
downloadandroid_packages_apps_Trebuchet-5d85c44fd873c740dc191b28424c2ee367d730a2.tar.gz
android_packages_apps_Trebuchet-5d85c44fd873c740dc191b28424c2ee367d730a2.tar.bz2
android_packages_apps_Trebuchet-5d85c44fd873c740dc191b28424c2ee367d730a2.zip
Adding sort switch in FolderPagedView
> Adding options column in DB to store generation purpose flags > Storing isSorted flag in FolderInfo > Adding a switch for A-Z sorting (only visible if pageCount > 1) > When in sorted mode, spring-load snaps to the target location for 1.5 seconds Change-Id: I8c7c778d2cc3ccbd35a2890a1a705e1c1a7e9a66
Diffstat (limited to 'src/com/android/launcher3/Folder.java')
-rw-r--r--src/com/android/launcher3/Folder.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 7ff60de4f..deb94ca28 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -86,6 +86,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
public static final int SCROLL_HINT_DURATION = DragController.SCROLL_DELAY;
/**
+ * Time in milliseconds for which an icon sticks to the target position
+ * in case of a sorted folder.
+ */
+ private static final int SORTED_STICKY_REORDER_DELAY = 1500;
+
+ /**
* Fraction of icon width which behave as scroll region.
*/
private static final float ICON_OVERSCROLL_WIDTH_FACTOR = 0.45f;
@@ -423,8 +429,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
if (!(getParent() instanceof DragLayer)) return;
if (ALLOW_FOLDER_SCROLL) {
- // Always open on the first page.
- mPagedView.snapToPageImmediately(0);
+ mPagedView.completePendingPageChanges();
+ if (!(mDragInProgress && mPagedView.mIsSorted)) {
+ // Open on the first page.
+ mPagedView.snapToPageImmediately(0);
+ }
}
Animator openFolderAnim = null;
@@ -531,9 +540,15 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
public void beginExternalDrag(ShortcutInfo item) {
mCurrentDragInfo = item;
- mEmptyCellRank = mContent.allocateNewLastItemRank();
+ mEmptyCellRank = mContent.allocateRankForNewItem(item);
mIsExternalDrag = true;
mDragInProgress = true;
+ if (ALLOW_FOLDER_SCROLL && mPagedView.mIsSorted) {
+ mScrollPauseAlarm.setOnAlarmListener(null);
+ mScrollPauseAlarm.cancelAlarm();
+ mScrollPauseAlarm.setAlarm(SORTED_STICKY_REORDER_DELAY);
+ }
+
}
private void sendCustomAccessibilityEvent(int type, String text) {
@@ -747,6 +762,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
if (!successfulDrop) {
mSuppressFolderDeletion = true;
}
+ mScrollPauseAlarm.cancelAlarm();
completeDragExit();
}
}
@@ -1155,7 +1171,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
// If the item was dropped onto this open folder, we have done the work associated
// with adding the item to the folder, as indicated by mSuppressOnAdd being set
if (mSuppressOnAdd) return;
- mContent.createAndAddViewForRank(item, mContent.allocateNewLastItemRank());
+ mContent.createAndAddViewForRank(item, mContent.allocateRankForNewItem(item));
LauncherModel.addOrMoveItemInDatabase(
mLauncher, item, mInfo.id, 0, item.cellX, item.cellY);
}
@@ -1304,10 +1320,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
ArrayList<ShortcutInfo> bindItems(ArrayList<ShortcutInfo> children);
/**
- * Create space for a new item at the end, and returns the rank for that item.
+ * Create space for a new item, and returns the rank for that item.
* Resizes the content if necessary.
*/
- int allocateNewLastItemRank();
+ int allocateRankForNewItem(ShortcutInfo info);
View createAndAddViewForRank(ShortcutInfo item, int rank);