Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

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

Prototype

public Dialog(@NonNull Context context) 

Source Link

Document

Creates a dialog window that uses the default dialog theme.

Usage

From source file:com.mitre.holdshort.MainActivity.java

private void showNotSupportedDialog(String airport) {
    final Dialog dialog = new Dialog(MainActivity.this);
    OnCancelListener notSupportedCancelListener = null;
    notSupportedCancelListener = new OnCancelListener() {

        @Override/*w  w w .j  a v a2s  .c om*/
        public void onCancel(DialogInterface dialog) {

            dialog.dismiss();
            finish();

        }

    };

    OnClickListener noAirportClickListener = new OnClickListener() {

        @Override
        public void onClick(View v) {

            switch (v.getId()) {

            case R.id.exit:
                dialog.dismiss();
                finish();
                break;
            case R.id.contactMitre:
                Log.d(LOG_TAG, "TEST");
                contactMITRE("RIPPLE App Support");
            case R.id.uploadData:
                AlertLogger al = new AlertLogger("999", MainActivity.this);
            default:
                return;

            }
        }

    };

    if (airport == null) {
        dialog.setOnCancelListener(notSupportedCancelListener);
        dialog.setContentView(R.layout.no_airport_found_dialog);
        dialog.setTitle("No Airport Found!");
        dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        Button exit = (Button) dialog.findViewById(R.id.exit);
        Button contact = (Button) dialog.findViewById(R.id.contactMitre);
        Button uploadData = (Button) dialog.findViewById(R.id.uploadData);
        contact.setOnClickListener(noAirportClickListener);
        exit.setOnClickListener(noAirportClickListener);
        uploadData.setOnClickListener(noAirportClickListener);

        dialog.show();
    } else {
        dialog.setOnCancelListener(notSupportedCancelListener);
        dialog.setContentView(R.layout.airport_not_supported_dialog);
        dialog.setTitle("Airport " + (airport.split("_"))[0] + " Not Supported");
        dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        Button exit = (Button) dialog.findViewById(R.id.exit);
        Button contact = (Button) dialog.findViewById(R.id.contactMitre);
        contact.setOnClickListener(noAirportClickListener);
        exit.setOnClickListener(noAirportClickListener);
        dialog.show();
    }

}

From source file:com.speed.traquer.app.TraqComplaintTaxi.java

