use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ActionFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(int dialogId) {
Dialog dialog = null;
switch(dialogId) {
case DIALOG_CATEGORY:
final DialogInterface.OnClickListener categoryClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
onTargetChange(getResources().getStringArray(R.array.action_dialog_values)[item]);
dialog.dismiss();
}
};
dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.choose_action_title).setItems(getResources().getStringArray(R.array.action_dialog_entries), categoryClickListener).setNegativeButton(getString(android.R.string.cancel), null).create();
break;
case DIALOG_CUSTOM_ACTIONS:
final CustomActionListAdapter adapter = new CustomActionListAdapter(getActivity());
if (!usesExtendedActionsList()) {
adapter.removeAction(ActionHandler.SYSTEMUI_TASK_HOME);
adapter.removeAction(ActionHandler.SYSTEMUI_TASK_BACK);
}
final DialogInterface.OnClickListener customActionClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
findAndUpdatePreference(adapter.getItem(item), mHolderTag);
dialog.dismiss();
}
};
dialog = new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.action_entry_custom_action)).setAdapter(adapter, customActionClickListener).setNegativeButton(getString(android.R.string.cancel), null).create();
break;
}
return dialog;
}
use of android.content.DialogInterface in project android_frameworks_base by ResurrectionRemix.
the class VersionDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Activity activity = getActivity();
// Need to use our library's resources for showing the dialog.
final Context context;
try {
context = activity.createPackageContext(SharedLibraryMain.LIBRARY_PACKAGE, 0);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalStateException("Can't find my package!", e);
}
final Resources res = context.getResources();
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(res.getText(R.string.upgrade_title));
builder.setMessage(res.getString(R.string.upgrade_body, activity.getApplicationInfo().loadLabel(activity.getPackageManager()), context.getApplicationInfo().loadLabel(context.getPackageManager())));
builder.setPositiveButton(res.getText(R.string.upgrade_button), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Launch play store into the details of our app.
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
} catch (android.content.ActivityNotFoundException anfe) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
}
}
});
return builder.create();
}
use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ShortcutPickHelper method processShortcut.
private void processShortcut(final Intent intent, int requestCodeApplication, int requestCodeShortcut) {
// Handle case where user selected "Applications"
String applicationName = mParent.getString(R.string.profile_applist_title);
String application2name = mParent.getString(R.string.picker_activities);
String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
if (applicationName != null && applicationName.equals(shortcutName)) {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
startFragmentOrActivity(pickIntent, requestCodeApplication);
} else if (application2name != null && application2name.equals(shortcutName)) {
final List<PackageInfo> pInfos = mPackageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES);
ExpandableListView appListView = new ExpandableListView(mParent);
AppExpandableAdapter appAdapter = new AppExpandableAdapter(pInfos, mParent);
appListView.setAdapter(appAdapter);
appListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Intent shortIntent = new Intent(Intent.ACTION_MAIN);
String pkgName = ((GroupInfo) parent.getExpandableListAdapter().getGroup(groupPosition)).info.packageName;
String actName = ((GroupInfo) parent.getExpandableListAdapter().getGroup(groupPosition)).info.activities[childPosition].name;
shortIntent.setClassName(pkgName, actName);
completeSetCustomApp(shortIntent);
mAlertDialog.dismiss();
return true;
}
});
Builder builder = new Builder(mParent);
builder.setView(appListView);
mAlertDialog = builder.create();
mAlertDialog.setTitle(mParent.getString(R.string.select_custom_activity_title));
mAlertDialog.show();
mAlertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mListener.shortcutPicked(null, null, false);
}
});
} else {
startFragmentOrActivity(intent, requestCodeShortcut);
}
}
use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimDialogActivity method displayPreferredDialog.
private void displayPreferredDialog(final int slotId) {
final Resources res = getResources();
final Context context = getApplicationContext();
final SubscriptionInfo sir = SubscriptionManager.from(context).getActiveSubscriptionInfoForSimSlotIndex(slotId);
if (sir != null) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(R.string.sim_preferred_title);
alertDialogBuilder.setMessage(res.getString(R.string.sim_preferred_message, sir.getDisplayName()));
alertDialogBuilder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
final int subId = sir.getSubscriptionId();
PhoneAccountHandle phoneAccountHandle = subscriptionIdToPhoneAccountHandle(subId);
setDefaultDataSubId(context, subId);
setDefaultSmsSubId(context, subId);
setUserSelectedOutgoingPhoneAccount(phoneAccountHandle);
finish();
}
});
alertDialogBuilder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
alertDialogBuilder.create().show();
} else {
finish();
}
}
use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ActionPickerDialogActivity method createDialog.
public Dialog createDialog(final Context context, final int id) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final Dialog dialog;
final DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
switch(id) {
case DIALOG_ROOT:
onTargetChange(getResources().getStringArray(mHasDefault ? R.array.action_dialog_values : R.array.action_dialog_no_default_values)[item]);
break;
case DIALOG_SYSTEM:
sendResultAndFinish(mCustomActionListAdapter.getItem(item).getAction());
finish();
break;
default:
throw new IllegalArgumentException("Invalid dialog type " + id + " in ActionPicker dialog.");
}
}
};
final DialogInterface.OnCancelListener cancel = new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
onTargetChange(null);
}
};
final DialogInterface.OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
cancel.onCancel(dialog);
}
};
switch(id) {
case DIALOG_ROOT:
dialog = builder.setTitle(R.string.choose_action_title).setItems(getResources().getStringArray(mHasDefault ? R.array.action_dialog_entries : R.array.action_dialog_no_default_entries), l).setOnCancelListener(cancel).setNegativeButton(getString(android.R.string.cancel), cancelClickListener).create();
break;
case DIALOG_SYSTEM:
dialog = builder.setTitle(getString(R.string.action_entry_custom_action)).setAdapter(mCustomActionListAdapter, l).setOnCancelListener(cancel).setNegativeButton(getString(android.R.string.cancel), cancelClickListener).create();
break;
default:
throw new IllegalArgumentException("Invalid dialog type " + id + " in ActionPicker dialog.");
}
return dialog;
}
Aggregations