From 2d75f125f4e8bb5358dfdb63096d0493488ac2e5 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 23 Sep 2013 16:53:31 -0700 Subject: Tweaking styles for AllApps and widgets spaces. (Bug 10843502) - Fixing various issues with Search bar showing when it shouldn't be. Change-Id: I2a553ad93e3422666a883b90a1ff97625bf05831 --- .../android/launcher3/AppsCustomizePagedView.java | 6 ---- .../android/launcher3/AppsCustomizeTabHost.java | 11 +++--- src/com/android/launcher3/CellLayout.java | 35 +++++++++++------- src/com/android/launcher3/DynamicGrid.java | 2 +- src/com/android/launcher3/Launcher.java | 42 +--------------------- src/com/android/launcher3/PagedViewIcon.java | 26 ++++++++++++++ src/com/android/launcher3/Workspace.java | 28 +++------------ 7 files changed, 59 insertions(+), 91 deletions(-) (limited to 'src/com') diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index 213e50a67..dd870e402 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -499,13 +499,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (mPressedIcon != null) { mPressedIcon.lockDrawableState(); } - - // NOTE: We want all transitions from launcher to act as if the wallpaper were enabled - // to be consistent. So re-enable the flag here, and we will re-disable it as necessary - // when Launcher resumes and we are still in AllApps. - mLauncher.updateWallpaperVisibility(true); mLauncher.startActivitySafely(v, appInfo.intent, appInfo); - } else if (v instanceof PagedViewWidget) { // Let the user know that they have to long press to add a widget if (mWidgetInstructionToast != null) { diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java index 89e74b218..23feda3f9 100644 --- a/src/com/android/launcher3/AppsCustomizeTabHost.java +++ b/src/com/android/launcher3/AppsCustomizeTabHost.java @@ -22,6 +22,7 @@ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.Resources; +import android.graphics.Color; import android.graphics.Rect; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -81,13 +82,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona setOnTabChangedListener(this); } - void selectAppsTab() { - setContentTypeImmediate(AppsCustomizePagedView.ContentType.Applications); - } - void selectWidgetsTab() { - setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets); - } - @Override public void setInsets(Rect insets) { mInsets.set(insets); @@ -203,6 +197,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona } private void onTabChangedEnd(AppsCustomizePagedView.ContentType type) { + int bgAlpha = (int) (255 * (getResources().getInteger( + R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f)); + setBackgroundColor(Color.argb(bgAlpha, 0, 0, 0)); mAppsCustomizePane.setContentType(type); } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 30ca7376b..22492ac31 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -949,9 +949,11 @@ public class CellLayout extends ViewGroup { int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); + int childWidthSize = widthSize - (getPaddingLeft() + getPaddingRight()); + int childHeightSize = heightSize - (getPaddingTop() + getPaddingBottom()); if (mFixedCellWidth < 0 || mFixedCellHeight < 0) { - int cw = grid.calculateCellWidth(widthSize, mCountX); - int ch = grid.calculateCellHeight(heightSize, mCountY); + int cw = grid.calculateCellWidth(childWidthSize, mCountX); + int ch = grid.calculateCellHeight(childHeightSize, mCountY); if (cw != mCellWidth || ch != mCellHeight) { mCellWidth = cw; mCellHeight = ch; @@ -960,8 +962,8 @@ public class CellLayout extends ViewGroup { } } - int newWidth = widthSize; - int newHeight = heightSize; + int newWidth = childWidthSize; + int newHeight = childHeightSize; if (mFixedWidth > 0 && mFixedHeight > 0) { newWidth = mFixedWidth; newHeight = mFixedHeight; @@ -973,8 +975,8 @@ public class CellLayout extends ViewGroup { int numHeightGaps = mCountY - 1; if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) { - int hSpace = widthSize - getPaddingLeft() - getPaddingRight(); - int vSpace = heightSize - getPaddingTop() - getPaddingBottom(); + int hSpace = childWidthSize; + int vSpace = childHeightSize; int hFreeSpace = hSpace - (mCountX * mCellWidth); int vFreeSpace = vSpace - (mCountY * mCellHeight); mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0); @@ -990,15 +992,19 @@ public class CellLayout extends ViewGroup { int maxHeight = 0; for (int i = 0; i < count; i++) { View child = getChildAt(i); - int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(newWidth - getPaddingLeft() - - getPaddingRight(), MeasureSpec.EXACTLY); - int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(newHeight - getPaddingTop() - - getPaddingBottom(), MeasureSpec.EXACTLY); + int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(newWidth, + MeasureSpec.EXACTLY); + int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(newHeight, + MeasureSpec.EXACTLY); child.measure(childWidthMeasureSpec, childheightMeasureSpec); maxWidth = Math.max(maxWidth, child.getMeasuredWidth()); maxHeight = Math.max(maxHeight, child.getMeasuredHeight()); } - setMeasuredDimension(maxWidth, maxHeight); + if (mFixedWidth > 0 && mFixedHeight > 0) { + setMeasuredDimension(maxWidth, maxHeight); + } else { + setMeasuredDimension(widthSize, heightSize); + } } @Override @@ -1006,8 +1012,11 @@ public class CellLayout extends ViewGroup { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); - child.layout(getPaddingLeft(), getPaddingTop(), - r - l - getPaddingRight(), b - t - getPaddingBottom()); + int left = getPaddingLeft(); + int top = getPaddingTop(); + child.layout(left, top, + left + r - l, + top + b - t); } } diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index 664a99cd0..bbf0e03fd 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -430,7 +430,7 @@ class DeviceProfile { lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; lp.height = hotseatBarHeightPx; - hotseat.setPadding(2 * edgeMarginPx, 0, + hotseat.findViewById(R.id.layout).setPadding(2 * edgeMarginPx, 0, 2 * edgeMarginPx, 0); } hotseat.setLayoutParams(lp); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 3bbb39ee3..695dfd20e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -895,11 +895,6 @@ public class Launcher extends Activity @Override protected void onPause() { - // NOTE: We want all transitions from launcher to act as if the wallpaper were enabled - // to be consistent. So re-enable the flag here, and we will re-disable it as necessary - // when Launcher resumes and we are still in AllApps. - updateWallpaperVisibility(true); - // Ensure that items added to Launcher are queued until Launcher returns InstallShortcutReceiver.enableInstallQueue(); @@ -2646,16 +2641,6 @@ public class Launcher extends Activity view.setPivotY(view.getHeight() / 2.0f); } - void disableWallpaperIfInAllApps() { - // Only disable it if we are in all apps - if (isAllAppsVisible()) { - if (mAppsCustomizeTabHost != null && - !mAppsCustomizeTabHost.isTransitioning()) { - updateWallpaperVisibility(false); - } - } - } - private void setWorkspaceBackground(boolean workspace) { mLauncherView.setBackground(workspace ? mWorkspaceBackgroundDrawable : null); @@ -2815,7 +2800,6 @@ public class Launcher extends Activity @Override public void onAnimationStart(Animator animation) { - updateWallpaperVisibility(true); // Prepare the position toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); @@ -2827,10 +2811,6 @@ public class Launcher extends Activity dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); - if (!animationCancelled) { - updateWallpaperVisibility(false); - } - // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); @@ -2904,7 +2884,6 @@ public class Launcher extends Activity dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); - updateWallpaperVisibility(false); } } @@ -2941,7 +2920,6 @@ public class Launcher extends Activity } setPivotsForZoom(fromView, scaleFactor); - updateWallpaperVisibility(true); showHotseat(animated); if (animated) { final LauncherViewPropertyAnimator scaleAnim = @@ -2973,7 +2951,6 @@ public class Launcher extends Activity mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - updateWallpaperVisibility(true); fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); @@ -3011,30 +2988,13 @@ public class Launcher extends Activity } } - @Override - public void onWindowFocusChanged(boolean hasFocus) { - if (!hasFocus) { - // When another window occludes launcher (like the notification shade, or recents), - // ensure that we enable the wallpaper flag so that transitions are done correctly. - updateWallpaperVisibility(true); - } else { - // When launcher has focus again, disable the wallpaper if we are in AllApps - mWorkspace.postDelayed(new Runnable() { - @Override - public void run() { - disableWallpaperIfInAllApps(); - } - }, 500); - } - } - void showWorkspace(boolean animated) { showWorkspace(animated, null); } void showWorkspace(boolean animated, Runnable onCompleteRunnable) { if (mState != State.WORKSPACE) { - boolean wasInSpringLoadedMode = (mState == State.APPS_CUSTOMIZE_SPRING_LOADED); + boolean wasInSpringLoadedMode = (mState != State.WORKSPACE); mWorkspace.setVisibility(View.VISIBLE); hideAppsCustomizeHelper(State.WORKSPACE, animated, false, onCompleteRunnable); diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java index fa9ec5a15..c6d5e4996 100644 --- a/src/com/android/launcher3/PagedViewIcon.java +++ b/src/com/android/launcher3/PagedViewIcon.java @@ -18,6 +18,9 @@ package com.android.launcher3; import android.content.Context; import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Region; +import android.graphics.Region.Op; import android.util.AttributeSet; import android.util.TypedValue; import android.widget.TextView; @@ -99,4 +102,27 @@ public class PagedViewIcon extends TextView { setAlpha(1f); } } + + @Override + public void draw(Canvas canvas) { + // If text is transparent, don't draw any shadow + if (getCurrentTextColor() == getResources().getColor(android.R.color.transparent)) { + getPaint().clearShadowLayer(); + super.draw(canvas); + return; + } + + // We enhance the shadow by drawing the shadow twice + getPaint().setShadowLayer(BubbleTextView.SHADOW_LARGE_RADIUS, 0.0f, + BubbleTextView.SHADOW_Y_OFFSET, BubbleTextView.SHADOW_LARGE_COLOUR); + super.draw(canvas); + canvas.save(Canvas.CLIP_SAVE_FLAG); + canvas.clipRect(getScrollX(), getScrollY() + getExtendedPaddingTop(), + getScrollX() + getWidth(), + getScrollY() + getHeight(), Region.Op.INTERSECT); + getPaint().setShadowLayer(BubbleTextView.SHADOW_SMALL_RADIUS, 0.0f, 0.0f, + BubbleTextView.SHADOW_SMALL_COLOUR); + super.draw(canvas); + canvas.restore(); + } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index aab0a639a..e95a7abf8 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1836,10 +1836,10 @@ public class Workspace extends SmoothPagedView final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED); final boolean stateIsSmall = (state == State.SMALL); final boolean stateIsOverview = (state == State.OVERVIEW); - float finalBackgroundAlpha = stateIsSpringLoaded ? 1.0f : 0f; + float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f; float finalHotseatAndPageIndicatorAlpha = (stateIsOverview || stateIsSmall) ? 0f : 1f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; - float finalSearchBarAlpha = stateIsOverview ? 0f : 1f; + float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0; boolean zoomIn = true; @@ -1862,8 +1862,6 @@ public class Workspace extends SmoothPagedView if (oldStateIsNormal && stateIsSmall) { zoomIn = false; updateChildrenLayersEnabled(false); - } else { - finalBackgroundAlpha = 1.0f; } } final int duration = zoomIn ? @@ -1871,24 +1869,9 @@ public class Workspace extends SmoothPagedView getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime); for (int i = 0; i < getChildCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); - float finalAlpha = (!mWorkspaceFadeInAdjacentScreens || stateIsSpringLoaded || - (i == mCurrentPage)) ? 1f : 0f; - float currentAlpha = cl.getShortcutsAndWidgets().getAlpha(); - float initialAlpha = currentAlpha; - - // Determine the pages alpha during the state transition - if ((oldStateIsSmall && stateIsNormal) || - (oldStateIsNormal && stateIsSmall)) { - // To/from workspace - only show the current page unless the transition is not - // animated and the animation end callback below doesn't run; - // or, if we're in spring-loaded mode - if (i == mCurrentPage || !animated || oldStateIsSpringLoaded) { - finalAlpha = 1f; - } else { - initialAlpha = 0f; - finalAlpha = 0f; - } - } + float finalAlpha = (!mWorkspaceFadeInAdjacentScreens || + (i == mCurrentPage)) && !stateIsSmall ? 1f : 0f; + float initialAlpha = cl.getShortcutsAndWidgets().getAlpha(); mOldAlphas[i] = initialAlpha; mNewAlphas[i] = finalAlpha; @@ -1917,7 +1900,6 @@ public class Workspace extends SmoothPagedView cl.setBackgroundAlpha(mNewBackgroundAlphas[i]); cl.setShortcutAndWidgetAlpha(mNewAlphas[i]); } else { - if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) { LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets()); -- cgit v1.2.3