Search in sources :

Example 76 with Dialog

use of android.app.Dialog in project Lightning-Browser by anthonycr.

the class AdvancedSettingsFragment method renderPicker.

private void renderPicker() {
    AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
    picker.setTitle(getResources().getString(R.string.rendering_mode));
    CharSequence[] chars = { mActivity.getString(R.string.name_normal), mActivity.getString(R.string.name_inverted), mActivity.getString(R.string.name_grayscale), mActivity.getString(R.string.name_inverted_grayscale), mActivity.getString(R.string.name_increase_contrast) };
    int n = mPreferenceManager.getRenderingMode();
    picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mPreferenceManager.setRenderingMode(which);
            switch(which) {
                case 0:
                    renderingmode.setSummary(getString(R.string.name_normal));
                    break;
                case 1:
                    renderingmode.setSummary(getString(R.string.name_inverted));
                    break;
                case 2:
                    renderingmode.setSummary(getString(R.string.name_grayscale));
                    break;
                case 3:
                    renderingmode.setSummary(getString(R.string.name_inverted_grayscale));
                    break;
                case 4:
                    renderingmode.setSummary(getString(R.string.name_increase_contrast));
                    break;
            }
        }
    });
    picker.setPositiveButton(getResources().getString(R.string.action_ok), null);
    Dialog dialog = picker.show();
    BrowserDialog.setDialogSize(mActivity, dialog);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) BrowserDialog(acr.browser.lightning.dialog.BrowserDialog) AlertDialog(android.support.v7.app.AlertDialog)

Example 77 with Dialog

use of android.app.Dialog in project StylishMusicPlayer by ryanhoo.

the class EditPlayListDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = new AlertDialog.Builder(getContext()).setTitle(getTitle()).setView(R.layout.dialog_create_or_edit_play_list).setNegativeButton(R.string.mp_cancel, null).setPositiveButton(R.string.mp_Confirm, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onConfirm();
        }
    }).create();
    dialog.setOnShowListener(this);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) NonNull(android.support.annotation.NonNull)

Example 78 with Dialog

use of android.app.Dialog in project Conversations by siacs.

the class SettingsFragment method initializeActionBar.

//http://stackoverflow.com/questions/16374820/action-bar-home-button-not-functional-with-nested-preferencescreen/16800527#16800527
private void initializeActionBar(PreferenceScreen preferenceScreen) {
    final Dialog dialog = preferenceScreen.getDialog();
    if (dialog != null) {
        View homeBtn = dialog.findViewById(android.R.id.home);
        if (homeBtn != null) {
            View.OnClickListener dismissDialogClickListener = new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            };
            ViewParent homeBtnContainer = homeBtn.getParent();
            if (homeBtnContainer instanceof FrameLayout) {
                ViewGroup containerParent = (ViewGroup) homeBtnContainer.getParent();
                if (containerParent instanceof LinearLayout) {
                    ((LinearLayout) containerParent).setOnClickListener(dismissDialogClickListener);
                } else {
                    ((FrameLayout) homeBtnContainer).setOnClickListener(dismissDialogClickListener);
                }
            } else {
                homeBtn.setOnClickListener(dismissDialogClickListener);
            }
        }
    }
}
Also used : Dialog(android.app.Dialog) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 79 with Dialog

use of android.app.Dialog in project ADWLauncher2 by boombuler.

