summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Folder.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-08-22 16:15:50 -0700
committerWinson Chung <winsonc@google.com>2013-08-23 12:13:02 -0700
commit892c74d460ad98c6306420e1127c9aa3e505ba25 (patch)
tree5abbb89efdad34335ef876284d520f6c7a705e3f /src/com/android/launcher3/Folder.java
parentfe14e04987a8baf77f0ffbd6d66839f33a4f0474 (diff)
downloadandroid_packages_apps_Trebuchet-892c74d460ad98c6306420e1127c9aa3e505ba25.tar.gz
android_packages_apps_Trebuchet-892c74d460ad98c6306420e1127c9aa3e505ba25.tar.bz2
android_packages_apps_Trebuchet-892c74d460ad98c6306420e1127c9aa3e505ba25.zip
Fixing folders to always show in view, removing old assets and references to LauncherModel count.
Diffstat (limited to 'src/com/android/launcher3/Folder.java')
-rw-r--r--src/com/android/launcher3/Folder.java48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index d428abc2c..6308bb792 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -29,7 +29,9 @@ import android.text.InputType;
import android.text.Selection;
import android.text.Spannable;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.TypedValue;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -85,7 +87,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private int mMaxCountY;
private int mMaxVisibleX;
private int mMaxVisibleY;
- private int mMaxContentAreaHeight = 0;
private int mMaxNumItems;
private ArrayList<View> mItemsInReadingOrder = new ArrayList<View>();
private Drawable mIconDrawable;
@@ -108,8 +109,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private float mFolderIconPivotX;
private float mFolderIconPivotY;
- private static final int SCROLL_CUT_OFF_AMOUNT = 60;
-
private static final float MAX_SCROLL_VELOCITY = 1500f;
private boolean mIsEditingName = false;
@@ -146,7 +145,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mIconCache = app.getIconCache();
Resources res = getResources();
- mMaxCountX = mMaxVisibleX = mMaxVisibleY = (int) (grid.numColumns);
+ mMaxCountX = mMaxVisibleX = (int) grid.numColumns;
+ mMaxVisibleY = (int) grid.numRows;
mMaxCountY = mMaxNumItems = Integer.MAX_VALUE;
mInputMethodManager = (InputMethodManager)
@@ -175,11 +175,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+ Rect padding = grid.getWorkspacePadding(grid.isLandscape ?
+ CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
+ DisplayMetrics dm = getResources().getDisplayMetrics();
- // Beyond this height, the area scrolls
mContent.setCellDimensions(grid.folderCellWidthPx, grid.folderCellHeightPx);
- mContent.setGridSize(mMaxVisibleX, mMaxVisibleY);
- mMaxContentAreaHeight = mContent.getDesiredHeight() - SCROLL_CUT_OFF_AMOUNT;
mContent.setGridSize(0, 0);
mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
mContent.setInvertIfRtl(true);
@@ -875,9 +875,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private void centerAboutIcon() {
DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
+ DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
int height = getFolderHeight();
- DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect);
@@ -945,31 +945,33 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
centerAboutIcon();
}
+ private int getContentAreaHeight() {
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+ Rect workspacePadding = grid.getWorkspacePadding(grid.isLandscape ?
+ CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
+ int maxContentAreaHeight = grid.availableHeightPx -
+ 4 * grid.edgeMarginPx -
+ workspacePadding.top - workspacePadding.bottom -
+ getPaddingTop() - getPaddingBottom() -
+ mFolderNameHeight;
+ return Math.min(maxContentAreaHeight,
+ mContent.getDesiredHeight());
+ }
+
private int getFolderHeight() {
- int contentAreaHeight = mContent.getDesiredHeight();
- if (contentAreaHeight >= mMaxContentAreaHeight) {
- // Subtract a bit so the user can see that it's scrollable.
- contentAreaHeight = mMaxContentAreaHeight;
- }
- int height = getPaddingTop() + getPaddingBottom() + contentAreaHeight
- + mFolderNameHeight;
+ int height = getPaddingTop() + getPaddingBottom()
+ + getContentAreaHeight() + mFolderNameHeight;
return height;
}
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int contentAreaHeight = mContent.getDesiredHeight();
- if (contentAreaHeight >= mMaxContentAreaHeight) {
- // Subtract a bit so the user can see that it's scrollable.
- contentAreaHeight = mMaxContentAreaHeight;
- }
-
int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
int height = getFolderHeight();
int contentAreaWidthSpec = MeasureSpec.makeMeasureSpec(mContent.getDesiredWidth(),
MeasureSpec.EXACTLY);
- int contentAreaHeightSpec = MeasureSpec.makeMeasureSpec(contentAreaHeight,
+ int contentAreaHeightSpec = MeasureSpec.makeMeasureSpec(getContentAreaHeight(),
MeasureSpec.EXACTLY);
-
mContent.setFixedSize(mContent.getDesiredWidth(), mContent.getDesiredHeight());
mScrollView.measure(contentAreaWidthSpec, contentAreaHeightSpec);
mFolderName.measure(contentAreaWidthSpec,