diff options
-rw-r--r-- | src/com/android/launcher3/DragLayer.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/GelIntegrationHelper.java | 25 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 2 |
5 files changed, 61 insertions, 8 deletions
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index 3ff4293af..2dde8e402 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -826,7 +826,13 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang Workspace workspace = mLauncher.getWorkspace(); int width = getMeasuredWidth(); Rect childRect = new Rect(); - getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect); + int firstWorkspaceIndex = 0; + if (mLauncher.hasCustomContentToLeft() && workspace.getChildCount() > 1) { + firstWorkspaceIndex = 1; + } + + getDescendantRectRelativeToSelf(workspace.getChildAt(firstWorkspaceIndex), + childRect); int page = workspace.getNextPage(); final boolean isRtl = isLayoutRtl(); diff --git a/src/com/android/launcher3/GelIntegrationHelper.java b/src/com/android/launcher3/GelIntegrationHelper.java index f43e7e6a0..4d2c4917b 100644 --- a/src/com/android/launcher3/GelIntegrationHelper.java +++ b/src/com/android/launcher3/GelIntegrationHelper.java @@ -2,8 +2,11 @@ package com.android.launcher3; import android.app.Activity; import android.app.ActivityManager; +import android.app.SearchManager; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.service.gesture.EdgeGestureManager; import com.android.internal.util.gesture.EdgeGesturePosition; @@ -15,9 +18,6 @@ import java.util.List; * in CyanogenMod. */ public class GelIntegrationHelper { - // The Intent for the search activity (resolves to Google Now when installed) - public final static String INTENT_ACTION_ASSIST = "android.intent.action.ASSIST"; - private static final String GEL_ACTIVITY = "com.google.android.velvet.ui.VelvetActivity"; private static final String GEL_PACKAGE_NAME = "com.google.android.googlequicksearchbox"; @@ -78,13 +78,26 @@ public class GelIntegrationHelper { int edge = isLayoutRtl ? EDGE_GESTURE_SERVICE_LEFT_EDGE : EDGE_GESTURE_SERVICE_RIGHT_EDGE; edgeGestureManager.updateEdgeGestureActivationListener(mEdgeGestureActivationListener, edge); + // Attempt to use Intent.ACTION_ASSIST, if supported + Intent intent = new Intent(Intent.ACTION_ASSIST); + if (!isIntentSupported(launcherActivity, intent)) { + // Start the Global Search Activity + final SearchManager searchManager = + (SearchManager) launcherActivity.getSystemService(Context.SEARCH_SERVICE); + ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity(); + intent = new Intent(); + intent.setComponent(globalSearchActivity); + } - // Start the Google Now Activity - Intent i = new Intent(INTENT_ACTION_ASSIST); - launcherActivity.startActivity(i); + launcherActivity.startActivity(intent); launcherActivity.overridePendingTransition(0, R.anim.exit_out_right); } + private boolean isIntentSupported(Context context, Intent intent) { + PackageManager pm = context.getPackageManager(); + return pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null; + } + /** * Handle necessary cleanup and reset tasks for GEL integration, to be called from onResume. */ diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 7f145aea2..11b2bf77a 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -143,7 +143,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc private boolean mCancelTap; - private int[] mPageScrolls; + protected int[] mPageScrolls; protected final static int TOUCH_STATE_REST = 0; protected final static int TOUCH_STATE_SCROLLING = 1; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 7e3584115..9617ace5b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2261,6 +2261,38 @@ public class Workspace extends SmoothPagedView setImportantForAccessibility(accessible); } + public void updatePageScrollForCustomPage(boolean enabled) { + int diff; + // If multiple PageScrolls have been computed already, + // find the distance between the first and second scroll. + if(mPageScrolls.length > 1) { + diff = mPageScrolls[1] - mPageScrolls[0]; + } else { + // The scroll distance will just be the width of the viewport + diff = getViewportWidth(); + } + + // Create an ArrayList to hold PageScrolls while we work with them + ArrayList<Integer> list = new ArrayList<Integer>(); + for(int i : mPageScrolls) { + list.add(i); + } + + // If custom page is enabled, add another page scroll entry + if(enabled){ + list.add(list.get(list.size() - 1) + diff); + } else { + // disabling custom page, remove the last element + list.remove(list.size() - 1); + } + + // Replace mPageScrolls with the list content + mPageScrolls = new int[list.size()]; + for(int i = 0; i < list.size();i++) { + mPageScrolls[i] = list.get(i); + } + } + Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { if (mState == state) { return null; diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index 805b51e37..4b0d40833 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -310,6 +310,8 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { v, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_SCREEN_LEFT, R.bool.preferences_interface_homescreen_search_screen_left_default); + mLauncher.restoreGelSetting(); + mLauncher.getWorkspace().updatePageScrollForCustomPage(!current); mLauncher.updateDynamicGrid(); } } else if (value.equals(res |