summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Workspace.java
diff options
context:
space:
mode:
authorMatt Garnes <matt@cyngn.com>2014-01-23 08:56:37 -0800
committerAbhisek Devkota <ciwrl@cyanogenmod.com>2014-06-12 16:33:16 -0700
commit44d180199b36f1ff17edbc7c0c68c0a0298f78f4 (patch)
treee57c09184ef03b8df8a571e247af8a0ba54adf4e /src/com/android/launcher3/Workspace.java
parent9d9a1c05734ba45d117748b28de366c4c345d858 (diff)
downloadandroid_packages_apps_Trebuchet-44d180199b36f1ff17edbc7c0c68c0a0298f78f4.tar.gz
android_packages_apps_Trebuchet-44d180199b36f1ff17edbc7c0c68c0a0298f78f4.tar.bz2
android_packages_apps_Trebuchet-44d180199b36f1ff17edbc7c0c68c0a0298f78f4.zip
GEL Integration (2/2)
Launch search from extra panel to mimic Google Launcher. Changed Trebuchet to build against CM instead of the AOSP SDK. Added support to swipe left from the home screen to enter Google Now, if it is installed. A right swipe will return the user to the home screen. Change-Id: Ia1a77fedea7e67bcd54a6b6d66099f8366d6b1dc
Diffstat (limited to 'src/com/android/launcher3/Workspace.java')
-rw-r--r--src/com/android/launcher3/Workspace.java53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index bba10a118..a5a1f5460 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1257,12 +1257,13 @@ public class Workspace extends SmoothPagedView
if (hasCustomContent() && getNextPage() == 0 && !mCustomContentShowing) {
mCustomContentShowing = true;
+
if (mCustomContentCallbacks != null) {
mCustomContentCallbacks.onShow();
mCustomContentShowTime = System.currentTimeMillis();
mLauncher.updateVoiceButtonProxyVisible(false);
}
- } else if (hasCustomContent() && getNextPage() != 0 && mCustomContentShowing) {
+ } else if (hasCustomContent() && mCustomContentShowing) {
mCustomContentShowing = false;
if (mCustomContentCallbacks != null) {
mCustomContentCallbacks.onHide();
@@ -1296,6 +1297,22 @@ public class Workspace extends SmoothPagedView
snapToPage(whichPage, SLOW_PAGE_SNAP_ANIMATION_DURATION, r);
}
+ @Override
+ protected void snapToPage(int whichPage, int delta, int duration, boolean immediate,
+ TimeInterpolator interpolator) {
+ super.snapToPage(whichPage, delta, duration, immediate, interpolator);
+
+ // Trigger onCustomContentLaunch if we have just snapped to the custom page.
+ int customPageIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID);
+ if (hasCustomContent() && whichPage == customPageIndex && !mCustomContentShowing) {
+ if(!isInOverviewMode()) {
+ mCustomContentShowing = true;
+ // Start Google Now and register the gesture to return to Trebuchet
+ mLauncher.onCustomContentLaunch();
+ }
+ }
+ }
+
protected void snapToPage(int whichPage, int duration, Runnable r) {
if (mDelayedSnapToPageRunnable != null) {
mDelayedSnapToPageRunnable.run();
@@ -1379,6 +1396,7 @@ public class Workspace extends SmoothPagedView
int firstIndex = numCustomPages();
// Exclude the last extra empty screen (if we have > MIN_PARALLAX_PAGE_SPAN pages)
int lastIndex = getChildCount() - 1 - emptyExtraPages;
+
if (isLayoutRtl()) {
int temp = firstIndex;
firstIndex = lastIndex;
@@ -1619,7 +1637,13 @@ public class Workspace extends SmoothPagedView
}
public int numCustomPages() {
- return hasCustomContent() ? 1 : 0;
+ // GEL integration is a special case (not a *real* screen) and should
+ // not be counted as custom content.
+ if(mLauncher.isGelIntegrationEnabled()) {
+ return 0;
+ } else {
+ return hasCustomContent() ? 1 : 0;
+ }
}
public boolean isOnOrMovingToCustomContent() {
@@ -1801,6 +1825,16 @@ public class Workspace extends SmoothPagedView
// Force the wallpaper offset steps to be set again, because another app might have changed
// them
mLastSetWallpaperOffsetSteps = 0f;
+
+ // Never resume to the custom page if GEL integration is enabled.
+ int customPageIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID);
+ // mCustomContentShowing can be lost if the Activity is recreated,
+ // So make sure it is set to the right value.
+ mCustomContentShowing = mCustomContentShowing
+ || (customPageIndex == getCurrentPage() && hasCustomContent());
+ if (mCustomContentShowing && mLauncher.isGelIntegrationEnabled()) {
+ moveToScreen((customPageIndex + 1), true);
+ }
}
@Override
@@ -2082,6 +2116,11 @@ public class Workspace extends SmoothPagedView
int start = numCustomPages();
int end = getChildCount() - 1;
+ // For GEL integration, do not include the first page (GEL)
+ if(mLauncher.isGelIntegrationEnabled()) {
+ start += 1;
+ }
+
range[0] = Math.max(0, Math.min(start, getChildCount() - 1));
range[1] = Math.max(0, end);
}
@@ -4811,7 +4850,15 @@ public class Workspace extends SmoothPagedView
}
void moveToDefaultScreen(boolean animate) {
- moveToScreen(getPageIndexForScreenId(mDefaultScreenId), animate);
+ // Do not use the custom page or index -1 as default,
+ // if GEL integration is enabled.
+ int idx = getPageIndexForScreenId(mDefaultScreenId);
+ int ccIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID);
+ if(hasCustomContent() && (idx == ccIndex || idx == -1)
+ && mLauncher.isGelIntegrationEnabled()) {
+ idx = 1;
+ }
+ moveToScreen(idx, animate);
}
void moveToCustomContentScreen(boolean animate) {