Search in sources :

Example 36 with DialogInterface

use of android.content.DialogInterface in project Rashr by DsLNeXuS.

the class FlashFragment method showUnifiedBuildsDialog.

/**
     * Check if Device uses a Unified base like some Galaxy S4: htle, htltespr htltexx uses the same
     * sources so they can use the unified kernels and recoveries. Let the User choice which one is
     * the correct for him. PLEASE BE CAREFUL!
     */
public void showUnifiedBuildsDialog() {
    final AppCompatDialog UnifiedBuildsDialog = new AppCompatDialog(mContext);
    UnifiedBuildsDialog.setTitle(R.string.make_choice);
    final ArrayList<String> DevName = new ArrayList<>();
    ArrayList<String> DevNamesCarriers = new ArrayList<>();
    UnifiedBuildsDialog.setContentView(R.layout.dialog_unified_build);
    ListView UnifiedList = (ListView) UnifiedBuildsDialog.findViewById(R.id.lvUnifiedList);
    ArrayAdapter<String> UnifiedAdapter = new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, DevNamesCarriers);
    if (UnifiedList != null) {
        UnifiedList.setAdapter(UnifiedAdapter);
        UnifiedList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
                UnifiedBuildsDialog.dismiss();
                final ProgressDialog reloading = new ProgressDialog(mContext);
                reloading.setMessage(mContext.getString(R.string.reloading));
                reloading.setCancelable(false);
                reloading.show();
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
                        RashrApp.DEVICE.setName(DevName.get(position));
                        RashrApp.DEVICE.loadRecoveryList();
                        mActivity.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                reloading.dismiss();
                                mActivity.switchTo(FlashFragment.newInstance(mActivity));
                            }
                        });
                    }
                }).start();
            }
        });
    }
    if (RashrApp.DEVICE.getManufacture().equals("samsung")) {
        String[] unifiedGalaxyS3 = { "d2lte", "d2att", "d2cri", "d2mtr", "d2spr", "d2tmo", "d2usc", "d2vzw" };
        String[] unifiedGalaxyNote3 = { "hlte", "hltespr", "hltetmo", "hltevzw", "htlexx" };
        String[] unifiedGalaxyS4 = { "jflte", "jflteatt", "jfltecan", "jfltecri", "jfltecsp", "jfltespr", "jfltetmo", "jflteusc", "jfltevzw", "jfltexx", "jgedlte" };
        String[] unifiedGalaxyNote4 = { "trlte", "trltecan", "trltedt", "trltexx", "trltespr", "trltetmo", "trltevzw", "trlteusc" };
        if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS3)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyS3));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS3)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyNote3));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS4)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyS4));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyNote4)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyNote4));
        }
    }
    if (RashrApp.DEVICE.getManufacture().equals("motorola")) {
        String[] unifiedMsm8960 = { "moto_msm8960" };
        if (RashrApp.DEVICE.getBOARD().equals("msm8960")) {
            DevName.addAll(Arrays.asList(unifiedMsm8960));
        }
    }
    for (String i : DevName) {
        if (i.contains("att")) {
            DevNamesCarriers.add(i + " (AT&T Mobility)");
        } else if (i.contains("can")) {
            DevNamesCarriers.add(i + " (Canada)");
        } else if (i.contains("cri")) {
            DevNamesCarriers.add(i + " (Cricket Wireless)");
        } else if (i.contains("csp")) {
            DevNamesCarriers.add(i + " (C Spire Wireless)");
        } else if (i.contains("mtr")) {
            DevNamesCarriers.add(i + " (MetroPCS)");
        } else if (i.contains("spr")) {
            DevNamesCarriers.add(i + " (Sprint Corporation)");
        } else if (i.contains("tmo")) {
            DevNamesCarriers.add(i + " (T-Mobile US)");
        } else if (i.contains("usc")) {
            DevNamesCarriers.add(i + " (U.S. Cellular)");
        } else if (i.contains("vzw")) {
            DevNamesCarriers.add(i + " (Verizon Wireless)");
        } else if (i.contains("xx")) {
            DevNamesCarriers.add(i + " (International)");
        } else if (i.contains("ged")) {
            DevNamesCarriers.add(i + " (Google Play Edition)");
        } else if (i.contains("dt")) {
            DevNamesCarriers.add(i + " (India)");
        } else {
            DevNamesCarriers.add(i + " (Unified)");
        }
    }
    AppCompatButton KeepCurrent = (AppCompatButton) UnifiedBuildsDialog.findViewById(R.id.bKeepCurrent);
    if (KeepCurrent != null) {
        KeepCurrent.setText(String.format(getString(R.string.keep_current_name), RashrApp.DEVICE.getName()));
        KeepCurrent.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
                UnifiedBuildsDialog.dismiss();
            }
        });
    }
    if (DevName.size() > 0) {
        UnifiedBuildsDialog.show();
        UnifiedBuildsDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) ProgressDialog(android.app.ProgressDialog) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) AppCompatButton(android.support.v7.widget.AppCompatButton) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) AppCompatDialog(android.support.v7.app.AppCompatDialog) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 37 with DialogInterface

