Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

In this page you can find the example usage for android.app Dialog setContentView.

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

public void showFlashHistory(View view) {
    final boolean RecoveryHistory = view.getTag().toString().equals("recovery");
    String PREF_KEY;/*from   w w w.  j  a  v a  2  s  .  c om*/
    if (RecoveryHistory) {
        PREF_KEY = PREF_KEY_RECOVERY_HISTORY;
    } else {
        PREF_KEY = PREF_KEY_KERNEL_HISTORY;
    }
    final ArrayList<File> HistoryFiles = new ArrayList<File>();
    final ArrayList<String> HistoryFileNames = new ArrayList<String>();
    final Dialog HistoryDialog = new Dialog(mContext);
    HistoryDialog.setTitle(R.string.sHistory);
    ListView HistoryList = new ListView(mContext);
    File tmp;
    for (int i = 0; i < 5; i++) {
        tmp = new File(Common.getStringPref(mContext, PREF_NAME, PREF_KEY + String.valueOf(i)));
        if (!tmp.exists())
            Common.setStringPref(mContext, PREF_NAME, PREF_KEY + String.valueOf(i), "");
        else {
            HistoryFiles.add(tmp);
            HistoryFileNames.add(tmp.getName());
        }
    }
    HistoryList.setAdapter(
            new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, HistoryFileNames));
    HistoryList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (HistoryFiles.get(arg2).exists()) {
                if (RecoveryHistory) {
                    fRECOVERY = HistoryFiles.get(arg2);
                    rRecoveryFlasher.run();
                } else {
                    fKERNEL = HistoryFiles.get(arg2);
                    rKernelFlasher.run();
                }
                HistoryDialog.dismiss();
            } else {
                Toast.makeText(mContext, R.string.no_choosed, Toast.LENGTH_SHORT).show();
            }
        }
    });
    HistoryDialog.setContentView(HistoryList);
    if (HistoryFileNames.toArray().length > 0) {
        HistoryDialog.show();
    } else {
        Toast.makeText(mContext, R.string.no_history, Toast.LENGTH_SHORT).show();
    }

}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void renameProfileGroupDlg(final String old_loc) {
    // ??/*from ww w  .j  av a  2s .c o  m*/
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //      dialog.getWindow().setSoftInputMode(
    //                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    dialog.setContentView(R.layout.single_item_input_dlg);
    final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title);
    final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir);
    //      final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg);
    final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn);
    final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn);
    btnOK.setEnabled(false);

    dlg_title.setText(mContext.getString(R.string.msgs_profile_group_rename_profile_group));

    CommonDialog.setDlgBoxSizeCompact(dialog);

    dlg_et_name.setText(old_loc);
    dlg_et_name.addTextChangedListener(new TextWatcher() {
        @Override
        final public void afterTextChanged(Editable s) {
            if (s.length() != 0) {
                //                dlg_et_name.selectAll();
                String newgrp = dlg_et_name.getText().toString();
                if (!newgrp.startsWith("*")) {
                    btnOK.setEnabled(true);
                    for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) {
                        if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) {
                            btnOK.setEnabled(false);
                            break;
                        }
                    }
                } else
                    btnOK.setEnabled(false);
            } else
                btnOK.setEnabled(false);
        }

        @Override
        final public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        final public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    final NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override
        final public void positiveResponse(Context c, Object[] o) {
            dlg_et_name.selectAll();
            String new_loc = dlg_et_name.getText().toString();
            renameProfileGroup(true, old_loc, new_loc);
        }

        @Override
        final public void negativeResponse(Context c, Object[] o) {
        }

    });

    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            dialog.dismiss();
        }
    });
    // OK?
    btnOK.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            ntfy.notifyToListener(POSITIVE, null);
            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void copyProfileGroupDlg(final String old_loc) {
    // ??//from  w  w w .  j  av a2s  . com
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //      dialog.getWindow().setSoftInputMode(
    //                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    dialog.setContentView(R.layout.single_item_input_dlg);
    final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title);
    final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir);
    //      final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg);
    final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn);
    final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn);
    btnOK.setEnabled(false);

    dlg_title.setText(mContext.getString(R.string.msgs_profile_group_copy_profile_group));

    CommonDialog.setDlgBoxSizeCompact(dialog);

    dlg_et_name.setText(old_loc);
    dlg_et_name.addTextChangedListener(new TextWatcher() {
        @Override
        final public void afterTextChanged(Editable s) {
            if (s.length() != 0) {
                //                dlg_et_name.selectAll();
                String newgrp = dlg_et_name.getText().toString();
                if (!newgrp.startsWith("*")) {
                    btnOK.setEnabled(true);
                    for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) {
                        if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) {
                            btnOK.setEnabled(false);
                            break;
                        }
                    }
                } else
                    btnOK.setEnabled(false);
            } else
                btnOK.setEnabled(false);
        }

        @Override
        final public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        final public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    final NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override
        final public void positiveResponse(Context c, Object[] o) {
            dlg_et_name.selectAll();
            String new_loc = dlg_et_name.getText().toString();
            copyProfileGroup(true, old_loc, new_loc);
        }

        @Override
        final public void negativeResponse(Context c, Object[] o) {
        }

    });

    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            dialog.dismiss();
        }
    });
    // OK?
    btnOK.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            ntfy.notifyToListener(POSITIVE, null);
            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void createNewProfileGroup() {
    // ??//from   w ww . j  a va2  s . co m
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //      dialog.getWindow().setSoftInputMode(
    //                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    dialog.setContentView(R.layout.single_item_input_dlg);
    final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title);
    final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir);
    //      final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg);
    final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn);
    final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn);
    btnOK.setEnabled(false);

    dlg_title.setText(mContext.getString(R.string.msgs_profile_group_create_new_profile_group));

    CommonDialog.setDlgBoxSizeCompact(dialog);

    dlg_et_name.addTextChangedListener(new TextWatcher() {
        @Override
        final public void afterTextChanged(Editable s) {
            if (s.length() != 0) {
                //                dlg_et_name.selectAll();
                String newgrp = dlg_et_name.getText().toString();
                if (!newgrp.startsWith("*")) {
                    btnOK.setEnabled(true);
                    for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) {
                        if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) {
                            btnOK.setEnabled(false);
                            break;
                        }
                    }
                } else
                    btnOK.setEnabled(false);
            } else
                btnOK.setEnabled(false);
        }

        @Override
        final public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        final public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    final NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override
        final public void positiveResponse(Context c, Object[] o) {
            dlg_et_name.selectAll();
            String newloc = dlg_et_name.getText().toString();
            mGlblParms.profileGroupAdapter.add(new ProfileGroupListItem(newloc, false, 0, 0, 0));
            mGlblParms.profileGroupAdapter.sort();
            mGlblParms.profileGroupAdapter.notifyDataSetChanged();

            ProfileListItem tpli = new ProfileListItem();
            tpli.setTaskEntry(PROFILE_VERSION_CURRENT, newloc, false, System.currentTimeMillis(), "",
                    mContext.getString(R.string.msgs_no_profile_entry), "", "", "", "", null, null);
            mGlblParms.profileAdapter.addDataListItem(tpli);
            mGlblParms.profileAdapter.updateShowList();

            setProfileGroupSelectorListener();
        }

        @Override
        final public void negativeResponse(Context c, Object[] o) {
        }

    });

    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            dialog.dismiss();
        }
    });
    // OK?
    btnOK.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            ntfy.notifyToListener(POSITIVE, null);
            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java

