diff options
author | Adam Cohen <adamcohen@google.com> | 2011-08-23 22:49:11 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-23 22:49:11 -0700 |
commit | debaf1e6be7312838b70d76d730d0b3403f8a2b8 (patch) | |
tree | 47bfe24be421151e93e8400763cbb796b8afa8b1 | |
parent | 2a9e228e6fd719732639beb880d6df64d48158a1 (diff) | |
parent | 099f60d51f6310e1290687e83958e665b3324504 (diff) | |
download | packages_apps_trebuchet-debaf1e6be7312838b70d76d730d0b3403f8a2b8.zip packages_apps_trebuchet-debaf1e6be7312838b70d76d730d0b3403f8a2b8.tar.gz packages_apps_trebuchet-debaf1e6be7312838b70d76d730d0b3403f8a2b8.tar.bz2 |
Merge "Fixing folder icon in landscape, issue 5135333"
-rw-r--r-- | res/values-land/dimens.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/FolderIcon.java | 41 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 24 |
3 files changed, 58 insertions, 11 deletions
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml index 4f6bc41..55a25ec 100644 --- a/res/values-land/dimens.xml +++ b/res/values-land/dimens.xml @@ -61,4 +61,8 @@ <dimen name="apps_customize_widget_cell_height_gap">5dp</dimen> <integer name="apps_customize_widget_cell_count_x">3</integer> <integer name="apps_customize_widget_cell_count_y">2</integer> + +<!-- Folders --> + <!-- The size of the image which sits behind the preview of the folder contents --> + <dimen name="folder_preview_size">58dp</dimen> </resources> diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java index f1a1508..cde5d94 100644 --- a/src/com/android/launcher2/FolderIcon.java +++ b/src/com/android/launcher2/FolderIcon.java @@ -27,6 +27,7 @@ import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.os.Parcelable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -50,6 +51,7 @@ public class FolderIcon extends LinearLayout implements FolderListener { private Launcher mLauncher; Folder mFolder; FolderInfo mInfo; + private static boolean sStaticValuesDirty = true; // The number of icons to display in the private static final int NUM_ITEMS_IN_PREVIEW = 3; @@ -132,18 +134,26 @@ public class FolderIcon extends LinearLayout implements FolderListener { folder.setFolderIcon(icon); folder.bind(folderInfo); icon.mFolder = folder; - icon.mFolderRingAnimator = new FolderRingAnimator(launcher, icon); - - folderInfo.addListener(icon); - Resources res = launcher.getResources(); - if (sSharedFolderLeaveBehind == null) { + + // We need to reload the static values when configuration changes in case they are + // different in another configuration + if (sStaticValuesDirty) { sSharedFolderLeaveBehind = res.getDrawable(R.drawable.portal_ring_rest); } + icon.mFolderRingAnimator = new FolderRingAnimator(launcher, icon); + folderInfo.addListener(icon); + return icon; } + @Override + protected Parcelable onSaveInstanceState() { + sStaticValuesDirty = true; + return super.onSaveInstanceState(); + } + public static class FolderRingAnimator { public int mCellX; public int mCellY; @@ -167,15 +177,14 @@ public class FolderIcon extends LinearLayout implements FolderListener { mOuterRingDrawable = res.getDrawable(R.drawable.portal_ring_outer_holo); mInnerRingDrawable = res.getDrawable(R.drawable.portal_ring_inner_holo); - if (sPreviewSize < 0 || sPreviewPadding < 0) { + // We need to reload the static values when configuration changes in case they are + // different in another configuration + if (sStaticValuesDirty) { sPreviewSize = res.getDimensionPixelSize(R.dimen.folder_preview_size); sPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding); - } - if (sSharedOuterRingDrawable == null) { sSharedOuterRingDrawable = res.getDrawable(R.drawable.portal_ring_outer_holo); - } - if (sSharedInnerRingDrawable == null) { sSharedInnerRingDrawable = res.getDrawable(R.drawable.portal_ring_inner_holo); + sStaticValuesDirty = false; } } @@ -554,6 +563,18 @@ public class FolderIcon extends LinearLayout implements FolderListener { va.start(); } + public void setTextVisible(boolean visible) { + if (visible) { + mFolderName.setVisibility(VISIBLE); + } else { + mFolderName.setVisibility(INVISIBLE); + } + } + + public boolean getTextVisible() { + return mFolderName.getVisibility() == VISIBLE; + } + public void onItemsChanged() { invalidate(); requestLayout(); diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index b6a1666..1c13f14 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -465,6 +465,11 @@ public class Workspace extends SmoothPagedView layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); + // Hide folder title in the hotseat + if (child instanceof FolderIcon) { + ((FolderIcon) child).setTextVisible(false); + } + if (screen < 0) { screen = mLauncher.getHotseat().getOrderInHotseat(x, y); } else { @@ -474,6 +479,11 @@ public class Workspace extends SmoothPagedView y = mLauncher.getHotseat().getCellYFromOrder(screen); } } else { + // Show folder title if not in the hotseat + if (child instanceof FolderIcon) { + ((FolderIcon) child).setTextVisible(true); + } + layout = (CellLayout) getChildAt(screen); child.setOnKeyListener(new BubbleTextViewKeyEventListener()); } @@ -1900,6 +1910,8 @@ public class Workspace extends SmoothPagedView final Rect clipRect = mTempRect; v.getDrawingRect(clipRect); + boolean textVisible = false; + destCanvas.save(); if (v instanceof TextView && pruneToDrawable) { Drawable d = ((TextView) v).getCompoundDrawables()[1]; @@ -1908,7 +1920,12 @@ public class Workspace extends SmoothPagedView d.draw(destCanvas); } else { if (v instanceof FolderIcon) { - clipRect.bottom = getResources().getDimensionPixelSize(R.dimen.folder_preview_size); + // For FolderIcons the text can bleed into the icon area, and so we need to + // hide the text completely (which can't be achieved by clipping). + if (((FolderIcon) v).getTextVisible()) { + ((FolderIcon) v).setTextVisible(false); + textVisible = true; + } } else if (v instanceof BubbleTextView) { final BubbleTextView tv = (BubbleTextView) v; clipRect.bottom = tv.getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + @@ -1921,6 +1938,11 @@ public class Workspace extends SmoothPagedView destCanvas.translate(-v.getScrollX() + padding / 2, -v.getScrollY() + padding / 2); destCanvas.clipRect(clipRect, Op.REPLACE); v.draw(destCanvas); + + // Restore text visibility of FolderIcon if necessary + if (textVisible) { + ((FolderIcon) v).setTextVisible(true); + } } destCanvas.restore(); } |