use of android.content.DialogInterface in project Rashr by DsLNeXuS.

the class FlashFragment method showFlashHistory.

/**
     * Lists the last 5 flashed images and shows a dialog for a re-flash
     */
public void showFlashHistory() {
    final ArrayList<File> HistoryFiles = getHistoryFiles();
    final ArrayList<String> HistoryFileNames = new ArrayList<>();
    final AlertDialog.Builder HistoryDialog = new AlertDialog.Builder(mContext);
    HistoryDialog.setTitle(R.string.history);
    for (File i : HistoryFiles) {
        HistoryFileNames.add(i.getName());
    }
    HistoryDialog.setAdapter(new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, HistoryFileNames), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (HistoryFiles.get(which).exists()) {
                mActivity.switchTo(FlashAsFragment.newInstance(mActivity, HistoryFiles.get(which), true));
            }
        }
    });
    if (HistoryFileNames.toArray().length > 0) {
        HistoryDialog.show();
    } else {
        Toast.makeText(mActivity, R.string.no_history, Toast.LENGTH_SHORT).show();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) File(java.io.File)

Example 38 with DialogInterface

use of android.content.DialogInterface in project XobotOS by xamarin.

the class IccCard method onIccSwap.

private void onIccSwap(boolean isAdded) {
    // TODO: Here we assume the device can't handle SIM hot-swap
    //      and has to reboot. We may want to add a property,
    //      e.g. REBOOT_ON_SIM_SWAP, to indicate if modem support
    //      hot-swap.
    DialogInterface.OnClickListener listener = null;
    // TODO: SimRecords is not reset while SIM ABSENT (only reset while
    //       Radio_off_or_not_available). Have to reset in both both
    //       added or removed situation.
    listener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                if (mDbg)
                    log("Reboot due to SIM swap");
                PowerManager pm = (PowerManager) mPhone.getContext().getSystemService(Context.POWER_SERVICE);
                pm.reboot("SIM is added.");
            }
        }
    };
    Resources r = Resources.getSystem();
    String title = (isAdded) ? r.getString(R.string.sim_added_title) : r.getString(R.string.sim_removed_title);
    String message = (isAdded) ? r.getString(R.string.sim_added_message) : r.getString(R.string.sim_removed_message);
    String buttonTxt = r.getString(R.string.sim_restart_button);
    AlertDialog dialog = new AlertDialog.Builder(mPhone.getContext()).setTitle(title).setMessage(message).setPositiveButton(buttonTxt, listener).create();
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    dialog.show();
}
Also used : PowerManager(android.os.PowerManager) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Resources(android.content.res.Resources)

Example 39 with DialogInterface

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

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 40 with DialogInterface

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

the class VolumeUI method showServiceActivationDialog.

private void showServiceActivationDialog(final ComponentName component) {
    final SystemUIDialog d = new SystemUIDialog(mContext);
    d.setMessage(mContext.getString(R.string.volumeui_prompt_message, getAppLabel(component)));
    d.setPositiveButton(R.string.volumeui_prompt_allow, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mVolumeControllerService.setComponent(component);
        }
    });
    d.setNegativeButton(R.string.volumeui_prompt_deny, null);
    d.show();
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Aggregations

DialogInterface (android.content.DialogInterface)2733 AlertDialog (android.app.AlertDialog)1228 View (android.view.View)877 Intent (android.content.Intent)709 TextView (android.widget.TextView)653 AlertDialog (android.support.v7.app.AlertDialog)649 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 Context (android.content.Context)181 Dialog (android.app.Dialog)180 File (java.io.File)160 OnClickListener (android.view.View.OnClickListener)157 Bundle (android.os.Bundle)146 Activity (android.app.Activity)143