private void showGraph(String bluetoothDeviceAddress, int requestCode, int which) {
    int beginAtField = 0;
    GraphView graphView = null;//from   w  w w. j ava 2s. com
    Dialog dialog = null;
    switch (requestCode) {
    case REQUEST_MAIN_COMMAND_SHIMMER:
        beginAtField = 1;
        switch (which) {
        case 1:
            beginAtField = 4;
            break;
        }

        graphView = new GraphView(this, beginAtField);
        if (this.shimmerImuService != null) {
            if (!isSessionStarted)
                this.startStreamingOfAllShimmerImus(false);
            this.shimmerImuService.startDataVisualization(bluetoothDeviceAddress, graphView);
        }
        dialog = new Dialog(this);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (shimmerImuService != null) {
                    shimmerImuService.stopDataVisualization();
                }
                if (!isSessionStarted) {
                    stopAllStreamingOfAllShimmerImus();
                }
            }
        });
        break;
    case REQUEST_MAIN_COMMAND_BIOHARNESS:
        graphView = new GraphView(this, beginAtField);
        if (this.bioHarnessService != null) {
            this.bioHarnessService.startDataVisualization(graphView);
        }
        dialog = new Dialog(this);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (bioHarnessService != null) {
                    bioHarnessService.stopDataVisualization();
                }
            }
        });
        break;
    }

    assert dialog != null;
    dialog.setContentView(graphView);
    dialog.setTitle(getString(R.string.graph));
    dialog.setCancelable(true);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.MATCH_PARENT;
    dialog.getWindow().setAttributes(lp);

    dialog.show();
}

