summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-07-29 12:58:51 -0700
committerWinson Chung <winsonc@google.com>2013-07-31 10:43:50 -0700
commit98ca0f7203f66c491a5362c2f4db79547872bdfe (patch)
tree345bc5183dee40e5bb893a69f3204ab201029d5a /src
parent18350f2dc483a92429f0b35c15ffd33a8ae41098 (diff)
downloadandroid_packages_apps_Trebuchet-98ca0f7203f66c491a5362c2f4db79547872bdfe.tar.gz
android_packages_apps_Trebuchet-98ca0f7203f66c491a5362c2f4db79547872bdfe.tar.bz2
android_packages_apps_Trebuchet-98ca0f7203f66c491a5362c2f4db79547872bdfe.zip
Adding hint for launcher to pre-create custom workspace screen.
Change-Id: I150fb8b6ff13053bf4b0b49f2b510630ed50714a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java18
-rw-r--r--src/com/android/launcher3/Workspace.java32
2 files changed, 33 insertions, 17 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 321c4e712..e84c708ae 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -444,6 +444,11 @@ public class Launcher extends Activity
sPausedFromUserAction = true;
}
+ /** To be overriden by subclasses to hint to Launcher that we have custom content */
+ protected boolean hasCustomContentToLeft() {
+ return false;
+ }
+
private void updateGlobalIcons() {
boolean searchVisible = false;
boolean voiceVisible = false;
@@ -868,13 +873,13 @@ public class Launcher extends Activity
}
// Add a fullscreen unpadded view to the workspace to the left all other screens.
- public QSBScroller addCustomContentToLeft(View customContent) {
- return addCustomContentToLeft(customContent, null);
+ public QSBScroller addToCustomContentPage(View customContent) {
+ return addToCustomContentPage(customContent, null);
}
- public QSBScroller addCustomContentToLeft(View customContent,
+ public QSBScroller addToCustomContentPage(View customContent,
CustomContentCallbacks callbacks) {
- mWorkspace.addCustomContentToLeft(customContent, callbacks);
+ mWorkspace.addToCustomContentPage(customContent, callbacks);
return mQsbScroller;
}
@@ -3718,6 +3723,11 @@ public class Launcher extends Activity
mSavedState = null;
}
+ // Create the custom content page here before onLayout to prevent flashing
+ if (!mWorkspace.hasCustomContent() && hasCustomContentToLeft()) {
+ mWorkspace.createCustomContentPage();
+ }
+
mWorkspace.restoreInstanceStateForRemainingPages();
// If we received the result of any pending adds while the loader was running (e.g. the
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 91f539689..1727c72c6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -528,19 +528,10 @@ public class Workspace extends SmoothPagedView
return screenId;
}
- public void addCustomContentToLeft(View customContent, CustomContentCallbacks callbacks) {
+ public void createCustomContentPage() {
CellLayout customScreen = (CellLayout)
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
- int spanX = customScreen.getCountX();
- int spanY = customScreen.getCountY();
-
- CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
- lp.canReorder = false;
- lp.isFullscreen = true;
-
- customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
-
Rect p = new Rect();
AppWidgetHostView.getDefaultPaddingForWidget(mLauncher, mLauncher.getComponentName(), p);
@@ -549,13 +540,28 @@ public class Workspace extends SmoothPagedView
addFullScreenPage(customScreen);
- mCustomContentCallbacks = callbacks;
-
// Ensure that the current page and default page are maintained.
mDefaultPage++;
setCurrentPage(getCurrentPage() + 1);
}
+ public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks) {
+ if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
+ throw new RuntimeException("Expected custom content screen to exist");
+ }
+
+ // Add the custom content to the full screen custom page
+ CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
+ int spanX = customScreen.getCountX();
+ int spanY = customScreen.getCountY();
+ CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
+ lp.canReorder = false;
+ lp.isFullscreen = true;
+ customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
+
+ mCustomContentCallbacks = callbacks;
+ }
+
public long commitExtraEmptyScreen() {
CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);
mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
@@ -1293,7 +1299,7 @@ public class Workspace extends SmoothPagedView
}
}
- private boolean hasCustomContent() {
+ public boolean hasCustomContent() {
return (mScreenOrder.size() > 0 && mScreenOrder.get(0) == CUSTOM_CONTENT_SCREEN_ID);
}