private void PromptCustomDialog() {

    // Create custom dialog object
    final Dialog dialog = new Dialog(TraqComplaintTaxi.this);
    // Include dialog.xml file
    dialog.setContentView(R.layout.activity_submit_social);
    // Set dialog title
    dialog.setTitle("Submit via");

    // set values for custom dialog components - text, image and button
    final TextView twitterText = (TextView) dialog.findViewById(R.id.textTwitterDialog);
    twitterText.setText("Twitter");

    final TextView facebookText = (TextView) dialog.findViewById(R.id.textFacebookDialog);
    facebookText.setText("Facebook");

    final TextView defaultText = (TextView) dialog.findViewById(R.id.textDefaultDialog);
    defaultText.setText("Default");
    defaultText.setTextColor(getResources().getColor(R.color.Orange));

    final TextView smsText = (TextView) dialog.findViewById(R.id.textSMSDialog);
    smsText.setText("SMS");

    final ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog);
    image.setImageResource(R.drawable.icon_twitter);

    final ImageView imageFb = (ImageView) dialog.findViewById(R.id.imageDialogFb);
    imageFb.setImageResource(R.drawable.ic_fb_grey);

    final ImageView imageDefault = (ImageView) dialog.findViewById(R.id.imageDialogDefault);
    imageDefault.setImageResource(R.drawable.icon_traquer_color);
    isDefaultSelected = true;//from  w w w  . j a va2  s  .  co m

    final ImageView imageSMS = (ImageView) dialog.findViewById(R.id.imageDialogSMS);
    imageSMS.setImageResource(R.drawable.icon_sms);

    dialog.show();

    //Retrieve form info
    taxi_id = inputTaxi.getText().toString().toUpperCase();
    taxi_id = taxi_id.replace(" ", "");
    taxi_comp = actv_comp_taxi.getText().toString();
    taxi_driver = taxiDriver.getText().toString();
    taxi_license = taxiLic.getText().toString();
    loc_frm = actv_from.getText().toString();
    loc_to = actv_to.getText().toString();
    dateBus = editDate.getText().toString();
    timeBus = editTime.getText().toString();
    curr_time = editCurrTime.getText().toString();
    user_name = SaveSharedPreference.getUserName(TraqComplaintTaxi.this);

    //Twitter Button
    final RelativeLayout twitterLogin = (RelativeLayout) dialog.findViewById(R.id.twitterImageButton);
    twitterLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isTwitterSelected) {
                image.setImageResource(R.drawable.icon_twitter);
                twitterText.setTextColor(getResources().getColor(R.color.DarkGray));
                isTwitterSelected = false;
            } else {
                loginToTwitter();
                image.setImageResource(R.drawable.icon_twitter_blue);
                twitterText.setTextColor(getResources().getColor(R.color.TwitterBlue));
                isTwitterSelected = true;
            }

        }
    });

    //facebook Button
    final RelativeLayout facebookLogin = (RelativeLayout) dialog.findViewById(R.id.facebookImageButton);
    facebookLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isFacebookSelected) {
                imageFb.setImageResource(R.drawable.ic_fb_grey);
                if (fbUserName != null)
                    facebookText.setText("Facebook");

                facebookText.setTextColor(getResources().getColor(R.color.DarkGray));
                isFacebookSelected = false;
            } else {

                //loginToTwitter();
                // start Facebook Login
                loginToFacebook();
                if (fbUserName != null)
                    facebookText.setText(fbUserName);
                imageFb.setImageResource(R.drawable.ic_fb_blue);
                facebookText.setTextColor(getResources().getColor(R.color.TwitterBlue));
                isFacebookSelected = true;
            }

        }
    });

    //SMS Button
    final RelativeLayout SMSLogin = (RelativeLayout) dialog.findViewById(R.id.smsImageButton);
    SMSLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isSmsSelected) {
                imageSMS.setImageResource(R.drawable.icon_sms);
                smsText.setTextColor(getResources().getColor(R.color.DarkGray));
                isSmsSelected = false;
            } else {
                imageSMS.setImageResource(R.drawable.icon_sms_color);
                smsText.setTextColor(getResources().getColor(R.color.Orange));
                isSmsSelected = true;
            }

        }
    });

    /*/Default Button
    final RelativeLayout defaultLogin = (RelativeLayout)dialog.findViewById(R.id.defaultImageButton);
    defaultLogin.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if(isDefaultSelected)
        {
            imageDefault.setImageResource(R.drawable.icon_traquer_color);
            defaultText.setTextColor(getResources().getColor(R.color.Orange));
            isDefaultSelected = false;
        }
        else
        {
            imageDefault.setImageResource(R.drawable.icon_traquer_color);
            defaultText.setTextColor(getResources().getColor(R.color.Orange));
            isDefaultSelected = true;
        }
            
    }
    });*/

    //Submit Button
    Button declineButton = (Button) dialog.findViewById(R.id.submitButton);
    // if decline button is clicked, close the custom dialog
    declineButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //submit complaint
            isSubmitButtonClicked = true;
            if (isNetworkConnected() == true) {
                Toast.makeText(TraqComplaintTaxi.this, "Complaint sent. Thank you for taking action!",
                        Toast.LENGTH_SHORT).show();

                //Combine Strings for Twitter Status

                String status = taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed
                        + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude)
                        + "E, " + curr_time + " @aduanSPAD @MyTraquer #Traquer";

                finalStatus = status;

                if (isFacebookSelected) {
                    //share to facebook
                    ShareToFacebook(status);
                    //publishFeedDialog();
                }

                if (isTwitterSelected) {

                    //Toast.makeText(TraqComplaintTaxi.this, Long.toString(twitterID) + userName, Toast.LENGTH_SHORT).show();

                    // Check for blank text
                    if (status.trim().length() > 0) {
                        // update status
                        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) {
                            new updateTwitterStatus().execute(status);
                        }

                        else
                            new updateTwitterStatus().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, status);

                    } else {
                        // EditText is empty
                        Toast.makeText(getApplicationContext(), "Please enter status message",
                                Toast.LENGTH_SHORT).show();
                    }

                } else {
                    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1)
                        new InsertForm().execute();
                    else
                        new InsertForm().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

                }

                // Close dialog
                dialog.dismiss();

            } else {
                if (isSmsSelected) {
                    Log.i("Clicks", "You clicked sent.");

                    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                    sendIntent.putExtra("address", "15888");
                    sendIntent.putExtra("sms_body",
                            "SPAD Aduan " + taxi_id + ", " + taxi_comp + " taxi is speeding with "
                                    + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, "
                                    + Double.toString(gLongitude) + "E, " + curr_time + " - Traquer");
                    sendIntent.setType("vnd.android-dir/mms-sms");
                    startActivity(sendIntent);

                    //1800-88-7723
                } else {
                    Toast.makeText(TraqComplaintTaxi.this,
                            "Failed to send. Please check your network connection.", Toast.LENGTH_SHORT).show();
                }
            }

        }

    });
    //TraqComplaintTaxi.this.showDialog(ALERT_DIALOG);
}

From source file:com.google.code.twisty.Twisty.java

/** Have our activity manage and persist dialogs, showing and hiding them */
@Override/*  w  w w  .  j a v a  2  s . co m*/
protected Dialog onCreateDialog(int id) {
    switch (id) {

    case DIALOG_ENTER_WRITEFILE:
        LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate(R.layout.save_file_prompt, null);
        final EditText et = (EditText) textEntryView.findViewById(R.id.savefile_entry);
        return new AlertDialog.Builder(Twisty.this).setTitle("Write to file").setView(textEntryView)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        savefile_path = savegame_dir + "/" + et.getText().toString();
                        // Directly modify the message-object passed to us by the terp thread:
                        dialog_message.path = savefile_path;
                        // Wake up the terp thread again
                        synchronized (glkLayout) {
                            glkLayout.notify();
                        }
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // This makes op_save() fail.
                        dialog_message.path = "";
                        // Wake up the terp thread again
                        synchronized (glkLayout) {
                            glkLayout.notify();
                        }
                    }
                }).create();

    case DIALOG_ENTER_READFILE:
        restoredialog = new Dialog(Twisty.this);
        restoredialog.setContentView(R.layout.restore_file_prompt);
        restoredialog.setTitle("Read a file");
        android.widget.RadioGroup rg = (RadioGroup) restoredialog.findViewById(R.id.radiomenu);
        updateRestoreRadioButtons(rg);
        android.widget.Button okbutton = (Button) restoredialog.findViewById(R.id.restoreokbutton);
        okbutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                android.widget.RadioGroup rg = (RadioGroup) restoredialog.findViewById(R.id.radiomenu);
                int checkedid = rg.getCheckedRadioButtonId();
                if (rg.getChildCount() == 0) { // no saved games:  FAIL
                    savefile_path = "";
                } else if (checkedid == -1) { // no game selected
                    RadioButton firstbutton = (RadioButton) rg.getChildAt(0); // default to first game
                    savefile_path = savegame_dir + "/" + firstbutton.getText();
                } else {
                    RadioButton checkedbutton = (RadioButton) rg.findViewById(checkedid);
                    savefile_path = savegame_dir + "/" + checkedbutton.getText();
                }
                dismissDialog(DIALOG_ENTER_READFILE);
                // Return control to the z-machine thread
                dialog_message.path = savefile_path;
                synchronized (glkLayout) {
                    glkLayout.notify();
                }
            }
        });
        android.widget.Button cancelbutton = (Button) restoredialog.findViewById(R.id.restorecancelbutton);
        cancelbutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                dismissDialog(DIALOG_ENTER_READFILE);
                // Return control to the z-machine thread
                dialog_message.path = "";
                synchronized (glkLayout) {
                    glkLayout.notify();
                }
            }
        });
        return restoredialog;

    case DIALOG_CHOOSE_GAME:
        choosegamedialog = new Dialog(Twisty.this);
        choosegamedialog.setContentView(R.layout.choose_game_prompt);
        choosegamedialog.setTitle("Choose Game");
        android.widget.RadioGroup zrg = (RadioGroup) choosegamedialog.findViewById(R.id.game_radiomenu);
        updateGameRadioButtons(zrg);
        zrg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                dismissDialog(DIALOG_CHOOSE_GAME);
                String path = (String) game_paths.get(checkedId);
                if (path != null) {
                    stopTerp();
                    startTerp(path);
                }
            }
        });
        return choosegamedialog;

    case DIALOG_CANT_SAVE:
        return new AlertDialog.Builder(Twisty.this).setTitle("Cannot Access Games")
                .setMessage("Twisty Games folder is not available on external media.")
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // A path of "" makes op_save() fail.
                        dialog_message.path = "";
                        // Wake up the terp thread again
                        synchronized (glkLayout) {
                            glkLayout.notify();
                        }
                    }
                }).create();

    case DIALOG_NO_SDCARD:
        return new AlertDialog.Builder(Twisty.this).setTitle("No External Media")
                .setMessage("Cannot find sdcard or other media.")
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // do nothing
                    }
                }).create();
    }
    return null;
}

