First pass of the Launcher Overlay interface / impl

-> Added simple reference launcher extension
-> Make launcher able to handle a null qsb

Change-Id: Ib1575243cac800a335e95bbf00cdc394bb4741c3
This commit is contained in:
Adam Cohen
2014-10-16 09:49:24 -07:00
parent 1aa3abea27
commit c2d6e897db
13 changed files with 693 additions and 39 deletions

View File

@@ -67,6 +67,7 @@ import android.widget.TextView;
import com.android.launcher3.FolderIcon.FolderRingAnimator;
import com.android.launcher3.Launcher.CustomContentCallbacks;
import com.android.launcher3.Launcher.LauncherOverlay;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
@@ -289,6 +290,12 @@ public class Workspace extends SmoothPagedView
private boolean mDeferDropAfterUninstall;
private boolean mUninstallSuccessful;
// State related to Launcher Overlay
LauncherOverlay mLauncherOverlay;
boolean mScrollInteractionBegan;
boolean mStartedSendingScrollEvents;
boolean mShouldSendPageSettled;
private final Runnable mBindPages = new Runnable() {
@Override
public void run() {
@@ -1249,6 +1256,58 @@ public class Workspace extends SmoothPagedView
stripEmptyScreens();
mStripScreensOnPageStopMoving = false;
}
if (mShouldSendPageSettled) {
mLauncherOverlay.onScrollSettled();
mShouldSendPageSettled = false;
}
}
protected void onScrollInteractionBegin() {
super.onScrollInteractionEnd();
mScrollInteractionBegan = true;
}
protected void onScrollInteractionEnd() {
super.onScrollInteractionEnd();
mScrollInteractionBegan = false;
if (mStartedSendingScrollEvents) {
mStartedSendingScrollEvents = false;
mLauncherOverlay.onScrollInteractionEnd();
}
}
public void setLauncherOverlay(LauncherOverlay overlay) {
mLauncherOverlay = overlay;
}
@Override
protected void overScroll(float amount) {
boolean isRtl = isLayoutRtl();
boolean shouldOverScroll = (amount <= 0 && (!hasCustomContent() || isRtl)) ||
(amount >= 0 && (!hasCustomContent() || !isRtl));
boolean shouldScrollOverlay = (amount <= 0 && mLauncherOverlay != null && !isRtl) ||
(amount >= 0 && mLauncherOverlay != null && isRtl);
if (shouldScrollOverlay) {
if (!mStartedSendingScrollEvents && mScrollInteractionBegan) {
mStartedSendingScrollEvents = true;
mLauncherOverlay.onScrollInteractionBegin();
mShouldSendPageSettled = true;
}
int screenSize = getViewportWidth();
float f = (amount / screenSize);
int progress = (int) Math.abs((f * 100));
mLauncherOverlay.onScrollChange(progress, isRtl);
} else if (shouldOverScroll) {
dampedOverScroll(amount);
mOverScrollEffect = acceleratedOverFactor(amount);
} else {
mOverScrollEffect = 0;
}
}
@Override
@@ -1710,18 +1769,6 @@ public class Workspace extends SmoothPagedView
}
}
@Override
protected void overScroll(float amount) {
boolean shouldOverScroll = (amount < 0 && (!hasCustomContent() || isLayoutRtl())) ||
(amount > 0 && (!hasCustomContent() || !isLayoutRtl()));
if (shouldOverScroll) {
dampedOverScroll(amount);
mOverScrollEffect = acceleratedOverFactor(amount);
} else {
mOverScrollEffect = 0;
}
}
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mWindowToken = getWindowToken();
@@ -2353,10 +2400,6 @@ public class Workspace extends SmoothPagedView
.alpha(finalHotseatAndPageIndicatorAlpha).withLayer();
hotseatAlpha.addListener(new AlphaUpdateListener(hotseat));
Animator searchBarAlpha = new LauncherViewPropertyAnimator(searchBar)
.alpha(finalSearchBarAlpha).withLayer();
searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));
Animator overviewPanelAlpha = new LauncherViewPropertyAnimator(overviewPanel)
.alpha(finalOverviewPanelAlpha).withLayer();
overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel));
@@ -2364,11 +2407,9 @@ public class Workspace extends SmoothPagedView
// For animation optimations, we may need to provide the Launcher transition
// with a set of views on which to force build layers in certain scenarios.
hotseat.setLayerType(View.LAYER_TYPE_HARDWARE, null);
searchBar.setLayerType(View.LAYER_TYPE_HARDWARE, null);
overviewPanel.setLayerType(View.LAYER_TYPE_HARDWARE, null);
if (layerViews != null) {
layerViews.add(hotseat);
layerViews.add(searchBar);
layerViews.add(overviewPanel);
}
@@ -2385,11 +2426,21 @@ public class Workspace extends SmoothPagedView
overviewPanelAlpha.setDuration(duration);
pageIndicatorAlpha.setDuration(duration);
hotseatAlpha.setDuration(duration);
searchBarAlpha.setDuration(duration);
if (searchBar != null) {
Animator searchBarAlpha = new LauncherViewPropertyAnimator(searchBar)
.alpha(finalSearchBarAlpha).withLayer();
searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));
searchBar.setLayerType(View.LAYER_TYPE_HARDWARE, null);
if (layerViews != null) {
layerViews.add(searchBar);
}
searchBarAlpha.setDuration(duration);
anim.play(searchBarAlpha);
}
anim.play(overviewPanelAlpha);
anim.play(hotseatAlpha);
anim.play(searchBarAlpha);
anim.play(pageIndicatorAlpha);
anim.setStartDelay(delay);
} else {