Search in sources :

Example 31 with Builder

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

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 32 with Builder

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

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 33 with Builder

use of android.app.AlertDialog.Builder in project Klyph by jonathangerbaud.

the class Util method showAlert.

/**
 * Display a simple alert dialog with the given text and title.
 *
 * @param context
 *          Android context in which the dialog should be displayed
 * @param title
 *          Alert dialog title
 * @param text
 *          Alert dialog message
 */
public static void showAlert(Context context, String title, String text) {
    Builder alertBuilder = new Builder(context);
    alertBuilder.setTitle(title);
    alertBuilder.setMessage(text);
    alertBuilder.create().show();
}
Also used : Builder(android.app.AlertDialog.Builder)

Example 34 with Builder

use of android.app.AlertDialog.Builder in project android_packages_apps_crDroidSettings by crdroidandroid.

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)

Example 35 with Builder

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

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)71 DialogInterface (android.content.DialogInterface)50 AlertDialog (android.app.AlertDialog)32 OnClickListener (android.content.DialogInterface.OnClickListener)18 Intent (android.content.Intent)18 View (android.view.View)16 TextView (android.widget.TextView)14 OnClickListener (android.view.View.OnClickListener)11 ArrayList (java.util.ArrayList)10 SuppressLint (android.annotation.SuppressLint)9 Bundle (android.os.Bundle)9 ImageView (android.widget.ImageView)8 ImageButton (android.widget.ImageButton)7 RelativeLayout (android.widget.RelativeLayout)7 List (java.util.List)7 Point (android.graphics.Point)6 ExpandableListView (android.widget.ExpandableListView)5 TileInfo (com.android.systemui.qs.customize.TileQueryHelper.TileInfo)5 LinearLayout (android.widget.LinearLayout)4 ListView (android.widget.ListView)4