diff options
author | Roman Birg <roman@cyngn.com> | 2016-02-25 09:08:19 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-02-25 09:08:19 -0800 |
commit | 9c1b73021cd6c58f098135ec6970fe3f5eb73417 (patch) | |
tree | be2a4ec0e1d5e6fe342353034d85b2a273c6690e /packages/SystemUI/src | |
parent | d218a202b74ec8278fdf3d93477204419a9250be (diff) | |
download | frameworks_base-9c1b73021cd6c58f098135ec6970fe3f5eb73417.zip frameworks_base-9c1b73021cd6c58f098135ec6970fe3f5eb73417.tar.gz frameworks_base-9c1b73021cd6c58f098135ec6970fe3f5eb73417.tar.bz2 |
SystemUI: reset tile page after inactivity
Reset the quick settings page back to the first page when the user
hasn't expanded their statusbar for 10s.
Ref: CYNGNOS-2132
Change-Id: Ia195f8c85c8e399ab5e4808fe0ccc343853a1577
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java index 0615842..86fc49e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java @@ -89,6 +89,9 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On private static final int MAX_ROW_COUNT = 3; + // how long to wait before resetting the page + private static final int PAGE_RESET_DELAY = 10000; + protected final ArrayList<QSPage> mPages = new ArrayList<>(); protected QSViewPager mViewPager; @@ -119,6 +122,16 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On private Point mDisplaySize; private int[] mTmpLoc; + private Runnable mResetPage = new Runnable() { + @Override + public void run() { + if (!mListening) { + // only reset when the user isn't interacting at all + mViewPager.setCurrentItem(0); + } + } + }; + public QSDragPanel(Context context) { this(context, null); } @@ -369,6 +382,12 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On public void setListening(boolean listening) { if (mListening == listening) return; mListening = listening; + // reset the page when inactive for a while + if (listening) { + removeCallbacks(mResetPage); + } else { + postDelayed(mResetPage, PAGE_RESET_DELAY); + } for (TileRecord r : mRecords) { r.tile.setListening(mListening); } @@ -481,36 +500,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On mDetailRemoveButton.setText(R.string.quick_settings_remove); } - /** - * @return returns the number of pages that has at least 1 visible tile - */ - protected int getVisibleTilePageCount() { - // if all tiles are invisible on the page, do not count it - int pages = 0; - - int lastPage = -1; - boolean allTilesInvisible = true; - - for (TileRecord record : mRecords) { - DragTileRecord dr = (DragTileRecord) record; - if (dr.destinationPage != lastPage) { - if (!allTilesInvisible) { - pages++; - } - lastPage = dr.destinationPage; - allTilesInvisible = true; - } - if (allTilesInvisible && dr.tile.getState().visible) { - allTilesInvisible = false; - } - } - // last tile may have set this - if (!allTilesInvisible) { - pages++; - } - return pages; - } - public void setTiles(final Collection<QSTile<?>> tilesCollection) { final List<QSTile<?>> tiles = new ArrayList<>(tilesCollection); if (DEBUG_TILES) { |