summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/CellLayout.java5
-rw-r--r--src/com/android/launcher3/FocusHelper.java4
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java4
-rw-r--r--src/com/android/launcher3/PageIndicator.java11
-rw-r--r--src/com/android/launcher3/PagedView.java37
-rw-r--r--src/com/android/launcher3/ShortcutAndWidgetContainer.java19
-rw-r--r--src/com/android/launcher3/Workspace.java35
8 files changed, 88 insertions, 29 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index ac41a2bd7..86bc1b047 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -3231,6 +3231,11 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
public boolean isLockedToGrid = true;
/**
+ * Indicates that this item should use the full extents of its parent.
+ */
+ public boolean isFullscreen = false;
+
+ /**
* Indicates whether this item can be reordered. Always true except in the case of the
* the AllApps button.
*/
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index a591433f2..1acaf3e3b 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -21,6 +21,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
+import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TabWidget;
@@ -817,7 +818,8 @@ public class FocusHelper {
static boolean handleFolderKeyEvent(View v, int keyCode, KeyEvent e) {
ShortcutAndWidgetContainer parent = (ShortcutAndWidgetContainer) v.getParent();
final CellLayout layout = (CellLayout) parent.getParent();
- final Folder folder = (Folder) layout.getParent();
+ final ScrollView scrollView = (ScrollView) layout.getParent();
+ final Folder folder = (Folder) scrollView.getParent();
View title = folder.mFolderName;
final int action = e.getAction();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 359204542..321c4e712 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -990,7 +990,7 @@ public class Launcher extends Activity
int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1);
if (currentScreen > -1) {
- mWorkspace.setCurrentPage(currentScreen);
+ mWorkspace.setRestorePage(currentScreen);
}
final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 28530e6ac..eaa2fd297 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1728,7 +1728,9 @@ public class LauncherModel extends BroadcastReceiver {
}
}
} finally {
- c.close();
+ if (c != null) {
+ c.close();
+ }
}
if (itemsToRemove.size() > 0) {
diff --git a/src/com/android/launcher3/PageIndicator.java b/src/com/android/launcher3/PageIndicator.java
index d7778fb1a..ce9814505 100644
--- a/src/com/android/launcher3/PageIndicator.java
+++ b/src/com/android/launcher3/PageIndicator.java
@@ -161,18 +161,17 @@ public class PageIndicator extends LinearLayout {
mWindowRange[1] = windowEnd;
}
- void addMarker(int index) {
+ void addMarker(int index, int layoutId) {
index = Math.max(0, Math.min(index, mMarkers.size()));
- int mLayoutId = R.layout.page_indicator_marker;
PageIndicatorMarker marker =
- (PageIndicatorMarker) mLayoutInflater.inflate(mLayoutId, this, false);
+ (PageIndicatorMarker) mLayoutInflater.inflate(layoutId, this, false);
mMarkers.add(index, marker);
offsetWindowCenterTo(mActiveMarkerIndex, true);
}
- void addMarkers(int count) {
- for (int i = 0; i < count; ++i) {
- addMarker(Integer.MAX_VALUE);
+ void addMarkers(ArrayList<Integer> layoutIds) {
+ for (int i = 0; i < layoutIds.size(); ++i) {
+ addMarker(Integer.MAX_VALUE, layoutIds.get(i));
}
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index aaff58886..2eb7a0ce0 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -104,6 +104,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected boolean mFirstLayout = true;
protected int mCurrentPage;
+ protected int mRestorePage = -1;
protected int mChildCountOnLastLayout;
protected int mNextPage = INVALID_PAGE;
@@ -326,7 +327,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (mPageIndicator == null && mPageIndicatorViewId > -1) {
mPageIndicator = (PageIndicator) parent.findViewById(mPageIndicatorViewId);
mPageIndicator.removeAllMarkers();
- mPageIndicator.addMarkers(getChildCount());
+
+ ArrayList<Integer> markers = new ArrayList<Integer>();
+ for (int i = 0; i < getChildCount(); ++i) {
+ markers.add(getPageIndicatorMarker(i));
+ }
+ mPageIndicator.addMarkers(markers);
}
}
@@ -403,6 +409,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
PageIndicator getPageIndicator() {
return mPageIndicator;
}
+ protected int getPageIndicatorMarker(int pageIndex) {
+ return R.layout.page_indicator_marker;
+ }
public void setPageSwitchListener(PageSwitchListener pageSwitchListener) {
mPageSwitchListener = pageSwitchListener;
@@ -506,6 +515,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
invalidate();
}
+ /**
+ * The restore page will be set in place of the current page at the next (likely first)
+ * layout.
+ */
+ void setRestorePage(int restorePage) {
+ mRestorePage = restorePage;
+ }
+
protected void notifyPageSwitchListener() {
if (mPageSwitchListener != null) {
mPageSwitchListener.onPageSwitch(getPageAt(mCurrentPage), mCurrentPage);
@@ -824,6 +841,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
for (int i = startIndex; i != endIndex; i += delta) {
+
final View child = getPageAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int childTop;
@@ -847,10 +865,13 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// We assume the left and right padding are equal, and hence center the pages
// horizontally
- int scrollOffset = false ? 0 : (getViewportWidth() - childWidth) / 2;
+ int scrollOffset = (getViewportWidth() - childWidth) / 2;
mPageScrolls[i] = childLeft - scrollOffset - offsetX;
- childLeft += childWidth + mPageSpacing;
+ if (i != endIndex - delta) {
+ int nextScrollOffset = (getViewportWidth() - getChildWidth(i + delta)) / 2;
+ childLeft += childWidth + nextScrollOffset;
+ }
}
}
@@ -870,7 +891,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (mScroller.isFinished() && mChildCountOnLastLayout != getChildCount() &&
!mDeferringForDelete) {
- setCurrentPage(getNextPage());
+ if (mRestorePage > -1) {
+ setCurrentPage(mRestorePage);
+ mRestorePage = -1;
+ } else {
+ setCurrentPage(getNextPage());
+ }
}
mChildCountOnLastLayout = getChildCount();
}
@@ -896,7 +922,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Update the page indicator, we don't update the page indicator as we
// add/remove pages
if (mPageIndicator != null && !isReordering(false)) {
- mPageIndicator.addMarker(indexOfChild(child));
+ int pageIndex = indexOfChild(child);
+ mPageIndicator.addMarker(pageIndex, getPageIndicatorMarker(pageIndex));
}
// This ensures that when children are added, they get the correct transforms / alphas
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index 18b9399d1..64a87ef07 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -92,13 +92,15 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int count = getChildCount();
+
+ int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
+ int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
+ setMeasuredDimension(widthSpecSize, heightSpecSize);
+
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
measureChild(child);
}
- int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
- int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
- setMeasuredDimension(widthSpecSize, heightSpecSize);
}
public void setupLp(CellLayout.LayoutParams lp) {
@@ -115,8 +117,15 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
final int cellWidth = mCellWidth;
final int cellHeight = mCellHeight;
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
-
- lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap, invertLayoutHorizontally(), mCountX);
+ if (!lp.isFullscreen) {
+ lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap, invertLayoutHorizontally(),
+ mCountX);
+ } else {
+ lp.x = 0;
+ lp.y = 0;
+ lp.width = getMeasuredWidth();
+ lp.height = getMeasuredHeight();
+ }
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height,
MeasureSpec.EXACTLY);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 63211bde1..75bf26986 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -537,6 +537,7 @@ public class Workspace extends SmoothPagedView
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
lp.canReorder = false;
+ lp.isFullscreen = true;
customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
@@ -769,6 +770,13 @@ public class Workspace extends SmoothPagedView
protected void onWindowVisibilityChanged (int visibility) {
mLauncher.onWindowVisibilityChanged(visibility);
+ if (mCustomContentShowing && mCustomContentCallbacks != null) {
+ if (visibility == View.VISIBLE) {
+ mCustomContentCallbacks.onShow();
+ } else if (visibility == View.GONE) {
+ mCustomContentCallbacks.onHide();
+ }
+ }
}
@Override
@@ -929,25 +937,25 @@ public class Workspace extends SmoothPagedView
stripEmptyScreens();
mStripScreensOnPageStopMoving = false;
}
- }
-
- @Override
- protected void notifyPageSwitchListener() {
- super.notifyPageSwitchListener();
- Launcher.setScreen(mCurrentPage);
- if (hasCustomContent() && mCurrentPage == 0) {
+ if (hasCustomContent() && getNextPage() == 0 && !mCustomContentShowing) {
mCustomContentShowing = true;
if (mCustomContentCallbacks != null) {
mCustomContentCallbacks.onShow();
}
- } else if (hasCustomContent() && mCustomContentShowing) {
+ } else if (hasCustomContent() && getNextPage() != 0 && mCustomContentShowing) {
mCustomContentShowing = false;
if (mCustomContentCallbacks != null) {
mCustomContentCallbacks.onHide();
mLauncher.resetQSBScroll();
}
}
+ }
+
+ @Override
+ protected void notifyPageSwitchListener() {
+ super.notifyPageSwitchListener();
+ Launcher.setScreen(mCurrentPage);
};
// As a ratio of screen height, the total distance we want the parallax effect to span
@@ -1302,11 +1310,9 @@ public class Workspace extends SmoothPagedView
private void updateStateForCustomContent(int screenCenter) {
if (hasCustomContent()) {
- CellLayout customContent = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);
int scrollDelta = getScrollForPage(index + 1) - getScrollX();
- float translationX = Math.max(scrollDelta, 0);
float progress = (1.0f * scrollDelta) /
(getScrollForPage(index + 1) - getScrollForPage(index));
@@ -1317,6 +1323,7 @@ public class Workspace extends SmoothPagedView
if (mLauncher.getHotseat() != null) {
mLauncher.getHotseat().setTranslationY(transY);
+ mLauncher.getHotseat().setAlpha(1 - progress);
}
if (getPageIndicator() != null) {
getPageIndicator().setAlpha(1 - progress);
@@ -4023,6 +4030,14 @@ public class Workspace extends SmoothPagedView
}
@Override
+ protected int getPageIndicatorMarker(int pageIndex) {
+ if (getScreenIdForPageIndex(pageIndex) == CUSTOM_CONTENT_SCREEN_ID) {
+ return R.layout.now_page_indicator_marker;
+ }
+ return super.getPageIndicatorMarker(pageIndex);
+ }
+
+ @Override
public void syncPages() {
}