Search in sources :

Example 56 with DialogInterface

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);
    }
}
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 57 with DialogInterface

use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeRuleSettingsBase method showDeleteRuleDialog.

private void showDeleteRuleDialog() {
    final AlertDialog dialog = new AlertDialog.Builder(mContext).setMessage(getString(R.string.zen_mode_delete_rule_confirmation, mRule.getName())).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.zen_mode_delete_rule_button, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_DELETE_RULE_OK);
            mDeleting = true;
            removeZenRule(mId);
        }
    }).show();
    final View messageView = dialog.findViewById(android.R.id.message);
    if (messageView != null) {
        messageView.setTextDirection(View.TEXT_DIRECTION_LOCALE);
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) View(android.view.View)

Example 58 with DialogInterface

use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SystemappRemover method selectDialog.

// profile select dialog
private void selectDialog(final ArrayList<String> sysAppProfile, final ArrayAdapter<String> adapter) {
    AlertDialog.Builder select = new AlertDialog.Builder(getActivity());
    select.setItems(R.array.slimsizer_profile_array, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // The 'which' argument contains the index position
            // of the selected item
            short state = sdAvailable();
            File path = new File(Environment.getExternalStorageDirectory() + "/rr");
            File savefile = new File(path + "/systemappremover.stf");
            if (which == 0) {
                // load profile action
                if (state >= 1) {
                    String profile;
                    try {
                        // read savefile and create arraylist
                        profile = new Scanner(savefile, "UTF-8").useDelimiter("\\A").next();
                        ArrayList<String> profileState = new ArrayList<String>(Arrays.asList(profile.split(", ")));
                        // create arraylist of unique entries in
                        // sysAppProfile (currently installed apps)
                        ArrayList<String> deleteList = new ArrayList<String>();
                        for (String item : sysAppProfile) {
                            if (!profileState.contains(item)) {
                                deleteList.add(item);
                            }
                        }
                        // delete all entries in deleteList
                        ArrayList<String> itemsList = new ArrayList<String>();
                        for (int i = deleteList.size() - 1; i > 0; i--) {
                            String item = deleteList.get(i);
                            itemsList.add(item);
                            // remove list entry
                            adapter.remove(item);
                        }
                        adapter.notifyDataSetChanged();
                        new SystemappRemover.Deleter().execute(itemsList.toArray(new String[itemsList.size()]));
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                } else {
                    toast(getResources().getString(R.string.sizer_message_sdnoread));
                }
            } else if (which == 1) {
                // save profile action
                if (state == 2) {
                    try {
                        // create directory if it doesnt exist
                        if (!path.exists()) {
                            path.mkdirs();
                        }
                        // create string from arraylists
                        String lists = sysAppProfile.toString();
                        lists = lists.replace("][", ",");
                        lists = lists.replace("[", "");
                        lists = lists.replace("]", "");
                        // delete savefile if it exists (overwrite)
                        if (savefile.exists()) {
                            savefile.delete();
                        }
                        // create savefile and output lists to it
                        FileWriter outstream = new FileWriter(savefile);
                        BufferedWriter save = new BufferedWriter(outstream);
                        save.write(lists);
                        save.close();
                        // check for success
                        if (savefile.exists()) {
                            toast(getResources().getString(R.string.sizer_message_filesuccess));
                        } else {
                            toast(getResources().getString(R.string.sizer_message_filefail));
                        }
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                } else {
                    toast(getResources().getString(R.string.sizer_message_sdnowrite));
                }
            }
        }
    });
    select.show();
}
Also used : AlertDialog(android.app.AlertDialog) Scanner(java.util.Scanner) DialogInterface(android.content.DialogInterface) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) File(java.io.File)

Example 59 with DialogInterface

use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SystemappRemover method showDialog.

private void showDialog(int id, final String item, final ArrayAdapter<String> adapter) {
    // startup dialog
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    if (id == STARTUP_DIALOG) {
        // create warning dialog
        alert.setMessage(R.string.sizer_message_startup).setTitle(R.string.caution).setCancelable(true).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                // action for ok
                dialog.cancel();
            }
        });
    // delete dialog
    } else if (id == DELETE_DIALOG) {
        alert.setMessage(R.string.sizer_message_delete).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                // action for ok
                // call delete
                new SystemappRemover.Deleter().execute(item);
                // remove list entry
                adapter.remove(item);
                adapter.notifyDataSetChanged();
            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                // action for cancel
                dialog.cancel();
            }
        });
    } else if (id == DELETE_MULTIPLE_DIALOG) {
        alert.setMessage(R.string.sizer_message_delete).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                final ListView lv = (ListView) getView().findViewById(R.string.listsystem);
                ArrayList<String> itemsList = new ArrayList<String>();
                SparseBooleanArray checked = lv.getCheckedItemPositions();
                for (int i = lv.getCount() - 1; i > 0; i--) {
                    if (checked.get(i)) {
                        String appName = mSysApp.get(i);
                        itemsList.add(appName);
                        // remove list entry
                        lv.setItemChecked(i, false);
                        adapter.remove(appName);
                    }
                }
                adapter.notifyDataSetChanged();
                new SystemappRemover.Deleter().execute(itemsList.toArray(new String[itemsList.size()]));
            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                // action for cancel
                dialog.cancel();
            }
        });
    }
    // show warning dialog
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) ListView(android.widget.ListView) SparseBooleanArray(android.util.SparseBooleanArray)

Example 60 with DialogInterface

use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class Helpers method showSystemUIrestartDialog.

public static void showSystemUIrestartDialog(Activity a) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(a);
    builder.setTitle(R.string.systemui_restart_title);
    builder.setMessage(R.string.systemui_restart_message);
    builder.setPositiveButton(R.string.print_restart, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {

                @Override
                protected void onPreExecute() {
                    ProgressDialog dialog = new ProgressDialog(a);
                    dialog.setMessage(a.getResources().getString(R.string.restarting_ui));
                    dialog.setCancelable(false);
                    dialog.setIndeterminate(true);
                    dialog.show();
                }

                @Override
                protected Void doInBackground(Void... params) {
                    // Give the user a second to see the dialog
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    // Ignore
                    }
                    // Restart the UI
                    CMDProcessor.startSuCommand("pkill -f com.android.systemui");
                    a.finish();
                    return null;
                }
            };
            task.execute();
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) AsyncTask(android.os.AsyncTask) ProgressDialog(android.app.ProgressDialog)

Aggregations

DialogInterface (android.content.DialogInterface)2727 AlertDialog (android.app.AlertDialog)1227 View (android.view.View)877 Intent (android.content.Intent)708 TextView (android.widget.TextView)653 AlertDialog (android.support.v7.app.AlertDialog)644 EditText (android.widget.EditText)426 ImageView (android.widget.ImageView)308 OnClickListener (android.content.DialogInterface.OnClickListener)285 LayoutInflater (android.view.LayoutInflater)242 SuppressLint (android.annotation.SuppressLint)225 AdapterView (android.widget.AdapterView)220 ListView (android.widget.ListView)220 ArrayList (java.util.ArrayList)213 Dialog (android.app.Dialog)179 Context (android.content.Context)179 File (java.io.File)160 OnClickListener (android.view.View.OnClickListener)157 Bundle (android.os.Bundle)146 Activity (android.app.Activity)143