diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java | 90 |
1 files changed, 33 insertions, 57 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java index 0c5b71b..995237d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java @@ -32,6 +32,7 @@ import android.graphics.Color; import android.graphics.Point; import android.graphics.PointF; import android.graphics.PorterDuff; +import android.graphics.drawable.Animatable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Handler; @@ -87,7 +88,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On public static final boolean DEBUG_DRAG = false; private static final int MAX_ROW_COUNT = 3; - private static final String BROADCAST_TILE_SPEC_PLACEHOLDER = "broadcast_placeholder"; protected final ArrayList<QSPage> mPages = new ArrayList<>(); @@ -143,10 +143,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On 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); @@ -202,7 +198,9 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } else { final int adjustedPosition = mEditing ? position - 1 : position; QSPage page = mPages.get(adjustedPosition); - container.addView(page); + if (!page.isAttachedToWindow()) { + container.addView(page); + } return page; } } @@ -965,6 +963,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On Log.v(TAG, "ACTION_DRAG_STARTED on target view."); } mRestored = false; + mQsPanelTop.setDropIcon(R.drawable.ic_qs_tile_delete_disable, R.color.qs_tile_trash_normal_tint); } break; @@ -981,16 +980,17 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On mMovedByLocation = false; if (v == mQsPanelTop) { - int color; + int icon, 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); + icon = R.drawable.ic_qs_tile_delete_disable_avd; + color = R.color.qs_tile_trash_delete_tint_warning; } else { - color = mContext.getColor(R.color.qs_tile_trash_delete_tint); + icon = R.drawable.ic_qs_tile_delete_disable; + color = R.color.qs_tile_trash_delete_tint; } - DrawableCompat.setTint(mQsPanelTop.getDropTargetIcon().getDrawable(), color); - mQsPanelTop.getDropTargetIcon().invalidate(); + mQsPanelTop.setDropIcon(icon, color); } if (!originatingTileEvent && v != getDropTarget() && targetTile != null) { @@ -1057,9 +1057,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } if (v == mQsPanelTop) { - final int color = mContext.getColor(R.color.qs_tile_trash); - DrawableCompat.setTint(mQsPanelTop.getDropTargetIcon().getDrawable(), color); - mQsPanelTop.getDropTargetIcon().invalidate(); + mQsPanelTop.setDropIcon(R.drawable.ic_qs_tile_delete_disable, R.color.qs_tile_trash_normal_tint); } if (originatingTileEvent @@ -1246,6 +1244,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On float destinationY = mDraggingRecord.destination.y + mViewPager.getTop(); mDraggingRecord.tileView.animate() + .withLayer() .x(destinationX) .y(destinationY) // part of the viewpager now .setListener(new AnimatorListenerAdapter() { @@ -1496,14 +1495,11 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On tilePageSource.addTransientView(ti.tileView, 0); ti.tileView.animate() + .withLayer() .x(ti.destination.x + getWidth()) .y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override - public void onAnimationStart(Animator animation) { - } - - @Override public void onAnimationEnd(Animator animation) { tilePageSource.removeTransientView(ti.tileView); ti.page = tilePageTarget.getPageIndex(); @@ -1518,12 +1514,21 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } else { ti.tileView.animate() + .withLayer() .x(ti.destination.x) .y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentlyAnimating.remove(ti); + final boolean dual = getPage(ti.destinationPage).dualRecord(ti); + if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) { + if (DEBUG_DRAG) { + Log.w(TAG, ti + " changed dual state to : " + + ti.tileView.isDual()); + } + } + requestLayout(); } }); } @@ -1544,6 +1549,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On tilePageSource.addTransientView(last.tileView, 0); last.tileView.animate() + .withLayer() .x(last.destination.x + getWidth()) .y(last.destination.y) .setListener(new AnimatorListenerAdapter() { @@ -1565,6 +1571,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On }); } else { last.tileView.animate() + .withLayer() .x(last.destination.x) .y(last.destination.y) .setListener(new AnimatorListenerAdapter() { @@ -1575,6 +1582,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } mCurrentlyAnimating.remove(last); + requestLayout(); } }); } @@ -1622,7 +1630,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On ti.col = lastCol; ti.destination.x = getLeft(lastRow, lastCol, columnCountF, - lastPage == 0 && lastRow == 0); + lastPage == 0 && lastRow == 0 && mFirstRowLarge); ti.destination.y = getRowTop(lastRow); final boolean dual = getPage(ti.destinationPage).dualRecord(ti); @@ -1639,6 +1647,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On originalPage.removeView(ti.tileView); ti.tileView.animate() + .withLayer() .x(ti.destination.x) .y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @@ -1659,21 +1668,19 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On }); } else { ti.tileView.animate() + .withLayer() .x(ti.destination.x) .y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { + mCurrentlyAnimating.remove(ti); if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) { if (DEBUG_DRAG) { Log.w(TAG, ti + " changed dual state to : " + ti.tileView.isDual()); } - ti.tileView.handleStateChanged(ti.tile.getState()); - ti.tileView.invalidate(); } - - mCurrentlyAnimating.remove(ti); requestLayout(); } }); @@ -1799,9 +1806,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } } - // add broadcast tile - mPackageTileMap.get(PACKAGE_ANDROID).add(BROADCAST_TILE_SPEC_PLACEHOLDER); - final List<String> systemTiles = mPackageTileMap.get(PACKAGE_ANDROID); Collections.sort(systemTiles); } @@ -1910,9 +1914,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On } private String getQSTileLabel(String spec) { - if (spec.equals(BROADCAST_TILE_SPEC_PLACEHOLDER)) { - return mContext.getText(R.string.broadcast_tile).toString(); - } else if (QSUtils.isStaticQsTile(spec)) { + if (QSUtils.isStaticQsTile(spec)) { int resource = QSTileHost.getLabelResource(spec); return mContext.getText(resource).toString(); } else if (QSUtils.isDynamicQsTile(spec)) { @@ -1939,9 +1941,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On return state.icon.getDrawable(mContext); } } - if (spec.equals(BROADCAST_TILE_SPEC_PLACEHOLDER)) { - return getPackageDrawable(PACKAGE_ANDROID); - } return getPackageDrawable(getCustomTilePackage(spec)); } } @@ -2005,12 +2004,8 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { String spec = getChild(groupPosition, childPosition); - if (spec.equals(BROADCAST_TILE_SPEC_PLACEHOLDER)) { - showBroadcastTileDialog(); - } else { - mPanel.add(spec); - mPanel.closeDetail(); - } + mPanel.add(spec); + mPanel.closeDetail(); return true; } }); @@ -2048,25 +2043,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On return CMMetricsLogger.DONT_LOG; } - public void showBroadcastTileDialog() { - final EditText editText = new EditText(mContext); - final AlertDialog d = new AlertDialog.Builder(mContext) - .setTitle(R.string.broadcast_tile) - .setView(editText) - .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - String action = editText.getText().toString(); - if (isValid(action)) { - mPanel.add(IntentTile.PREFIX + action + ')'); - mPanel.closeDetail(); - } - } - }).create(); - SystemUIDialog.makeSystemUIDialog(d); - d.show(); - } - private boolean isValid(String action) { for (int i = 0; i < action.length(); i++) { char c = action.charAt(i); |