summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-07-22 18:21:45 -0700
committerAdam Cohen <adamcohen@google.com>2013-07-22 18:22:02 -0700
commitbffe745b1e195deedc1dcc60f37950b3b0b4c652 (patch)
tree00fbf4cd1ea47cc0b0259f904a972e4b8b4b774c
parent9c0565fe9385f92b7b2608d6506e4e5a7c500c2d (diff)
downloadandroid_packages_apps_Trebuchet-bffe745b1e195deedc1dcc60f37950b3b0b4c652.tar.gz
android_packages_apps_Trebuchet-bffe745b1e195deedc1dcc60f37950b3b0b4c652.tar.bz2
android_packages_apps_Trebuchet-bffe745b1e195deedc1dcc60f37950b3b0b4c652.zip
Adding contract for custom content screen
Change-Id: Ia4dae3c641730ab24a0a124fd94b871d248b7dda
-rw-r--r--src/com/android/launcher3/Launcher.java39
-rw-r--r--src/com/android/launcher3/Workspace.java65
2 files changed, 61 insertions, 43 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7d9ebc0b5..359204542 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -838,9 +838,44 @@ public class Launcher extends Activity
protected void onFinishBindingItems() {
}
+ QSBScroller mQsbScroller = new QSBScroller() {
+ int scrollY = 0;
+
+ @Override
+ public void setScrollY(int scroll) {
+ scrollY = scroll;
+
+ if (mWorkspace.isOnOrMovingToCustomContent()) {
+ mSearchDropTargetBar.setTranslationY(- scrollY);
+ }
+ }
+ };
+
+ public void resetQSBScroll() {
+ mSearchDropTargetBar.animate().translationY(0).start();
+ }
+
+ public interface CustomContentCallbacks {
+ // Custom content is completely shown
+ public void onShow();
+
+ // Custom content is completely hidden
+ public void onHide();
+ }
+
+ public interface QSBScroller {
+ public void setScrollY(int scrollY);
+ }
+
// Add a fullscreen unpadded view to the workspace to the left all other screens.
- public void addCustomContentToLeft(View customContent) {
- mWorkspace.addCustomContentToLeft(customContent);
+ public QSBScroller addCustomContentToLeft(View customContent) {
+ return addCustomContentToLeft(customContent, null);
+ }
+
+ public QSBScroller addCustomContentToLeft(View customContent,
+ CustomContentCallbacks callbacks) {
+ mWorkspace.addCustomContentToLeft(customContent, callbacks);
+ return mQsbScroller;
}
// The custom content needs to offset its content to account for the QSB
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index b8ef6b117..edf372144 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -56,6 +56,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.android.launcher3.FolderIcon.FolderRingAnimator;
+import com.android.launcher3.Launcher.CustomContentCallbacks;
import com.android.launcher3.LauncherSettings.Favorites;
import java.net.URISyntaxException;
@@ -98,8 +99,6 @@ public class Workspace extends SmoothPagedView
boolean mDrawBackground = true;
private float mBackgroundAlpha = 0;
- private float mWallpaperScrollRatio = 1.0f;
-
private LayoutTransition mLayoutTransition;
private final WallpaperManager mWallpaperManager;
private IBinder mWindowToken;
@@ -129,6 +128,9 @@ public class Workspace extends SmoothPagedView
static Rect mLandscapeCellLayoutMetrics = null;
static Rect mPortraitCellLayoutMetrics = null;
+ CustomContentCallbacks mCustomContentCallbacks;
+ boolean mCustomContentShowing;
+
/**
* The CellLayout that is currently being dragged over
*/
@@ -526,7 +528,7 @@ public class Workspace extends SmoothPagedView
return screenId;
}
- public void addCustomContentToLeft(View customContent) {
+ public void addCustomContentToLeft(View customContent, CustomContentCallbacks callbacks) {
CellLayout customScreen = (CellLayout)
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
@@ -541,17 +543,13 @@ public class Workspace extends SmoothPagedView
Rect p = new Rect();
AppWidgetHostView.getDefaultPaddingForWidget(mLauncher, mLauncher.getComponentName(), p);
- // For now we force top padding on the entire custom content screen. The intention
- // is for the hosted content to get this offset and account for it so that upon scrolling
- // it can use the entire space.
- customContent.setPadding(p.left, mLauncher.getTopOffsetForCustomContent(),
- p.right, p.bottom);
-
mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen);
mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID);
addFullScreenPage(customScreen);
+ mCustomContentCallbacks = callbacks;
+
// Ensure that the current page and default page are maintained.
mDefaultPage++;
setCurrentPage(getCurrentPage() + 1);
@@ -937,6 +935,19 @@ public class Workspace extends SmoothPagedView
protected void notifyPageSwitchListener() {
super.notifyPageSwitchListener();
Launcher.setScreen(mCurrentPage);
+
+ if (hasCustomContent() && mCurrentPage == 0) {
+ mCustomContentShowing = true;
+ if (mCustomContentCallbacks != null) {
+ mCustomContentCallbacks.onShow();
+ }
+ } else if (hasCustomContent() && mCustomContentShowing) {
+ mCustomContentShowing = false;
+ if (mCustomContentCallbacks != null) {
+ mCustomContentCallbacks.onHide();
+ mLauncher.resetQSBScroll();
+ }
+ }
};
// As a ratio of screen height, the total distance we want the parallax effect to span
@@ -966,11 +977,6 @@ public class Workspace extends SmoothPagedView
return x * aspectRatio + y;
}
- // The range of scroll values for Workspace
- private int getScrollRange() {
- return getChildOffset(getChildCount() - 1) - getChildOffset(0);
- }
-
protected void setWallpaperDimension() {
Point minDims = new Point();
Point maxDims = new Point();
@@ -995,33 +1001,6 @@ public class Workspace extends SmoothPagedView
}.start();
}
- private float wallpaperOffsetForCurrentScroll() {
- // Set wallpaper offset steps (1 / (number of screens - 1))
- mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f);
-
- int scrollRange = getScrollRange();
-
- float adjustedScrollX = Math.max(0, Math.min(getScrollX(), mMaxScrollX));
- adjustedScrollX *= mWallpaperScrollRatio;
-
- float scrollProgress =
- adjustedScrollX / (float) scrollRange;
-
- if (LauncherAppState.getInstance().isScreenLarge() && mIsStaticWallpaper) {
- // The wallpaper travel width is how far, from left to right, the wallpaper will move
- // at this orientation. On tablets in portrait mode we don't move all the way to the
- // edges of the wallpaper, or otherwise the parallax effect would be too strong.
- int wallpaperTravelWidth = Math.min(mWallpaperTravelWidth, mWallpaperWidth);
-
- float offsetInDips = wallpaperTravelWidth * scrollProgress +
- (mWallpaperWidth - wallpaperTravelWidth) / 2; // center it
- float offset = offsetInDips / (float) mWallpaperWidth;
- return offset;
- } else {
- return scrollProgress;
- }
- }
-
private void syncWallpaperOffsetWithScroll() {
final boolean enableWallpaperEffects = isHardwareAccelerated();
if (enableWallpaperEffects) {
@@ -1317,6 +1296,10 @@ public class Workspace extends SmoothPagedView
return (mScreenOrder.size() > 0 && mScreenOrder.get(0) == CUSTOM_CONTENT_SCREEN_ID);
}
+ public boolean isOnOrMovingToCustomContent() {
+ return hasCustomContent() && getNextPage() == 0;
+ }
+
private void updateStateForCustomContent(int screenCenter) {
if (hasCustomContent()) {
CellLayout customContent = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);