the class CustomShirtcutActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        switch(requestCode) {
            case PICK_CUSTOM_PICTURE:
                mBitmap = (Bitmap) data.getParcelableExtra("data");
                if (mBitmap != null) {
                    if (mBitmap.getWidth() > mIconSize)
                        mBitmap = Bitmap.createScaledBitmap(mBitmap, mIconSize, mIconSize, true);
                    btPickIcon.setImageBitmap(mBitmap);
                }
                break;
            case PICK_CUSTOM_ICON:
                Uri photoUri = data.getData();
                try {
                    InputStream is = getContentResolver().openInputStream(photoUri);
                    BitmapFactory.Options opts = new BitmapFactory.Options();
                    opts.inJustDecodeBounds = true;
                    BitmapFactory.decodeStream(is, null, opts);
                    BitmapFactory.Options ops2 = new BitmapFactory.Options();
                    int width = mIconSize;
                    float w = opts.outWidth;
                    //int scale = Math.round(w / width);
                    int scale = (int) (w / width);
                    ops2.inSampleSize = scale;
                    is = getContentResolver().openInputStream(photoUri);
                    mBitmap = BitmapFactory.decodeStream(is, null, ops2);
                    if (mBitmap != null) {
                        if (mBitmap.getWidth() > mIconSize)
                            mBitmap = Bitmap.createScaledBitmap(mBitmap, mIconSize, mIconSize, true);
                        btPickIcon.setImageBitmap(mBitmap);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            case PICK_FROM_ICON_PACK:
                mBitmap = (Bitmap) data.getParcelableExtra("icon");
                if (mBitmap != null) {
                    if (mBitmap.getWidth() > mIconSize)
                        mBitmap = Bitmap.createScaledBitmap(mBitmap, mIconSize, mIconSize, true);
                    btPickIcon.setImageBitmap(mBitmap);
                }
                break;
            case PICK_STANDARD_MENU:
                String applicationName = getResources().getString(R.string.group_applications);
                String activitiesName = getResources().getString(R.string.shirtcuts_activity);
                String launcheractionsName = getResources().getString(R.string.launcher_actions);
                String shortcutName = data.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);
                    startActivityForResult(pickIntent, PICK_STANDARD_APPLICATION);
                } else if (activitiesName != null && activitiesName.equals(shortcutName)) {
                    Intent picker = new Intent();
                    picker.setClass(this, ActivityPickerActivity.class);
                    startActivityForResult(picker, PICK_STANDARD_SHORTCUT);
                } else if (launcheractionsName != null && launcheractionsName.equals(shortcutName)) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.setTitle(getString(R.string.launcher_actions));
                    final ListAdapter adapter = LauncherActions.getInstance().getSelectActionAdapter();
                    builder.setAdapter(adapter, new Dialog.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            LauncherActions.Action action = (LauncherActions.Action) adapter.getItem(which);
                            Intent result = new Intent();
                            result.putExtra(Intent.EXTRA_SHORTCUT_NAME, action.getName());
                            result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, LauncherActions.getInstance().getIntentForAction(action));
                            ShortcutIconResource iconResource = new ShortcutIconResource();
                            iconResource.packageName = CustomShirtcutActivity.this.getPackageName();
                            iconResource.resourceName = getResources().getResourceName(action.getIconResourceId());
                            result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
                            onActivityResult(PICK_STANDARD_SHORTCUT, RESULT_OK, result);
                        }
                    });
                    builder.create().show();
                } else {
                    startActivityForResult(data, PICK_STANDARD_SHORTCUT);
                }
                break;
            case PICK_STANDARD_APPLICATION:
                if (mBitmap != null) {
                    mBitmap.recycle();
                    mBitmap = null;
                }
                ComponentName component = data.getComponent();
                ActivityInfo activityInfo = null;
                try {
                    activityInfo = mPackageManager.getActivityInfo(component, 0);
                } catch (NameNotFoundException e) {
                }
                String title = null;
                if (activityInfo != null) {
                    title = activityInfo.loadLabel(mPackageManager).toString();
                    if (title == null) {
                        title = activityInfo.name;
                    }
                    mIntent = data;
                    btPickActivity.setText(title);
                    mBitmap = null;
                    btPickIcon.setImageDrawable(activityInfo.loadIcon(mPackageManager));
                    btPickIcon.setEnabled(true);
                    btOk.setEnabled(true);
                    edLabel.setText(title);
                }
                break;
            case PICK_STANDARD_SHORTCUT:
                if (mBitmap != null) {
                    mBitmap.recycle();
                    mBitmap = null;
                }
                Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
                String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
                Bitmap bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
                Drawable icon = null;
                if (bitmap != null) {
                    icon = new FastBitmapDrawable(Bitmap.createScaledBitmap(bitmap, mIconSize, mIconSize, true));
                    mBitmap = bitmap;
                } else {
                    Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                    if (extra != null && extra instanceof ShortcutIconResource) {
                        try {
                            ShortcutIconResource iconResource = (ShortcutIconResource) extra;
                            Resources resources = mPackageManager.getResourcesForApplication(iconResource.packageName);
                            final int id = resources.getIdentifier(iconResource.resourceName, null, null);
                            icon = resources.getDrawable(id);
                            mBitmap = Utilities.createIconBitmap(icon, this);
                        } catch (Exception e) {
                        }
                    }
                }
                if (icon == null) {
                    icon = getPackageManager().getDefaultActivityIcon();
                }
                mIntent = intent;
                btPickActivity.setText(name);
                btPickIcon.setImageDrawable(icon);
                btPickIcon.setEnabled(true);
                btOk.setEnabled(true);
                edLabel.setText(name);
                break;
            default:
                break;
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) ComponentName(android.content.ComponentName) BitmapFactory(android.graphics.BitmapFactory) ListAdapter(android.widget.ListAdapter) ActivityInfo(android.content.pm.ActivityInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) InputStream(java.io.InputStream) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) Parcelable(android.os.Parcelable) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) LauncherActions(org.adw.launcher2.actions.LauncherActions) Resources(android.content.res.Resources)

Example 80 with Dialog

use of android.app.Dialog in project glitch-hq-android by tinyspeck.

the class HomeScreen method onCreateDialog.

// // Dialog Creation ////
protected Dialog onCreateDialog(int id) {
    Dialog dialog;
    switch(id) {
        case DIALOG_LOGIN_FAIL_ID:
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Login failure").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            dialog = builder.create();
            break;
        case DIALOG_REQUEST_FAIL_ID:
            AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
            builder1.setMessage("Request failure").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            dialog = builder1.create();
            break;
        default:
            dialog = null;
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog)

Aggregations

Dialog (android.app.Dialog)792 View (android.view.View)317 AlertDialog (android.app.AlertDialog)256 TextView (android.widget.TextView)219 DialogInterface (android.content.DialogInterface)200 Intent (android.content.Intent)97 Bundle (android.os.Bundle)94 Context (android.content.Context)93 AlertDialog (android.support.v7.app.AlertDialog)93 ListView (android.widget.ListView)87 EditText (android.widget.EditText)84 Button (android.widget.Button)80 AdapterView (android.widget.AdapterView)79 NonNull (android.support.annotation.NonNull)77 LayoutInflater (android.view.LayoutInflater)75 ImageView (android.widget.ImageView)70 ArrayList (java.util.ArrayList)64 LinearLayout (android.widget.LinearLayout)54 WindowManager (android.view.WindowManager)52 ProgressDialog (android.app.ProgressDialog)51