From source file:com.mobicage.rogerthat.plugins.messaging.widgets.AdvancedOrderWidget.java

private void showAdvancedOrderItemDetail(final int position, final AdvancedOrderCategoryItemRow row) {
    if (mDetailDialog != null && mDetailDialog.isShowing())
        return;/*from ww  w .  j ava 2  s.c  o  m*/
    mCurrentItemDetail = position;
    final View v = mLayoutInFlater.inflate(R.layout.widget_advanced_order_item_detail, this, false);

    mDetailDialog = new Dialog(mActivity);
    mDetailDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDetailDialog.setContentView(v);
    mDetailDialog.setCanceledOnTouchOutside(true);
    mDetailDialog.setCancelable(true);

    final TextView nameLbl = (TextView) v.findViewById(R.id.name);
    final TextView priceLbl = (TextView) v.findViewById(R.id.price);
    final TextView descriptionLbl = (TextView) v.findViewById(R.id.description);
    final Resizable16by9ImageView imageView = (Resizable16by9ImageView) v.findViewById(R.id.image);
    final TextView minValueBtn = (TextView) v.findViewById(R.id.value_min);
    final TextView valueLbl = (TextView) v.findViewById(R.id.value);
    final TextView plusValueBtn = (TextView) v.findViewById(R.id.value_plus);

    final Button dismissBtn = (Button) v.findViewById(R.id.dismiss);

    nameLbl.setText(row.name);
    nameLbl.setTextColor(ContextCompat.getColor(mActivity, android.R.color.black));

    if (row.hasPrice) {
        priceLbl.setVisibility(View.VISIBLE);
        priceLbl.setText(getPriceStringForRow(row));
        priceLbl.setTextColor(ContextCompat.getColor(mActivity, R.color.mc_divider_gray));
    } else {
        priceLbl.setVisibility(View.GONE);
    }

    if (TextUtils.isEmptyOrWhitespace(row.description)) {
        descriptionLbl.setVisibility(View.GONE);
    } else {
        descriptionLbl.setVisibility(View.VISIBLE);
        descriptionLbl.setText(row.description);
        descriptionLbl.setTextColor(ContextCompat.getColor(mActivity, android.R.color.black));
    }

    minValueBtn.setText(R.string.fa_minus_circle);
    minValueBtn.setTypeface(mFontAwesomeTypeFace);
    minValueBtn.setTextColor(ContextCompat.getColor(mActivity, R.color.mc_red_divider));

    minValueBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            long value = excecuteMinValuePress(row);
            AdvancedOrderCategoryItemRow tmpRow = (AdvancedOrderCategoryItemRow) mData.get(position);
            tmpRow.value = value;
            mData.set(position, tmpRow);
            valueLbl.setText(getValueStringForRow(tmpRow));
            mListAdapter.notifyDataSetChanged();
        }
    });

    valueLbl.setText(getValueStringForRow(row));

    plusValueBtn.setText(R.string.fa_plus_circle);
    plusValueBtn.setTypeface(mFontAwesomeTypeFace);
    plusValueBtn.setTextColor(ContextCompat.getColor(mActivity, R.color.mc_divider_green));

    plusValueBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            long value = excecutePlusValuePress(row);
            AdvancedOrderCategoryItemRow tmpRow = (AdvancedOrderCategoryItemRow) mData.get(position);
            tmpRow.value = value;
            mData.set(position, tmpRow);
            valueLbl.setText(getValueStringForRow(tmpRow));
            mListAdapter.notifyDataSetChanged();
        }
    });

    dismissBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mDetailDialog.dismiss();
        }
    });

    if (!TextUtils.isEmptyOrWhitespace(row.imageUrl)) {
        new DownloadImageTask(mCachedDownloader, mActivity).execute(row.imageUrl);
    }

    mActivity.getMainService().postOnUIHandler(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            setDetailScrollViewHeight();
        }
    });

    mDetailDialog.show();
}

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

