diff options
author | AdrianDC <radian.dc@gmail.com> | 2015-11-29 10:47:48 +0100 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2015-11-30 09:17:33 -0800 |
commit | e4c0797ac0dc5ee3fe9abb34e5054390954061d0 (patch) | |
tree | d27ed1f135ae8e21362c1b33c20d2693940b6f80 | |
parent | a9cdd4ff38aed1fb1bac64caec97bfb0b72d0ce9 (diff) | |
download | frameworks_base-e4c0797ac0dc5ee3fe9abb34e5054390954061d0.zip frameworks_base-e4c0797ac0dc5ee3fe9abb34e5054390954061d0.tar.gz frameworks_base-e4c0797ac0dc5ee3fe9abb34e5054390954061d0.tar.bz2 |
QuickSettings: Improve draggable tiles management
* Hide the carret on dual tiles that don't have details
* Handle dual label clicks as primary for basic tiles
* Fix the ripples management to avoid missing effects
* Prevent a crash on wrong size array to add a tile
Change-Id: I01471ea6e279b3437961c30bcfa922e9e0872388
Signed-off-by: AdrianDC <radian.dc@gmail.com>
8 files changed, 40 insertions, 36 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java index f7a7ac4..7301525 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java @@ -870,8 +870,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On @Override public void onAnimationStart(Animator animation) { mDraggingRecord.tileView.setAlpha(1); - mDraggingRecord.tileView.setBackground( - mDraggingRecord.tileView.newTileBackground()); } @Override @@ -977,15 +975,14 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On final DragTileRecord record = (DragTileRecord) getRecord(v); if (record == null) { // TODO couldn't find a matching tag? - Log.e(TAG, "got a null record on touh down."); + Log.e(TAG, "got a null record on touch down."); return false; } mDraggingRecord = record; mDraggingRecord.tileView.setAlpha(0); - mDraggingRecord.tileView.setTileBackground(null); - mDraggingRecord.tileView.setDual(false); + mDraggingRecord.tileView.setDual(false, false); TileShadow mTileShadow = new TileShadow(mDraggingRecord.tileView); v.startDrag(null, mTileShadow, null, 0); @@ -1261,7 +1258,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (ti.tileView.setDual(dual)) { + if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) { if (DEBUG_DRAG) { Log.w(TAG, ti + " changed dual state to : " + ti.tileView.isDual()); @@ -1319,9 +1316,12 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } String[] defaults = getContext().getString(R.string.quick_settings_tiles_default).split(","); - final String[] available = new String[defaults.length + 1 - - (tiles.size() - numBroadcast)]; - final String[] availableTiles = new String[available.length]; + int availableSize = defaults.length + 1 - (tiles.size() - numBroadcast); + if (availableSize < 1) { + availableSize = 1; + } + final String[] available = new String[availableSize]; + final String[] availableTiles = new String[availableSize]; int index = 0; for (int i = 0; i < defaults.length; i++) { if (tiles.contains(defaults[i])) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPage.java b/packages/SystemUI/src/com/android/systemui/qs/QSPage.java index f06e6f8..274a431 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPage.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPage.java @@ -58,7 +58,6 @@ public class QSPage extends ViewGroup { if (record.page != mPage) continue; if (record.tileView.getVisibility() == GONE) continue; - boolean dual = dualRecord(record); if (mPage == 0 && r == 0 && c == 1) { r = 1; c = 0; @@ -82,7 +81,7 @@ public class QSPage extends ViewGroup { if (record.page != record.destinationPage) continue; final boolean dual = dualRecord(record); - if (record.tileView.setDual(dual)) { + if (record.tileView.setDual(dual, record.tile.hasDualTargetsDetails())) { record.tileView.handleStateChanged(record.tile.getState()); } if (record.tileView.getVisibility() == GONE) continue; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 88bcbff..4d37553 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -483,15 +483,12 @@ public class QSPanel extends ViewGroup { int r = -1; int c = -1; int rows = 0; - boolean rowIsDual = false; for (TileRecord record : mRecords) { if (record.tileView.getVisibility() == GONE) continue; // wrap to next column if we've reached the max # of columns - // also don't allow dual + single tiles on the same row - if (r == -1 || c == (mColumns - 1) || rowIsDual != record.tile.supportsDualTargets()) { + if (r == -1 || c == (mColumns - 1)) { r++; c = 0; - rowIsDual = record.tile.supportsDualTargets(); } else { c++; } @@ -502,7 +499,8 @@ public class QSPanel extends ViewGroup { View previousView = mBrightnessView; for (TileRecord record : mRecords) { - if (record.tileView.setDual(record.tile.supportsDualTargets())) { + final boolean dualTarget = record.tile.hasDualTargetsDetails(); + if (record.tileView.setDual(dualTarget, dualTarget)) { record.tileView.handleStateChanged(record.tile.getState()); } if (record.tileView.getVisibility() == GONE) continue; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 2a33c3a..da73e15 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -84,8 +84,8 @@ public abstract class QSTile<TState extends State> implements Listenable { mHandler = new H(host.getLooper()); } - public boolean supportsDualTargets() { - return true; + public boolean hasDualTargetsDetails() { + return false; } public Host getHost() { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java index d109782..dc54c16 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 The Android Open Source Project + * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,6 +67,7 @@ public class QSTileView extends ViewGroup { private TextView mLabel; private QSDualTileLabel mDualLabel; private boolean mDual; + private boolean mDualDetails; private OnClickListener mClickPrimary; private OnClickListener mClickSecondary; private OnLongClickListener mLongClick; @@ -145,15 +147,18 @@ public class QSTileView extends ViewGroup { mDualLabel = new QSDualTileLabel(mContext); mDualLabel.setId(View.generateViewId()); mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect); - mDualLabel.setFirstLineCaret(mContext.getDrawable(R.drawable.qs_dual_tile_caret)); + if (mDualDetails) { + mDualLabel.setFirstLineCaret(mContext.getDrawable(R.drawable.qs_dual_tile_caret)); + } mDualLabel.setTextColor(mContext.getColor(R.color.qs_tile_text)); mDualLabel.setPadding(0, mDualTileVerticalPaddingPx, 0, mDualTileVerticalPaddingPx); mDualLabel.setTypeface(CONDENSED); mDualLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.qs_tile_text_size)); mDualLabel.setClickable(true); - mDualLabel.setOnClickListener(mClickSecondary); mDualLabel.setFocusable(true); + mDualLabel.setOnClickListener(mDualDetails ? mClickSecondary : mClickPrimary); + mDualLabel.setOnLongClickListener(mLongClick); if (labelText != null) { mDualLabel.setText(labelText); } @@ -172,6 +177,7 @@ public class QSTileView extends ViewGroup { mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.qs_tile_text_size)); mLabel.setClickable(false); + mLabel.setFocusable(false); if (labelText != null) { mLabel.setText(labelText); } @@ -183,45 +189,46 @@ public class QSTileView extends ViewGroup { return mDual; } - public boolean setDual(boolean dual) { + public boolean setDual(boolean dual, boolean hasDetails) { final boolean changed = dual != mDual; mDual = dual; + mDualDetails = hasDetails; if (changed) { recreateLabel(); } if (dual) { mTopBackgroundView.setOnClickListener(mClickPrimary); + mTopBackgroundView.setOnLongClickListener(mLongClick); setOnClickListener(null); - setClickable(false); + setOnLongClickListener(null); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } else { mTopBackgroundView.setOnClickListener(null); - mTopBackgroundView.setClickable(false); + mTopBackgroundView.setOnLongClickListener(null); setOnClickListener(mClickPrimary); setOnLongClickListener(mLongClick); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); } - setTileBackground(mTileBackground); + setTileBackground(); + mTopBackgroundView.setClickable(dual); mTopBackgroundView.setFocusable(dual); + setClickable(!dual); setFocusable(!dual); mDivider.setVisibility(dual ? VISIBLE : GONE); + mTopBackgroundView.setVisibility(dual ? VISIBLE : GONE); postInvalidate(); return changed; } - protected void setTileBackground(Drawable background) { - mTileBackground = background; + protected void setTileBackground() { if (mTileBackground instanceof RippleDrawable) { setRipple((RippleDrawable) mTileBackground); } else { setRipple(null); } - if (mDual) { - mTopBackgroundView.setBackground(mTileBackground); - } else { - setBackground(mTileBackground); - } + mTopBackgroundView.setBackground(mDual ? mTileBackground : null); + setBackground(!mDual ? mTileBackground : null); } private void setRipple(RippleDrawable tileBackground) { @@ -373,6 +380,7 @@ public class QSTileView extends ViewGroup { if (mDual) { if (mTopBackgroundView != null) { mTopBackgroundView.setFocusable(!editing); + mTopBackgroundView.setClickable(!editing); } if (mDualLabel != null) { mDualLabel.setFocusable(!editing); @@ -380,7 +388,6 @@ public class QSTileView extends ViewGroup { } setClickable(editing); setFocusable(editing); - setOnLongClickListener(editing ? mLongClick : null); } else { if (mLabel != null) { mLabel.setFocusable(!editing); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index abce31f..4502ccc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -50,7 +50,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> { } @Override - public boolean supportsDualTargets() { + public boolean hasDualTargetsDetails() { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java index e654efd..30ebacd 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java @@ -58,7 +58,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> { } @Override - public boolean supportsDualTargets() { + public boolean hasDualTargetsDetails() { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java b/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java index 790beb7..a38993d 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java @@ -247,8 +247,8 @@ public class QsTuner extends Fragment implements Callback { } @Override - public boolean supportsDualTargets() { - return true; + public boolean hasDualTargetsDetails() { + return "wifi".equals(mSpec) || "bt".equals(mSpec); } @Override |