use of com.android.systemui.qs.customize.TileQueryHelper.TileInfo in project android_frameworks_base by ResurrectionRemix.
the class TileAdapter method showAccessibilityDialog.
private void showAccessibilityDialog(final int position, final View v) {
final TileInfo info = mTiles.get(position);
CharSequence[] options = new CharSequence[] { mContext.getString(R.string.accessibility_qs_edit_move_tile, info.state.label), mContext.getString(R.string.accessibility_qs_edit_remove_tile, info.state.label) };
AlertDialog dialog = new Builder(mContext).setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
startAccessibleDrag(position);
} else {
move(position, info.isSystem ? mEditIndex : mTileDividerIndex, v);
notifyItemChanged(mTileDividerIndex);
notifyDataSetChanged();
}
}
}).setNegativeButton(android.R.string.cancel, null).create();
SystemUIDialog.setShowForAllUsers(dialog, true);
SystemUIDialog.applyFlags(dialog);
dialog.show();
}
use of com.android.systemui.qs.customize.TileQueryHelper.TileInfo in project android_frameworks_base by DirtyUnicorns.
the class TileAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final Holder holder, int position) {
if (holder.getItemViewType() == TYPE_DIVIDER) {
holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE);
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;
}
if (holder.getItemViewType() == TYPE_ACCESSIBLE_DROP) {
holder.mTileView.setClickable(true);
holder.mTileView.setFocusable(true);
holder.mTileView.setFocusableInTouchMode(true);
holder.mTileView.setVisibility(View.VISIBLE);
holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
holder.mTileView.setContentDescription(mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1));
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectPosition(holder.getAdapterPosition(), v);
}
});
if (mNeedsFocus) {
// Wait for this to get laid out then set its focus.
// Ensure that tile gets laid out so we get the callback.
holder.mTileView.requestLayout();
holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
holder.mTileView.removeOnLayoutChangeListener(this);
holder.mTileView.requestFocus();
}
});
mNeedsFocus = false;
}
return;
}
TileInfo info = mTiles.get(position);
if (position > mEditIndex) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_add_tile_label, info.state.label);
} else if (mAccessibilityMoving) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1);
} else {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_tile_label, position + 1, info.state.label);
}
holder.mTileView.onStateChanged(info.state);
holder.mTileView.setAppLabel(info.appLabel);
holder.mTileView.setShowAppLabel(position > mEditIndex && !info.isSystem);
if (mAccessibilityManager.isTouchExplorationEnabled()) {
final boolean selectable = !mAccessibilityMoving || position < mEditIndex;
holder.mTileView.setClickable(selectable);
holder.mTileView.setFocusable(selectable);
holder.mTileView.setImportantForAccessibility(selectable ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
if (selectable) {
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getAdapterPosition();
if (mAccessibilityMoving) {
selectPosition(position, v);
} else {
if (position < mEditIndex) {
showAccessibilityDialog(position, v);
} else {
startAccessibleDrag(position);
}
}
}
});
}
}
}
use of com.android.systemui.qs.customize.TileQueryHelper.TileInfo in project android_frameworks_base by DirtyUnicorns.
the class TileAdapter method recalcSpecs.
private void recalcSpecs() {
if (mCurrentSpecs == null || mAllTiles == null) {
return;
}
mOtherTiles = new ArrayList<TileInfo>(mAllTiles);
mTiles.clear();
for (int i = 0; i < mCurrentSpecs.size(); i++) {
final TileInfo tile = getAndRemoveOther(mCurrentSpecs.get(i));
if (tile != null) {
mTiles.add(tile);
}
}
mTiles.add(null);
for (int i = 0; i < mOtherTiles.size(); i++) {
final TileInfo tile = mOtherTiles.get(i);
if (tile.isSystem) {
mOtherTiles.remove(i--);
mTiles.add(tile);
}
}
mTileDividerIndex = mTiles.size();
mTiles.add(null);
mTiles.addAll(mOtherTiles);
updateDividerLocations();
notifyDataSetChanged();
}
use of com.android.systemui.qs.customize.TileQueryHelper.TileInfo in project platform_frameworks_base by android.
the class TileAdapter method recalcSpecs.
private void recalcSpecs() {
if (mCurrentSpecs == null || mAllTiles == null) {
return;
}
mOtherTiles = new ArrayList<TileInfo>(mAllTiles);
mTiles.clear();
for (int i = 0; i < mCurrentSpecs.size(); i++) {
final TileInfo tile = getAndRemoveOther(mCurrentSpecs.get(i));
if (tile != null) {
mTiles.add(tile);
}
}
mTiles.add(null);
for (int i = 0; i < mOtherTiles.size(); i++) {
final TileInfo tile = mOtherTiles.get(i);
if (tile.isSystem) {
mOtherTiles.remove(i--);
mTiles.add(tile);
}
}
mTileDividerIndex = mTiles.size();
mTiles.add(null);
mTiles.addAll(mOtherTiles);
updateDividerLocations();
notifyDataSetChanged();
}
use of com.android.systemui.qs.customize.TileQueryHelper.TileInfo in project platform_frameworks_base by android.
the class TileAdapter method showAccessibilityDialog.
private void showAccessibilityDialog(final int position, final View v) {
final TileInfo info = mTiles.get(position);
CharSequence[] options = new CharSequence[] { mContext.getString(R.string.accessibility_qs_edit_move_tile, info.state.label), mContext.getString(R.string.accessibility_qs_edit_remove_tile, info.state.label) };
AlertDialog dialog = new Builder(mContext).setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
startAccessibleDrag(position);
} else {
move(position, info.isSystem ? mEditIndex : mTileDividerIndex, v);
notifyItemChanged(mTileDividerIndex);
notifyDataSetChanged();
}
}
}).setNegativeButton(android.R.string.cancel, null).create();
SystemUIDialog.setShowForAllUsers(dialog, true);
SystemUIDialog.applyFlags(dialog);
dialog.show();
}
Aggregations