@SuppressLint("NewApi")
final private void aboutTaskAutomation() {
    // common ??/*from  ww  w.  j  a  va2  s.  com*/
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.about_dialog);
    ((TextView) dialog.findViewById(R.id.about_dialog_title))
            .setText(getString(R.string.msgs_about_dlg_title) + " Ver " + getApplVersionName());
    final WebView func_view = (WebView) dialog.findViewById(R.id.about_dialog_function);
    //       func_view.setWebViewClient(new WebViewClient());
    //       func_view.getSettings().setJavaScriptEnabled(true); 
    func_view.getSettings().setSupportZoom(true);
    //      func_view.setVerticalScrollbarOverlay(true);
    func_view.setBackgroundColor(Color.LTGRAY);
    //      func_view.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
    func_view.setVerticalScrollBarEnabled(true);
    func_view.setScrollbarFadingEnabled(false);
    if (Build.VERSION.SDK_INT > 10) {
        func_view.getSettings().setDisplayZoomControls(true);
        func_view.getSettings().setBuiltInZoomControls(true);
    } else {
        func_view.getSettings().setBuiltInZoomControls(true);
    }
    func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_about_dlg_func_html));

    final WebView change_view = (WebView) dialog.findViewById(R.id.about_dialog_change_history);
    if (Build.VERSION.SDK_INT > 10) {
        func_view.getSettings().setDisplayZoomControls(true);
        func_view.getSettings().setBuiltInZoomControls(true);
    } else {
        func_view.getSettings().setBuiltInZoomControls(true);
    }
    change_view.loadDataWithBaseURL("file:///android_asset/", getString(R.string.msgs_about_dlg_change_desc),
            "text/html", "UTF-8", "");
    change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    change_view.getSettings().setSupportZoom(true);
    if (Build.VERSION.SDK_INT > 10) {
        change_view.getSettings().setDisplayZoomControls(true);
        change_view.getSettings().setBuiltInZoomControls(true);
    } else {
        change_view.getSettings().setBuiltInZoomControls(true);
    }

    final Button btnFunc = (Button) dialog.findViewById(R.id.about_dialog_btn_show_func);
    final Button btnChange = (Button) dialog.findViewById(R.id.about_dialog_btn_show_change);
    final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok);

    func_view.setVisibility(TextView.VISIBLE);
    change_view.setVisibility(TextView.GONE);
    btnChange.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnFunc.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnChange.setTextColor(Color.DKGRAY);
    btnFunc.setTextColor(Color.GREEN);
    btnFunc.setEnabled(false);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    // func?
    btnFunc.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            change_view.setVisibility(TextView.GONE);
            func_view.setVisibility(TextView.VISIBLE);
            CommonDialog.setDlgBoxSizeLimit(dialog, true);
            btnFunc.setTextColor(Color.GREEN);
            btnChange.setTextColor(Color.DKGRAY);
            btnChange.setEnabled(true);
            btnFunc.setEnabled(false);
        }
    });

    // change?
    btnChange.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            change_view.setVisibility(TextView.VISIBLE);
            func_view.setVisibility(TextView.GONE);
            CommonDialog.setDlgBoxSizeLimit(dialog, true);
            btnChange.setTextColor(Color.GREEN);
            btnFunc.setTextColor(Color.DKGRAY);
            btnChange.setEnabled(false);
            btnFunc.setEnabled(true);
        }
    });

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnOk.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //      dialog.setCancelable(false);
    dialog.show();

}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

