Merge "Fix bug where all apps didn't load sometimes" into ics-mr1
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index 1b01b48..efd29a6 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -29,6 +29,7 @@
android:id="@+id/tabs_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/apps_customize_tab_bar_height"
+ android:layout_marginTop="@dimen/apps_customize_tab_bar_margin_top"
android:layout_gravity="center_horizontal">
<com.android.launcher2.FocusOnlyTabWidget
android:id="@android:id/tabs"
@@ -36,7 +37,8 @@
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/tab_unselected_holo"
- android:tabStripEnabled="false" />
+ android:tabStripEnabled="false"
+ android:divider="@null" />
<include
android:id="@+id/market_button"
layout="@layout/market_button"
diff --git a/res/values-land/config.xml b/res/values-land/config.xml
index 121bb0c..fc20456 100644
--- a/res/values-land/config.xml
+++ b/res/values-land/config.xml
@@ -20,4 +20,9 @@
<bool name="config_useDropTargetDownTransition">false</bool>
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">false</bool>
+
+ <!-- Folder max bounds and max number of items.
+ Note: folder_max_count_x * folder_max_count_y >= folder_max_num_items. -->
+ <integer name="folder_max_count_x">6</integer>
+ <integer name="folder_max_count_y">3</integer>
</resources>
diff --git a/res/values-sw340dp-port/dimens.xml b/res/values-sw340dp-port/dimens.xml
index ef44913..bf7ebc3 100644
--- a/res/values-sw340dp-port/dimens.xml
+++ b/res/values-sw340dp-port/dimens.xml
@@ -59,7 +59,4 @@
<dimen name="apps_customize_pageLayoutPaddingRight">8dp</dimen>
<dimen name="apps_customize_cell_height">92dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">16dp</dimen>
-
-<!-- Folders -->
- <dimen name="folder_preview_size">64dp</dimen>
</resources>
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
index 2a81e12..7a07898 100644
--- a/res/values-sw600dp/config.xml
+++ b/res/values-sw600dp/config.xml
@@ -19,4 +19,9 @@
<!-- When shrinking the workspace, this is the percentage of its original size. -->
<integer name="config_workspaceShrinkPercent">17</integer>
+ <!-- Folder max bounds and max number of items. Note: folder_max_count_x * folder_max_count_y
+ >= folder_max_num_items. When these are set to -1, they are automatically determined. -->
+ <integer name="folder_max_count_x">-1</integer>
+ <integer name="folder_max_count_y">-1</integer>
+ <integer name="folder_max_num_items">-1</integer>
</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 584734b..5c3b950 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -33,6 +33,7 @@
<!-- AppsCustomize -->
<dimen name="apps_customize_tab_bar_height">56dp</dimen>
+ <dimen name="apps_customize_tab_bar_margin_top">8dp</dimen>
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">98dp</dimen>
<dimen name="apps_customize_widget_cell_width_gap">36dp</dimen>
@@ -74,7 +75,7 @@
<!-- Folders -->
<!-- The size of the image which sits behind the preview of the folder contents -->
- <dimen name="folder_preview_size">80dp</dimen>
+ <dimen name="folder_preview_size">78dp</dimen>
<!-- The amount that the preview contents are inset from the preview background -->
<dimen name="folder_preview_padding">4dp</dimen>
</resources>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
index ec281f9..70e24be 100644
--- a/res/values-sw600dp/styles.xml
+++ b/res/values-sw600dp/styles.xml
@@ -28,11 +28,13 @@
<item name="android:textSize">13sp</item>
</style>
<style name="WorkspaceIcon.Portrait.Folder">
+ <item name="android:drawablePadding">0dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:textSize">13sp</item>
+ <item name="android:layout_marginTop">-2dp</item>
</style>
<style name="WorkspaceIcon.Landscape">
<item name="android:drawablePadding">0dp</item>
@@ -43,11 +45,13 @@
<item name="android:textSize">13sp</item>
</style>
<style name="WorkspaceIcon.Landscape.Folder">
+ <item name="android:drawablePadding">0dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:textSize">13sp</item>
+ <item name="android:layout_marginTop">-2dp</item>
</style>
<style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
@@ -77,6 +81,8 @@
<style name="TabIndicator.AppsCustomize">
<item name="android:paddingTop">16dp</item>
<item name="android:paddingBottom">20dp</item>
+ <item name="android:paddingLeft">48dp</item>
+ <item name="android:paddingRight">48dp</item>
<item name="android:textSize">14sp</item>
</style>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 5ad3af9..164f1e1 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -32,7 +32,7 @@
<string name="external_drop_widget_error" msgid="127440783198670829">"Không thể thả mục vào Màn hình chính này."</string>
<string name="external_drop_widget_pick_title" msgid="7040647073452295370">"Chọn tiện ích con để tạo"</string>
<string name="rename_folder_label" msgid="5646236631298452787">"Tên thư mục"</string>
- <string name="rename_folder_title" msgid="4544573104191526550">"Đổi tên thư mục"</string>
+ <string name="rename_folder_title" msgid="4544573104191526550">"Đổi tên thư mục"</string>
<string name="rename_action" msgid="6016003384693240896">"OK"</string>
<string name="cancel_action" msgid="3811860427489435048">"Hủy"</string>
<string name="menu_item_add_item" msgid="6233177331075781114">"Thêm vào Màn hình chính"</string>
diff --git a/res/values/config.xml b/res/values/config.xml
index b8040e6..7ab9870 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -84,4 +84,10 @@
<!-- When shrinking the workspace, this is the percentage of its original size. -->
<integer name="config_workspaceShrinkPercent">17</integer>
+
+ <!-- Folder max bounds and max number of items. Note: folder_max_count_x * folder_max_count_y
+ >= folder_max_num_items. When these are set to -1, they are automatically determined. -->
+ <integer name="folder_max_count_x">4</integer>
+ <integer name="folder_max_count_y">4</integer>
+ <integer name="folder_max_num_items">16</integer>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index da82809..87c9be8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -59,6 +59,7 @@
<!-- The height of the tab bar - if this changes, we should update the
external icon width/height above to compensate -->
<dimen name="apps_customize_tab_bar_height">52dp</dimen>
+ <dimen name="apps_customize_tab_bar_margin_top">0dp</dimen>
<dimen name="app_icon_size">48dp</dimen>
<!-- The width can be 72dp because we don't have L/R padding -->
<dimen name="apps_customize_cell_width">74dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e38c395..ddbdb34 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -86,7 +86,7 @@
<style name="WorkspaceIcon.Portrait.Folder">
<item name="android:drawablePadding">0dp</item>
- <item name="android:paddingTop">0dp</item>
+ <item name="android:paddingTop">2dp</item>
</style>
<style name="WorkspaceIcon.Landscape.Folder">
<item name="android:drawablePadding">0dp</item>
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 7321a79..897a7fb 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -171,7 +171,7 @@
private void reloadCurrentPage() {
if (!LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.flashScrollingIndicator();
+ mAppsCustomizePane.flashScrollingIndicator(true);
}
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
mAppsCustomizePane.requestFocus();
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 33b5de1..a6757d7 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -83,6 +83,7 @@
private FolderIcon mFolderIcon;
private int mMaxCountX;
private int mMaxCountY;
+ private int mMaxNumItems;
private Rect mNewSize = new Rect();
private Rect mIconRect = new Rect();
private ArrayList<View> mItemsInReadingOrder = new ArrayList<View>();
@@ -121,13 +122,20 @@
setAlwaysDrawnWithCacheEnabled(false);
mInflater = LayoutInflater.from(context);
mIconCache = ((LauncherApplication)context.getApplicationContext()).getIconCache();
- mMaxCountX = LauncherModel.getCellCountX();
- mMaxCountY = LauncherModel.getCellCountY();
+
+ Resources res = getResources();
+ mMaxCountX = res.getInteger(R.integer.folder_max_count_x);
+ mMaxCountY = res.getInteger(R.integer.folder_max_count_y);
+ mMaxNumItems = res.getInteger(R.integer.folder_max_num_items);
+ if (mMaxCountX < 0 || mMaxCountY < 0 || mMaxNumItems < 0) {
+ mMaxCountX = LauncherModel.getCellCountX();
+ mMaxCountY = LauncherModel.getCellCountY();
+ mMaxNumItems = mMaxCountX * mMaxCountY;
+ }
mInputMethodManager = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
- Resources res = getResources();
mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);
if (sDefaultFolderName == null) {
@@ -746,7 +754,7 @@
int oldCountY = countY;
if (countX * countY < count) {
// Current grid is too small, expand it
- if (countX <= countY && countX < mMaxCountX) {
+ if ((countX <= countY || countY == mMaxCountY) && countX < mMaxCountX) {
countX++;
} else if (countY < mMaxCountY) {
countY++;
@@ -764,7 +772,7 @@
}
public boolean isFull() {
- return getItemCount() >= mMaxCountX * mMaxCountY;
+ return getItemCount() >= mMaxNumItems;
}
private void centerAboutIcon() {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 7ee03fc..43510c2 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -78,6 +78,7 @@
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -161,6 +162,7 @@
private enum State { WORKSPACE, APPS_CUSTOMIZE, APPS_CUSTOMIZE_SPRING_LOADED };
private State mState = State.WORKSPACE;
private AnimatorSet mStateAnimation;
+ private AnimatorSet mDividerAnimator;
static final int APPWIDGET_HOST_ID = 1024;
private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
@@ -177,8 +179,11 @@
private LayoutInflater mInflater;
- private DragController mDragController;
private Workspace mWorkspace;
+ private View mQsbDivider;
+ private View mDockDivider;
+ private DragLayer mDragLayer;
+ private DragController mDragController;
private AppWidgetManager mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
@@ -241,7 +246,6 @@
static final ArrayList<String> sDumpLogs = new ArrayList<String>();
- private DragLayer mDragLayer;
private BubbleTextView mWaitingForResume;
@@ -560,7 +564,24 @@
// market intent, so refresh the icon
updateAppMarketIcon();
if (!mWorkspaceLoading) {
- mWorkspace.post(mBuildLayersRunnable);
+ final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
+ final Workspace workspace = mWorkspace;
+ // We want to let Launcher draw itself at least once before we force it to build
+ // layers on all the workspace pages, so that transitioning to Launcher from other
+ // apps is nice and speedy. Usually the first call to preDraw doesn't correspond to
+ // a true draw so we wait until the second preDraw call to be safe
+ observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
+ boolean mFirstTime = true;
+ public boolean onPreDraw() {
+ if (mFirstTime) {
+ mFirstTime = false;
+ } else {
+ workspace.post(mBuildLayersRunnable);
+ observer.removeOnPreDrawListener(this);
+ }
+ return true;
+ }
+ });
}
clearTypedText();
}
@@ -726,6 +747,8 @@
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
+ mQsbDivider = (ImageView) findViewById(R.id.qsb_divider);
+ mDockDivider = (ImageView) findViewById(R.id.dock_divider);
// Setup the drag layer
mDragLayer.setup(this, dragController);
@@ -2252,7 +2275,7 @@
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
- mWorkspace.hideDockDivider(true);
+ hideDockDivider();
}
if (!animationCancelled) {
updateWallpaperVisibility(false);
@@ -2294,7 +2317,7 @@
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
- mWorkspace.hideDockDivider(true);
+ hideDockDivider();
}
}
updateWallpaperVisibility(false);
@@ -2306,7 +2329,7 @@
* This is the opposite of showAppsCustomizeHelper.
* @param animated If true, the transition will be animated.
*/
- private void hideAppsCustomizeHelper(boolean animated) {
+ private void hideAppsCustomizeHelper(boolean animated, final boolean springLoaded) {
if (mStateAnimation != null) {
mStateAnimation.cancel();
mStateAnimation = null;
@@ -2370,6 +2393,7 @@
((LauncherTransitionable) fromView).onLauncherTransitionStart(instance, null, true);
((LauncherTransitionable) fromView).onLauncherTransitionEnd(instance, null, true);
}
+ mWorkspace.hideScrollingIndicator(false);
}
}
@@ -2380,10 +2404,12 @@
mWorkspace.changeState(Workspace.State.NORMAL, animated, stagger);
if (mState != State.WORKSPACE) {
mWorkspace.setVisibility(View.VISIBLE);
- hideAppsCustomizeHelper(animated);
+ hideAppsCustomizeHelper(animated, false);
// Show the search bar and hotseat
mSearchDropTargetBar.showSearchBar(animated);
+ // We only need to animate in the dock divider if we're going from spring loaded mode
+ showDockDivider(animated && mState == State.APPS_CUSTOMIZE_SPRING_LOADED);
// Set focus to the AppsCustomize button
if (mAllAppsButton != null) {
@@ -2391,8 +2417,7 @@
}
}
- mWorkspace.showDockDivider(!animated);
- mWorkspace.flashScrollingIndicator();
+ mWorkspace.flashScrollingIndicator(animated);
// Change the state *after* we've called all the transition code
mState = State.WORKSPACE;
@@ -2429,7 +2454,8 @@
void enterSpringLoadedDragMode() {
if (mState == State.APPS_CUSTOMIZE) {
mWorkspace.changeState(Workspace.State.SPRING_LOADED);
- hideAppsCustomizeHelper(true);
+ hideAppsCustomizeHelper(true, true);
+ hideDockDivider();
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
}
}
@@ -2466,6 +2492,33 @@
// Otherwise, we are not in spring loaded mode, so don't do anything.
}
+ void hideDockDivider() {
+ if (mQsbDivider != null && mDockDivider != null) {
+ mQsbDivider.setVisibility(View.INVISIBLE);
+ mDockDivider.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ void showDockDivider(boolean animated) {
+ if (mQsbDivider != null && mDockDivider != null) {
+ mQsbDivider.setVisibility(View.VISIBLE);
+ mDockDivider.setVisibility(View.VISIBLE);
+ if (mDividerAnimator != null) {
+ mDividerAnimator.cancel();
+ mQsbDivider.setAlpha(1f);
+ mDockDivider.setAlpha(1f);
+ mDividerAnimator = null;
+ }
+ if (animated) {
+ mDividerAnimator = new AnimatorSet();
+ mDividerAnimator.playTogether(ObjectAnimator.ofFloat(mQsbDivider, "alpha", 1f),
+ ObjectAnimator.ofFloat(mDockDivider, "alpha", 1f));
+ mDividerAnimator.setDuration(mSearchDropTargetBar.getTransitionInDuration());
+ mDividerAnimator.start();
+ }
+ }
+ }
+
void lockAllApps() {
// TODO
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 935d26d..2f66537 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1766,9 +1766,9 @@
hideScrollingIndicator(false);
}
};
- protected void flashScrollingIndicator() {
+ protected void flashScrollingIndicator(boolean animated) {
removeCallbacks(hideScrollingIndicatorRunnable);
- showScrollingIndicator(false);
+ showScrollingIndicator(!animated);
postDelayed(hideScrollingIndicatorRunnable, sScrollIndicatorFlashDuration);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 8ac5248..8c57349 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -107,7 +107,6 @@
private float mBackgroundAlpha = 0;
private float mOverScrollMaxBackgroundAlpha = 0.0f;
private int mOverScrollPageIndex = -1;
- private AnimatorSet mDividerAnimator;
private float mWallpaperScrollRatio = 1.0f;
@@ -3493,30 +3492,6 @@
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
- void showDockDivider(boolean immediately) {
- final ViewGroup parent = (ViewGroup) getParent();
- final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
- final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
- if (qsbDivider != null && dockDivider != null) {
- qsbDivider.setVisibility(View.VISIBLE);
- dockDivider.setVisibility(View.VISIBLE);
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- mDividerAnimator = null;
- }
- if (immediately) {
- qsbDivider.setAlpha(1f);
- dockDivider.setAlpha(1f);
- } else {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 1f),
- ObjectAnimator.ofFloat(dockDivider, "alpha", 1f));
- mDividerAnimator.setDuration(sScrollIndicatorFadeInDuration);
- mDividerAnimator.start();
- }
- }
- }
-
void setFadeForOverScroll(float fade) {
if (!isScrollingIndicatorEnabled()) return;
@@ -3530,42 +3505,4 @@
dockDivider.setAlpha(reducedFade);
scrollIndicator.setAlpha(1 - fade);
}
-
- void hideDockDivider(boolean immediately) {
- final ViewGroup parent = (ViewGroup) getParent();
- final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
- final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
- if (qsbDivider != null && dockDivider != null) {
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- mDividerAnimator = null;
- }
- if (immediately) {
- qsbDivider.setVisibility(View.GONE);
- dockDivider.setVisibility(View.GONE);
- qsbDivider.setAlpha(0f);
- dockDivider.setAlpha(0f);
- } else {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 0f),
- ObjectAnimator.ofFloat(dockDivider, "alpha", 0f));
- mDividerAnimator.addListener(new AnimatorListenerAdapter() {
- private boolean cancelled = false;
- @Override
- public void onAnimationCancel(android.animation.Animator animation) {
- cancelled = true;
- }
- @Override
- public void onAnimationEnd(android.animation.Animator animation) {
- if (!cancelled) {
- qsbDivider.setVisibility(View.GONE);
- dockDivider.setVisibility(View.GONE);
- }
- }
- });
- mDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration);
- mDividerAnimator.start();
- }
- }
- }
}