summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
diff options
context:
space:
mode:
authorWinson <winsonc@google.com>2015-08-18 17:43:02 -0700
committerWinson Chung <winsonc@google.com>2015-08-20 19:25:48 +0000
commitd2eb49e4c3bb37d35e72c36d8a308262b690075f (patch)
treee3996eded022f712e48c2721d5315c069c6eb831 /src/com/android/launcher3/allapps/AlphabeticalAppsList.java
parent97b0d08d92c64034ba03ae8da5a8531edbd60d52 (diff)
downloadandroid_packages_apps_Trebuchet-d2eb49e4c3bb37d35e72c36d8a308262b690075f.tar.gz
android_packages_apps_Trebuchet-d2eb49e4c3bb37d35e72c36d8a308262b690075f.tar.bz2
android_packages_apps_Trebuchet-d2eb49e4c3bb37d35e72c36d8a308262b690075f.zip
Tweaking fast scroller to follow touch closer.
- Issue: The fast scroller currently does not follow the touch input because fundamentally, the fixed scrollbar height and the mapping of the scroll space to the scrollbar space is fundamentally incompatible. - This CL changes the fast scroller to allow it to detach when the user fast-scrolls, then re-attaches after the user scrolls the screen and the current scroll position for the scrollbar picks up the thumb position. - Since the scroll position and the fast scroller thumb is now detached, we can change the distribution of the fast scroll letters to make it independent of the rows for each section and instead uniformly distribute it along the scrollbar, which allows for more stability. - There are edge cases where this fails, especially when there are few apps, which we can investigate further. Bug: 20035978 Change-Id: I8322f862107e6f330deff692885233706564bffd
Diffstat (limited to 'src/com/android/launcher3/allapps/AlphabeticalAppsList.java')
-rw-r--r--src/com/android/launcher3/allapps/AlphabeticalAppsList.java59
1 files changed, 37 insertions, 22 deletions
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 396f75790..dac0df12a 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -43,6 +43,11 @@ public class AlphabeticalAppsList {
private static final boolean DEBUG = false;
private static final boolean DEBUG_PREDICTIONS = false;
+ private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION = 0;
+ private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS = 1;
+
+ private final int mFastScrollDistributionMode = FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS;
+
/**
* Info about a section in the alphabetic list
*/
@@ -85,8 +90,6 @@ public class AlphabeticalAppsList {
/** Section & App properties */
// The section for this item
public SectionInfo sectionInfo;
- // The row that this item shows up on
- public int rowIndex;
/** App-only properties */
// The section name of this app. Note that there can be multiple items with different
@@ -94,6 +97,8 @@ public class AlphabeticalAppsList {
public String sectionName = null;
// The index of this app in the section
public int sectionAppIndex = -1;
+ // The row that this item shows up on
+ public int rowIndex;
// The index of this app in the row
public int rowAppIndex;
// The associated AppInfo for the app
@@ -188,7 +193,6 @@ public class AlphabeticalAppsList {
private int mNumAppsPerRow;
private int mNumPredictedAppsPerRow;
private int mNumAppRowsInAdapter;
- private boolean mDisableEmptyText;
public AlphabeticalAppsList(Context context) {
mLauncher = (Launcher) context;
@@ -216,13 +220,6 @@ public class AlphabeticalAppsList {
}
/**
- * Disables the empty text message when there are no search results.
- */
- public void disableEmptyText() {
- mDisableEmptyText = true;
- }
-
- /**
* Returns all the apps.
*/
public List<AppInfo> getApps() {
@@ -523,18 +520,36 @@ public class AlphabeticalAppsList {
}
mNumAppRowsInAdapter = rowIndex + 1;
- // Pre-calculate all the fast scroller fractions based on the number of rows
- float rowFraction = 1f / mNumAppRowsInAdapter;
- for (FastScrollSectionInfo info : mFastScrollerSections) {
- AdapterItem item = info.fastScrollToItem;
- if (item.viewType != AllAppsGridAdapter.ICON_VIEW_TYPE &&
- item.viewType != AllAppsGridAdapter.PREDICTION_ICON_VIEW_TYPE) {
- info.touchFraction = 0f;
- continue;
- }
-
- float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
- info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
+ // Pre-calculate all the fast scroller fractions
+ switch (mFastScrollDistributionMode) {
+ case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION:
+ float rowFraction = 1f / mNumAppRowsInAdapter;
+ for (FastScrollSectionInfo info : mFastScrollerSections) {
+ AdapterItem item = info.fastScrollToItem;
+ if (item.viewType != AllAppsGridAdapter.ICON_VIEW_TYPE &&
+ item.viewType != AllAppsGridAdapter.PREDICTION_ICON_VIEW_TYPE) {
+ info.touchFraction = 0f;
+ continue;
+ }
+
+ float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
+ info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
+ }
+ break;
+ case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS:
+ float perSectionTouchFraction = 1f / mFastScrollerSections.size();
+ float cumulativeTouchFraction = 0f;
+ for (FastScrollSectionInfo info : mFastScrollerSections) {
+ AdapterItem item = info.fastScrollToItem;
+ if (item.viewType != AllAppsGridAdapter.ICON_VIEW_TYPE &&
+ item.viewType != AllAppsGridAdapter.PREDICTION_ICON_VIEW_TYPE) {
+ info.touchFraction = 0f;
+ continue;
+ }
+ info.touchFraction = cumulativeTouchFraction;
+ cumulativeTouchFraction += perSectionTouchFraction;
+ }
+ break;
}
}