private void checkMixedMountPoint(final ArrayList<LocalFileLastModifiedMaintListItem> maint_list) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!prefs.getBoolean(SMBSYNC_SUPPRESS_WARNING_MIXED_MP, false)) {
        boolean mixed_mp = false;
        String mp_name = null;/* w w w  . j a  va 2  s .c  om*/
        for (int i = 0; i < mGp.profileAdapter.getCount(); i++) {
            ProfileListItem s_pli = mGp.profileAdapter.getItem(i);
            if (s_pli.getType().equals(SMBSYNC_PROF_TYPE_SYNC)
                    && s_pli.getActive().equals(SMBSYNC_PROF_ACTIVE)) {
                ProfileListItem o_pli = null;
                if (s_pli.getMasterType().equals(SMBSYNC_PROF_TYPE_LOCAL)) {
                    o_pli = getProfileListItem(SMBSYNC_PROF_TYPE_LOCAL, s_pli.getMasterName());
                } else {
                    o_pli = getProfileListItem(SMBSYNC_PROF_TYPE_LOCAL, s_pli.getTargetName());
                }
                if (o_pli != null) {
                    if (mp_name != null) {
                        //                     Log.v("","mp_name="+o_pli.getLocalMountPoint());
                        if (!o_pli.getLocalMountPoint().equals(mp_name)) {
                            mixed_mp = true;
                            break;
                        }
                    } else {
                        //                     Log.v("","mp_name init ="+mp_name);
                        mp_name = o_pli.getLocalMountPoint();
                    }
                }
            }
        }
        //         Log.v("","mixed_mp="+mixed_mp);
        if (!mixed_mp) {
            checkLastModifiedCorrupted(maint_list);
        } else {
            final Dialog dialog = new Dialog(mContext);//, android.R.style.Theme_Black);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.mixed_mount_point_dialog);
            TextView title = (TextView) dialog.findViewById(R.id.mixed_mount_point_dialog_title);
            title.setText(mContext.getString(R.string.msgs_common_dialog_warning));
            title.setTextColor(Color.YELLOW);

            ((TextView) dialog.findViewById(R.id.mixed_mount_point_dialog_subtitle))
                    .setText(mContext.getString(R.string.msgs_local_file_modified_maint_mixed_old_new_title));

            ((TextView) dialog.findViewById(R.id.mixed_mount_point_dialog_msg))
                    .setText(mContext.getString(R.string.msgs_local_file_modified_maint_mixed_old_new_msg));

            final Button btnOk = (Button) dialog.findViewById(R.id.common_dialog_btn_ok);
            final CheckBox cbSuppr = (CheckBox) dialog.findViewById(R.id.mixed_mount_point_dialog_suppress);

            CommonDialog.setDlgBoxSizeCompact(dialog);
            cbSuppr.setChecked(false);
            // OK?
            btnOk.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    if (cbSuppr.isChecked()) {
                        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
                        prefs.edit().putBoolean(SMBSYNC_SUPPRESS_WARNING_MIXED_MP, true).commit();
                    }
                    checkLastModifiedCorrupted(maint_list);
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btnOk.performClick();
                }
            });
            //            dialog.setOnKeyListener(new DialogOnKeyListener(mContext));
            //            dialog.setCancelable(false);
            dialog.show();
        }
    }
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {

    if (PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean(getString(R.string.showPrevNextButtonsKey), true)) {
        // Next word.
        nextWordMenuItem = menu.add(getString(R.string.nextWord)).setIcon(R.drawable.arrow_down_float);
        MenuItemCompat.setShowAsAction(nextWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);
        nextWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override/*from   w  w w. j  ava2s  .  c  o m*/
            public boolean onMenuItemClick(MenuItem item) {
                onUpDownButton(false);
                return true;
            }
        });

        // Previous word.
        previousWordMenuItem = menu.add(getString(R.string.previousWord)).setIcon(R.drawable.arrow_up_float);
        MenuItemCompat.setShowAsAction(previousWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);
        previousWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                onUpDownButton(true);
                return true;
            }
        });
    }

    randomWordMenuItem = menu.add(getString(R.string.randomWord));
    randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            onRandomWordButton();
            return true;
        }
    });

    application.onCreateGlobalOptionsMenu(this, menu);

    {
        final MenuItem dictionaryManager = menu.add(getString(R.string.dictionaryManager));
        MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER);
        dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(final MenuItem menuItem) {
                startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
                finish();
                return false;
            }
        });
    }

    {
        final MenuItem aboutDictionary = menu.add(getString(R.string.aboutDictionary));
        MenuItemCompat.setShowAsAction(aboutDictionary, MenuItem.SHOW_AS_ACTION_NEVER);
        aboutDictionary.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(final MenuItem menuItem) {
                final Context context = getListView().getContext();
                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.about_dictionary_dialog);
                final TextView textView = (TextView) dialog.findViewById(R.id.text);

                final String name = application.getDictionaryName(dictFile.getName());
                dialog.setTitle(name);

                final StringBuilder builder = new StringBuilder();
                final DictionaryInfo dictionaryInfo = dictionary.getDictionaryInfo();
                dictionaryInfo.uncompressedBytes = dictFile.length();
                if (dictionaryInfo != null) {
                    builder.append(dictionaryInfo.dictInfo).append("\n\n");
                    builder.append(getString(R.string.dictionaryPath, dictFile.getPath())).append("\n");
                    builder.append(getString(R.string.dictionarySize, dictionaryInfo.uncompressedBytes))
                            .append("\n");
                    builder.append(getString(R.string.dictionaryCreationTime, dictionaryInfo.creationMillis))
                            .append("\n");
                    for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) {
                        builder.append("\n");
                        builder.append(getString(R.string.indexName, indexInfo.shortName)).append("\n");
                        builder.append(getString(R.string.mainTokenCount, indexInfo.mainTokenCount))
                                .append("\n");
                    }
                    builder.append("\n");
                    builder.append(getString(R.string.sources)).append("\n");
                    for (final EntrySource source : dictionary.sources) {
                        builder.append(getString(R.string.sourceInfo, source.getName(), source.getNumEntries()))
                                .append("\n");
                    }
                }
                textView.setText(builder.toString());

                dialog.show();
                final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
                layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
                layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
                dialog.getWindow().setAttributes(layoutParams);
                return false;
            }
        });
    }

    return true;
}

From source file:co.taqat.call.LinphoneActivity.java

public Dialog displayDialog(String text) {
    Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
    d.setAlpha(200);//  www  .j a  v a 2  s .co  m
    dialog.setContentView(R.layout.dialog);
    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);
    dialog.getWindow().setBackgroundDrawable(d);

    TextView customText = (TextView) dialog.findViewById(R.id.customText);
    customText.setText(text);
    return dialog;
}

From source file:co.taqat.call.LinphoneActivity.java

public Dialog displayWrongPasswordDialog(final String username, final String realm, final String domain) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
    d.setAlpha(200);/* www.  j  a va  2 s. co  m*/
    dialog.setContentView(R.layout.input_dialog);
    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);
    dialog.getWindow().setBackgroundDrawable(d);

    TextView customText = (TextView) dialog.findViewById(R.id.customText);
    customText.setText(getString(R.string.error_bad_credentials));

    Button retry = (Button) dialog.findViewById(R.id.retry);
    Button cancel = (Button) dialog.findViewById(R.id.cancel);

    retry.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            String newPassword = ((EditText) dialog.findViewById(R.id.password)).getText().toString();
            LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(username, null,
                    newPassword, null, realm, domain);
            LinphoneManager.getLc().addAuthInfo(authInfo);
            LinphoneManager.getLc().refreshRegisters();
            dialog.dismiss();
        }
    });

    cancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    return dialog;
}

From source file:foam.opensauces.StarwispBuilder.java

