Merge "Fixing regression in calculating workspace padding." into ub-launcher3-burnaby
diff --git a/res/values-ml-rIN/strings.xml b/res/values-ml-rIN/strings.xml
index 71a9e36..59ad153 100644
--- a/res/values-ml-rIN/strings.xml
+++ b/res/values-ml-rIN/strings.xml
@@ -38,7 +38,7 @@
<string name="all_apps_home_button_label" msgid="252062713717058851">"ഹോം"</string>
<string name="delete_target_label" msgid="1822697352535677073">"നീക്കംചെയ്യുക"</string>
<string name="delete_target_uninstall_label" msgid="5100785476250872595">"അണ്ഇസ്റ്റാളുചെയ്യുക"</string>
- <string name="info_target_label" msgid="8053346143994679532">"അപ്ലിക്കേഷൻ വിവരം"</string>
+ <string name="info_target_label" msgid="8053346143994679532">"ആപ്പ് വിവരം"</string>
<string name="permlab_install_shortcut" msgid="5632423390354674437">"കുറുക്കുവഴികൾ ഇൻസ്റ്റാളുചെയ്യുക"</string>
<string name="permdesc_install_shortcut" msgid="923466509822011139">"ഉപയോക്തൃ ഇടപെടൽ ഇല്ലാതെ കുറുക്കുവഴികൾ ചേർക്കാൻ അപ്ലിക്കേഷനെ അനുവദിക്കുന്നു."</string>
<string name="permlab_read_settings" msgid="1941457408239617576">"ഹോം ക്രമീകരണങ്ങളും കുറുക്കുവഴികളും റീഡുചെയ്യുക"</string>
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ff4c93a..17fdeb1 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -123,9 +123,10 @@
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
if (mLauncher != null) {
- allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
mLauncher.setAllAppsButton(allAppsButton);
+ allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
allAppsButton.setOnClickListener(mLauncher);
+ allAppsButton.setOnLongClickListener(mLauncher);
allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 55b8f03..6648b6e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -263,6 +263,7 @@
private ViewGroup mOverviewPanel;
private View mAllAppsButton;
+ private View mWidgetsButton;
private SearchDropTargetBar mSearchDropTargetBar;
@@ -990,7 +991,7 @@
// view after launching an app, as they may be depending on the UI to be static to
// switch to another app, otherwise, if it was
showAppsView(false /* animated */, false /* resetListToTop */,
- !launchedFromApp /* updatePredictedApps */);
+ !launchedFromApp /* updatePredictedApps */, false /* focusSearchBar */);
} else if (mOnResumeState == State.WIDGETS) {
showWidgetsView(false, false);
}
@@ -1370,8 +1371,8 @@
}
mOverviewPanel = (ViewGroup) findViewById(R.id.overview_panel);
- View widgetButton = findViewById(R.id.widget_button);
- widgetButton.setOnClickListener(new OnClickListener() {
+ mWidgetsButton = findViewById(R.id.widget_button);
+ mWidgetsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (!mWorkspace.isSwitchingState()) {
@@ -1379,7 +1380,7 @@
}
}
});
- widgetButton.setOnTouchListener(getHapticFeedbackTouchListener());
+ mWidgetsButton.setOnTouchListener(getHapticFeedbackTouchListener());
View wallpaperButton = findViewById(R.id.wallpaper_button);
wallpaperButton.setOnClickListener(new OnClickListener() {
@@ -1465,6 +1466,10 @@
return mAllAppsButton;
}
+ public View getWidgetsButton() {
+ return mWidgetsButton;
+ }
+
/**
* Creates a view representing a shortcut.
*
@@ -2543,12 +2548,17 @@
*/
protected void onClickAllAppsButton(View v) {
if (LOGD) Log.d(TAG, "onClickAllAppsButton");
- if (isAppsViewVisible()) {
- showWorkspace(true);
- } else {
- // Try and refresh the set of predicted apps before we enter launcher
+ if (!isAppsViewVisible()) {
showAppsView(true /* animated */, false /* resetListToTop */,
- true /* updatePredictedApps */);
+ true /* updatePredictedApps */, false /* focusSearchBar */);
+ }
+ }
+
+ protected void onLongClickAllAppsButton(View v) {
+ if (LOGD) Log.d(TAG, "onLongClickAllAppsButton");
+ if (!isAppsViewVisible()) {
+ showAppsView(true /* animated */, false /* resetListToTop */,
+ true /* updatePredictedApps */, true /* focusSearchBar */);
}
}
@@ -3125,6 +3135,11 @@
if (isWorkspaceLocked()) return false;
if (mState != State.WORKSPACE) return false;
+ if (v == mAllAppsButton) {
+ onLongClickAllAppsButton(v);
+ return true;
+ }
+
if (v instanceof Workspace) {
if (!mWorkspace.isInOverviewMode()) {
if (!mWorkspace.isTouchActive()) {
@@ -3317,14 +3332,15 @@
/**
* Shows the apps view.
*/
- void showAppsView(boolean animated, boolean resetListToTop, boolean updatePredictedApps) {
+ void showAppsView(boolean animated, boolean resetListToTop, boolean updatePredictedApps,
+ boolean focusSearchBar) {
if (resetListToTop) {
mAppsView.scrollToTop();
}
if (updatePredictedApps) {
tryAndUpdatePredictedApps();
}
- showAppsOrWidgets(animated, State.APPS);
+ showAppsOrWidgets(State.APPS, animated, focusSearchBar);
}
/**
@@ -3335,7 +3351,7 @@
if (resetPageToZero) {
mWidgetsView.scrollToTop();
}
- showAppsOrWidgets(animated, State.WIDGETS);
+ showAppsOrWidgets(State.WIDGETS, animated, false);
mWidgetsView.post(new Runnable() {
@Override
@@ -3352,7 +3368,7 @@
*/
// TODO: calling method should use the return value so that when {@code false} is returned
// the workspace transition doesn't fall into invalid state.
- private boolean showAppsOrWidgets(boolean animated, State toState) {
+ private boolean showAppsOrWidgets(State toState, boolean animated, boolean focusSearchBar) {
if (mState != State.WORKSPACE && mState != State.APPS_SPRING_LOADED &&
mState != State.WIDGETS_SPRING_LOADED) {
return false;
@@ -3362,7 +3378,7 @@
}
if (toState == State.APPS) {
- mStateTransitionAnimation.startAnimationToAllApps(mState, animated);
+ mStateTransitionAnimation.startAnimationToAllApps(animated, focusSearchBar);
} else {
mStateTransitionAnimation.startAnimationToWidgets(animated);
}
@@ -3432,7 +3448,7 @@
void exitSpringLoadedDragMode() {
if (mState == State.APPS_SPRING_LOADED) {
showAppsView(true /* animated */, false /* resetListToTop */,
- false /* updatePredictedApps */);
+ false /* updatePredictedApps */, false /* focusSearchBar */);
} else if (mState == State.WIDGETS_SPRING_LOADED) {
showWidgetsView(true, false);
}
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index e94a2ac..d69b743 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -90,24 +90,17 @@
* Private callbacks made during transition setup.
*/
static abstract class PrivateTransitionCallbacks {
- void onRevealViewVisible(View revealView, View contentView, View allAppsButtonView) {}
- void onAnimationComplete(View revealView, View contentView, View allAppsButtonView) {}
float getMaterialRevealViewFinalAlpha(View revealView) {
return 0;
}
- float getMaterialRevealViewFinalXDrift(View revealView) {
- return 0;
- }
- float getMaterialRevealViewFinalYDrift(View revealView) {
- return 0;
- }
float getMaterialRevealViewStartFinalRadius() {
return 0;
}
AnimatorListenerAdapter getMaterialRevealViewAnimatorListener(View revealView,
- View allAppsButtonView) {
+ View buttonView) {
return null;
}
+ void onTransitionComplete() {}
}
public static final String TAG = "LauncherStateTransitionAnimation";
@@ -128,33 +121,20 @@
/**
* Starts an animation to the apps view.
+ *
+ * @param startSearchAfterTransition Immediately starts app search after the transition to
+ * All Apps is completed.
*/
- public void startAnimationToAllApps(final Launcher.State fromState, final boolean animated) {
+ public void startAnimationToAllApps(final boolean animated,
+ final boolean startSearchAfterTransition) {
final AllAppsContainerView toView = mLauncher.getAppsView();
+ final View buttonView = mLauncher.getAllAppsButton();
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
- private int[] mAllAppsToPanelDelta;
-
- @Override
- public void onRevealViewVisible(View revealView, View contentView,
- View allAppsButtonView) {
- // Get the y delta between the center of the page and the center of the all apps
- // button
- mAllAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
- allAppsButtonView, null);
- }
@Override
public float getMaterialRevealViewFinalAlpha(View revealView) {
return 1f;
}
@Override
- public float getMaterialRevealViewFinalXDrift(View revealView) {
- return mAllAppsToPanelDelta[0];
- }
- @Override
- public float getMaterialRevealViewFinalYDrift(View revealView) {
- return mAllAppsToPanelDelta[1];
- }
- @Override
public float getMaterialRevealViewStartFinalRadius() {
int allAppsButtonSize = mLauncher.getDeviceProfile().allAppsButtonVisualSize;
return allAppsButtonSize / 2;
@@ -171,10 +151,17 @@
}
};
}
+ @Override
+ void onTransitionComplete() {
+ if (startSearchAfterTransition) {
+ toView.startAppsSearch();
+ }
+ }
};
// Only animate the search bar if animating from spring loaded mode back to all apps
- startAnimationToOverlay(Workspace.State.NORMAL_HIDDEN, toView, toView.getContentView(),
- toView.getRevealView(), toView.getSearchBarView(), animated, true, cb);
+ startAnimationToOverlay(Workspace.State.NORMAL_HIDDEN, buttonView, toView,
+ toView.getContentView(), toView.getRevealView(), toView.getSearchBarView(),
+ animated, true /* hideSearchBar */, cb);
}
/**
@@ -182,22 +169,15 @@
*/
public void startAnimationToWidgets(final boolean animated) {
final WidgetsContainerView toView = mLauncher.getWidgetsView();
- final Resources res = mLauncher.getResources();
+ final View buttonView = mLauncher.getWidgetsButton();
+
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
@Override
- public void onRevealViewVisible(View revealView, View contentView,
- View allAppsButtonView) {
- }
- @Override
public float getMaterialRevealViewFinalAlpha(View revealView) {
return 0.3f;
}
- @Override
- public float getMaterialRevealViewFinalYDrift(View revealView) {
- return revealView.getMeasuredHeight() / 2;
- }
};
- startAnimationToOverlay(Workspace.State.OVERVIEW_HIDDEN, toView,
+ startAnimationToOverlay(Workspace.State.OVERVIEW_HIDDEN, buttonView, toView,
toView.getContentView(), toView.getRevealView(), null, animated,
true /* hideSearchBar */, cb);
}
@@ -227,23 +207,22 @@
* Creates and starts a new animation to a particular overlay view.
*/
@SuppressLint("NewApi")
- private void startAnimationToOverlay(final Workspace.State toWorkspaceState, final View toView,
- final View contentView, final View revealView, final View overlaySearchBarView,
- final boolean animated, final boolean hideSearchBar,
- final PrivateTransitionCallbacks pCb) {
+ private void startAnimationToOverlay(final Workspace.State toWorkspaceState,
+ final View buttonView, final View toView, final View contentView, final View revealView,
+ final View overlaySearchBarView, final boolean animated, final boolean hideSearchBar,
+ final PrivateTransitionCallbacks pCb) {
final Resources res = mLauncher.getResources();
final boolean material = Utilities.isLmpOrAbove();
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
final int itemsAlphaStagger =
res.getInteger(R.integer.config_overlayItemsAlphaStagger);
- final View allAppsButtonView = mLauncher.getAllAppsButton();
final View fromView = mLauncher.getWorkspace();
final HashMap<View, Integer> layerViews = new HashMap<>();
// If for some reason our views aren't initialized, don't animate
- boolean initialized = allAppsButtonView != null;
+ boolean initialized = buttonView != null;
// Cancel the current animation
cancelAnimation();
@@ -264,16 +243,17 @@
revealView.setAlpha(0f);
revealView.setTranslationY(0f);
revealView.setTranslationX(0f);
- pCb.onRevealViewVisible(revealView, contentView, allAppsButtonView);
// Calculate the final animation values
final float revealViewToAlpha;
final float revealViewToXDrift;
final float revealViewToYDrift;
if (material) {
+ int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
+ buttonView, null);
revealViewToAlpha = pCb.getMaterialRevealViewFinalAlpha(revealView);
- revealViewToYDrift = pCb.getMaterialRevealViewFinalYDrift(revealView);
- revealViewToXDrift = pCb.getMaterialRevealViewFinalXDrift(revealView);
+ revealViewToYDrift = buttonViewToPanelDelta[1];
+ revealViewToXDrift = buttonViewToPanelDelta[0];
} else {
revealViewToAlpha = 0f;
revealViewToYDrift = 2 * height / 3;
@@ -326,10 +306,9 @@
mStateAnimation.play(itemsAlpha);
if (material) {
- // Animate the all apps button
float startRadius = pCb.getMaterialRevealViewStartFinalRadius();
AnimatorListenerAdapter listener = pCb.getMaterialRevealViewAnimatorListener(
- revealView, allAppsButtonView);
+ revealView, buttonView);
Animator reveal = UiThreadCircularReveal.createCircularReveal(revealView, width / 2,
height / 2, startRadius, revealRadius);
reveal.setDuration(revealDuration);
@@ -348,7 +327,6 @@
// Hide the reveal view
revealView.setVisibility(View.INVISIBLE);
- pCb.onAnimationComplete(revealView, contentView, allAppsButtonView);
// Disable all necessary layers
for (View v : layerViews.keySet()) {
@@ -363,6 +341,7 @@
// This can hold unnecessary references to views.
mStateAnimation = null;
+ pCb.onTransitionComplete();
}
});
@@ -428,6 +407,7 @@
dispatchOnLauncherTransitionPrepare(toView, animated, false);
dispatchOnLauncherTransitionStart(toView, animated, false);
dispatchOnLauncherTransitionEnd(toView, animated, false);
+ pCb.onTransitionComplete();
}
}
@@ -441,22 +421,6 @@
int[] mAllAppsToPanelDelta;
@Override
- public void onRevealViewVisible(View revealView, View contentView,
- View allAppsButtonView) {
- // Get the y delta between the center of the page and the center of the all apps
- // button
- mAllAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
- allAppsButtonView, null);
- }
- @Override
- public float getMaterialRevealViewFinalXDrift(View revealView) {
- return mAllAppsToPanelDelta[0];
- }
- @Override
- public float getMaterialRevealViewFinalYDrift(View revealView) {
- return mAllAppsToPanelDelta[1];
- }
- @Override
float getMaterialRevealViewFinalAlpha(View revealView) {
// No alpha anim from all apps
return 1f;
@@ -487,9 +451,10 @@
}
};
// Only animate the search bar if animating to spring loaded mode from all apps
- startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage, appsView,
- appsView.getContentView(), appsView.getRevealView(), appsView.getSearchBarView(),
- animated, onCompleteRunnable, cb);
+ startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage,
+ mLauncher.getAllAppsButton(), appsView, appsView.getContentView(),
+ appsView.getRevealView(), appsView.getSearchBarView(), animated,
+ onCompleteRunnable, cb);
}
/**
@@ -498,23 +463,14 @@
private void startAnimationToWorkspaceFromWidgets(final Workspace.State toWorkspaceState,
final int toWorkspacePage, final boolean animated, final Runnable onCompleteRunnable) {
final WidgetsContainerView widgetsView = mLauncher.getWidgetsView();
- final Resources res = mLauncher.getResources();
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
@Override
- public void onRevealViewVisible(View revealView, View contentView,
- View allAppsButtonView) {
- }
- @Override
- public float getMaterialRevealViewFinalYDrift(View revealView) {
- return revealView.getMeasuredHeight() / 2;
- }
- @Override
float getMaterialRevealViewFinalAlpha(View revealView) {
- return 0.4f;
+ return 0.3f;
}
@Override
public AnimatorListenerAdapter getMaterialRevealViewAnimatorListener(
- final View revealView, final View allAppsButtonView) {
+ final View revealView, final View widgetsButtonView) {
return new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
// Hide the reveal view
@@ -523,31 +479,31 @@
};
}
};
- startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage, widgetsView,
- widgetsView.getContentView(), widgetsView.getRevealView(), null, animated,
- onCompleteRunnable, cb);
+ startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage,
+ mLauncher.getWidgetsButton(), widgetsView, widgetsView.getContentView(),
+ widgetsView.getRevealView(), null, animated, onCompleteRunnable, cb);
}
/**
* Creates and starts a new animation to the workspace.
*/
private void startAnimationToWorkspaceFromOverlay(final Workspace.State toWorkspaceState,
- final int toWorkspacePage, final View fromView, final View contentView,
- final View revealView, final View overlaySearchBarView, final boolean animated,
- final Runnable onCompleteRunnable, final PrivateTransitionCallbacks pCb) {
+ final int toWorkspacePage, final View buttonView, final View fromView,
+ final View contentView, final View revealView, final View overlaySearchBarView,
+ final boolean animated, final Runnable onCompleteRunnable,
+ final PrivateTransitionCallbacks pCb) {
final Resources res = mLauncher.getResources();
final boolean material = Utilities.isLmpOrAbove();
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
final int itemsAlphaStagger =
res.getInteger(R.integer.config_overlayItemsAlphaStagger);
- final View allAppsButtonView = mLauncher.getAllAppsButton();
final View toView = mLauncher.getWorkspace();
final HashMap<View, Integer> layerViews = new HashMap<>();
// If for some reason our views aren't initialized, don't animate
- boolean initialized = allAppsButtonView != null;
+ boolean initialized = buttonView != null;
// Cancel the current animation
cancelAnimation();
@@ -577,14 +533,15 @@
revealView.setAlpha(1f);
revealView.setTranslationY(0);
layerViews.put(revealView, BUILD_AND_SET_LAYER);
- pCb.onRevealViewVisible(revealView, contentView, allAppsButtonView);
// Calculate the final animation values
final float revealViewToXDrift;
final float revealViewToYDrift;
if (material) {
- revealViewToYDrift = pCb.getMaterialRevealViewFinalYDrift(revealView);
- revealViewToXDrift = pCb.getMaterialRevealViewFinalXDrift(revealView);
+ int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
+ buttonView, null);
+ revealViewToYDrift = buttonViewToPanelDelta[1];
+ revealViewToXDrift = buttonViewToPanelDelta[0];
} else {
revealViewToYDrift = 2 * height / 3;
revealViewToXDrift = 0;
@@ -654,7 +611,7 @@
// Animate the all apps button
float finalRadius = pCb.getMaterialRevealViewStartFinalRadius();
AnimatorListenerAdapter listener =
- pCb.getMaterialRevealViewAnimatorListener(revealView, allAppsButtonView);
+ pCb.getMaterialRevealViewAnimatorListener(revealView, buttonView);
Animator reveal = UiThreadCircularReveal.createCircularReveal(revealView, width / 2,
height / 2, revealRadius, finalRadius);
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
@@ -682,9 +639,6 @@
onCompleteRunnable.run();
}
- // Animation complete callback
- pCb.onAnimationComplete(revealView, contentView, allAppsButtonView);
-
// Disable all necessary layers
for (View v : layerViews.keySet()) {
if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
@@ -704,6 +658,7 @@
// This can hold unnecessary references to views.
mStateAnimation = null;
+ pCb.onTransitionComplete();
}
});
@@ -739,6 +694,7 @@
dispatchOnLauncherTransitionPrepare(toView, animated, true);
dispatchOnLauncherTransitionStart(toView, animated, true);
dispatchOnLauncherTransitionEnd(toView, animated, true);
+ pCb.onTransitionComplete();
// Run any queued runnables
if (onCompleteRunnable != null) {
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 47bbf15..67d5728 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -284,6 +284,15 @@
return new DefaultAppSearchController(getContext(), this, mAppsRecyclerView);
}
+ /**
+ * Focuses the search field and begins an app search.
+ */
+ public void startAppsSearch() {
+ if (mSearchBarController != null) {
+ mSearchBarController.focusSearchField();
+ }
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
diff --git a/src/com/android/launcher3/model/WidgetsModel.java b/src/com/android/launcher3/model/WidgetsModel.java
index 09a3242..15d3717 100644
--- a/src/com/android/launcher3/model/WidgetsModel.java
+++ b/src/com/android/launcher3/model/WidgetsModel.java
@@ -122,8 +122,10 @@
continue;
}
if (mAppFilter != null && !mAppFilter.shouldShowApp(componentName)) {
- Log.d(TAG, String.format("%s is filtered and not added to the widget tray.",
+ if (DEBUG) {
+ Log.d(TAG, String.format("%s is filtered and not added to the widget tray.",
packageName));
+ }
continue;
}