Merge "Change drag label while dragging QS tiles" into nyc-dev

This commit is contained in:
Jason Monk
2016-03-17 13:32:02 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 1 deletions

View File

@@ -1432,6 +1432,9 @@
<!-- Label for area where tiles can be dragged out of [CHAR LIMIT=60] --> <!-- Label for area where tiles can be dragged out of [CHAR LIMIT=60] -->
<string name="drag_to_add_tiles">Drag to add tiles</string> <string name="drag_to_add_tiles">Drag to add tiles</string>
<!-- Label for area where tiles can be dragged in to [CHAR LIMIT=60] -->
<string name="drag_to_remove_tiles">Drag here to remove</string>
<!-- Button to edit the tile ordering of quick settings [CHAR LIMIT=60] --> <!-- Button to edit the tile ordering of quick settings [CHAR LIMIT=60] -->
<string name="qs_edit">Edit</string> <string name="qs_edit">Edit</string>

View File

@@ -28,6 +28,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.qs.QSIconView; import com.android.systemui.qs.QSIconView;
import com.android.systemui.qs.QSTileView; import com.android.systemui.qs.QSTileView;
@@ -153,7 +154,12 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
@Override @Override
public void onBindViewHolder(final Holder holder, int position) { public void onBindViewHolder(final Holder holder, int position) {
if (holder.getItemViewType() == TYPE_EDIT) return; if (holder.getItemViewType() == TYPE_EDIT) {
((TextView) holder.itemView.findViewById(android.R.id.title)).setText(
mCurrentDrag != null ? R.string.drag_to_remove_tiles
: R.string.drag_to_add_tiles);
return;
}
TileInfo info = mTiles.get(position); TileInfo info = mTiles.get(position);
holder.mTileView.onStateChanged(info.state); holder.mTileView.onStateChanged(info.state);
@@ -250,11 +256,13 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
super.onSelectedChanged(viewHolder, actionState); super.onSelectedChanged(viewHolder, actionState);
if (mCurrentDrag != null) { if (mCurrentDrag != null) {
mCurrentDrag.stopDrag(); mCurrentDrag.stopDrag();
mCurrentDrag = null;
} }
if (viewHolder != null) { if (viewHolder != null) {
mCurrentDrag = (Holder) viewHolder; mCurrentDrag = (Holder) viewHolder;
mCurrentDrag.startDrag(); mCurrentDrag.startDrag();
} }
notifyItemChanged(mDividerIndex);
} }
@Override @Override