public void Update(final StarwispActivity ctx, final String ctxname, JSONArray arr) {
    try {/*from ww  w  .jav a2  s  .co m*/

        String type = arr.getString(0);
        final Integer id = arr.getInt(1);
        String token = arr.getString(2);

        Log.i("starwisp", "Update: " + type + " " + id + " " + token);

        // non widget commands
        if (token.equals("toast")) {
            Toast msg = Toast.makeText(ctx.getBaseContext(), arr.getString(3), Toast.LENGTH_SHORT);
            msg.show();
            return;
        }

        if (token.equals("play-sound")) {
            String name = arr.getString(3);

            if (name.equals("ping")) {
                MediaPlayer mp = MediaPlayer.create(ctx, R.raw.ping);
                mp.start();
            }
            if (name.equals("active")) {
                MediaPlayer mp = MediaPlayer.create(ctx, R.raw.active);
                mp.start();
            }
        }

        if (token.equals("vibrate")) {
            Vibrator v = (Vibrator) ctx.getSystemService(Context.VIBRATOR_SERVICE);
            v.vibrate(arr.getInt(3));
        }

        if (type.equals("replace-fragment")) {
            int ID = arr.getInt(1);
            String name = arr.getString(2);
            Fragment fragment = ActivityManager.GetFragment(name);
            FragmentTransaction ft = ctx.getSupportFragmentManager().beginTransaction();

            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

            //ft.setCustomAnimations(
            //    R.animator.card_flip_right_in, R.animator.card_flip_right_out,
            //    R.animator.card_flip_left_in, R.animator.card_flip_left_out);
            ft.replace(ID, fragment);
            //ft.addToBackStack(null);
            ft.commit();
            return;
        }

        if (token.equals("dialog-fragment")) {
            FragmentManager fm = ctx.getSupportFragmentManager();
            final int ID = arr.getInt(3);
            final JSONArray lp = arr.getJSONArray(4);
            final String name = arr.getString(5);

            final Dialog dialog = new Dialog(ctx);
            dialog.setTitle("Title...");

            LinearLayout inner = new LinearLayout(ctx);
            inner.setId(ID);
            inner.setLayoutParams(BuildLayoutParams(lp));

            dialog.setContentView(inner);

            //                Fragment fragment = ActivityManager.GetFragment(name);
            //                FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction();
            //                fragmentTransaction.add(ID,fragment);
            //                fragmentTransaction.commit();

            dialog.show();

            /*                DialogFragment df = new DialogFragment() {
            @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                     Bundle savedInstanceState) {
                LinearLayout inner = new LinearLayout(ctx);
                inner.setId(ID);
                inner.setLayoutParams(BuildLayoutParams(lp));
                    
                return inner;
            }
                    
            @Override
            public Dialog onCreateDialog(Bundle savedInstanceState) {
                Dialog ret = super.onCreateDialog(savedInstanceState);
                Log.i("starwisp","MAKINGDAMNFRAGMENT");
                    
                Fragment fragment = ActivityManager.GetFragment(name);
                FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction();
                fragmentTransaction.add(1,fragment);
                fragmentTransaction.commit();
                return ret;
            }
                            };
                            df.show(ctx.getFragmentManager(), "foo");
            */
        }

        if (token.equals("time-picker-dialog")) {

            final Calendar c = Calendar.getInstance();
            int hour = c.get(Calendar.HOUR_OF_DAY);
            int minute = c.get(Calendar.MINUTE);

            // Create a new instance of TimePickerDialog and return it
            TimePickerDialog d = new TimePickerDialog(ctx, null, hour, minute, true);
            d.show();
            return;
        }
        ;

        if (token.equals("make-directory")) {
            File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(3));
            file.mkdirs();
            return;
        }

        if (token.equals("list-files")) {
            final String name = arr.getString(3);
            File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(5));
            // todo, should probably call callback with empty list
            if (file != null) {
                File list[] = file.listFiles();

                if (list != null) {
                    String code = "(";
                    for (int i = 0; i < list.length; i++) {
                        code += " \"" + list[i].getName() + "\"";
                    }
                    code += ")";

                    DialogCallback(ctx, ctxname, name, code);
                }
            }
            return;
        }

        if (token.equals("gps-start")) {
            final String name = arr.getString(3);

            if (m_LocationManager == null) {
                m_LocationManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE);
                m_GPS = new DorisLocationListener(m_LocationManager);
            }

            m_GPS.Start((StarwispActivity) ctx, name, this);
            return;
        }

        if (token.equals("walk-draggable")) {
            final String name = arr.getString(3);
            int iid = arr.getInt(5);
            DialogCallback(ctx, ctxname, name, WalkDraggable(ctx, name, ctxname, iid));
            return;
        }

        if (token.equals("delayed")) {
            final String name = arr.getString(3);
            final int d = arr.getInt(5);
            Runnable timerThread = new Runnable() {
                public void run() {
                    DialogCallback(ctx, ctxname, name, "");
                }
            };
            m_Handler.removeCallbacksAndMessages(null);
            m_Handler.postDelayed(timerThread, d);
            return;
        }

        if (token.equals("network-connect")) {
            final String name = arr.getString(3);
            final String ssid = arr.getString(5);
            m_NetworkManager.Start(ssid, (StarwispActivity) ctx, name, this);
            return;
        }

        if (token.equals("http-request")) {
            if (m_NetworkManager.state == NetworkManager.State.CONNECTED) {
                Log.i("starwisp", "attempting http request");
                final String name = arr.getString(3);
                final String url = arr.getString(5);
                m_NetworkManager.StartRequestThread(url, "normal", name);
            }
            return;
        }

        if (token.equals("http-download")) {
            if (m_NetworkManager.state == NetworkManager.State.CONNECTED) {
                Log.i("starwisp", "attempting http dl request");
                final String filename = arr.getString(4);
                final String url = arr.getString(5);
                m_NetworkManager.StartRequestThread(url, "download", filename);
            }
            return;
        }

        if (token.equals("send-mail")) {
            final String to[] = new String[1];
            to[0] = arr.getString(3);
            final String subject = arr.getString(4);
            final String body = arr.getString(5);

            JSONArray attach = arr.getJSONArray(6);
            ArrayList<String> paths = new ArrayList<String>();
            for (int a = 0; a < attach.length(); a++) {
                Log.i("starwisp", attach.getString(a));
                paths.add(attach.getString(a));
            }

            email(ctx, to[0], "", subject, body, paths);
        }

        if (token.equals("date-picker-dialog")) {
            final Calendar c = Calendar.getInstance();
            int day = c.get(Calendar.DAY_OF_MONTH);
            int month = c.get(Calendar.MONTH);
            int year = c.get(Calendar.YEAR);

            final String name = arr.getString(3);

            // Create a new instance of TimePickerDialog and return it
            DatePickerDialog d = new DatePickerDialog(ctx, new DatePickerDialog.OnDateSetListener() {
                public void onDateSet(DatePicker view, int year, int month, int day) {
                    DialogCallback(ctx, ctxname, name, day + " " + month + " " + year);
                }
            }, year, month, day);
            d.show();
            return;
        }
        ;

        if (token.equals("alert-dialog")) {

            final String name = arr.getString(3);
            final String msg = arr.getString(5);

            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    int result = 0;
                    if (which == DialogInterface.BUTTON_POSITIVE)
                        result = 1;
                    DialogCallback(ctx, ctxname, name, "" + result);
                }
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
            builder.setMessage(msg).setPositiveButton("Yes", dialogClickListener)
                    .setNegativeButton("No", dialogClickListener).show();

            return;
        }

        if (token.equals("start-activity")) {
            ActivityManager.StartActivity(ctx, arr.getString(3), arr.getInt(4), arr.getString(5));
            return;
        }

        if (token.equals("start-activity-goto")) {
            ActivityManager.StartActivityGoto(ctx, arr.getString(3), arr.getString(4));
            return;
        }

        if (token.equals("finish-activity")) {
            ctx.setResult(arr.getInt(3));
            ctx.finish();
            return;
        }

        ///////////////////////////////////////////////////////////

        // now try and find the widget
        View vv = ctx.findViewById(id);
        if (vv == null) {
            Log.i("starwisp", "Can't find widget : " + id);
            return;
        }

        // tokens that work on everything
        if (token.equals("hide")) {
            vv.setVisibility(View.GONE);
            return;
        }

        if (token.equals("show")) {
            vv.setVisibility(View.VISIBLE);
            return;
        }

        // tokens that work on everything
        if (token.equals("set-enabled")) {
            vv.setEnabled(arr.getInt(3) == 1);
            return;
        }

        // special cases
        if (type.equals("linear-layout")) {
            LinearLayout v = (LinearLayout) vv;
            if (token.equals("contents")) {
                v.removeAllViews();
                JSONArray children = arr.getJSONArray(3);
                for (int i = 0; i < children.length(); i++) {
                    Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
                }
            }
        }

        // special cases
        if (type.equals("draggable")) {
            LinearLayout v = (LinearLayout) vv;
            if (token.equals("contents")) {
                //                    v.removeAllViews();
                JSONArray children = arr.getJSONArray(3);
                for (int i = 0; i < children.length(); i++) {
                    Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
                }
            }
        }

        if (type.equals("button-grid")) {
            LinearLayout horiz = (LinearLayout) vv;
            if (token.equals("grid-buttons")) {
                horiz.removeAllViews();

                JSONArray params = arr.getJSONArray(3);
                String buttontype = params.getString(0);
                int height = params.getInt(1);
                int textsize = params.getInt(2);
                LinearLayout.LayoutParams lp = BuildLayoutParams(params.getJSONArray(3));
                final JSONArray buttons = params.getJSONArray(4);
                final int count = buttons.length();
                int vertcount = 0;
                LinearLayout vert = null;

                for (int i = 0; i < count; i++) {
                    JSONArray button = buttons.getJSONArray(i);

                    if (vertcount == 0) {
                        vert = new LinearLayout(ctx);
                        vert.setId(0);
                        vert.setOrientation(LinearLayout.VERTICAL);
                        horiz.addView(vert);
                    }
                    vertcount = (vertcount + 1) % height;

                    if (buttontype.equals("button")) {
                        Button b = new Button(ctx);
                        b.setId(button.getInt(0));
                        b.setText(button.getString(1));
                        b.setTextSize(textsize);
                        b.setLayoutParams(lp);
                        b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                        final String fn = params.getString(5);
                        b.setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t");
                            }
                        });
                        vert.addView(b);
                    } else if (buttontype.equals("toggle")) {
                        ToggleButton b = new ToggleButton(ctx);
                        b.setId(button.getInt(0));
                        b.setText(button.getString(1));
                        b.setTextSize(textsize);
                        b.setLayoutParams(lp);
                        b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                        final String fn = params.getString(5);
                        b.setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                String arg = "#f";
                                if (((ToggleButton) v).isChecked())
                                    arg = "#t";
                                CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg);
                            }
                        });
                        vert.addView(b);
                    } else if (buttontype.equals("single")) {
                        ToggleButton b = new ToggleButton(ctx);
                        b.setId(button.getInt(0));
                        b.setText(button.getString(1));
                        b.setTextSize(textsize);
                        b.setLayoutParams(lp);
                        b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                        final String fn = params.getString(5);
                        b.setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                try {
                                    for (int i = 0; i < count; i++) {
                                        JSONArray button = buttons.getJSONArray(i);
                                        int bid = button.getInt(0);
                                        if (bid != v.getId()) {
                                            ToggleButton tb = (ToggleButton) ctx.findViewById(bid);
                                            tb.setChecked(false);
                                        }
                                    }
                                } catch (JSONException e) {
                                    Log.e("starwisp", "Error parsing data " + e.toString());
                                }

                                CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t");
                            }
                        });
                        vert.addView(b);
                    }

                }
            }
        }

        /*
                    if (type.equals("grid-layout")) {
        GridLayout v = (GridLayout)vv;
        if (token.equals("contents")) {
            v.removeAllViews();
            JSONArray children = arr.getJSONArray(3);
            for (int i=0; i<children.length(); i++) {
                Build(ctx,ctxname,new JSONArray(children.getString(i)), v);
            }
        }
                    }
        */
        if (type.equals("view-pager")) {
            ViewPager v = (ViewPager) vv;
            if (token.equals("switch")) {
                v.setCurrentItem(arr.getInt(3));
            }
            if (token.equals("pages")) {
                final JSONArray items = arr.getJSONArray(3);
                v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) {
                    @Override
                    public int getCount() {
                        return items.length();
                    }

                    @Override
                    public Fragment getItem(int position) {
                        try {
                            String fragname = items.getString(position);
                            return ActivityManager.GetFragment(fragname);
                        } catch (JSONException e) {
                            Log.e("starwisp", "Error parsing data " + e.toString());
                        }
                        return null;
                    }
                });
            }
        }

        if (type.equals("image-view")) {
            ImageView v = (ImageView) vv;
            if (token.equals("image")) {
                int iid = ctx.getResources().getIdentifier(arr.getString(3), "drawable", ctx.getPackageName());
                v.setImageResource(iid);
            }
            if (token.equals("external-image")) {
                Bitmap bitmap = BitmapFactory.decodeFile(arr.getString(3));
                v.setImageBitmap(bitmap);
            }
            return;
        }

        if (type.equals("text-view") || type.equals("debug-text-view")) {
            TextView v = (TextView) vv;
            if (token.equals("text")) {
                if (type.equals("debug-text-view")) {
                    //v.setMovementMethod(new ScrollingMovementMethod());
                }
                v.setText(arr.getString(3));
            }
            return;
        }

        if (type.equals("edit-text")) {
            EditText v = (EditText) vv;
            if (token.equals("text")) {
                v.setText(arr.getString(3));
            }
            if (token.equals("request-focus")) {
                v.requestFocus();
                InputMethodManager imm = (InputMethodManager) ctx
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
            }
            return;
        }

        if (type.equals("button")) {
            Button v = (Button) vv;
            if (token.equals("text")) {
                v.setText(arr.getString(3));
            }

            if (token.equals("listener")) {
                final String fn = arr.getString(3);
                v.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        m_Scheme.eval("(" + fn + ")");
                    }
                });
            }
            return;
        }

        if (type.equals("toggle-button")) {
            ToggleButton v = (ToggleButton) vv;
            if (token.equals("text")) {
                v.setText(arr.getString(3));
                return;
            }

            if (token.equals("checked")) {
                if (arr.getInt(3) == 0)
                    v.setChecked(false);
                else
                    v.setChecked(true);
                return;
            }

            if (token.equals("listener")) {
                final String fn = arr.getString(3);
                v.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        m_Scheme.eval("(" + fn + ")");
                    }
                });
            }
            return;
        }

        if (type.equals("canvas")) {
            StarwispCanvas v = (StarwispCanvas) vv;
            if (token.equals("drawlist")) {
                v.SetDrawList(arr.getJSONArray(3));
            }
            return;
        }

        if (type.equals("camera-preview")) {
            final CameraPreview v = (CameraPreview) vv;

            if (token.equals("take-picture")) {
                final String path = ((StarwispActivity) ctx).m_AppDir + arr.getString(3);

                v.TakePicture(new PictureCallback() {
                    public void onPictureTaken(byte[] data, Camera camera) {
                        String datetime = getDateTime();
                        String filename = path + datetime + ".jpg";
                        SaveData(filename, data);
                        v.Shutdown();
                        ctx.finish();
                    }
                });
            }

            if (token.equals("shutdown")) {
                v.Shutdown();
            }

            return;
        }

        if (type.equals("seek-bar")) {
            SeekBar v = new SeekBar(ctx);
            if (token.equals("max")) {
                // android seekbar bug workaround
                int p = v.getProgress();
                v.setMax(0);
                v.setProgress(0);
                v.setMax(arr.getInt(3));
                v.setProgress(1000);

                // not working.... :(
            }
        }

        if (type.equals("spinner")) {
            Spinner v = (Spinner) vv;

            if (token.equals("selection")) {
                v.setSelection(arr.getInt(3));
            }

            if (token.equals("array")) {
                final JSONArray items = arr.getJSONArray(3);
                ArrayList<String> spinnerArray = new ArrayList<String>();

                for (int i = 0; i < items.length(); i++) {
                    spinnerArray.add(items.getString(i));
                }

                ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx,
                        android.R.layout.simple_spinner_item, spinnerArray) {
                    public View getView(int position, View convertView, ViewGroup parent) {
                        View v = super.getView(position, convertView, parent);
                        ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface);
                        return v;
                    }
                };

                v.setAdapter(spinnerArrayAdapter);

                final int wid = id;
                // need to update for new values
                v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                    public void onItemSelected(AdapterView<?> a, View v, int pos, long id) {
                        try {
                            CallbackArgs(ctx, ctxname, wid, "\"" + items.getString(pos) + "\"");
                        } catch (JSONException e) {
                            Log.e("starwisp", "Error parsing data " + e.toString());
                        }
                    }

                    public void onNothingSelected(AdapterView<?> v) {
                    }
                });

            }
            return;
        }

    } catch (JSONException e) {
        Log.e("starwisp", "Error parsing data " + e.toString());
    }
}