use of android.content.DialogInterface in project android_frameworks_base by ResurrectionRemix.
the class NekoLand method showNameDialog.
private void showNameDialog(final Cat cat) {
final Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material_Light_Dialog_NoActionBar);
// TODO: Move to XML, add correct margins.
View view = LayoutInflater.from(context).inflate(R.layout.edit_text, null);
final EditText text = (EditText) view.findViewById(android.R.id.edit);
text.setText(cat.getName());
text.setSelection(cat.getName().length());
final int size = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
Drawable catIcon = cat.createIcon(this, size, size).loadDrawable(this);
new AlertDialog.Builder(context).setTitle(" ").setIcon(catIcon).setView(view).setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
cat.logRename(context);
cat.setName(text.getText().toString().trim());
mPrefs.addCat(cat);
}
}).show();
}
use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class IconPickerActivity method getIconPackDialog.
private Dialog getIconPackDialog(Context context) {
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View view = inflater.inflate(R.layout.dialog_iconpack, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final IconPackageAdapter adapter = new IconPackageAdapter(this);
final ListView listView = (ListView) view.findViewById(R.id.iconpack_list);
final Dialog dialog;
adapter.load();
dialog = builder.setTitle(getString(R.string.icon_pack_picker_dialog_title)).setView(view).setOnCancelListener(this).setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onCancel(dialog);
}
}).create();
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ResolveInfo info = adapter.getItem(position);
String packageName = info.activityInfo.packageName;
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.rr.IconPackGridActivity");
intent.putExtra("icon_package_name", packageName);
dialog.dismiss();
startActivityForResult(intent, ICON_PACK_ICON_RESULT);
}
});
return dialog;
}
use of android.content.DialogInterface in project android_frameworks_base by ResurrectionRemix.
the class TrackerActivity method showConfirm.
private void showConfirm(int textId, final Runnable onConfirmAction) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(R.string.confirm_title);
dialogBuilder.setMessage(textId);
dialogBuilder.setPositiveButton(android.R.string.ok, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
onConfirmAction.run();
}
});
dialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
});
dialogBuilder.show();
}
use of android.content.DialogInterface in project android_frameworks_base by ResurrectionRemix.
the class DirectoryFragment method deleteDocuments.
private void deleteDocuments(final Selection selected) {
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_DELETE);
if (selected.isEmpty()) {
return;
}
final DocumentInfo srcParent = getDisplayState().stack.peek();
// Model must be accessed in UI thread, since underlying cursor is not threadsafe.
List<DocumentInfo> docs = mModel.getDocuments(selected);
TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null);
message.setText(generateDeleteMessage(docs));
// This "insta-hides" files that are being deleted, because
// the delete operation may be not execute immediately (it
// may be queued up on the FileOperationService.)
// To hide the files locally, we call the hide method on the adapter
// ...which a live object...cannot be parceled.
// For that reason, for now, we implement this dialog NOT
// as a fragment (which can survive rotation and have its own state),
// but as a simple runtime dialog. So rotating a device with an
// active delete dialog...results in that dialog disappearing.
// We can do better, but don't have cycles for it now.
new AlertDialog.Builder(getActivity()).setView(message).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// the user cancels the delete.
if (mActionMode != null) {
mActionMode.finish();
} else {
Log.w(TAG, "Action mode is null before deleting documents.");
}
// Hide the files in the UI...since the operation
// might be queued up on FileOperationService.
// We're walking a line here.
mAdapter.hide(selected.getAll());
FileOperations.delete(getActivity(), docs, srcParent, getDisplayState().stack);
}
}).setNegativeButton(android.R.string.no, null).show();
}
use of android.content.DialogInterface in project android_frameworks_base by ResurrectionRemix.
the class DataSaverTile method handleClick.
@Override
protected void handleClick() {
if (mState.value || Prefs.getBoolean(mContext, Prefs.Key.QS_DATA_SAVER_DIALOG_SHOWN, false)) {
// Do it right away.
toggleDataSaver();
return;
}
// Shows dialog first
SystemUIDialog dialog = new SystemUIDialog(mContext);
dialog.setTitle(com.android.internal.R.string.data_saver_enable_title);
dialog.setMessage(com.android.internal.R.string.data_saver_description);
dialog.setPositiveButton(com.android.internal.R.string.data_saver_enable_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
toggleDataSaver();
}
});
dialog.setNegativeButton(com.android.internal.R.string.cancel, null);
dialog.setShowForAllUsers(true);
dialog.show();
Prefs.putBoolean(mContext, Prefs.Key.QS_DATA_SAVER_DIALOG_SHOWN, true);
}
Aggregations