Search in sources :

Example 71 with Builder

use of android.app.AlertDialog.Builder in project ignition by mttkay.

the class IgnitedDialogs method newErrorHandlerDialog.

/**
     * Displays a error dialog with an exception's message as its body. Also displays a Send Email
     * button to send the exception to the developer, if an appropriate Intent handler is available
     * (otherwise it will behave exactly like {@link #newErrorDialog(Activity, String, Exception)}.
     * 
     * <p>
     * Email subject and button label will have default values, but you can override them by
     * defining the following strings resources:
     * 
     * <ul>
     * <li>ign_error_report_email_subject - The subject of the email.</li>
     * <li>ign_dialog_button_send_error_report - The text on the Send Email button.</li>
     * </ul>
     * </p>
     * 
     * @param activity
     * @param title
     * @param error
     * @return
     */
public static AlertDialog.Builder newErrorHandlerDialog(final Activity activity, String title, String emailAddress, Exception error) {
    AlertDialog.Builder builder = newErrorDialog(activity, title, error);
    if (IgnitedIntents.isIntentAvailable(activity, Intent.ACTION_SEND, IgnitedIntents.MIME_TYPE_EMAIL)) {
        String buttonText = activity.getString(R.string.ign_error_report_send_button);
        String bugReportEmailSubject = activity.getString(R.string.ign_error_report_email_subject, error.getClass().getName());
        final String diagnosis = IgnitedDiagnostics.createDiagnosis(activity, error);
        final Intent intent = IgnitedIntents.newEmailIntent(activity, emailAddress, bugReportEmailSubject, diagnosis);
        builder.setNegativeButton(buttonText, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                activity.startActivity(intent);
            }
        });
    }
    return builder;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent)

Example 72 with Builder

use of android.app.AlertDialog.Builder in project ignition by mttkay.

the class IgnitedDialogs method newErrorDialog.

public static AlertDialog.Builder newErrorDialog(final Activity activity, String title, Exception error) {
    String screenMessage = "";
    if (error instanceof ResourceMessageException) {
        screenMessage = activity.getString(((ResourceMessageException) error).getClientMessageResourceId());
    } else {
        screenMessage = error.getLocalizedMessage();
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(title);
    builder.setMessage(screenMessage);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setCancelable(false);
    builder.setPositiveButton(activity.getString(android.R.string.ok), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return builder;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) OnClickListener(android.content.DialogInterface.OnClickListener) ResourceMessageException(com.github.ignition.core.exceptions.ResourceMessageException)

Example 73 with Builder

use of android.app.AlertDialog.Builder in project android_frameworks_base by AOSPA.

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();
}
Also used : AlertDialog(android.app.AlertDialog) TileInfo(com.android.systemui.qs.customize.TileQueryHelper.TileInfo) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder)

Example 74 with Builder

use of android.app.AlertDialog.Builder in project android_frameworks_base by ResurrectionRemix.

the class ResolverTargetActionsDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final int itemRes = args.getBoolean(PINNED_KEY, false) ? R.array.resolver_target_actions_unpin : R.array.resolver_target_actions_pin;
    return new Builder(getContext()).setCancelable(true).setItems(itemRes, this).setTitle(args.getCharSequence(TITLE_KEY)).create();
}
Also used : Bundle(android.os.Bundle) Builder(android.app.AlertDialog.Builder)

Example 75 with Builder

use of android.app.AlertDialog.Builder in project android_frameworks_base 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);
    }
}
Also used : DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Intent(android.content.Intent) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) View(android.view.View) ExpandableListView(android.widget.ExpandableListView) ExpandableListView(android.widget.ExpandableListView)

Aggregations

Builder (android.app.AlertDialog.Builder)112 DialogInterface (android.content.DialogInterface)64 AlertDialog (android.app.AlertDialog)42 Intent (android.content.Intent)29 View (android.view.View)28 TextView (android.widget.TextView)25 OnClickListener (android.content.DialogInterface.OnClickListener)21 SuppressLint (android.annotation.SuppressLint)16 ArrayList (java.util.ArrayList)15 OnClickListener (android.view.View.OnClickListener)13 ImageView (android.widget.ImageView)13 Context (android.content.Context)12 AlertDialog (android.support.v7.app.AlertDialog)12 List (java.util.List)12 Bundle (android.os.Bundle)11 RelativeLayout (android.widget.RelativeLayout)10 Point (android.graphics.Point)9 ExpandableListView (android.widget.ExpandableListView)9 ImageButton (android.widget.ImageButton)7 EditText (android.widget.EditText)6