From source file:ua.mkh.settings.full.MainActivity.java

public void lock() {
    final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_inform);

    // set the custom dialog components - text, image and button

    Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
    TextView text = (TextView) dialog.findViewById(R.id.text);
    TextView textB = (TextView) dialog.findViewById(R.id.textBold);
    text.setText(R.string.block_license);
    textB.setText(R.string.attention);/*w  ww.  j  a v a2  s  . c  om*/

    dialogButton.setTypeface(typefaceRoman);
    text.setTypeface(typefaceRoman);
    textB.setTypeface(typefaceBold);

    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    });
    dialog.show();
}

From source file:ua.mkh.settings.full.MainActivity.java

private void openDialog() {
    final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_menu);
    dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
    Button ButtonInfo = (Button) dialog.getWindow().findViewById(R.id.button1);
    ButtonMenuCancel = (Button) dialog.getWindow().findViewById(R.id.ButtonMenuCancel);
    ButtonMenuSettings = (Button) dialog.getWindow().findViewById(R.id.ButtonMenuSettings);
    ButtonMenuSettings.setTypeface(typefaceRoman);
    ButtonMenuCancel.setTypeface(typefaceMedium);
    ButtonInfo.setTypeface(typefaceRoman);
    ButtonInfo.setText(R.string.menu_info_main);

    ButtonMenuCancel.setOnClickListener(new OnClickListener() {

        @Override/*from   ww w.  ja v  a  2  s  . c o  m*/
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    ButtonMenuSettings.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            launchIntent();
        }
    });

    dialog.show();
}

From source file:ua.mkh.settings.full.MainActivity.java

public void update_app() {

    final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_inform);

    // set the custom dialog components - text, image and button

    Button dialogButtone = (Button) dialog.findViewById(R.id.dialogButtonOK);
    TextView text1 = (TextView) dialog.findViewById(R.id.text);
    TextView textB = (TextView) dialog.findViewById(R.id.textBold);
    text1.setText(R.string.update_version);
    textB.setText(R.string.attention);// w w w .  ja  v a  2s. c  o  m

    dialogButtone.setTypeface(typefaceRoman);
    text1.setTypeface(typefaceRoman);
    textB.setTypeface(typefaceBold);
    // if button is clicked, close the custom dialog
    dialogButtone.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("yastore://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                //startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://khaydarov-studio.bl.ee/fineSettings/")));
            }
            overridePendingTransition(center_to_left, center_to_left2);
            dialog.dismiss();
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);

        }

    });
    dialog.show();
}

From source file:ua.mkh.settings.full.MainActivity.java

public void send_email() {
    final Dialog Activation = new Dialog(MainActivity.this, android.R.style.Theme_Translucent);
    Activation.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Activation.setContentView(R.layout.dialog_inform);

    // set the custom dialog components - text, image and button

    Button dialogButton12 = (Button) Activation.findViewById(R.id.dialogButtonOK);
    TextView textf = (TextView) Activation.findViewById(R.id.textBold);
    TextView textverf = (TextView) Activation.findViewById(R.id.text);

    dialogButton12.setTypeface(typefaceRoman);
    textf.setTypeface(typefaceBold);// ww w .  j a  v  a  2  s.  c  o  m
    textverf.setTypeface(typefaceRoman);
    textverf.setText(R.string.activation);

    // if button is clicked, close the custom dialog
    dialogButton12.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (YA != null && G != null) {
                Intent i2 = new Intent(Intent.ACTION_SEND);
                i2.setType("text/rfc822");
                i2.putExtra(Intent.EXTRA_EMAIL, new String[] { "maxim.khaydarov@yandex.ru" });
                i2.putExtra(Intent.EXTRA_SUBJECT, "Activation");
                i2.putExtra(Intent.EXTRA_TEXT, "2: " + codes(YA) + "\n" + "1: " + codes(G));
                Editor e = mSettings.edit();
                e.putBoolean(APP_PREFERENCES_ACTIVATION, true);
                e.commit(); //    ?
                try {
                    startActivity(Intent.createChooser(i2, "Send mail..."));
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(MainActivity.this, "No email clients installed.", Toast.LENGTH_SHORT).show();
                    Editor e1 = mSettings.edit();
                    e1.putBoolean(APP_PREFERENCES_ACTIVATION, false);
                    e1.commit(); //    ?
                }

            }
            Editor e = mSettings.edit();
            e.putBoolean(APP_PREFERENCES_ACTIVATION, true);
            e.commit(); //    ?

            Activation.dismiss();
        }
    });
    Activation.show();
}

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;
    ProgressDialog pdialog;//from w  w  w  .  j  a v  a  2s  .  c om
    AlertDialog.Builder builder;
    LayoutInflater inflater;

    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, false) {
            @Override
            public void onLoginChosen(String user, String password) {
                removeDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_COMMENT_CLICK:
        dialog = new CommentClickDialog(this, mSettings);
        break;

    case Constants.DIALOG_REPLY: {
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);

        replySaveButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new CommentReplyTask(mReplyTargetName).execute(replyBody.getText().toString());
                    dialog.dismiss();
                } else {
                    Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT,
                            CommentsListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mVoteTargetThing.setReplyDraft(replyBody.getText().toString());
                dialog.cancel();
            }
        });
        dialog.setCancelable(false); // disallow the BACK key
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                replyBody.setText("");
            }
        });
        break;
    }

    case Constants.DIALOG_EDIT: {
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);

        replyBody.setText(mEditTargetBody);

        replySaveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new EditTask(mReplyTargetName).execute(replyBody.getText().toString());
                    dialog.dismiss();
                } else {
                    Common.showErrorToast("Error editing. Please try again.", Toast.LENGTH_SHORT,
                            CommentsListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.cancel();
            }
        });
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                replyBody.setText("");
            }
        });
        break;
    }

    case Constants.DIALOG_DELETE:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Really delete this?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                removeDialog(Constants.DIALOG_DELETE);
                new DeleteTask(mDeleteTargetKind).execute(mReplyTargetName);
            }
        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        break;

    case Constants.DIALOG_SORT_BY:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Sort by:");
        int selectedSortBy = -1;
        for (int i = 0; i < Constants.CommentsSort.SORT_BY_URL_CHOICES.length; i++) {
            if (Constants.CommentsSort.SORT_BY_URL_CHOICES[i].equals(mSettings.getCommentsSortByUrl())) {
                selectedSortBy = i;
                break;
            }
        }
        builder.setSingleChoiceItems(Constants.CommentsSort.SORT_BY_CHOICES, selectedSortBy,
                sortByOnClickListener);
        dialog = builder.create();
        break;

    case Constants.DIALOG_REPORT:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Really report this?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                removeDialog(Constants.DIALOG_REPORT);
                new ReportTask(mReportTargetName.toString()).execute();
            }
        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        break;

    // "Please wait"
    case Constants.DIALOG_DELETING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Deleting...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_EDITING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Submitting edit...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_FIND:
        inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View content = inflater.inflate(R.layout.dialog_find, null);
        final EditText find_box = (EditText) content.findViewById(R.id.input_find_box);
        //          final CheckBox wrap_box = (CheckBox) content.findViewById(R.id.find_wrap_checkbox);

        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setView(content);
        builder.setTitle(R.string.find).setPositiveButton(R.string.find, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String search_text = find_box.getText().toString().toLowerCase();
                //               findCommentText(search_text, wrap_box.isChecked(), false);
                findCommentText(search_text, true, false);
            }
        }).setNegativeButton("Cancel", null);
        dialog = builder.create();
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}