diff options
author | Roman Birg <roman@cyngn.com> | 2016-01-18 10:40:00 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-01-18 11:36:16 -0800 |
commit | b5dd079914e35128d775ff64fbaba40ee74f209a (patch) | |
tree | 81442aab55359a5679794faa4d082cd14201e5e2 | |
parent | 627df3cd7367f0198abb92b8e435bb057ba6f433 (diff) | |
download | frameworks_base-b5dd079914e35128d775ff64fbaba40ee74f209a.zip frameworks_base-b5dd079914e35128d775ff64fbaba40ee74f209a.tar.gz frameworks_base-b5dd079914e35128d775ff64fbaba40ee74f209a.tar.bz2 |
SystemUI: add some tile removal hints
Ref: CYNGNOS-1644
Change-Id: I41e921c641f53a5870fb5685e2ef67060d613989
Signed-off-by: Roman Birg <roman@cyngn.com>
7 files changed, 100 insertions, 64 deletions
diff --git a/packages/SystemUI/res/layout/qs_tile_top.xml b/packages/SystemUI/res/layout/qs_tile_top.xml index 0a6736a..4413ec3 100644 --- a/packages/SystemUI/res/layout/qs_tile_top.xml +++ b/packages/SystemUI/res/layout/qs_tile_top.xml @@ -17,11 +17,12 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/qs_panel_top" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:paddingTop="@dimen/qs_brightness_padding_top" + android:clipToPadding="false" + android:layout_height="wrap_content"> <!-- brightness --> <include android:id="@+id/brightness_container" - android:paddingTop="@dimen/qs_brightness_padding_top" layout="@layout/quick_settings_brightness_dialog"/> <!-- delete target --> @@ -29,7 +30,6 @@ android:id="@+id/delete_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="@dimen/qs_brightness_padding_top" android:paddingLeft="16dp" android:paddingRight="16dp" android:orientation="horizontal"> @@ -49,7 +49,6 @@ android:id="@+id/edit_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="@dimen/qs_brightness_padding_top" android:paddingLeft="16dp" android:paddingRight="16dp" android:orientation="horizontal"> @@ -75,7 +74,6 @@ <TextView android:id="@+id/qs_toast" android:layout_height="match_parent" - android:paddingTop="@dimen/qs_brightness_padding_top" android:paddingLeft="16dp" android:paddingRight="16dp" android:gravity="center_vertical" diff --git a/packages/SystemUI/res/values/cm_colors.xml b/packages/SystemUI/res/values/cm_colors.xml index 098a942..ec1da61 100644 --- a/packages/SystemUI/res/values/cm_colors.xml +++ b/packages/SystemUI/res/values/cm_colors.xml @@ -74,6 +74,13 @@ <color name="qs_edit_header_instruction_text_color">@android:color/white</color> <color name="qs_row_text_color">@android:color/white</color> + <!-- natural color of the trash can --> + <color name="qs_tile_trash">#FFFFFF</color> + <!-- tint to color trash can when tile is hovering over it --> + <color name="qs_tile_trash_delete_tint">#FF0000</color> + <!-- tint to color trash can when hovering edit tile, user cannot delete it --> + <color name="qs_tile_trash_delete_tint_warning">#FF9C00</color> + <!-- More exposed hard coded colors --> <color name="toggle_slider_text_color">#666666</color> <color name="no_recent_apps_text_color">@android:color/holo_blue_light</color> diff --git a/packages/SystemUI/res/values/cm_dimens.xml b/packages/SystemUI/res/values/cm_dimens.xml index 73608b7..3bce97b 100644 --- a/packages/SystemUI/res/values/cm_dimens.xml +++ b/packages/SystemUI/res/values/cm_dimens.xml @@ -39,6 +39,9 @@ <!-- Padding end for weather text --> <dimen name="status_bar_weather_padding_end">16dp</dimen> + <!-- height of the qs page indicator --> + <dimen name="qs_panel_page_indicator_height">8dp</dimen> + <dimen name="lockscreen_icon_side_padding">10dp</dimen> <dimen name="lockscreen_icon_size">35dp</dimen> <dimen name="phone_side_padding">10dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java index f45378d..88b5d4e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java @@ -36,6 +36,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.UserHandle; +import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.ArrayMap; @@ -46,7 +47,6 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; import android.widget.BaseExpandableListAdapter; import android.widget.EditText; import android.widget.ExpandableListView; @@ -72,7 +72,6 @@ import org.cyanogenmod.internal.logging.CMMetricsLogger; 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; @@ -96,6 +95,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On protected PagerAdapter mPagerAdapter; QSPanelTopView mQsPanelTop; CirclePageIndicator mPageIndicator; + private int mPageIndicatorHeight; private TextView mDetailRemoveButton; private DragTileRecord mDraggingRecord, mLastDragRecord; @@ -140,27 +140,16 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On mDetail.setVisibility(GONE); mDetail.setClickable(true); - mQsPanelTop = (QSPanelTopView) LayoutInflater.from(mContext).inflate(R.layout.qs_tile_top, this, false); + mQsPanelTop = (QSPanelTopView) LayoutInflater.from(mContext).inflate(R.layout.qs_tile_top, + this, false); + + // tint trash can to default color + final int color = mContext.getColor(R.color.qs_tile_trash); + DrawableCompat.setTint(mQsPanelTop.getDropTargetIcon().getDrawable(), color); mBrightnessView = mQsPanelTop.getBrightnessView(); mFooter = new QSFooter(this, mContext); - getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - getViewTreeObserver().removeOnGlobalLayoutListener(this); - - ViewPager.LayoutParams params = new ViewPager.LayoutParams(); - params.isDecor = true; - - mViewPager.addView(mQsPanelTop, params); - - mQsPanelTop.setOnDragListener(QSDragPanel.this); - mPageIndicator.setOnDragListener(QSDragPanel.this); - mViewPager.setOnDragListener(QSDragPanel.this); - } - }); - // add target click listener mQsPanelTop.getAddTarget().setOnClickListener( new OnClickListener() { @@ -176,6 +165,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On mPageIndicator = new CirclePageIndicator(getContext()); addView(mDetail); + addView(mQsPanelTop); addView(mViewPager); addView(mPageIndicator); addView(mFooter.getView()); @@ -330,6 +320,11 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On setClipChildren(false); mSettingsObserver = new SettingsObserver(new Handler()); + + mViewPager.setOnDragListener(QSDragPanel.this); + mQsPanelTop.setOnDragListener(QSDragPanel.this); + mPageIndicator.setOnDragListener(QSDragPanel.this); + setOnDragListener(QSDragPanel.this); } @Override @@ -715,16 +710,12 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int width = MeasureSpec.getSize(widthMeasureSpec); - if (isLaidOut()) { - mQsPanelTop.measure(exactly(width), MeasureSpec.UNSPECIFIED); - } + mQsPanelTop.measure(exactly(width), MeasureSpec.UNSPECIFIED); mViewPager.measure(exactly(width), MeasureSpec.UNSPECIFIED); - mPageIndicator.measure(exactly(width), MeasureSpec.UNSPECIFIED); + mPageIndicator.measure(exactly(width), atMost(mPageIndicatorHeight)); mFooter.getView().measure(exactly(width), MeasureSpec.UNSPECIFIED); - int h = mBrightnessPaddingTop - + mViewPager.getMeasuredHeight() - + mPageIndicator.getMeasuredHeight(); + int h = mViewPager.getMeasuredHeight() + mPageIndicatorHeight; if (mFooter.hasFooter()) { h += mFooter.getView().getMeasuredHeight(); } @@ -773,6 +764,10 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); } + public static int atMost(int size) { + return MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST); + } + @Override protected void handleShowDetailTile(TileRecord r, boolean show) { if (r instanceof DragTileRecord) { @@ -795,13 +790,14 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On protected void onLayout(boolean changed, int l, int t, int r, int b) { final int w = getWidth(); - int top = mBrightnessPaddingTop; + mQsPanelTop.layout(0, 0, w, mQsPanelTop.getMeasuredHeight()); - mViewPager.layout(0, top, w, top + mViewPager.getMeasuredHeight()); - top += mViewPager.getMeasuredHeight(); + int viewPagerBottom = mQsPanelTop.getMeasuredHeight() + mViewPager.getMeasuredHeight(); + // view pager laid out from top of brightness view to bottom to page through settings + mViewPager.layout(0, 0, w, viewPagerBottom); - // layout page indicator below view pager - mPageIndicator.layout(0, top, w, top + mPageIndicator.getMeasuredHeight()); + // layout page indicator inside viewpager inset + mPageIndicator.layout(0, b - mPageIndicatorHeight, w, b); mDetail.layout(0, 0, w, mDetail.getMeasuredHeight()); @@ -811,11 +807,13 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On footer.getMeasuredWidth(), getMeasuredHeight()); } + mQsPanelTop.bringToFront(); + ensurePagerState(); } protected int getRowTop(int row) { - int baseHeight = mBrightnessView.getMeasuredHeight() + mBrightnessPaddingTop; + int baseHeight = mBrightnessView.getMeasuredHeight(); if (row <= 0) return baseHeight; return baseHeight + mLargeCellHeight - mDualTileUnderlap + (row - 1) * mCellHeight; } @@ -916,21 +914,43 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On boolean dragRecordAttached = dragRecordIndex != -1; switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: + if (DEBUG_DRAG) { + Log.v(TAG, "ACTION_DRAG_STARTED on view: " + v); + } + if (originatingTileEvent) { if (DEBUG_DRAG) { Log.v(TAG, "ACTION_DRAG_STARTED on target view."); } mRestored = false; } - return true; + + break; case DragEvent.ACTION_DRAG_ENTERED: if (DEBUG_DRAG) { - Log.v(TAG, "ACTION_DRAG_ENTERED on view with tile: " + targetTile); + if (targetTile != null) { + Log.v(TAG, "ACTION_DRAG_ENTERED on view with tile: " + targetTile); + } else { + Log.v(TAG, "ACTION_DRAG_ENTERED on view: " + v); + } } mLocationHits = 0; mMovedByLocation = false; + if (v == mQsPanelTop) { + int color; + if (mDraggingRecord.tile instanceof EditTile) { + // use a different warning, user can't erase this one + color = mContext.getColor(R.color.qs_tile_trash_delete_tint_warning); + } else { + color = mContext.getColor(R.color.qs_tile_trash_delete_tint); + } + + DrawableCompat.setTint(mQsPanelTop.getDropTargetIcon().getDrawable(), color); + mQsPanelTop.getDropTargetIcon().invalidate(); + } + if (!originatingTileEvent && v != getDropTarget() && targetTile != null) { if (DEBUG_DRAG) { Log.e(TAG, "entered tile " + targetTile); @@ -947,7 +967,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } } - return true; + break; case DragEvent.ACTION_DRAG_ENDED: if (DEBUG_DRAG) { Log.v(TAG, "ACTION_DRAG_ENDED on view: " + v + "(tile: " @@ -958,7 +978,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On restoreDraggingTilePosition(v); } - return true; + break; case DragEvent.ACTION_DROP: if (DEBUG_DRAG) { @@ -975,7 +995,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On if (mDraggingRecord.tile instanceof EditTile) { mQsPanelTop.toast(R.string.quick_settings_cannot_delete_edit_tile); restoreDraggingTilePosition(v); - return true; + break; } else { mRestored = true; // what spec is this tile? @@ -989,7 +1009,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } else { restoreDraggingTilePosition(v); } - return true; + break; case DragEvent.ACTION_DRAG_EXITED: if (DEBUG_DRAG) { @@ -999,6 +1019,13 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On Log.v(TAG, "ACTION_DRAG_EXITED on view: " + v); } } + + if (v == mQsPanelTop) { + final int color = mContext.getColor(R.color.qs_tile_trash); + DrawableCompat.setTint(mQsPanelTop.getDropTargetIcon().getDrawable(), color); + mQsPanelTop.getDropTargetIcon().invalidate(); + } + if (originatingTileEvent && mCurrentlyAnimating.isEmpty() && !mViewPager.isFakeDragging() @@ -1014,7 +1041,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On // move tiles back shiftTiles(mDraggingRecord, false); - return true; + break; } // fall through so exit events can trigger a left shift case DragEvent.ACTION_DRAG_LOCATION: @@ -1076,17 +1103,20 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On shiftTiles((DragTileRecord) mRecords.get(mLastRightShift), false); mMovedByLocation = true; } + } else { if (DEBUG_DRAG) { Log.i(TAG, "ignoring location event because things are animating, size: " + mCurrentlyAnimating.size()); } } - return true; + break; + default: Log.w(TAG, "unhandled event"); + return false; } - return false; + return true; } private boolean isDropTargetEvent(DragEvent event, View v) { @@ -1668,6 +1698,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On mPanelPaddingBottom = res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom); mDualTileUnderlap = res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical); mBrightnessPaddingTop = res.getDimensionPixelSize(R.dimen.qs_brightness_padding_top); + mPageIndicatorHeight = res.getDimensionPixelSize(R.dimen.qs_panel_page_indicator_height); if (isLaidOut()) { if (mColumns != columns) { mColumns = columns; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPage.java b/packages/SystemUI/src/com/android/systemui/qs/QSPage.java index be2f7e5..5bfbdc7 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPage.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPage.java @@ -95,7 +95,7 @@ public class QSPage extends ViewGroup { record.tileView.measure(exactly(cw), exactly(ch)); previousView = record.tileView.updateAccessibilityOrder(previousView); } - setMeasuredDimension(width, mGridHeight); + setMeasuredDimension(width, exactly(mGridHeight)); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelTopView.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelTopView.java index 060d06c..bfff5f2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelTopView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelTopView.java @@ -25,8 +25,8 @@ import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.util.AttributeSet; import android.util.Log; import android.view.View; -import android.view.ViewTreeObserver; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.TextView; import com.android.systemui.R; @@ -48,6 +48,7 @@ public class QSPanelTopView extends FrameLayout { private boolean mDisplayingToast = false; private AnimatorSet mAnimator; + private ImageView mDropTargetIcon; public QSPanelTopView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); @@ -60,6 +61,7 @@ public class QSPanelTopView extends FrameLayout { public QSPanelTopView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); + setFocusable(true); } @Override @@ -71,6 +73,10 @@ public class QSPanelTopView extends FrameLayout { return mDropTarget; } + public ImageView getDropTargetIcon() { + return mDropTargetIcon; + } + public View getBrightnessView() { return mBrightnessView; } @@ -83,6 +89,7 @@ public class QSPanelTopView extends FrameLayout { protected void onFinishInflate() { super.onFinishInflate(); mDropTarget = findViewById(R.id.delete_container); + mDropTargetIcon = (ImageView) findViewById(R.id.delete_target); mEditTileInstructionView = findViewById(R.id.edit_container); mBrightnessView = findViewById(R.id.brightness_container); mToastView = (TextView) findViewById(R.id.qs_toast); @@ -92,14 +99,14 @@ public class QSPanelTopView extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int width = MeasureSpec.getSize(widthMeasureSpec); - mBrightnessView.measure(exactly(width), MeasureSpec.UNSPECIFIED); + mBrightnessView.measure(QSDragPanel.exactly(width), MeasureSpec.UNSPECIFIED); int dh = mBrightnessView.getMeasuredHeight(); - mDropTarget.measure(exactly(width), atMost(dh)); - mEditTileInstructionView.measure(exactly(width), atMost(dh)); - mToastView.measure(exactly(width), atMost(dh)); + mDropTarget.measure(QSDragPanel.exactly(width), QSDragPanel.atMost(dh)); + mEditTileInstructionView.measure(QSDragPanel.exactly(width), QSDragPanel.atMost(dh)); + mToastView.measure(QSDragPanel.exactly(width), QSDragPanel.atMost(dh)); - setMeasuredDimension(width, mBrightnessView.getMeasuredHeight()); + setMeasuredDimension(width, QSDragPanel.exactly(mBrightnessView.getMeasuredHeight())); } @Override @@ -112,14 +119,6 @@ public class QSPanelTopView extends FrameLayout { } } - private static int atMost(int height) { - return MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); - } - - private static int exactly(int size) { - return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); - } - public void setEditing(boolean editing) { mEditing = editing; if (editing) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSViewPager.java b/packages/SystemUI/src/com/android/systemui/qs/QSViewPager.java index 94c7c62..01c48b1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSViewPager.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSViewPager.java @@ -16,7 +16,6 @@ public class QSViewPager extends ViewPager { protected static final float SCROLL_PERCENT = .10f; private boolean mPagingEnabled; QSDragPanel mDragPanel; - private int mLastHeight = 0; public QSViewPager(Context context) { super(context); @@ -45,14 +44,13 @@ public class QSViewPager extends ViewPager { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int height = mLastHeight; + int height = 0; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int h = child.getMeasuredHeight(); if (h > height) height = h; } - mLastHeight = height; heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } |