diff options
author | Roman Birg <roman@cyngn.com> | 2016-05-11 07:32:21 -0700 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-05-24 05:15:57 -0700 |
commit | 112543548e41c9f58cdb5ba9b4f2a1f980555a88 (patch) | |
tree | 1fa03056ff8665c70dcd46dd46b96b6650116789 /packages | |
parent | ed671ae44aa112b15607731f057f988bde679a5a (diff) | |
download | frameworks_base-112543548e41c9f58cdb5ba9b4f2a1f980555a88.zip frameworks_base-112543548e41c9f58cdb5ba9b4f2a1f980555a88.tar.gz frameworks_base-112543548e41c9f58cdb5ba9b4f2a1f980555a88.tar.bz2 |
SystemUI: improve layout of qs detail panel
Don't try to fit the detail views, but allow the user to scroll freely
while detail view is showing and we are in landscape. The user can still
fling up and down and the velocity flings are respected in the detail
scroll lock mode.
Hitting done will always return the user
to the QS panel, or they can close the detail view manually.
Ticket: FEIJ-201
Change-Id: Id8b16a682ba5cebdc57c0455d81aa38fd5e90cbd
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages')
6 files changed, 69 insertions, 50 deletions
diff --git a/packages/SystemUI/res/layout/qs_detail.xml b/packages/SystemUI/res/layout/qs_detail.xml index 5058314..7ff9345 100644 --- a/packages/SystemUI/res/layout/qs_detail.xml +++ b/packages/SystemUI/res/layout/qs_detail.xml @@ -29,6 +29,7 @@ android:layout_weight="1" /> <LinearLayout + android:id="@+id/buttons" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingEnd="8dp" diff --git a/packages/SystemUI/res/layout/qs_detail_items_list.xml b/packages/SystemUI/res/layout/qs_detail_items_list.xml index 09021f9..33dd579 100644 --- a/packages/SystemUI/res/layout/qs_detail_items_list.xml +++ b/packages/SystemUI/res/layout/qs_detail_items_list.xml @@ -18,7 +18,7 @@ <com.android.systemui.qs.QSDetailItemsList xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:minHeight="200dp" + android:minHeight="100dp" android:paddingTop="16dp" android:paddingStart="16dp" android:paddingEnd="16dp"> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetailItemsList.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetailItemsList.java index 578a983..3e0ab8b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDetailItemsList.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetailItemsList.java @@ -27,6 +27,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListAdapter; @@ -42,7 +43,7 @@ import java.util.List; /** * Quick settings common detail list view with line items. */ -public class QSDetailItemsList extends LinearLayout { +public class QSDetailItemsList extends FrameLayout { private static final String TAG = "QSDetailItemsList"; private ListView mListView; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java index 74b1bc7..4b9036e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java @@ -57,6 +57,7 @@ import com.android.systemui.qs.tiles.CustomQSTile; import com.android.systemui.qs.tiles.EditTile; import com.android.systemui.settings.BrightnessController; import com.android.systemui.settings.ToggleSlider; +import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.QSTileHost; import com.android.systemui.statusbar.policy.BrightnessMirrorController; import com.android.systemui.tuner.QsTuner; @@ -64,11 +65,9 @@ import com.viewpagerindicator.CirclePageIndicator; import cyanogenmod.app.StatusBarPanelCustomTile; import cyanogenmod.providers.CMSettings; import org.cyanogenmod.internal.logging.CMMetricsLogger; -import org.cyanogenmod.internal.util.QSConstants; import org.cyanogenmod.internal.util.QSUtils; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -76,6 +75,8 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; + public class QSDragPanel extends QSPanel implements View.OnDragListener, View.OnLongClickListener { private static final String TAG = "QSDragPanel"; @@ -90,6 +91,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On protected final ArrayList<QSPage> mPages = new ArrayList<>(); + private NotificationPanelView mPanelView; protected QSViewPager mViewPager; protected PagerAdapter mPagerAdapter; QSPanelTopView mQsPanelTop; @@ -98,6 +100,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On private TextView mDetailRemoveButton; private DragTileRecord mDraggingRecord, mLastDragRecord; + private ViewGroup mDetailButtons; private boolean mEditing; private boolean mDragging; private float mLastTouchLocationX, mLastTouchLocationY; @@ -115,9 +118,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On List<TileRecord> mCurrentlyAnimating = Collections.synchronizedList(new ArrayList<TileRecord>()); - private Point mDisplaySize; - private int[] mTmpLoc; - private Runnable mResetPage = new Runnable() { @Override public void run() { @@ -141,6 +141,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On updateResources(); mDetail = LayoutInflater.from(mContext).inflate(R.layout.qs_detail, this, false); + mDetailButtons = (ViewGroup) mDetail.findViewById(R.id.buttons); mDetailContent = (ViewGroup) mDetail.findViewById(android.R.id.content); mDetailRemoveButton = (TextView) mDetail.findViewById(android.R.id.button3); mDetailSettingsButton = (TextView) mDetail.findViewById(android.R.id.button2); @@ -787,13 +788,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - mTmpLoc = null; - mDisplaySize = null; - } - - @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int width = MeasureSpec.getSize(widthMeasureSpec); @@ -807,37 +801,18 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On if (mFooter.hasFooter()) { h += mFooter.getView().getMeasuredHeight(); } + mGridHeight = h; + mDetail.measure(exactly(width), MeasureSpec.UNSPECIFIED); + if (mDetail.getMeasuredHeight() < h) { mDetail.measure(exactly(width), exactly(h)); } - - // Check if the detail view would be overflowing below the physical height of the device - // and cutting the content off. If it is, reduce the detail height to fit. - if (isShowingDetail()) { - if (mDisplaySize == null) { - mDisplaySize = new Point(); - getDisplay().getSize(mDisplaySize); - } - if (mTmpLoc == null) { - mTmpLoc = new int[2]; - mDetail.getLocationOnScreen(mTmpLoc); - } - - final int containerTop = mTmpLoc[1]; - final int detailBottom = containerTop + mDetail.getMeasuredHeight(); - if (detailBottom >= mDisplaySize.y) { - // panel is hanging below the screen - final int detailMinHeight = mDisplaySize.y - containerTop; - mDetail.measure(exactly(width), exactly(detailMinHeight)); - } - setMeasuredDimension(width, mDetail.getMeasuredHeight()); - mGridHeight = mDetail.getMeasuredHeight(); - } else { - setMeasuredDimension(width, h); - mGridHeight = h; + if (isShowingDetail() && !isClosingDetail() && mExpanded) { + h = mDetail.getMeasuredHeight(); } + setMeasuredDimension(width, h); for (TileRecord record : mRecords) { setupRecord(record); } @@ -867,11 +842,13 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } r.tile.setDetailListening(show); int x = (int) ((DragTileRecord) r).destination.x + r.tileView.getWidth() / 2; - int y = mViewPager.getTop() + (int) ((DragTileRecord) r).destination.y + r.tileView.getHeight() / 2; + int y = mViewPager.getTop() + + (int) ((DragTileRecord) r).destination.y + r.tileView.getHeight() / 2; handleShowDetailImpl(r, show, x, y); } else { super.handleShowDetailTile(r, show); } + mPageIndicator.setVisibility(!show ? View.VISIBLE : View.INVISIBLE); } @Override @@ -884,9 +861,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On // view pager laid out from top of brightness view to bottom to page through settings mViewPager.layout(0, 0, w, viewPagerBottom); - // layout page indicator inside viewpager inset - mPageIndicator.layout(0, b - mPageIndicatorHeight, w, b); - mDetail.layout(0, 0, w, mDetail.getMeasuredHeight()); if (mFooter.hasFooter()) { @@ -897,7 +871,10 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On if (!isShowingDetail() && !isClosingDetail()) { mQsPanelTop.bringToFront(); + } + // layout page indicator inside viewpager inset + mPageIndicator.layout(0, b - mPageIndicatorHeight, w, b); } protected int getRowTop(int row) { @@ -1832,12 +1809,16 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } }); } + mPanelView.setDetailRequestedScrollLock(mExpanded && show + && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); FontSizeUtils.updateFontSize(mDetailRemoveButton, R.dimen.qs_detail_button_text_size); + mPanelView.setDetailRequestedScrollLock(mExpanded && isShowingDetail() + && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE); } @Override @@ -1887,6 +1868,10 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } } + public void setPanelView(NotificationPanelView panelView) { + this.mPanelView = panelView; + } + public static class TilesListAdapter extends BaseExpandableListAdapter implements QSTile.DetailAdapter { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 60dc787..77ede93 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -72,7 +72,7 @@ public class QSPanel extends ViewGroup { protected int mDualTileUnderlap; protected int mBrightnessPaddingTop; protected int mGridHeight; - private boolean mExpanded; + protected boolean mExpanded; protected boolean mListening; private boolean mClosingDetail; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 4de6271..936fcca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -264,8 +264,7 @@ public class NotificationPanelView extends PanelView implements private final GestureDetector mGestureDetector; private ViewLinker mViewLinker; private final UnlockMethodCache mUnlockMethodCache; - - + private boolean mDetailScrollLock; private enum SwipeLockedDirection { UNKNOWN, HORIZONTAL, @@ -412,6 +411,7 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusView = (KeyguardStatusView) findViewById(R.id.keyguard_status_view); mQsContainer = (QSContainer) findViewById(R.id.quick_settings_container); mQsPanel = (QSDragPanel) findViewById(R.id.quick_settings_panel); + mQsPanel.setPanelView(this); mClockView = (TextView) findViewById(R.id.clock_view); mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view); mScrollView.setFocusable(false); @@ -1227,8 +1227,13 @@ public class NotificationPanelView extends PanelView implements mTrackingPointer = -1; trackMovement(event); float fraction = getQsExpansionFraction(); - if ((fraction != 0f || y >= mInitialTouchY) - && (fraction != 1f || y <= mInitialTouchY)) { + final boolean fling = (fraction != 0f || y >= mInitialTouchY) + && (fraction != 1f || y <= mInitialTouchY); + final boolean flingExpand = Math.abs(getCurrentVelocity()) + > mFlingAnimationUtils.getMinVelocityPxPerSecond(); + final boolean detailFling = mDetailScrollLock && mQsExpanded + && flingExpand; + if ((fling && !mDetailScrollLock) || detailFling) { flingQsWithCurrentVelocity(y, event.getActionMasked() == MotionEvent.ACTION_CANCEL); } else { @@ -1806,7 +1811,8 @@ public class NotificationPanelView extends PanelView implements && y >= header.getTop() && y <= header.getBottom(); if (mQsExpanded) { - return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0) && isInQsArea(x, y); + return onHeader || mDetailScrollLock + || (mScrollView.isScrolledToBottom() && yDiff < 0) && isInQsArea(x, y); } else { return onHeader; } @@ -1896,7 +1902,7 @@ public class NotificationPanelView extends PanelView implements */ private int getTempQsMaxExpansion() { int qsTempMaxExpansion = mQsMaxExpansionHeight; - if (mScrollYOverride != -1) { + if (mScrollYOverride != -1 && !mDetailScrollLock) { qsTempMaxExpansion -= mScrollYOverride; } return qsTempMaxExpansion; @@ -2842,6 +2848,32 @@ public class NotificationPanelView extends PanelView implements return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName()); } + public void setDetailRequestedScrollLock(boolean detailScrollFlag) { + if (mDetailScrollLock != detailScrollFlag) { + if (mStatusBarState != StatusBarState.SHADE) { + mDetailScrollLock = false; + } else { + mDetailScrollLock = detailScrollFlag; + } + if (!detailScrollFlag && getQsExpansionFraction() > 0.3f) { + flingSettings(getCurrentVelocity(), true, new Runnable() { + @Override + public void run() { + mStackScrollerOverscrolling = false; + mQsExpansionFromOverscroll = false; + updateQsState(); + updateHeader(); + updateMaxHeadsUpTranslation(); + updatePanelExpanded(); + requestLayout(); + } + }, false); + } else { + requestLayout(); + } + } + } + private class SlideInAnimationListener implements ValueAnimator.AnimatorUpdateListener, ValueAnimator.AnimatorListener { @Override |