Fixing issue with folders not showing up.
- Add long click on empty spaces in hotseat to show overview mode
- Limit the height of all apps to the workspace + hotseat size
- Fixing some comments
Change-Id: Ie5a97a8b04e449385e2b3f6230079aebf8e15d5a
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 682c2ed..04f4d81 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -64,6 +64,8 @@
private Launcher mLauncher;
private int mCellWidth;
private int mCellHeight;
+ private int mFixedCellWidth;
+ private int mFixedCellHeight;
private int mCountX;
private int mCountY;
@@ -193,8 +195,8 @@
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
- mCellWidth = -1;
- mCellHeight = -1;
+ mCellWidth = mCellHeight = -1;
+ mFixedCellHeight = mFixedCellHeight = -1;
mWidthGap = mOriginalWidthGap = 0;
mHeightGap = mOriginalHeightGap = 0;
mMaxGap = Integer.MAX_VALUE;
@@ -310,8 +312,8 @@
}
public void setCellDimensions(int width, int height) {
- mCellWidth = width;
- mCellHeight = height;
+ mFixedCellWidth = mCellWidth = width;
+ mFixedCellHeight = mCellHeight = height;
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
mCountX, mCountY);
}
@@ -947,13 +949,15 @@
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
- int cw = grid.calculateCellWidth(widthSize, mCountX);
- int ch = grid.calculateCellHeight(heightSize, mCountY);
- if (cw != mCellWidth || ch != mCellHeight) {
- mCellWidth = cw;
- mCellHeight = ch;
- mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap,
- mHeightGap, mCountX, mCountY);
+ if (mFixedCellWidth < 0 || mFixedCellHeight < 0) {
+ int cw = grid.calculateCellWidth(widthSize, mCountX);
+ int ch = grid.calculateCellHeight(heightSize, mCountY);
+ if (cw != mCellWidth || ch != mCellHeight) {
+ mCellWidth = cw;
+ mCellHeight = ch;
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap,
+ mHeightGap, mCountX, mCountY);
+ }
}
int newWidth = widthSize;
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index f43af61..70f0000 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -223,17 +223,16 @@
availableWidthPx = awPx;
availableHeightPx = ahPx;
- if (isLandscape) {
- allAppsNumRows = (int) numRows - 1;
- } else {
- allAppsNumRows = (int) numRows + 1;
- }
Rect padding = getWorkspacePadding(isLandscape ?
CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
int pageIndicatorOffset =
resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset);
- allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /
- (iconSizePx + iconTextSizePx + 2 * edgeMarginPx);
+ if (isLandscape) {
+ allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /
+ (iconSizePx + iconTextSizePx + 2 * edgeMarginPx);
+ } else {
+ allAppsNumRows = (int) numRows + 1;
+ }
allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) /
(iconSizePx + 2 * edgeMarginPx);
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ec78761..fbbb09f 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -69,6 +69,14 @@
CellLayout getLayout() {
return mContent;
}
+
+ /**
+ * Registers the specified listener on the cell layout of the hotseat.
+ */
+ @Override
+ public void setOnLongClickListener(OnLongClickListener l) {
+ mContent.setOnLongClickListener(l);
+ }
private boolean hasVerticalHotseat() {
return (mIsLandscape && mTransposeLayoutWithOrientation);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 29c4e3e..99e4b0c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1114,6 +1114,7 @@
mHotseat = (Hotseat) findViewById(R.id.hotseat);
if (mHotseat != null) {
mHotseat.setup(this);
+ mHotseat.setOnLongClickListener(this);
}
mOverviewPanel = findViewById(R.id.overview_panel);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 18e1c85..179c8aa 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2428,9 +2428,6 @@
private void loadAllApps() {
final long loadTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
- // "two variables"?
- // Don't use these two variables in any of the callback runnables.
- // Otherwise we hold a reference to them.
final Callbacks oldCallbacks = mCallbacks.get();
if (oldCallbacks == null) {
// This launcher has exited and nobody bothered to tell us. Just bail.
@@ -2477,7 +2474,6 @@
}
// Huh? Shouldn't this be inside the Runnable below?
- final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
final ArrayList<AppInfo> added = mBgAllAppsList.added;
mBgAllAppsList.added = new ArrayList<AppInfo>();
@@ -2485,6 +2481,7 @@
mHandler.post(new Runnable() {
public void run() {
final long bindTime = SystemClock.uptimeMillis();
+ final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindAllApplications(added);
if (DEBUG_LOADERS) {