diff options
author | Roman Birg <roman@cyngn.com> | 2015-12-16 17:47:57 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2015-12-16 17:55:24 -0800 |
commit | 9ca8d4c76a2f80d5a87225d09d0155a43d2263dc (patch) | |
tree | 3edb56d457bf1e60f35ae7c983c3c7333ea82da3 /packages/SystemUI | |
parent | 44a3303477d114fcfad90bc03ae88f028006c26a (diff) | |
download | frameworks_base-9ca8d4c76a2f80d5a87225d09d0155a43d2263dc.zip frameworks_base-9ca8d4c76a2f80d5a87225d09d0155a43d2263dc.tar.gz frameworks_base-9ca8d4c76a2f80d5a87225d09d0155a43d2263dc.tar.bz2 |
SystemUI: fix incorrect tile shifting behavior
We need to clamp the max row count to 3 so that the method which
shifts any given tile to the next position can properly account when to
put a tile on the next page.
Also removed some extra debugging, make sure the user can't end up in a
blank page after removing the last tile.
Change-Id: I9367f35b1970c63383ab07dee2bf0622fcb8e94a
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java index 9cc45d8..8bbd619 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java @@ -62,7 +62,6 @@ import org.cyanogenmod.internal.util.QSUtils; import cyanogenmod.providers.CMSettings; import cyanogenmod.app.StatusBarPanelCustomTile; -import cyanogenmod.providers.CMSettings; import java.util.ArrayList; import java.util.Arrays; @@ -76,6 +75,8 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On private static final String TAG = "QSDragPanel"; public static final boolean DEBUG_DRAG = false; + + private static final int MAX_ROW_COUNT = 3; private static final int INITIAL_OFFSCREEN_PAGE_LIMIT = 3; private static final String BROADCAST_TILE_SPEC_PLACEHOLDER = "broadcast_placeholder"; @@ -229,7 +230,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On if (object instanceof QSPage) { final int indexOf = ((QSPage) object).getPageIndex(); - Log.v(TAG, "getItemPosition() for: " + object + ", returning: " + indexOf); if (mEditing) return indexOf + 1; else return indexOf; @@ -264,9 +264,11 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - Log.i(TAG, "onPageScrolled() called with " + "position = [" - + position + "], positionOffset = [" + positionOffset - + "], positionOffsetPixels = [" + positionOffsetPixels + "]"); + if (DEBUG_DRAG) { + Log.i(TAG, "onPageScrolled() called with " + "position = [" + + position + "], positionOffset = [" + positionOffset + + "], positionOffsetPixels = [" + positionOffsetPixels + "]"); + } if (mEditing) { float targetTranslationX = 0; @@ -287,7 +289,9 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On public void onPageSelected(int position) { if (mDragging && position != mDraggingRecord.page && !mViewPager.isFakeDragging() && !mRestoring) { - Log.w(TAG, "moving drag record to page: " + position); + if (DEBUG_DRAG) { + Log.w(TAG, "moving drag record to page: " + position); + } // remove it from the previous page and add it here final QSPage sourceP = getPage(mDraggingRecord.page); @@ -406,6 +410,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On mQsPanelTop.onStopDrag(); requestLayout(); + ensurePagerState(); } protected View getDropTarget() { @@ -741,7 +746,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On return cols; } - public int getMaxRows() { + public int getCurrentMaxRow() { int max = 0; for (TileRecord record : mRecords) { if (record.row > max) { @@ -1113,9 +1118,10 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } } - int maxRows = getMaxRows(); + // clamp this value to the max count we want. + int maxRows = Math.min(MAX_ROW_COUNT - 1 /* we are 0 based */, getCurrentMaxRow()); - if (tile.row >= maxRows) { + if (tile.row > maxRows) { tile.destinationPage = tile.destinationPage + 1; tile.row = 0; tile.col = 0; @@ -1136,7 +1142,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On Log.w(TAG, "column count adjusted to: " + columnCount); } } - boolean firstRowLarge = tile.row == 0 && tile.destinationPage == 0; + boolean firstRowLarge = mFirstRowLarge && tile.row == 0 && tile.destinationPage == 0; tile.destination.x = getLeft(tile.row, tile.col, columnCount, firstRowLarge); tile.destination.y = getRowTop(tile.row); |