Example usage for android.widget RadioButton setChecked

List of usage examples for android.widget RadioButton setChecked

Introduction

In this page you can find the example usage for android.widget RadioButton setChecked.

Prototype

@Override
public void setChecked(boolean checked) 

Source Link

Document

Changes the checked state of this button.

Usage

From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java

/**
 * Show frequency dialog/*w  w  w.  j  a  v a 2 s  .  co m*/
 */
private void showFrequencyPurchaseDialog(final int value) {
    final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.alert_dialog_main);
    final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title);
    final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg);
    final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt);
    Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn);
    Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn);
    final RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.myRadioGroup);

    final RadioButton radioOneMonth = (RadioButton) dialog.findViewById(R.id.oneMonth);
    final RadioButton radioThreeMonth = (RadioButton) dialog.findViewById(R.id.threeMonth);
    final RadioButton radioSixMonth = (RadioButton) dialog.findViewById(R.id.sixMonth);
    final RadioButton radioOneYear = (RadioButton) dialog.findViewById(R.id.oneYear);

    //long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);
    radioGroup.setVisibility(View.VISIBLE);
    alertTitle.setText("Purchase Product");
    if (value == updateDurationValue[0]) {
        alertMsg.setText("Buy Update Frequency for 1 Minutes");
        //radioOneMonth.setChecked(true);
        if (userType == PurchaseStatus.FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[1]) {
        alertMsg.setText("Buy Update Frequency for 2 Minutes");
        if (userType == PurchaseStatus.SEMI_FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[2]) {
        alertMsg.setText("Buy Update Frequency for 3 Minutes");

        if (userType == PurchaseStatus.PARTIAL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    }
    alertEditTxt.setVisibility(View.GONE);

    radioOneMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
            }
        }
    });
    radioThreeMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
            }
        }
    });
    radioSixMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
            }
        }
    });
    radioOneYear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
            }
        }
    });
    cancelBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);

            // Set Spinner
            setSpinnerUpdateTime(updateTime);
            firstSelect = false;
        }
    });
    okBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            if (radioOneMonth.isChecked() || radioThreeMonth.isChecked() || radioSixMonth.isChecked()
                    || radioOneYear.isChecked()) {
                // One min update
                if (value == updateDurationValue[0] && radioOneMonth.isChecked()) {
                    fullPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioThreeMonth.isChecked()) {
                    fullPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioSixMonth.isChecked()) {
                    fullPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioOneYear.isChecked()) {
                    fullPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Two min update
                else if (value == updateDurationValue[1] && radioOneMonth.isChecked()) {
                    semiparticalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioThreeMonth.isChecked()) {
                    semiparticalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioSixMonth.isChecked()) {
                    semiparticalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioOneYear.isChecked()) {
                    semiparticalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Three min update
                else if (value == updateDurationValue[2] && radioOneMonth.isChecked()) {
                    particalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioThreeMonth.isChecked()) {
                    particalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioSixMonth.isChecked()) {
                    particalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioOneYear.isChecked()) {
                    particalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }

                long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF,
                        AppConstants.DEFAULT_TIME_INTERVAL);
                // Set Spinner
                setSpinnerUpdateTime(updateTime);
                firstSelect = false;
                dialog.dismiss();
            } else {
                dialog.show();
                Utils.showToast("Select durations");
                //Toast.makeText(getActivity(), "Select durations", Toast.LENGTH_LONG).show();
            }
        }
    });
    dialog.show();
}

From source file:pt.aptoide.backupapps.Aptoide.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    EnumOptionsMenu menuEntry = EnumOptionsMenu.reverseOrdinal(item.getItemId());
    Log.d("Aptoide-OptionsMenu", "menuOption: " + menuEntry + " itemid: " + item.getItemId());
    switch (menuEntry) {
    //         case MANAGE_REPO:
    //            availableAdapter.sleep();
    //            Intent manageRepo = new Intent(this, ManageRepos.class);
    //            startActivity(manageRepo);
    //            return true;

    case UNINSTALL:
        try {/* ww  w . j  a  va2s .c  o m*/
            serviceDataCaller.callUninstallApps(installedAdapter.getSelectedIds());
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return true;

    case DELETE:
        //TODO improve listIds as an extended parcelable array ;) then use it as a carrier for checked hashids list
        return true;

    case DISPLAY_OPTIONS:
        if (!loadingRepos.get()) {
            //TODO refactor extract dialog management class
            LayoutInflater displayOptionsInflater = LayoutInflater.from(this);
            View displayOptions = displayOptionsInflater.inflate(R.layout.dialog_display_options, null);
            Builder dialogBuilder = new AlertDialog.Builder(theme).setView(displayOptions);
            final AlertDialog sortDialog = dialogBuilder.create();
            sortDialog.setIcon(android.R.drawable.ic_menu_sort_by_size);
            sortDialog.setTitle(getString(R.string.display_options));

            // ***********************************************************
            // Categories
            //               final RadioButton byCategory = (RadioButton) displayOptions.findViewById(R.id.by_category);
            //               final RadioButton byAll = (RadioButton) displayOptions.findViewById(R.id.by_all);
            //               if(availableByCategory){
            //                  byCategory.setChecked(true);
            //               }else{
            //                  byAll.setChecked(true);
            //               }
            //   
            //               final View spacer = displayOptions.findViewById(R.id.spacer);
            //               
            //               if(currentAppsList != EnumAppsLists.Available){
            //                  spacer.setVisibility(View.GONE);
            //                  ((RadioGroup) displayOptions.findViewById(R.id.group_show)).setVisibility(View.GONE);
            //               }

            // ***********************************************************
            // Sorting            
            final View group_sort = displayOptions.findViewById(R.id.group_sort);
            final RadioButton byAlphabetic = (RadioButton) displayOptions.findViewById(R.id.by_alphabetic);
            final RadioButton byFreshness = (RadioButton) displayOptions.findViewById(R.id.by_freshness);
            final RadioButton bySize = (RadioButton) displayOptions.findViewById(R.id.by_size);

            //               spacer.setVisibility(View.VISIBLE);
            group_sort.setVisibility(View.VISIBLE);
            switch (appsSortingPolicy) {
            case ALPHABETIC:
                byAlphabetic.setChecked(true);
                break;

            case FRESHNESS:
                byFreshness.setChecked(true);
                break;

            case SIZE:
                bySize.setChecked(true);
                break;

            default:
                break;
            }

            // ***********************************************************

            final CheckBox showSystemApps = (CheckBox) displayOptions.findViewById(R.id.show_system_apps);
            boolean showSystemAppsState = false;
            try {
                showSystemAppsState = serviceDataCaller.callGetShowSystemApps();
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            showSystemApps.setChecked(showSystemAppsState);
            final boolean storedShowSystemAppsState = showSystemAppsState;

            sortDialog.setButton(getString(R.string.done), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    //                     boolean byCategoryChanged = false;
                    EnumAppsSorting newSortingPolicy = null;

                    //                     if(byCategory.isChecked() != availableByCategory){
                    //                        byCategoryChanged = true;
                    //                        availableByCategory = byCategory.isChecked();
                    //                        setAvailableListBy(availableByCategory);
                    //                     }

                    if (showSystemApps.isChecked() != storedShowSystemAppsState) {
                        setShowSystemApps(showSystemApps.isChecked());
                    }

                    if (byAlphabetic.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.ALPHABETIC;
                    } else if (byFreshness.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.FRESHNESS;
                    } else if (bySize.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.SIZE;
                    }
                    if (newSortingPolicy != null && newSortingPolicy != appsSortingPolicy) {
                        //                        availableAdapter.sleep();
                        appsSortingPolicy = newSortingPolicy;
                        setAppsSortingPolicy(appsSortingPolicy);
                    }

                    //                     if(byCategoryChanged){
                    //                        if(availableByCategory){
                    //                           availableAdapter.sleep();
                    //                           categoriesAdapter.resetDisplayCategories();
                    //                        }else{
                    //                           availableAdapter.resetDisplay(null);                        
                    //                        }
                    //                     }
                    sortDialog.dismiss();
                }
            });

            sortDialog.show();
        } else {
            Toast.makeText(Aptoide.this, getString(R.string.option_not_available_while_updating_repos),
                    Toast.LENGTH_SHORT).show();
        }
        return true;

    //         case SEARCH_MENU:
    //            onSearchRequested();
    //            return true;

    case UN_SELECT_ALL:
        switch (currentAppsList) {
        case RESTORE:
            if (availableAdapter.isDynamic()) {
                Toast.makeText(Aptoide.this, getString(R.string.too_many_apps_to_select_at_once),
                        Toast.LENGTH_SHORT).show();
                return true;
            }
            availableAdapter.toggleSelectAll();
            break;

        case BACKUP:
            installedAdapter.toggleSelectAll();
            break;

        default:
            break;
        }
        return true;

    case ABOUT:
        LayoutInflater aboutInflater = LayoutInflater.from(this);
        View about = aboutInflater.inflate(R.layout.about, null);
        TextView info = (TextView) about.findViewById(R.id.credits);
        info.setText(getString(R.string.credits, versionName));
        Builder aboutCreator = new AlertDialog.Builder(theme).setView(about);
        final AlertDialog aboutDialog = aboutCreator.create();
        aboutDialog.setIcon(R.drawable.icon);
        aboutDialog.setTitle(R.string.self_name);
        //            aboutDialog.setButton(getText(R.string.changelog), new DialogInterface.OnClickListener() {
        //               public void onClick(DialogInterface dialog, int   whichButton) {
        //                  Uri uri = Uri.parse(getString(R.string.changelog_url));
        //                  startActivity(new Intent( Intent.ACTION_VIEW, uri));
        //               }
        //            });
        aboutDialog.show();
        return true;

    case SETTINGS:
        //            availableAdapter.sleep();
        Intent settings = new Intent(this, Settings.class);
        startActivity(settings);
        return true;

    case LOGIN:
        //            boolean insertingRepo = false;
        //            try {
        //               insertingRepo = serviceDataCaller.callIsInsertingRepo();
        //            } catch (RemoteException e1) {
        //               // TODO Auto-generated catch block
        //               e1.printStackTrace();
        //            }
        //            if(insertingRepo){
        //               AptoideLog.d(Aptoide.this, getString(R.string.updating_repo_please_wait));
        //               Toast.makeText(getApplicationContext(), getResources().getString(R.string.updating_repo_please_wait), Toast.LENGTH_SHORT).show();
        //            }
        //            else{
        Log.d("Aptoide-Settings", "clicked set server login");
        String token = null;
        try {
            token = serviceDataCaller.callGetServerToken();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (token == null) {
            Log.d("Aptoide-Settings", "No login set");
            Intent login = new Intent(Aptoide.this, BazaarLogin.class);
            login.putExtra("InvoqueType", BazaarLogin.InvoqueType.NO_CREDENTIALS_SET.ordinal());
            startActivity(login);
            //               DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.NO_CREDENTIALS_SET);
            //               loginComments.setOnDismissListener(new OnDismissListener() {
            //                  @Override
            //                  public void onDismiss(DialogInterface dialog) {
            //                     addAppVersionComment();
            //                  }
            //               });
            //               dialogLogin.show();
        } else {
            Log.d("Aptoide-Settings", "Login edit");
            Intent login = new Intent(Aptoide.this, BazaarLogin.class);
            login.putExtra("InvoqueType", BazaarLogin.InvoqueType.OVERRIDE_CREDENTIALS.ordinal());
            startActivity(login);
            //               DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.OVERRIDE_CREDENTIALS);
            //               Toast.makeText(Settings.this, "Login already set", Toast.LENGTH_SHORT).show();
            //               dialogLogin.show();
        }
        //            }
        return true;

    case FOLLOW:
        new DialogFollowOnSocialNets(this, serviceDataCaller).show();
        return true;

    //         case SCHEDULED_DOWNLOADS:
    //            availableAdapter.sleep();
    //            Intent manageScheduled = new Intent(this, ManageScheduled.class);
    //            startActivity(manageScheduled);
    //            return true;

    //         case UPDATE_ALL:
    //            if(!loadingRepos.get()){
    //               AptoideLog.d(this, "Update all");
    //               try {
    //                  serviceDataCaller.callUpdateAll();
    //               } catch (RemoteException e) {
    //                  // TODO Auto-generated catch block
    //                  e.printStackTrace();
    //               }
    //            }else{
    //               Toast.makeText(Aptoide.this, "Option not available while updating stores!", Toast.LENGTH_SHORT).show();
    //            }
    //            return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:usbong.android.utils.UsbongScreenProcessor.java

public void init() {
    //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
    Resources myRes = udtea.getResources();
    Drawable myDrawableImage;/*from w w w  .ja  v a  2s .  co m*/

    //added by Mike, Feb. 13, 2013
    udtea.isAnOptionalNode = UsbongUtils.isAnOptionalNode(udtea.currUsbongNode);

    String myStringToken = "";
    //      if (usedBackButton) {

    //        System.out.println(">>>>>> udtea.currAnswer: "+udtea.currAnswer);

    StringTokenizer st = new StringTokenizer(udtea.currAnswer, ",");
    if ((st != null) && (st.hasMoreTokens())) {
        myStringToken = st.nextToken();
        udtea.currAnswer = udtea.currAnswer.replace(myStringToken + ",", "");
    }

    StringTokenizer st_two = new StringTokenizer(udtea.currAnswer, ";");

    if (st_two != null) {
        if (udtea.currAnswer.length() > 1) {
            myStringToken = st_two.nextToken(); //get next element (i.e. 1 in "Y,1;")                
        } else {
            myStringToken = "";
        }
    }

    if (udtea.currScreen == udtea.MULTIPLE_RADIO_BUTTONS_SCREEN) {
        udtea.setContentView(R.layout.multiple_radio_buttons_screen);
        udtea.initBackNextButtons();
        TextView myMultipleRadioButtonsScreenTextView = (TextView) udtea
                .findViewById(R.id.radio_buttons_textview);
        myMultipleRadioButtonsScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myMultipleRadioButtonsScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        RadioGroup radioGroup = (RadioGroup) udtea.findViewById(R.id.multiple_radio_buttons_radiogroup);
        int totalRadioButtonsInContainer = udtea.radioButtonsContainer.size();
        for (int i = 0; i < totalRadioButtonsInContainer; i++) {
            View radioButtonView = new RadioButton(udtea.getBaseContext());
            RadioButton radioButton = (RadioButton) UsbongUtils.applyTagsInView(
                    UsbongDecisionTreeEngineActivity.getInstance(), radioButtonView, UsbongUtils.IS_RADIOBUTTON,
                    udtea.radioButtonsContainer.elementAt(i).toString());
            radioButton.setTextSize(20);
            radioButton.setId(i);
            radioButton.setTextColor(Color.parseColor("#4a452a"));

            int myStringTokenInt;
            try {
                myStringTokenInt = Integer.parseInt(myStringToken);
            } catch (NumberFormatException e) {//if myStringToken is not an int;
                myStringTokenInt = -1;
            }

            if ((!myStringToken.equals("")) && (i == myStringTokenInt)) {
                radioButton.setChecked(true);
            } else {
                radioButton.setChecked(false);
            }

            radioGroup.addView(radioButton);
        }
    } else if (udtea.currScreen == udtea.MULTIPLE_RADIO_BUTTONS_WITH_ANSWER_SCREEN) {
        udtea.setContentView(R.layout.multiple_radio_buttons_screen);
        udtea.initBackNextButtons();
        String myMultipleRadioButtonsWithAnswerScreenStringToken = "";
        //             Log.d(">>>>>>>>udtea.currUsbongNode", udtea.currUsbongNode);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNode.replace("Answer=", "~");
        StringTokenizer myMultipleRadioButtonsWithAnswerScreenStringTokenizer = new StringTokenizer(
                udtea.currUsbongNodeWithoutAnswer, "~");
        if (myMultipleRadioButtonsWithAnswerScreenStringTokenizer != null) {
            myMultipleRadioButtonsWithAnswerScreenStringToken = myMultipleRadioButtonsWithAnswerScreenStringTokenizer
                    .nextToken();

            while (myMultipleRadioButtonsWithAnswerScreenStringTokenizer.hasMoreTokens()) { //get last element (i.e. 0 in "radioButtonsWithAnswer~You see your teacher approaching you. What do you do?Answer=0")
                myMultipleRadioButtonsWithAnswerScreenStringToken = myMultipleRadioButtonsWithAnswerScreenStringTokenizer
                        .nextToken();
            }
        }
        udtea.myMultipleRadioButtonsWithAnswerScreenAnswer = myMultipleRadioButtonsWithAnswerScreenStringToken
                .toString();
        //             Log.d(">>>>>>>>udtea.myMultipleRadioButtonsWithAnswerScreenAnswer", udtea.myMultipleRadioButtonsWithAnswerScreenAnswer);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNodeWithoutAnswer.substring(0,
                udtea.currUsbongNodeWithoutAnswer.length()
                        - udtea.myMultipleRadioButtonsWithAnswerScreenAnswer.length() - 1); //do a -1 for the last tilde             
        //             Log.d(">>>>>>>>udtea.currUsbongNodeWithoutAnswer", udtea.currUsbongNodeWithoutAnswer);
        TextView myMultipleRadioButtonsWithAnswerScreenTextView = (TextView) udtea
                .findViewById(R.id.radio_buttons_textview);
        myMultipleRadioButtonsWithAnswerScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myMultipleRadioButtonsWithAnswerScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNodeWithoutAnswer);
        RadioGroup myMultipleRadioButtonsWithAnswerRadioGroup = (RadioGroup) udtea
                .findViewById(R.id.multiple_radio_buttons_radiogroup);
        int myMultipleRadioButtonsWithAnswerTotalRadioButtonsInContainer = udtea.radioButtonsContainer.size();
        for (int i = 0; i < myMultipleRadioButtonsWithAnswerTotalRadioButtonsInContainer; i++) {
            View radioButtonView = new RadioButton(udtea.getBaseContext());
            RadioButton radioButton = (RadioButton) UsbongUtils.applyTagsInView(
                    UsbongDecisionTreeEngineActivity.getInstance(), radioButtonView, UsbongUtils.IS_RADIOBUTTON,
                    udtea.radioButtonsContainer.elementAt(i).toString());
            radioButton.setTextSize(20);
            radioButton.setId(i);
            radioButton.setTextColor(Color.parseColor("#4a452a"));

            if ((!myStringToken.equals("")) && (i == Integer.parseInt(myStringToken))) {
                radioButton.setChecked(true);
            } else {
                radioButton.setChecked(false);
            }

            myMultipleRadioButtonsWithAnswerRadioGroup.addView(radioButton);
        }
    } else if (udtea.currScreen == udtea.LINK_SCREEN) {
        //use same contentView as multiple_radio_buttons_screen
        udtea.setContentView(R.layout.multiple_radio_buttons_screen);
        udtea.initBackNextButtons();
        TextView myLinkScreenTextView = (TextView) udtea.findViewById(R.id.radio_buttons_textview);
        myLinkScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myLinkScreenTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);

        RadioGroup myLinkScreenRadioGroup = (RadioGroup) udtea
                .findViewById(R.id.multiple_radio_buttons_radiogroup);
        int myLinkScreenTotalRadioButtonsInContainer = udtea.radioButtonsContainer.size();
        for (int i = 0; i < myLinkScreenTotalRadioButtonsInContainer; i++) {
            View radioButtonView = new RadioButton(udtea.getBaseContext());
            RadioButton radioButton = (RadioButton) UsbongUtils.applyTagsInView(
                    UsbongDecisionTreeEngineActivity.getInstance(), radioButtonView, UsbongUtils.IS_RADIOBUTTON,
                    UsbongUtils.trimUsbongNodeName(udtea.radioButtonsContainer.elementAt(i).toString()));

            Log.d(">>>>>radioButton", radioButton.getText().toString());

            //                  radioButton.setChecked(false);
            radioButton.setTextSize(20);
            radioButton.setId(i);
            radioButton.setTextColor(Color.parseColor("#4a452a"));

            if ((!myStringToken.equals("")) && (i == Integer.parseInt(myStringToken))) {
                radioButton.setChecked(true);
            } else {
                radioButton.setChecked(false);
            }

            myLinkScreenRadioGroup.addView(radioButton);
        }
    } else if (udtea.currScreen == udtea.MULTIPLE_CHECKBOXES_SCREEN) {
        udtea.setContentView(R.layout.multiple_checkboxes_screen);
        udtea.initBackNextButtons();
        TextView myMultipleCheckBoxesScreenTextView = (TextView) udtea.findViewById(R.id.checkboxes_textview);
        myMultipleCheckBoxesScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myMultipleCheckBoxesScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        LinearLayout myMultipleCheckboxesLinearLayout = (LinearLayout) udtea
                .findViewById(R.id.multiple_checkboxes_linearlayout);
        int totalCheckBoxesInContainer = udtea.checkBoxesContainer.size();
        StringTokenizer myMultipleCheckboxStringTokenizer = new StringTokenizer(myStringToken, ",");
        Vector<String> myCheckedAnswers = new Vector<String>();
        //             int counter=0;             
        while (myMultipleCheckboxStringTokenizer.countTokens() > 0) {
            String myMultipleCheckboxStringToken = myMultipleCheckboxStringTokenizer.nextToken();
            if (myMultipleCheckboxStringToken != null) {
                myCheckedAnswers.add(myMultipleCheckboxStringToken);
            } else {
                break;
            }
            //                counter++;
        }
        for (int i = 0; i < totalCheckBoxesInContainer; i++) {
            CheckBox checkBox = new CheckBox(udtea.getBaseContext());
            //                  checkBox.setText(StringEscapeUtils.unescapeJava(udtea.checkBoxesContainer.elementAt(i).toString()));
            checkBox = (CheckBox) UsbongUtils.applyTagsInView(UsbongDecisionTreeEngineActivity.getInstance(),
                    checkBox, UsbongUtils.IS_CHECKBOX,
                    StringEscapeUtils.unescapeJava(udtea.checkBoxesContainer.elementAt(i).toString()));

            for (int k = 0; k < myCheckedAnswers.size(); k++) {
                try {
                    if (i == Integer.parseInt(myCheckedAnswers.elementAt(k))) {
                        checkBox.setChecked(true);
                    }
                } catch (NumberFormatException e) {//if myCheckedAnswers.elementAt(k) is not an int;
                    continue;
                }
            }

            checkBox.setTextSize(20);
            checkBox.setTextColor(Color.parseColor("#4a452a"));
            myMultipleCheckboxesLinearLayout.addView(checkBox);
        }
    } else if (udtea.currScreen == udtea.AUDIO_RECORD_SCREEN) {
        udtea.setContentView(R.layout.audio_recorder_screen);
        udtea.initRecordAudioScreen();
        udtea.initBackNextButtons();
        TextView myAudioRecorderTextView = (TextView) udtea.findViewById(R.id.audio_recorder_textview);
        myAudioRecorderTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myAudioRecorderTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        Button recordButton = (Button) udtea.findViewById(R.id.record_button);
        Button stopButton = (Button) udtea.findViewById(R.id.stop_button);
        Button playButton = (Button) udtea.findViewById(R.id.play_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            recordButton.setText((String) udtea.getResources().getText(R.string.UsbongRecordTextViewFILIPINO));
            stopButton.setText((String) udtea.getResources().getText(R.string.UsbongStopTextViewFILIPINO));
            playButton.setText((String) udtea.getResources().getText(R.string.UsbongPlayTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            recordButton.setText((String) udtea.getResources().getText(R.string.UsbongRecordTextViewJAPANESE));
            stopButton.setText((String) udtea.getResources().getText(R.string.UsbongStopTextViewJAPANESE));
            playButton.setText((String) udtea.getResources().getText(R.string.UsbongPlayTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            recordButton.setText((String) udtea.getResources().getText(R.string.UsbongRecordTextViewENGLISH));
            stopButton.setText((String) udtea.getResources().getText(R.string.UsbongStopTextViewENGLISH));
            playButton.setText((String) udtea.getResources().getText(R.string.UsbongPlayTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.PHOTO_CAPTURE_SCREEN) {
        udtea.setContentView(R.layout.photo_capture_screen);
        if (!udtea.performedCapturePhoto) {
            udtea.initTakePhotoScreen();
        }
        udtea.initBackNextButtons();
        TextView myPhotoCaptureScreenTextView = (TextView) udtea.findViewById(R.id.photo_capture_textview);
        myPhotoCaptureScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myPhotoCaptureScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        Button photoCaptureButton = (Button) udtea.findViewById(R.id.photo_capture_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            photoCaptureButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongTakePhotoTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            photoCaptureButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongTakePhotoTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            photoCaptureButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongTakePhotoTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.PAINT_SCREEN) {
        udtea.setContentView(R.layout.paint_screen);
        if (!udtea.performedRunPaint) {
            udtea.initPaintScreen();
        }
        udtea.initBackNextButtons();
        TextView myPaintScreenTextView = (TextView) udtea.findViewById(R.id.paint_textview);
        myPaintScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myPaintScreenTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);
        Button paintButton = (Button) udtea.findViewById(R.id.paint_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            paintButton.setText((String) udtea.getResources().getText(R.string.UsbongRunPaintTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            paintButton.setText((String) udtea.getResources().getText(R.string.UsbongRunPaintTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            paintButton.setText((String) udtea.getResources().getText(R.string.UsbongRunPaintTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.QR_CODE_READER_SCREEN) {
        udtea.setContentView(R.layout.qr_code_reader_screen);
        if (!udtea.performedGetQRCode) {
            udtea.initQRCodeReaderScreen();
        }
        udtea.initBackNextButtons();
        TextView myQRCodeReaderScreenTextView = (TextView) udtea.findViewById(R.id.qr_code_reader_textview);
        myQRCodeReaderScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myQRCodeReaderScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        Button qrCodeReaderButton = (Button) udtea.findViewById(R.id.qr_code_reader_button);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            qrCodeReaderButton.setText(
                    (String) udtea.getResources().getText(R.string.UsbongQRCodeReaderTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            qrCodeReaderButton.setText(
                    (String) udtea.getResources().getText(R.string.UsbongQRCodeReaderTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            qrCodeReaderButton
                    .setText((String) udtea.getResources().getText(R.string.UsbongQRCodeReaderTextViewENGLISH));
        }
    } else if (udtea.currScreen == udtea.TEXTFIELD_SCREEN) {
        udtea.setContentView(R.layout.textfield_screen);
        udtea.initBackNextButtons();
        TextView myTextFieldScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myTextFieldScreenEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myTextFieldScreenEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTFIELD_WITH_ANSWER_SCREEN) {
        udtea.setContentView(R.layout.textfield_screen);
        udtea.initBackNextButtons();
        String myTextFieldWithAnswerScreenStringToken = "";
        //             Log.d(">>>>>>>>udtea.currUsbongNode", udtea.currUsbongNode);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNode.replace("Answer=", "~");
        StringTokenizer myTextFieldWithAnswerScreenStringTokenizer = new StringTokenizer(
                udtea.currUsbongNodeWithoutAnswer, "~");
        if (myTextFieldWithAnswerScreenStringTokenizer != null) {
            myTextFieldWithAnswerScreenStringToken = myTextFieldWithAnswerScreenStringTokenizer.nextToken();

            while (myTextFieldWithAnswerScreenStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textFieldWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike")
                myTextFieldWithAnswerScreenStringToken = myTextFieldWithAnswerScreenStringTokenizer.nextToken();
            }
        }
        udtea.myTextFieldWithAnswerScreenAnswer = myTextFieldWithAnswerScreenStringToken.toString();
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNodeWithoutAnswer.substring(0,
                udtea.currUsbongNodeWithoutAnswer.length() - udtea.myTextFieldWithAnswerScreenAnswer.length()
                        - 1); //do a -1 for the last tilde             
        TextView myTextFieldWithAnswerScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldWithAnswerScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldWithAnswerScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNodeWithoutAnswer);
        EditText myTextFieldScreenWithAnswerEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myTextFieldScreenWithAnswerEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTAREA_SCREEN) {
        udtea.setContentView(R.layout.textarea_screen);
        udtea.initBackNextButtons();
        TextView myTextAreaScreenTextView = (TextView) udtea.findViewById(R.id.textarea_textview);
        myTextAreaScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextAreaScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myTextAreaScreenEditText = (EditText) udtea.findViewById(R.id.textarea_edittext);
        myTextAreaScreenEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTAREA_WITH_ANSWER_SCREEN) {
        udtea.setContentView(R.layout.textarea_screen);
        udtea.initBackNextButtons();
        String myTextAreaWithAnswerScreenStringToken = "";
        //             Log.d(">>>>>>>>udtea.currUsbongNode", udtea.currUsbongNode);
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNode.replace("Answer=", "~");
        StringTokenizer myTextAreaWithAnswerScreenStringTokenizer = new StringTokenizer(
                udtea.currUsbongNodeWithoutAnswer, "~");
        if (myTextAreaWithAnswerScreenStringTokenizer != null) {
            myTextAreaWithAnswerScreenStringToken = myTextAreaWithAnswerScreenStringTokenizer.nextToken();

            while (myTextAreaWithAnswerScreenStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textFieldWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike")
                myTextAreaWithAnswerScreenStringToken = myTextAreaWithAnswerScreenStringTokenizer.nextToken();
            }
        }
        udtea.myTextAreaWithAnswerScreenAnswer = myTextAreaWithAnswerScreenStringToken.toString();
        udtea.currUsbongNodeWithoutAnswer = udtea.currUsbongNodeWithoutAnswer.substring(0,
                udtea.currUsbongNodeWithoutAnswer.length() - udtea.myTextAreaWithAnswerScreenAnswer.length()
                        - 1); //do a -1 for the last tilde             
        TextView myTextAreaWithAnswerScreenTextView = (TextView) udtea.findViewById(R.id.textarea_textview);
        myTextAreaWithAnswerScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextAreaWithAnswerScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNodeWithoutAnswer);
        EditText myTextAreaScreenWithAnswerEditText = (EditText) udtea.findViewById(R.id.textarea_edittext);
        myTextAreaScreenWithAnswerEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.TEXTFIELD_WITH_UNIT_SCREEN) {
        udtea.setContentView(R.layout.textfield_with_unit_screen);
        udtea.initBackNextButtons();
        TextView myTextFieldWithUnitScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldWithUnitScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldWithUnitScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        myEditText.setText(myStringToken);
        TextView myUnitScreenTextView = (TextView) udtea.findViewById(R.id.textfieldunit_textview);
        myUnitScreenTextView.setText(udtea.textFieldUnit);
    } else if (udtea.currScreen == udtea.TEXTFIELD_NUMERICAL_SCREEN) {
        udtea.setContentView(R.layout.textfield_screen);
        udtea.initBackNextButtons();
        TextView myTextFieldNumericalScreenTextView = (TextView) udtea.findViewById(R.id.textfield_textview);
        myTextFieldNumericalScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextFieldNumericalScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        EditText myTextFieldNumericalScreenEditText = (EditText) udtea.findViewById(R.id.textfield_edittext);
        myTextFieldNumericalScreenEditText
                .setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        myTextFieldNumericalScreenEditText.setText(myStringToken);
    } else if (udtea.currScreen == udtea.CLASSIFICATION_SCREEN) {
        udtea.setContentView(R.layout.classification_screen);
        udtea.initBackNextButtons();
        TextView myClassificationScreenTextView = (TextView) udtea.findViewById(R.id.classification_textview);
        myClassificationScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myClassificationScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        LinearLayout myClassificationLinearLayout = (LinearLayout) udtea
                .findViewById(R.id.classification_linearlayout);
        int totalClassificationsInContainer = udtea.classificationContainer.size();
        for (int i = 0; i < totalClassificationsInContainer; i++) {
            TextView myTextView = new TextView(udtea.getBaseContext());
            //consider removing this code below; not needed; Mike, May 23, 2013
            myTextView = (TextView) UsbongUtils.applyTagsInView(UsbongDecisionTreeEngineActivity.getInstance(),
                    myTextView, UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);

            int bulletCount = i + 1;
            if (UsbongUtils.USE_UNESCAPE) {
                myTextView.setText(bulletCount + ") " + StringEscapeUtils
                        .unescapeJava(udtea.classificationContainer.elementAt(i).toString()));
            } else {
                myTextView.setText(bulletCount + ") " + UsbongUtils
                        .trimUsbongNodeName(udtea.classificationContainer.elementAt(i).toString()));
            }

            //add 5 so that the text does not touch the left border
            myTextView.setPadding(udtea.padding_in_px, 0, 0, 0);
            myTextView.setTextSize(24);
            //                 myTextView.setTextColor(Color.WHITE);
            myTextView.setTextColor(Color.parseColor("#4a452a"));
            myClassificationLinearLayout.addView(myTextView);
        }
    } else if (udtea.currScreen == udtea.DCAT_SUMMARY_SCREEN) {
        udtea.setContentView(R.layout.dcat_summary_screen);
        udtea.initBackNextButtons();
        TextView myDCATSummaryScreenTextView = (TextView) udtea.findViewById(R.id.dcat_summary_textview);
        myDCATSummaryScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myDCATSummaryScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        udtea.myDcatSummaryStringBuffer = new StringBuffer();
        String weightsString = "1.9;2.1;2.6;1.8;2.4;1.8;.7;1.0;1.6;2.6;6.9;5.7;3.3;2.2;3.3;3.3;2;2;1.7;1.9;3.9;1.3;2.5;.8";
        StringTokenizer myWeightsStringTokenizer = new StringTokenizer(weightsString, ";");
        String myWeightString = myWeightsStringTokenizer.nextToken();
        //            
        //            while (st.hasMoreTokens()) {
        //               myStringToken = st.nextToken(); 
        //            }
        //
        double myWeightedScoreInt = 0;
        double myNegotiatedWeightedScoreInt = 0;
        double[][] dcatSum = new double[8][4];
        final int sumWeightedRatingIndex = 0;
        final int sumWeightedScoreIndex = 1;
        final int sumNegotiatedRatingIndex = 2;
        final int sumNegotiatedScoreIndex = 3;
        int currStandard = 0;//standard 1
        //            boolean hasReachedNegotiated=false;
        boolean hasReachedStandardTotal = false;
        LinearLayout myDCATSummaryLinearLayout = (LinearLayout) udtea
                .findViewById(R.id.dcat_summary_linearlayout);
        int totalElementsInDCATSummaryBasedOnUsbongNodeContainer = udtea.usbongNodeContainer.size();
        //              for (int i=0; i<totalElementsInDCATSummaryBasedOnUsbongNodeContainer.usbongNodeContainer; i++) {                 
        for (int i = 0; i < totalElementsInDCATSummaryBasedOnUsbongNodeContainer; i++) {

            TextView myTextView = new TextView(udtea.getBaseContext());
            myTextView.setPadding(udtea.padding_in_px, 0, 0, 0); //add 5 so that the text does not touch the left border
            myTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
            myTextView.setTextColor(Color.parseColor("#4a452a"));

            //the only way to check if the element is already the last item in the standard
            //is if the next element in the node container has "STANDARD", but not the first standard
            if ((i + 1 >= totalElementsInDCATSummaryBasedOnUsbongNodeContainer) || (i
                    + 1 < totalElementsInDCATSummaryBasedOnUsbongNodeContainer)
                    && ((udtea.usbongNodeContainer.elementAt(i + 1).toString().contains("STANDARD")))
                    && (!(udtea.usbongNodeContainer.elementAt(i + 1).toString().contains("STANDARD ONE")))) {
                int tempCurrStandard = currStandard + 1; //do a +1 since currStandard begins at 0

                TextView myIssuesTextView = new TextView(udtea.getBaseContext());

                //added by Mike, May 31, 2013
                if (!udtea.usbongAnswerContainer.elementAt(i).toString().contains("dcat_end,")) {

                    String s = udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", "");
                    s = s.replace("A,", "");
                    if (!s.equals("")) {
                        myIssuesTextView = (TextView) UsbongUtils.applyTagsInView(
                                UsbongDecisionTreeEngineActivity.getInstance(), myIssuesTextView,
                                UsbongUtils.IS_TEXTVIEW, "ISSUES: " + s + "{br}");
                    } else {
                        myIssuesTextView = (TextView) UsbongUtils.applyTagsInView(
                                UsbongDecisionTreeEngineActivity.getInstance(), myIssuesTextView,
                                UsbongUtils.IS_TEXTVIEW, "ISSUES: none{br}");
                    }

                    myIssuesTextView.setPadding(udtea.padding_in_px, 0, 0, 0); //add 5 so that the text does not touch the left border
                    myIssuesTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
                    myIssuesTextView.setTextColor(Color.parseColor("#4a452a"));
                    myDCATSummaryLinearLayout.addView(myIssuesTextView);
                    udtea.myDcatSummaryStringBuffer.append(myIssuesTextView.getText().toString() + "\n");
                }

                if (myWeightsStringTokenizer.hasMoreElements()) {
                    //get the next weight
                    myWeightString = myWeightsStringTokenizer.nextToken();
                }

                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        "//--------------------" + " STANDARD " + tempCurrStandard + " (TOTAL){br}"
                                + "Total (Rating): "
                                + String.format("%.2f", dcatSum[currStandard][sumWeightedRatingIndex]) + "{br}"
                                + "Total (Weighted Score): "
                                + String.format("%.2f", dcatSum[currStandard][sumWeightedScoreIndex]) + "{br}"
                                + "Total (Negotiated Rating): "
                                + String.format("%.2f", dcatSum[currStandard][sumNegotiatedRatingIndex])
                                + "{br}" + "Total (Negotiated WS): "
                                + String.format("%.2f", dcatSum[currStandard][sumNegotiatedScoreIndex]) + "{br}"
                                + "//--------------------");
                hasReachedStandardTotal = true;
                currStandard++;
            }

            if (hasReachedStandardTotal) {
                hasReachedStandardTotal = false;
            } else if (udtea.usbongNodeContainer.elementAt(i).toString().contains("ISSUES")) {
                String s = udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", "");
                s = s.replace("A,", "");
                if (!s.equals("")) {
                    myTextView = (TextView) UsbongUtils.applyTagsInView(
                            UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                            "ISSUES: " + s + "{br}");
                } else {
                    myTextView = (TextView) UsbongUtils.applyTagsInView(
                            UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                            "ISSUES: none{br}");
                }

                if (myWeightsStringTokenizer.hasMoreElements()) {
                    //get the next weight
                    myWeightString = myWeightsStringTokenizer.nextToken();
                }
            } else if (udtea.usbongNodeContainer.elementAt(i).toString().contains("Weighted")) {
                TextView myWeightedTextView = new TextView(udtea.getBaseContext());
                myWeightedTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myWeightedTextView,
                        UsbongUtils.IS_TEXTVIEW,
                        udtea.usbongNodeContainer.elementAt(i).toString().replace("{br}(Weighted Score)", ""));
                myWeightedTextView.setPadding(udtea.padding_in_px, 0, 0, 0); //add 5 so that the text does not touch the left border
                myWeightedTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
                myWeightedTextView.setTextColor(Color.parseColor("#4a452a"));

                myDCATSummaryLinearLayout.addView(myWeightedTextView);
                udtea.myDcatSummaryStringBuffer.append(myWeightedTextView.getText().toString() + "\n");

                int weightedAnswer;
                //added by Mike, July 8, 2013
                try {
                    weightedAnswer = Integer
                            .parseInt(udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", ""));
                } catch (Exception e) { //if there's no answer selected
                    weightedAnswer = 0;
                }
                if (weightedAnswer <= 0) {
                    weightedAnswer = 0;
                }

                //the weight is in double
                myWeightedScoreInt = weightedAnswer * Double.parseDouble(myWeightString);
                if (myWeightedScoreInt <= 0) {
                    myWeightedScoreInt = 0;
                    myTextView.setBackgroundColor(Color.YELLOW);
                }

                dcatSum[currStandard][sumWeightedRatingIndex] += weightedAnswer;
                dcatSum[currStandard][sumWeightedScoreIndex] += myWeightedScoreInt;

                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        "Weighted: " + myWeightedScoreInt);
            } else if (udtea.usbongNodeContainer.elementAt(i).toString().contains("Negotiated")) {
                //added by Mike, July 8, 2013
                int negotiatedAnswer;
                try {
                    negotiatedAnswer = Integer
                            .parseInt(udtea.usbongAnswerContainer.elementAt(i).toString().replace(";", ""));
                } catch (Exception e) { //if there's no answer selected
                    negotiatedAnswer = 0;
                }
                if (negotiatedAnswer <= 0) {
                    negotiatedAnswer = 0;
                }

                //the weight is in double
                myNegotiatedWeightedScoreInt = negotiatedAnswer * Double.parseDouble(myWeightString);
                if (myNegotiatedWeightedScoreInt <= 0) {
                    myNegotiatedWeightedScoreInt = 0;
                    myTextView.setBackgroundColor(Color.YELLOW);
                }

                dcatSum[currStandard][sumNegotiatedRatingIndex] += negotiatedAnswer;
                dcatSum[currStandard][sumNegotiatedScoreIndex] += myNegotiatedWeightedScoreInt;

                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        "Negotiated: " + myNegotiatedWeightedScoreInt);
                //                    hasReachedNegotiated=true;
            } else {
                myTextView = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), myTextView, UsbongUtils.IS_TEXTVIEW,
                        udtea.usbongNodeContainer.elementAt(i).toString() + "{br}");
            }

            //                 if (!hasReachedStandardTotal) {
            myDCATSummaryLinearLayout.addView(myTextView);
            udtea.myDcatSummaryStringBuffer.append(myTextView.getText().toString() + "\n");
            Log.d(">>>>>myTextView.getText().toString()", myTextView.getText().toString());
            //                 }
            //                 else {
            //                    hasReachedStandardTotal=false;
            //                 }
        }
    } else if (udtea.currScreen == udtea.DATE_SCREEN) {
        udtea.setContentView(R.layout.date_screen);
        udtea.initBackNextButtons();
        TextView myDateScreenTextView = (TextView) udtea.findViewById(R.id.date_textview);
        myDateScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myDateScreenTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);
        //Reference: http://code.google.com/p/android/issues/detail?id=2037
        //last accessed: 21 Aug. 2012
        Configuration userConfig = new Configuration();
        Settings.System.getConfiguration(udtea.getContentResolver(), userConfig);
        Calendar date = Calendar.getInstance(userConfig.locale);
        //Reference: http://www.androidpeople.com/android-spinner-default-value;
        //last accessed: 21 Aug. 2012              
        //month-------------------------------
        int month = date.get(Calendar.MONTH); //first month of the year is 0
        Spinner dateMonthSpinner = (Spinner) udtea.findViewById(R.id.date_month_spinner);
        udtea.monthAdapter = ArrayAdapter.createFromResource(((Activity) udtea), R.array.months_array,
                android.R.layout.simple_spinner_item);
        //              udtea.monthAdapter  = ArrayAdapter.createFromResource(
        //                this, R.array.months_array, R.layout.date_textview);
        udtea.monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        dateMonthSpinner.setAdapter(udtea.monthAdapter);
        dateMonthSpinner.setSelection(month);
        //              System.out.println(">>>>>>>>>>>>>> month"+month);
        //              Log.d(">>>>>>myStringToken",myStringToken);
        for (int i = 0; i < udtea.monthAdapter.getCount(); i++) {
            //                 Log.d(">>>>>>udtea.monthAdapter ",udtea.monthAdapter .getItem(i).toString());

            if (myStringToken.contains(udtea.monthAdapter.getItem(i).toString())) {
                dateMonthSpinner.setSelection(i);

                //added by Mike, March 4, 2013
                myStringToken = myStringToken.replace(udtea.monthAdapter.getItem(i).toString(), "");
            }
        }
        //-------------------------------------
        //day----------------------------------
        //Reference: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html#MONTH
        //last accessed: 21 Aug 2012
        int day = date.get(Calendar.DAY_OF_MONTH); //first day of the month is 1
        day = day - 1; //do this to offset, when retrieving the day in strings.xml
        Spinner dateDaySpinner = (Spinner) udtea.findViewById(R.id.date_day_spinner);
        udtea.dayAdapter = ArrayAdapter.createFromResource(((Activity) udtea), R.array.day_array,
                android.R.layout.simple_spinner_item);
        udtea.dayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        dateDaySpinner.setAdapter(udtea.dayAdapter);
        dateDaySpinner.setSelection(day);
        //              System.out.println(">>>>>>>>>>>>>> day"+day);
        //              Log.d(">>>>>myStringToken",myStringToken);
        //              System.out.println(">>>>>>>> myStringToken"+myStringToken);
        StringTokenizer myDateStringTokenizer = new StringTokenizer(myStringToken, ",");
        String myDayStringToken = "";
        if (!myStringToken.equals("")) {
            myDayStringToken = myDateStringTokenizer.nextToken();
        }
        for (int i = 0; i < udtea.dayAdapter.getCount(); i++) {
            if (myDayStringToken.contains(udtea.dayAdapter.getItem(i).toString())) {
                dateDaySpinner.setSelection(i);

                myStringToken = myStringToken.replace(udtea.dayAdapter.getItem(i).toString() + ",", "");
                //                    System.out.println(">>>>>>>>>>>myStringToken: "+myStringToken);
            }
        }
        //-------------------------------------            
        //year---------------------------------
        int year = date.get(Calendar.YEAR);
        EditText myDateYearEditText = (EditText) udtea.findViewById(R.id.date_edittext);
        myDateYearEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        //added by Mike, March 4, 2013
        if (myStringToken.equals("")) {
            myDateYearEditText.setText("" + year);
        } else {
            myDateYearEditText.setText(myStringToken);
        }
    } else if (udtea.currScreen == udtea.TEXT_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.text_display_screen);
        udtea.initBackNextButtons();
        TextView myTextDisplayScreenTextView = (TextView) udtea.findViewById(R.id.text_display_textview);
        myTextDisplayScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextDisplayScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);

        //         Log.d(">>>>>","inside udtea.currScreen == udtea.TEXT_DISPLAY_SCREEN");
        //         myTextDisplayScreenTextView = (TextView) UsbongUtils.applyHintsInView(UsbongDecisionTreeEngineActivity.getInstance(), myTextDisplayScreenTextView, UsbongUtils.IS_TEXTVIEW);
        //         Log.d(">>>>>","after myTextDisplayScreenTextView");

    } else if (udtea.currScreen == udtea.TIMESTAMP_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.timestamp_display_screen);
        udtea.initBackNextButtons();
        TextView myTimeDisplayScreenTextView = (TextView) udtea.findViewById(R.id.time_display_textview);
        udtea.timestampString = UsbongUtils.getCurrTimeStamp();
        myTimeDisplayScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTimeDisplayScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode + "{br}" + udtea.timestampString);

    } else if (udtea.currScreen == udtea.SIMPLE_ENCRYPT_SCREEN) {
        udtea.setContentView(R.layout.simple_encrypt_screen);
        udtea.initBackNextButtons();
        TextView myEncryptScreenTextView = (TextView) udtea.findViewById(R.id.encrypt_textview);
        myEncryptScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myEncryptScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);

        String message = "";
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            message = (String) udtea.getResources().getText(R.string.UsbongEncryptAlertMessageFILIPINO);
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            message = (String) udtea.getResources().getText(R.string.UsbongEncryptAlertMessageJAPANESE);
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            message = (String) udtea.getResources().getText(R.string.UsbongEncryptAlertMessageENGLISH);
        }

        new AlertDialog.Builder(udtea).setTitle("Hey!").setMessage(message)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();

    } else if (udtea.currScreen == udtea.IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.image_display_screen);
        udtea.initBackNextButtons();
        ImageView myImageDisplayScreenImageView = (ImageView) udtea.findViewById(R.id.special_imageview);
        //              if (!UsbongUtils.setImageDisplay(myImageDisplayScreenImageView, myTree+".utree/res/" +UsbongUtils.getResName(udtea.currUsbongNode))) {
        if (!UsbongUtils.setImageDisplay(myImageDisplayScreenImageView, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myImageDisplayScreenImageView.setImageDrawable(myDrawableImage);
        }
    } else if (udtea.currScreen == udtea.CLICKABLE_IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.clickable_image_display_screen);
        udtea.initBackNextButtons();
        ImageButton myClickableImageDisplayScreenImageButton = (ImageButton) udtea
                .findViewById(R.id.clickable_image_display_imagebutton);
        if (!UsbongUtils.setClickableImageDisplay(myClickableImageDisplayScreenImageButton, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myClickableImageDisplayScreenImageButton.setBackgroundDrawable(myDrawableImage);
        }
        myClickableImageDisplayScreenImageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //                      myMessage = UsbongUtils.applyTagsInString(udtea.currUsbongNode).toString();                   

                TextView tv = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(),
                        new TextView(UsbongDecisionTreeEngineActivity.getInstance()), UsbongUtils.IS_TEXTVIEW,
                        udtea.currUsbongNode);
                if (tv.toString().equals("")) {
                    tv.setText("No message.");
                }
                tv.setTextSize((UsbongDecisionTreeEngineActivity.getInstance().getResources()
                        .getDimension(R.dimen.textsize)));

                new AlertDialog.Builder(udtea).setTitle("Hey!")
                        //                     .setMessage(myMessage)
                        .setView(tv).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        });
    } else if (udtea.currScreen == udtea.TEXT_CLICKABLE_IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.text_clickable_image_display_screen);
        udtea.initBackNextButtons();
        TextView myTextClickableImageDisplayTextView = (TextView) udtea
                .findViewById(R.id.text_clickable_image_display_textview);
        myTextClickableImageDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextClickableImageDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageButton myTextClickableImageDisplayScreenImageButton = (ImageButton) udtea
                .findViewById(R.id.clickable_image_display_imagebutton);
        if (!UsbongUtils.setClickableImageDisplay(myTextClickableImageDisplayScreenImageButton, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myTextClickableImageDisplayScreenImageButton.setBackgroundDrawable(myDrawableImage);
        }
        myTextClickableImageDisplayScreenImageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //                      myMessage = UsbongUtils.applyTagsInString(udtea.currUsbongNode).toString();                   

                TextView tv = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), new TextView(udtea),
                        UsbongUtils.IS_TEXTVIEW, UsbongUtils.getAlertName(udtea.currUsbongNode));
                if (tv.toString().equals("")) {
                    tv.setText("No message.");
                }
                tv.setTextSize((UsbongDecisionTreeEngineActivity.getInstance().getResources()
                        .getDimension(R.dimen.textsize)));

                new AlertDialog.Builder(udtea).setTitle("Hey!")
                        //                     .setMessage(myMessage)
                        .setView(tv).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        });
    } else if (udtea.currScreen == udtea.CLICKABLE_IMAGE_TEXT_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.clickable_image_text_display_screen);
        udtea.initBackNextButtons();
        TextView myClickableImageTextDisplayTextView = (TextView) udtea
                .findViewById(R.id.clickable_image_text_display_textview);
        myClickableImageTextDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myClickableImageTextDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageButton myClickableImageTextDisplayScreenImageButton = (ImageButton) udtea
                .findViewById(R.id.clickable_image_display_imagebutton);
        if (!UsbongUtils.setClickableImageDisplay(myClickableImageTextDisplayScreenImageButton, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myClickableImageTextDisplayScreenImageButton.setBackgroundDrawable(myDrawableImage);
        }
        myClickableImageTextDisplayScreenImageButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //                      myMessage = UsbongUtils.applyTagsInString(udtea.currUsbongNode).toString();                   

                TextView tv = (TextView) UsbongUtils.applyTagsInView(
                        UsbongDecisionTreeEngineActivity.getInstance(), new TextView(udtea),
                        UsbongUtils.IS_TEXTVIEW, UsbongUtils.getAlertName(udtea.currUsbongNode));
                if (tv.toString().equals("")) {
                    tv.setText("No message.");
                }
                tv.setTextSize((UsbongDecisionTreeEngineActivity.getInstance().getResources()
                        .getDimension(R.dimen.textsize)));

                new AlertDialog.Builder(udtea).setTitle("Hey!")
                        //                     .setMessage(myMessage)
                        .setView(tv).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        });
    } else if (udtea.currScreen == udtea.VIDEO_FROM_FILE_SCREEN) {
        udtea.setContentView(R.layout.video_from_file_screen);
        udtea.initBackNextButtons();
        VideoView myVideoFromFileScreenVideoView = (VideoView) udtea
                .findViewById(R.id.video_from_file_videoview);
        myVideoFromFileScreenVideoView.setVideoPath(
                UsbongUtils.getPathOfVideoFile(udtea.myTree, UsbongUtils.getResName(udtea.currUsbongNode)));
        //added by Mike, Sept. 9, 2013
        myVideoFromFileScreenVideoView.setMediaController(new MediaController(((Activity) udtea)));
        myVideoFromFileScreenVideoView.start();
    } else if (udtea.currScreen == udtea.VIDEO_FROM_FILE_WITH_TEXT_SCREEN) {
        udtea.setContentView(R.layout.video_from_file_with_text_screen);
        udtea.initBackNextButtons();
        TextView myVideoFromFileWithTextTextView = (TextView) udtea
                .findViewById(R.id.video_from_file_with_text_textview);
        myVideoFromFileWithTextTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myVideoFromFileWithTextTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        VideoView myVideoFromFileWithTextScreenVideoView = (VideoView) udtea
                .findViewById(R.id.video_from_file_with_text_videoview);
        myVideoFromFileWithTextScreenVideoView.setVideoPath(
                UsbongUtils.getPathOfVideoFile(udtea.myTree, UsbongUtils.getResName(udtea.currUsbongNode)));
        myVideoFromFileWithTextScreenVideoView.setMediaController(new MediaController(((Activity) udtea)));
        myVideoFromFileWithTextScreenVideoView.start();
    } else if (udtea.currScreen == udtea.TEXT_IMAGE_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.text_image_display_screen);
        udtea.initBackNextButtons();
        TextView myTextImageDisplayTextView = (TextView) udtea.findViewById(R.id.text_image_display_textview);
        myTextImageDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myTextImageDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageView myTextImageDisplayImageView = (ImageView) udtea.findViewById(R.id.image_display_imageview);
        //              if (!UsbongUtils.setImageDisplay(myTextImageDisplayImageView, myTree+".utree/res/" +UsbongUtils.getResName(udtea.currUsbongNode))) {
        if (!UsbongUtils.setImageDisplay(myTextImageDisplayImageView, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myTextImageDisplayImageView.setImageDrawable(myDrawableImage);
        }
    } else if (udtea.currScreen == udtea.IMAGE_TEXT_DISPLAY_SCREEN) {
        udtea.setContentView(R.layout.image_text_display_screen);
        udtea.initBackNextButtons();
        TextView myImageTextDisplayTextView = (TextView) udtea.findViewById(R.id.image_text_display_textview);
        myImageTextDisplayTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myImageTextDisplayTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        ImageView myImageTextDisplayImageView = (ImageView) udtea.findViewById(R.id.image_display_imageview);

        if (!UsbongUtils.setImageDisplay(myImageTextDisplayImageView, udtea.myTree,
                UsbongUtils.getResName(udtea.currUsbongNode))) {
            //Reference: http://www.anddev.org/tinytut_-_get_resources_by_name__getidentifier_-t460.html; last accessed 14 Sept 2011
            //                 Resources myRes = getResources();
            myDrawableImage = myRes
                    .getDrawable(myRes.getIdentifier("no_image", "drawable", udtea.myPackageName));
            myImageTextDisplayImageView.setImageDrawable(myDrawableImage);
        }
    } else if (udtea.currScreen == udtea.GPS_LOCATION_SCREEN) {
        udtea.setContentView(R.layout.gps_location_screen);
        udtea.initBackNextButtons();
        TextView myGPSLocationTextView = (TextView) udtea.findViewById(R.id.gps_location_textview);
        myGPSLocationTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myGPSLocationTextView, UsbongUtils.IS_TEXTVIEW,
                udtea.currUsbongNode);
        //         TextView myLongitudeTextView = (TextView)udtea.findViewById(R.id.longitude_textview);
        //         TextView myLatitudeTextView = (TextView)udtea.findViewById(R.id.latitude_textview);
        hasGottenGPSLocation = false;

        locationResult = new LocationResult() {
            @Override
            public void gotLocation(Location location) {
                //Got the location!
                System.out.println(">>>>>>>>>>>>>>>>>location: " + location);
                if (udtea.currScreen == udtea.GPS_LOCATION_SCREEN) {
                    if (location != null) {
                        myLongitude = location.getLongitude() + "";
                        myLatitude = location.getLatitude() + "";

                        myLongitudeTextView = (TextView) udtea.findViewById(R.id.longitude_textview);
                        myLatitudeTextView = (TextView) udtea.findViewById(R.id.latitude_textview);

                        hasGottenGPSLocation = true;

                        udtea.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                myLongitudeTextView.setText("long: " + myLongitude);
                                myLatitudeTextView.setText("lat: " + myLatitude);
                            }
                        });
                    } else {
                        Toast.makeText(UsbongDecisionTreeEngineActivity.getInstance(),
                                "Error getting location. Please make sure you are not inside a building.",
                                Toast.LENGTH_SHORT).show();
                    }
                } else {
                    hasGottenGPSLocation = true; //to stop the cycling progress bar
                }
            }
        };
        //         myLoadingProgressBar =  new ProgressBar(udtea);
        //         myLoadingProgressBar.setIndeterminate(false);
        //         myLoadingProgressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);         

        udtea.myLocation = new FedorMyLocation();
        udtea.myLocation.getLocation(udtea, locationResult);

        myLoadingProgressBar = (ProgressBar) udtea.findViewById(R.id.progressBar);
        new ProgressTask().execute();

    } else if (udtea.currScreen == udtea.YES_NO_DECISION_SCREEN) {
        udtea.setContentView(R.layout.yes_no_decision_screen);
        udtea.initBackNextButtons();
        TextView myYesNoDecisionScreenTextView = (TextView) udtea.findViewById(R.id.yes_no_decision_textview);
        myYesNoDecisionScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), myYesNoDecisionScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        RadioButton myYesRadioButton = (RadioButton) udtea.findViewById(R.id.yes_radiobutton);
        myYesRadioButton.setText(udtea.yesStringValue);
        myYesRadioButton.setTextSize(20);
        RadioButton myNoRadioButton = (RadioButton) udtea.findViewById(R.id.no_radiobutton);
        myNoRadioButton.setText(udtea.noStringValue);
        myNoRadioButton.setTextSize(20);
        if (myStringToken.equals("N")) {
            myNoRadioButton.setChecked(true);
        } else if ((myStringToken.equals("Y"))) {
            myYesRadioButton.setChecked(true);
        }
    } else if (udtea.currScreen == udtea.SEND_TO_CLOUD_BASED_SERVICE_SCREEN) {
        udtea.setContentView(R.layout.yes_no_decision_screen);
        udtea.initBackNextButtons();
        TextView mySendToCloudBasedServiceScreenTextView = (TextView) udtea
                .findViewById(R.id.yes_no_decision_textview);
        mySendToCloudBasedServiceScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), mySendToCloudBasedServiceScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        RadioButton mySendToCloudBasedServiceScreenYesRadioButton = (RadioButton) udtea
                .findViewById(R.id.yes_radiobutton);
        mySendToCloudBasedServiceScreenYesRadioButton.setText(udtea.yesStringValue);
        mySendToCloudBasedServiceScreenYesRadioButton.setTextSize(20);
        RadioButton mySendToCloudBasedServiceScreenNoRadioButton = (RadioButton) udtea
                .findViewById(R.id.no_radiobutton);
        mySendToCloudBasedServiceScreenNoRadioButton.setText(udtea.noStringValue);
        mySendToCloudBasedServiceScreenNoRadioButton.setTextSize(20);
        if (myStringToken.equals("N")) {
            mySendToCloudBasedServiceScreenNoRadioButton.setChecked(true);
        } else if ((myStringToken.equals("Y"))) {
            mySendToCloudBasedServiceScreenYesRadioButton.setChecked(true);
        }
    } else if (udtea.currScreen == udtea.SEND_TO_WEBSERVER_SCREEN) {
        udtea.setContentView(R.layout.send_to_webserver_screen);
        udtea.initBackNextButtons();
        TextView mySendToWebserverScreenTextView = (TextView) udtea
                .findViewById(R.id.send_to_webserver_textview);
        mySendToWebserverScreenTextView = (TextView) UsbongUtils.applyTagsInView(
                UsbongDecisionTreeEngineActivity.getInstance(), mySendToWebserverScreenTextView,
                UsbongUtils.IS_TEXTVIEW, udtea.currUsbongNode);
        TextView myWebserverURLScreenTextView = (TextView) udtea.findViewById(R.id.webserver_url_textview);

        if (!UsbongUtils.getDestinationServerURL().toString().equals("")) {
            myWebserverURLScreenTextView.setText("[" + UsbongUtils.getDestinationServerURL() + "]");
        } else {
            myWebserverURLScreenTextView.setText("[Warning: No URL specified in Settings.]");
        }

        RadioButton mySendToWebserverYesRadioButton = (RadioButton) udtea.findViewById(R.id.yes_radiobutton);
        mySendToWebserverYesRadioButton.setText(udtea.yesStringValue);
        mySendToWebserverYesRadioButton.setTextSize(20);
        RadioButton mySendToWebserverNoRadioButton = (RadioButton) udtea.findViewById(R.id.no_radiobutton);
        mySendToWebserverNoRadioButton.setText(udtea.noStringValue);
        mySendToWebserverNoRadioButton.setTextSize(20);
        if (myStringToken.equals("N")) {
            mySendToWebserverNoRadioButton.setChecked(true);
        } else if ((myStringToken.equals("Y"))) {
            mySendToWebserverYesRadioButton.setChecked(true);
        }
    } else if (udtea.currScreen == udtea.END_STATE_SCREEN) {
        udtea.setContentView(R.layout.end_state_screen);
        TextView endStateTextView = (TextView) udtea.findViewById(R.id.end_state_textview);
        if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
            endStateTextView
                    .setText((String) udtea.getResources().getText(R.string.UsbongEndStateTextViewFILIPINO));
        } else if (udtea.currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
            endStateTextView
                    .setText((String) udtea.getResources().getText(R.string.UsbongEndStateTextViewJAPANESE));
        } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
            endStateTextView
                    .setText((String) udtea.getResources().getText(R.string.UsbongEndStateTextViewENGLISH));
        }
        udtea.initBackNextButtons();
    }
    View myLayout = udtea.findViewById(R.id.parent_layout_id);
    if (!UsbongUtils.setBackgroundImage(myLayout, udtea.myTree, "bg")) {
        myLayout.setBackgroundResource(R.drawable.bg);//default bg
    }

    if ((!udtea.usedBackButton) && (!udtea.hasReturnedFromAnotherActivity)) {
        udtea.usbongNodeContainer.addElement(udtea.currUsbongNode);
        udtea.usbongNodeContainerCounter++;
    } else {
        udtea.usedBackButton = false;
        udtea.hasReturnedFromAnotherActivity = false;
    }
}

From source file:com.rsmsa.accapp.ScreenSlidePageFragmentTwo.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.vehicle_two, container, false);

    tab_one = (EditText) rootView.findViewById(R.id.dob_one);

    vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner);

    vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button);

    /**/*from   w w  w . jav a 2  s.c o  m*/
     * Defining all layout items
     **/

    inputFatal = (EditText) rootView.findViewById(R.id.fatal_edit);
    inputInjuries = (EditText) rootView.findViewById(R.id.injury_edit);
    inputSimple = (EditText) rootView.findViewById(R.id.simple_edit);
    inputNotInjured = (EditText) rootView.findViewById(R.id.not_injured_edit);

    //driver 0ne details
    surname_one = (EditText) rootView.findViewById(R.id.surname_one);
    othernames_one = (EditText) rootView.findViewById(R.id.othernames_one);
    physical_address_one = (EditText) rootView.findViewById(R.id.physical_address_one);
    address_box_one = (EditText) rootView.findViewById(R.id.address_box_one);
    national_id_one = (EditText) rootView.findViewById(R.id.national_id_one);
    phone_no_one = (EditText) rootView.findViewById(R.id.phone_no_one);
    final RadioButton male = (RadioButton) rootView.findViewById(R.id.male);
    final RadioButton female = (RadioButton) rootView.findViewById(R.id.female);
    nationality_one = (EditText) rootView.findViewById(R.id.nationality_one);
    license_one = (EditText) rootView.findViewById(R.id.license_one);
    occupation_one = (EditText) rootView.findViewById(R.id.occupation_one);

    alcohol_edit = (EditText) rootView.findViewById(R.id.alcohol_edit);
    drug = (CheckBox) rootView.findViewById(R.id.drug_edit);
    phone_use = (CheckBox) rootView.findViewById(R.id.phone_edit);
    seat_belt = (CheckBox) rootView.findViewById(R.id.seat_belt_edit);

    //Vehicle one details
    type_one = (EditText) rootView.findViewById(R.id.type_one);
    registration_number_one = (EditText) rootView.findViewById(R.id.registration_number_one);

    //Vehicle one  Insurance details
    company_one = (EditText) rootView.findViewById(R.id.company_one);
    insurance_type_one = (EditText) rootView.findViewById(R.id.insurance_type_one);
    insurance_phone = (EditText) rootView.findViewById(R.id.insurance_phone);
    policy_period_one = (EditText) rootView.findViewById(R.id.policy_period_one);
    policy_number_one = (EditText) rootView.findViewById(R.id.policy_number_one);
    repair_amount_one = (EditText) rootView.findViewById(R.id.repair_amount_one);

    //Vehicle one  damage details
    vehicle = (EditText) rootView.findViewById(R.id.vehicle_title_edit);
    vehicle_total = (EditText) rootView.findViewById(R.id.vehicle_total_edit);
    infrastructure = (EditText) rootView.findViewById(R.id.infrastructure_edit);
    cost = (EditText) rootView.findViewById(R.id.rescue_cost_edit);

    /**
     * getting values of our view elements
     */
    drug.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (((CheckBox) v).isChecked()) {

                MainActivity.V2_drug_edit = "Drugs Use";
            } else {
                MainActivity.V2_drug_edit = " No Drug use";
            }
        }
    });

    phone_use.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (((CheckBox) v).isChecked()) {

                MainActivity.V2_phone_edit = "Was using Phone";
            } else {
                MainActivity.V2_phone_edit = " No phone use";
            }
        }
    });

    seat_belt.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (((CheckBox) v).isChecked()) {

                MainActivity.V2_seat_belt_edit = "Seat belt not fastened";
            } else {
                MainActivity.V2_seat_belt_edit = "Seat belt fastened";
            }
        }
    });

    male.setChecked(true);
    //   Fatal.setChecked(true);

    male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                female.setChecked(false);
                MainActivity.V2_gender = "male";
            }
        }
    });

    female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                male.setChecked(false);
                MainActivity.V2_gender = "female";
            }
        }
    });

    cal = Calendar.getInstance();

    day = cal.get(Calendar.DAY_OF_MONTH);

    month = cal.get(Calendar.MONTH);

    year = cal.get(Calendar.YEAR);

    pickDate = (Button) rootView.findViewById(R.id.date_picker);
    pickDate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), datePickerListener, year,
                    month, day);
            datePickerDialog.show();
        }
    });

    List<String> vehicle_category_list = new ArrayList<String>();
    vehicle_category_list.add("Private");
    vehicle_category_list.add("Commercial");
    vehicle_category_list.add("Government");
    vehicle_category_list.add("Emergency");
    vehicle_category_list.add("Passenger Service Vehicles");

    vehicle_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            selectedSpinner = i;
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    vehicle_type.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), VehicleType.class);
            intent.putExtra("category", selectedSpinner + "");
            startActivity(intent);
        }
    });

    ArrayAdapter<String> atc_adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, vehicle_category_list);
    atc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    vehicle_category.setAdapter(atc_adapter);

    return rootView;
}

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

private void restoreViewContents(final SavedViewContents sv) {
    final EditText dlg_prof_name_et = (EditText) mDialog.findViewById(R.id.edit_profile_action_profile_et_name);
    final CheckBox cb_active = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_enabled);
    final CheckBox cb_enable_env_parms = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_enable_env_parms);

    final TextView tv_sound_filename = (TextView) mDialog
            .findViewById(R.id.edit_profile_action_exec_sound_file_name);
    final CheckBox cb_music_vol = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_profile_sound_use_volume);
    final SeekBar sb_music_vol = (SeekBar) mDialog.findViewById(R.id.edit_profile_action_profile_sound_volume);
    final CheckBox cb_ringtone_vol = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_use_volume);
    final SeekBar sb_ringtone_vol = (SeekBar) mDialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_volume);
    final Spinner spinnerActionType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_action_type);
    final Spinner spinnerActivityName = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_name);
    final Spinner spinnerActivityDataType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_data_type);
    final Spinner spinnerRingtoneType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_type);
    final Spinner spinnerRingtoneName = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_name);
    final Spinner spinnerCompareType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_compare_type);
    final EditText et_comp_value1 = (EditText) mDialog.findViewById(R.id.edit_profile_action_compare_value1);
    final EditText et_comp_value2 = (EditText) mDialog.findViewById(R.id.edit_profile_action_compare_value2);
    final ListView lv_comp_data = (ListView) mDialog
            .findViewById(R.id.edit_profile_action_compare_value_listview);
    final Spinner spinnerCompareResult = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_compare_result);
    final Spinner spinnerCompareTarget = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_compare_target);
    final Spinner spinnerMessageType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_message_type);
    final EditText et_msg_text = (EditText) mDialog.findViewById(R.id.edit_profile_action_message_message);
    final CheckBox cb_vib_used = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_message_vibration);
    final CheckBox cb_led_used = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_message_led);
    final RadioButton rb_msg_blue = (RadioButton) mDialog
            .findViewById(R.id.edit_profile_action_message_led_blue);
    final RadioButton rb_msg_red = (RadioButton) mDialog.findViewById(R.id.edit_profile_action_message_led_red);
    final RadioButton rb_msg_green = (RadioButton) mDialog
            .findViewById(R.id.edit_profile_action_message_led_green);
    final Spinner spinnerTimeType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_time_type);
    final Spinner spinnerTimeTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_time_target);
    final Spinner spinnerTaskType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_task_type);
    final Spinner spinnerTaskTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_task_target);
    final Spinner spinnerWaitTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_wait_target);
    final Spinner spinnerWaitTimeoutType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout);
    final Spinner spinnerWaitTimeoutValue = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout_value);
    final Spinner spinnerWaitTimeoutUnits = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout_units);
    final EditText et_bsh_script = (EditText) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_script_text);
    final Spinner spinnerBshMethod = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_add_method);
    final Spinner spinnerCatMethod = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_cat_method);

    final EditText uri_data = (EditText) mDialog.findViewById(R.id.edit_profile_action_exec_activity_uri_data);
    final ListView lv_aed = (ListView) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_extra_data_listview);

    dlg_prof_name_et.setText(sv.dlg_prof_name_et);
    dlg_prof_name_et.setSelection(sv.dlg_prof_name_et_spos, sv.dlg_prof_name_et_epos);
    cb_active.setChecked(sv.cb_active);//from www . j  a  v  a  2s  .c o  m
    tv_sound_filename.setText(sv.tv_sound_filename);
    cb_music_vol.setChecked(sv.cb_music_vol);
    sb_music_vol.setProgress(sv.sb_music_vol);
    cb_ringtone_vol.setChecked(sv.cb_ringtone_vol);
    sb_ringtone_vol.setProgress(sv.sb_ringtone_vol);
    et_comp_value1.setText(sv.et_comp_value1);
    et_comp_value2.setText(sv.et_comp_value2);
    lv_comp_data.setSelectionFromTop(sv.lv_comp_data[0], sv.lv_comp_data[1]);
    et_msg_text.setText(sv.et_msg_text);
    cb_vib_used.setChecked(sv.cb_vib_used);
    cb_led_used.setChecked(sv.cb_led_used);
    if (sv.rb_msg_blue)
        rb_msg_blue.setChecked(sv.rb_msg_blue);
    if (sv.rb_msg_red)
        rb_msg_red.setChecked(sv.rb_msg_red);
    if (sv.rb_msg_green)
        rb_msg_green.setChecked(sv.rb_msg_green);
    et_bsh_script.setText(sv.et_bsh_script);
    uri_data.setText(sv.uri_data);
    lv_aed.setSelectionFromTop(sv.lv_aed[0], sv.lv_aed[1]);
    cb_enable_env_parms.setChecked(sv.cb_enable_env_parms);

    for (int i = 0; i < mGlblParms.activityExtraDataEditListAdapter.getCount(); i++)
        mGlblParms.activityExtraDataEditListAdapter.remove(0);
    for (int i = 0; i < sv.aed_adapter_list.size(); i++)
        mGlblParms.activityExtraDataEditListAdapter.add(sv.aed_adapter_list.get(i));
    mGlblParms.activityExtraDataEditListAdapter.notifyDataSetChanged();

    for (int i = 0; i < mGlblParms.actionCompareDataAdapter.getCount(); i++)
        mGlblParms.actionCompareDataAdapter.remove(0);
    for (int i = 0; i < sv.data_array_adapter_list.size(); i++)
        mGlblParms.actionCompareDataAdapter.add(sv.data_array_adapter_list.get(i));
    mGlblParms.actionCompareDataAdapter.notifyDataSetChanged();

    spinnerActionType.setSelection(sv.spinnerActionType);
    spinnerActivityName.setSelection(sv.spinnerActivityName);
    spinnerActivityDataType.setSelection(sv.spinnerActivityDataType);
    spinnerRingtoneType.setSelection(sv.spinnerRingtoneType);
    spinnerRingtoneName.setSelection(sv.spinnerRingtoneName);
    spinnerCompareType.setSelection(sv.spinnerCompareType);
    spinnerCompareResult.setSelection(sv.spinnerCompareResult);
    spinnerCompareTarget.setSelection(sv.spinnerCompareTarget);
    spinnerMessageType.setSelection(sv.spinnerMessageType);
    spinnerTimeType.setSelection(sv.spinnerTimeType);
    spinnerTimeTarget.setSelection(sv.spinnerTimeTarget);
    spinnerTaskType.setSelection(sv.spinnerTaskType);
    spinnerTaskTarget.setSelection(sv.spinnerTaskTarget);
    spinnerWaitTarget.setSelection(sv.spinnerWaitTarget);
    spinnerWaitTimeoutType.setSelection(sv.spinnerWaitTimeoutType);
    spinnerWaitTimeoutValue.setSelection(sv.spinnerWaitTimeoutValue);
    spinnerWaitTimeoutUnits.setSelection(sv.spinnerWaitTimeoutUnits);
    spinnerBshMethod.setSelection(sv.spinnerBshMethod);
    spinnerCatMethod.setSelection(sv.spinnerCatMethod);

    //       Handler hndl1=new Handler();
    //       hndl1.postDelayed(new Runnable(){
    //         @Override
    //         public void run() {
    //
    //            Handler hndl2=new Handler();
    //             hndl2.postDelayed(new Runnable(){
    //               @Override
    //               public void run() {
    //               }
    //             },50);
    //         }
    //       },50);
}

From source file:cm.aptoide.pt.MainActivity.java

private void displayOptionsDialog() {

    final SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(this);
    final Editor editor = sPref.edit();

    View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_order_popup, null);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(view);
    final AlertDialog orderDialog = dialogBuilder.create();
    orderDialog.setIcon(android.R.drawable.ic_menu_sort_by_size);
    orderDialog.setTitle(getString(R.string.menu_display_options));
    orderDialog.setCancelable(true);//from w  w w  .j a va  2  s.  co  m

    final RadioButton ord_rct = (RadioButton) view.findViewById(R.id.org_rct);
    final RadioButton ord_abc = (RadioButton) view.findViewById(R.id.org_abc);
    final RadioButton ord_rat = (RadioButton) view.findViewById(R.id.org_rat);
    final RadioButton ord_dwn = (RadioButton) view.findViewById(R.id.org_dwn);
    final RadioButton ord_price = (RadioButton) view.findViewById(R.id.org_price);
    final RadioButton btn1 = (RadioButton) view.findViewById(R.id.shw_ct);
    final RadioButton btn2 = (RadioButton) view.findViewById(R.id.shw_all);

    final ToggleButton adult = (ToggleButton) view.findViewById(R.id.adultcontent_toggle);

    orderDialog.setButton(Dialog.BUTTON_NEUTRAL, "Ok", new Dialog.OnClickListener() {
        boolean pop_change = false;
        private boolean pop_change_category = false;

        public void onClick(DialogInterface dialog, int which) {
            if (ord_rct.isChecked()) {
                pop_change = true;
                order = Order.DATE;
            } else if (ord_abc.isChecked()) {
                pop_change = true;
                order = Order.NAME;
            } else if (ord_rat.isChecked()) {
                pop_change = true;
                order = Order.RATING;
            } else if (ord_dwn.isChecked()) {
                pop_change = true;
                order = Order.DOWNLOADS;
            } else if (ord_price.isChecked()) {
                pop_change = true;
                order = Order.PRICE;
            }

            if (btn1.isChecked()) {
                pop_change = true;
                pop_change_category = true;
                editor.putBoolean("orderByCategory", true);
            } else if (btn2.isChecked()) {
                pop_change = true;
                pop_change_category = true;
                editor.putBoolean("orderByCategory", false);
            }
            if (adult.isChecked()) {
                pop_change = true;
                editor.putBoolean("matureChkBox", false);
            } else {
                editor.putBoolean("matureChkBox", true);
            }
            if (pop_change) {
                editor.putInt("order_list", order.ordinal());
                editor.commit();
                if (pop_change_category) {

                    if (!depth.equals(ListDepth.CATEGORY1) && !depth.equals(ListDepth.STORES)) {
                        if (depth.equals(ListDepth.APPLICATIONS)) {
                            removeLastBreadCrumb();
                        }
                        removeLastBreadCrumb();
                        depth = ListDepth.CATEGORY1;
                    }

                }
                redrawAll();
                refreshAvailableList(true);
            }
        }
    });

    if (sPref.getBoolean("orderByCategory", false)) {
        btn1.setChecked(true);
    } else {
        btn2.setChecked(true);
    }
    if (!ApplicationAptoide.MATURECONTENTSWITCH) {
        adult.setVisibility(View.GONE);
        view.findViewById(R.id.dialog_adult_content_label).setVisibility(View.GONE);
    }
    adult.setChecked(!sPref.getBoolean("matureChkBox", false));
    // adult.setOnCheckedChangeListener(adultCheckedListener);
    switch (order) {
    case DATE:
        ord_rct.setChecked(true);
        break;
    case DOWNLOADS:
        ord_dwn.setChecked(true);
        break;
    case NAME:
        ord_abc.setChecked(true);
        break;
    case RATING:
        ord_rat.setChecked(true);
        break;
    case PRICE:
        ord_price.setChecked(true);
        break;

    default:
        break;
    }

    orderDialog.show();

}

From source file:org.thoughtland.xlocation.ActivityShare.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;/*ww  w  . j  a  v  a  2  s  .  c  o  m*/

    // Get data
    int userId = Util.getUserId(Process.myUid());
    final Bundle extras = getIntent().getExtras();
    final String action = getIntent().getAction();
    final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList)
            : new int[0]);
    final String restrictionName = (extras != null ? extras.getString(cRestriction) : null);
    int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1);
    if (action.equals(ACTION_EXPORT))
        mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null);

    // License check
    if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) {
        if (!Util.isProEnabled() && Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) {
        if (Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    }

    // Registration check
    if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) {
        finish();
        return;
    }

    // Check whether we need a user interface
    if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false))
        mInteractive = true;

    // Set layout
    setContentView(R.layout.sharelist);

    // Reference controls
    final TextView tvDescription = (TextView) findViewById(R.id.tvDescription);
    final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle);
    final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle);
    final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction);
    RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear);
    RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull);
    RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand);
    RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand);
    final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate);
    final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear);
    final Button btnOk = (Button) findViewById(R.id.btnOk);
    final Button btnCancel = (Button) findViewById(R.id.btnCancel);

    // Set title
    if (action.equals(ACTION_TOGGLE)) {
        mActionId = R.string.menu_toggle;
        setTitle(R.string.menu_toggle);
    } else if (action.equals(ACTION_IMPORT)) {
        mActionId = R.string.menu_import;
        setTitle(R.string.menu_import);
    } else if (action.equals(ACTION_EXPORT)) {
        mActionId = R.string.menu_export;
        setTitle(R.string.menu_export);
    } else if (action.equals(ACTION_FETCH)) {
        mActionId = R.string.menu_fetch;
        setTitle(R.string.menu_fetch);
    } else if (action.equals(ACTION_SUBMIT)) {
        mActionId = R.string.menu_submit;
        setTitle(R.string.menu_submit);
    } else {
        finish();
        return;
    }

    // Get localized restriction name
    List<String> listRestrictionName = new ArrayList<String>(
            PrivacyManager.getRestrictions(this).navigableKeySet());
    listRestrictionName.add(0, getString(R.string.menu_all));

    // Build restriction adapter
    SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    saRestriction.addAll(listRestrictionName);

    // Setup restriction spinner
    int pos = 0;
    if (restrictionName != null)
        for (String restriction : PrivacyManager.getRestrictions(this).values()) {
            pos++;
            if (restrictionName.equals(restriction))
                break;
        }

    spRestriction.setAdapter(saRestriction);
    spRestriction.setSelection(pos);

    // Build template adapter
    SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spAdapter.add(getString(R.string.title_default));
    for (int i = 1; i <= 4; i++)
        spAdapter.add(getString(R.string.title_alternate) + " " + i);
    spTemplate.setAdapter(spAdapter);

    // Build application list
    AppListTask appListTask = new AppListTask();
    appListTask.executeOnExecutor(mExecutor, uids);

    // Import/export filename
    if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) {
        // Check for availability of sharing intent
        Intent file = new Intent(Intent.ACTION_GET_CONTENT);
        file.setType("file/*");
        boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file);

        // Get file name
        if (mFileName == null)
            if (action.equals(ACTION_EXPORT)) {
                String packageName = null;
                if (uids.length == 1)
                    try {
                        ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]);
                        packageName = appInfo.getPackageName().get(0);
                    } catch (Throwable ex) {
                        Util.bug(null, ex);
                    }
                mFileName = getFileName(this, hasIntent, packageName);
            } else
                mFileName = (hasIntent ? null : getFileName(this, false, null));

        if (mFileName == null)
            fileChooser();
        else
            showFileName();

        if (action.equals(ACTION_IMPORT))
            cbClear.setVisibility(View.VISIBLE);

    } else if (action.equals(ACTION_FETCH)) {
        tvDescription.setText(getBaseURL());
        cbClear.setVisibility(View.VISIBLE);

    } else if (action.equals(ACTION_TOGGLE)) {
        tvDescription.setText(R.string.menu_toggle);
        spRestriction.setVisibility(View.VISIBLE);
        svToggle.setVisibility(View.VISIBLE);

        // Listen for radio button
        rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                btnOk.setEnabled(checkedId >= 0);
                spRestriction.setVisibility(
                        checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE
                                : View.VISIBLE);

                spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory
                        || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet
                        || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE);
            }
        });

        boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
        rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE);
        rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE);

        if (choice == CHOICE_CLEAR)
            rbClear.setChecked(true);
        else if (choice == CHOICE_TEMPLATE)
            rbTemplateFull.setChecked(true);

    } else
        tvDescription.setText(getBaseURL());

    if (mInteractive) {
        // Enable ok
        // (showFileName does this for export/import)
        if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH))
            btnOk.setEnabled(true);

        // Listen for ok
        btnOk.setOnClickListener(new Button.OnClickListener() {
            @Override
            public void onClick(View v) {
                btnOk.setEnabled(false);

                // Toggle
                if (action.equals(ACTION_TOGGLE)) {
                    mRunning = true;
                    for (int i = 0; i < rgToggle.getChildCount(); i++)
                        ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false);
                    int pos = spRestriction.getSelectedItemPosition();
                    String restrictionName = (pos == 0 ? null
                            : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos
                                    - 1]);
                    new ToggleTask().executeOnExecutor(mExecutor, restrictionName);

                    // Import
                } else if (action.equals(ACTION_IMPORT)) {
                    mRunning = true;
                    cbClear.setEnabled(false);
                    new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked());
                }

                // Export
                else if (action.equals(ACTION_EXPORT)) {
                    mRunning = true;
                    new ExportTask().executeOnExecutor(mExecutor, new File(mFileName));

                    // Fetch
                } else if (action.equals(ACTION_FETCH)) {
                    if (uids.length > 0) {
                        mRunning = true;
                        cbClear.setEnabled(false);
                        new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked());
                    }
                }

                // Submit
                else if (action.equals(ACTION_SUBMIT)) {
                    if (uids.length > 0) {
                        if (uids.length <= cSubmitLimit) {
                            mRunning = true;
                            new SubmitTask().executeOnExecutor(mExecutor);
                        } else {
                            String message = getString(R.string.msg_limit, cSubmitLimit + 1);
                            Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show();
                            btnOk.setEnabled(false);
                        }
                    }
                }
            }
        });

    } else
        btnOk.setEnabled(false);

    // Listen for cancel
    btnCancel.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mRunning) {
                mAbort = true;
                Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show();
            } else
                finish();
        }
    });
}

From source file:biz.bokhorst.xprivacy.ActivityShare.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;//from  w w w.j av  a2 s .c o  m

    // Get data
    int userId = Util.getUserId(Process.myUid());
    final Bundle extras = getIntent().getExtras();
    final String action = getIntent().getAction();
    final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList)
            : new int[0]);
    final String restrictionName = (extras != null ? extras.getString(cRestriction) : null);
    int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1);
    if (action.equals(ACTION_EXPORT))
        mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null);

    // License check
    if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) {
        if (!Util.isProEnabled() && Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) {
        if (Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    }

    // Registration check
    if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) {
        finish();
        return;
    }

    // Check whether we need a user interface
    if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false))
        mInteractive = true;

    // Set layout
    setContentView(R.layout.sharelist);
    setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar));

    // Reference controls
    final TextView tvDescription = (TextView) findViewById(R.id.tvDescription);
    final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle);
    final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle);
    final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction);
    RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear);
    RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull);
    RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand);
    RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand);
    final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate);
    final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear);
    final Button btnOk = (Button) findViewById(R.id.btnOk);
    final Button btnCancel = (Button) findViewById(R.id.btnCancel);

    // Set title
    if (action.equals(ACTION_TOGGLE)) {
        mActionId = R.string.menu_toggle;
        getSupportActionBar().setSubtitle(R.string.menu_toggle);
    } else if (action.equals(ACTION_IMPORT)) {
        mActionId = R.string.menu_import;
        getSupportActionBar().setSubtitle(R.string.menu_import);
    } else if (action.equals(ACTION_EXPORT)) {
        mActionId = R.string.menu_export;
        getSupportActionBar().setSubtitle(R.string.menu_export);
    } else if (action.equals(ACTION_FETCH)) {
        mActionId = R.string.menu_fetch;
        getSupportActionBar().setSubtitle(R.string.menu_fetch);
    } else if (action.equals(ACTION_SUBMIT)) {
        mActionId = R.string.menu_submit;
        getSupportActionBar().setSubtitle(R.string.menu_submit);
    } else {
        finish();
        return;
    }

    // Get localized restriction name
    List<String> listRestrictionName = new ArrayList<String>(
            PrivacyManager.getRestrictions(this).navigableKeySet());
    listRestrictionName.add(0, getString(R.string.menu_all));

    // Build restriction adapter
    SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    saRestriction.addAll(listRestrictionName);

    // Setup restriction spinner
    int pos = 0;
    if (restrictionName != null)
        for (String restriction : PrivacyManager.getRestrictions(this).values()) {
            pos++;
            if (restrictionName.equals(restriction))
                break;
        }

    spRestriction.setAdapter(saRestriction);
    spRestriction.setSelection(pos);

    // Build template adapter
    SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0",
            getString(R.string.title_default));
    spAdapter.add(defaultName);
    for (int i = 1; i <= 4; i++) {
        String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i),
                getString(R.string.title_alternate) + " " + i);
        spAdapter.add(alternateName);
    }
    spTemplate.setAdapter(spAdapter);

    // Build application list
    AppListTask appListTask = new AppListTask();
    appListTask.executeOnExecutor(mExecutor, uids);

    // Import/export filename
    if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) {
        // Check for availability of sharing intent
        Intent file = new Intent(Intent.ACTION_GET_CONTENT);
        file.setType("file/*");
        boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file);

        // Get file name
        if (mFileName == null)
            if (action.equals(ACTION_EXPORT)) {
                String packageName = null;
                if (uids.length == 1)
                    try {
                        ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]);
                        packageName = appInfo.getPackageName().get(0);
                    } catch (Throwable ex) {
                        Util.bug(null, ex);
                    }
                mFileName = getFileName(this, hasIntent, packageName);
            } else
                mFileName = (hasIntent ? null : getFileName(this, false, null));

        if (mFileName == null)
            fileChooser();
        else
            showFileName();

        if (action.equals(ACTION_IMPORT))
            cbClear.setVisibility(View.VISIBLE);

    } else if (action.equals(ACTION_FETCH)) {
        tvDescription.setText(getBaseURL());
        cbClear.setVisibility(View.VISIBLE);

    } else if (action.equals(ACTION_TOGGLE)) {
        tvDescription.setVisibility(View.GONE);
        spRestriction.setVisibility(View.VISIBLE);
        svToggle.setVisibility(View.VISIBLE);

        // Listen for radio button
        rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                btnOk.setEnabled(checkedId >= 0);
                spRestriction.setVisibility(
                        checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE
                                : View.VISIBLE);

                spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory
                        || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet
                        || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE);
            }
        });

        boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
        rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE);
        rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE);

        if (choice == CHOICE_CLEAR)
            rbClear.setChecked(true);
        else if (choice == CHOICE_TEMPLATE)
            rbTemplateFull.setChecked(true);

    } else
        tvDescription.setText(getBaseURL());

    if (mInteractive) {
        // Enable ok
        // (showFileName does this for export/import)
        if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH))
            btnOk.setEnabled(true);

        // Listen for ok
        btnOk.setOnClickListener(new Button.OnClickListener() {
            @Override
            public void onClick(View v) {
                btnOk.setEnabled(false);

                // Toggle
                if (action.equals(ACTION_TOGGLE)) {
                    mRunning = true;
                    for (int i = 0; i < rgToggle.getChildCount(); i++)
                        ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false);
                    int pos = spRestriction.getSelectedItemPosition();
                    String restrictionName = (pos == 0 ? null
                            : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos
                                    - 1]);
                    new ToggleTask().executeOnExecutor(mExecutor, restrictionName);

                    // Import
                } else if (action.equals(ACTION_IMPORT)) {
                    mRunning = true;
                    cbClear.setEnabled(false);
                    new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked());
                }

                // Export
                else if (action.equals(ACTION_EXPORT)) {
                    mRunning = true;
                    new ExportTask().executeOnExecutor(mExecutor, new File(mFileName));

                    // Fetch
                } else if (action.equals(ACTION_FETCH)) {
                    if (uids.length > 0) {
                        mRunning = true;
                        cbClear.setEnabled(false);
                        new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked());
                    }
                }

                // Submit
                else if (action.equals(ACTION_SUBMIT)) {
                    if (uids.length > 0) {
                        if (uids.length <= cSubmitLimit) {
                            mRunning = true;
                            new SubmitTask().executeOnExecutor(mExecutor);
                        } else {
                            String message = getString(R.string.msg_limit, cSubmitLimit + 1);
                            Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show();
                            btnOk.setEnabled(false);
                        }
                    }
                }
            }
        });

    } else
        btnOk.setEnabled(false);

    // Listen for cancel
    btnCancel.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mRunning) {
                mAbort = true;
                Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show();
            } else
                finish();
        }
    });
}

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

final static private void initProfileActionWidget(GlobalParameters mGlblParms, Dialog dialog,
        ProfileListItem tpli, ArrayList<DataArrayEditListItem> comp_data_list,
        ArrayList<ActivityExtraDataItem> aed_edit_list, String curr_grp, AdapterProfileList pfla,
        CustomSpinnerAdapter adapterActionType, CustomSpinnerAdapter adapterActivityName,
        CustomSpinnerAdapter adapterActivityDataType, CustomSpinnerAdapter adapterRingtoneType,
        CustomSpinnerAdapter adapterRingtoneName, CustomSpinnerAdapter adapterCompareType,
        CustomSpinnerAdapter adapterCompareResult, CustomSpinnerAdapter adapterCompareTarget,
        CustomSpinnerAdapter adapterMessageType, CustomSpinnerAdapter adapterTimeType,
        CustomSpinnerAdapter adapterTimeTarget, CustomSpinnerAdapter adapterTaskType,
        CustomSpinnerAdapter adapterTaskTarget, CustomSpinnerAdapter adapterWaitTarget,
        CustomSpinnerAdapter adapterWaitTimeoutType, CustomSpinnerAdapter adapterWaitTimeoutValue,
        CustomSpinnerAdapter adapterWaitTimeoutUnits) {
    final CheckBox cb_active = (CheckBox) dialog.findViewById(R.id.edit_profile_action_enabled);
    final TextView tv_sound_filename = (TextView) dialog
            .findViewById(R.id.edit_profile_action_exec_sound_file_name);
    final CheckBox cb_music_vol = (CheckBox) dialog
            .findViewById(R.id.edit_profile_action_profile_sound_use_volume);
    final SeekBar sb_music_vol = (SeekBar) dialog.findViewById(R.id.edit_profile_action_profile_sound_volume);
    //      final Button playBtnMusic = (Button)dialog.findViewById(R.id.edit_profile_action_profile_sound_play_back);
    //      final Button playBtnRingtone = (Button)dialog.findViewById(R.id.edit_profile_action_profile_ringtone_play_back);
    final CheckBox cb_ringtone_vol = (CheckBox) dialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_use_volume);
    final SeekBar sb_ringtone_vol = (SeekBar) dialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_volume);
    final Spinner spinnerActionType = (Spinner) dialog.findViewById(R.id.edit_profile_action_action_type);
    final Spinner spinnerActivityName = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_exec_activity_name);
    final Spinner spinnerActivityDataType = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_exec_activity_data_type);
    final Spinner spinnerRingtoneType = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_type);
    final Spinner spinnerRingtoneName = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_name);
    final Spinner spinnerCompareType = (Spinner) dialog.findViewById(R.id.edit_profile_action_compare_type);
    final EditText et_comp_value1 = (EditText) dialog.findViewById(R.id.edit_profile_action_compare_value1);
    final EditText et_comp_value2 = (EditText) dialog.findViewById(R.id.edit_profile_action_compare_value2);
    final ListView lv_comp_data = (ListView) dialog
            .findViewById(R.id.edit_profile_action_compare_value_listview);
    final Spinner spinnerCompareResult = (Spinner) dialog.findViewById(R.id.edit_profile_action_compare_result);
    final Spinner spinnerCompareTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_compare_target);
    final Spinner spinnerMessageType = (Spinner) dialog.findViewById(R.id.edit_profile_action_message_type);
    final EditText et_msg_text = (EditText) dialog.findViewById(R.id.edit_profile_action_message_message);
    final CheckBox cb_vib_used = (CheckBox) dialog.findViewById(R.id.edit_profile_action_message_vibration);
    final CheckBox cb_led_used = (CheckBox) dialog.findViewById(R.id.edit_profile_action_message_led);
    final RadioButton rb_msg_blue = (RadioButton) dialog
            .findViewById(R.id.edit_profile_action_message_led_blue);
    final RadioButton rb_msg_red = (RadioButton) dialog.findViewById(R.id.edit_profile_action_message_led_red);
    final RadioButton rb_msg_green = (RadioButton) dialog
            .findViewById(R.id.edit_profile_action_message_led_green);
    final Spinner spinnerTimeType = (Spinner) dialog.findViewById(R.id.edit_profile_action_time_type);
    final Spinner spinnerTimeTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_time_target);
    final Spinner spinnerTaskType = (Spinner) dialog.findViewById(R.id.edit_profile_action_task_type);
    final Spinner spinnerTaskTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_task_target);
    final Spinner spinnerWaitTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_wait_target);
    final Spinner spinnerWaitTimeoutType = (Spinner) dialog.findViewById(R.id.edit_profile_action_wait_timeout);
    final Spinner spinnerWaitTimeoutValue = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_wait_timeout_value);
    final Spinner spinnerWaitTimeoutUnits = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_wait_timeout_units);
    //        final EditText et_bsh_script=(EditText) dialog.findViewById(R.id.edit_profile_action_dlg_bsh_script_text);

    if (tpli == null || tpli.getActionSoundVolLeft().equals("-1") || tpli.getActionSoundVolLeft().equals("")) {
        cb_music_vol.setChecked(false);/*w w w  .  j  av  a2s  .c  o  m*/
        sb_music_vol.setProgress(100);
        sb_music_vol.setEnabled(false);
    } else {
        cb_music_vol.setChecked(true);
        sb_music_vol.setProgress(Integer.valueOf(tpli.getActionSoundVolLeft()));
        sb_music_vol.setEnabled(true);
    }
    if (tpli == null || tpli.getActionRingtoneVolLeft().equals("-1")
            || tpli.getActionRingtoneVolLeft().equals("")) {
        cb_ringtone_vol.setChecked(false);
        sb_ringtone_vol.setProgress(100);
        sb_ringtone_vol.setEnabled(false);
    } else {
        cb_ringtone_vol.setChecked(true);
        sb_ringtone_vol.setProgress(Integer.valueOf(tpli.getActionRingtoneVolLeft()));
        sb_ringtone_vol.setEnabled(true);
    }

    if (tpli == null || tpli.isProfileEnabled())
        cb_active.setChecked(true);
    else
        cb_active.setChecked(false);

    if (tpli != null && tpli.getActionType().equals(PROFILE_ACTION_TYPE_MUSIC)) {
        if (tpli.getActionSoundFileName().equals(""))
            tv_sound_filename.setText("Not specified");
        else
            tv_sound_filename.setText(tpli.getActionSoundFileName());
    } else
        tv_sound_filename.setText("Not specified");

    if (tpli != null && tpli.getActionCompareValue() != null) {
        String[] c_data_array = tpli.getActionCompareValue();
        for (int i = 0; i < c_data_array.length; i++) {
            if (c_data_array[i] != null && !c_data_array[i].equals("")) {
                DataArrayEditListItem daeli = new DataArrayEditListItem();
                daeli.data_value = c_data_array[i];
                comp_data_list.add(daeli);
            }
        }
    }
    if (comp_data_list.size() == 0) {
        DataArrayEditListItem daeli = new DataArrayEditListItem();
        daeli.data_value = "";
        daeli.dummy_data = true;
        comp_data_list.add(daeli);
    }
    if (tpli != null && tpli.getActionActivityExtraData() != null) {
        for (int i = 0; i < tpli.getActionActivityExtraData().size(); i++)
            aed_edit_list.add(tpli.getActionActivityExtraData().get(i).clone());
    }

    String action_type = "";
    if (tpli != null)
        action_type = tpli.getActionType();
    adapterActionType.setTextColor(Color.BLACK);
    setSpinnerActionType(mGlblParms, dialog, spinnerActionType, adapterActionType, action_type);

    String action_activity_name = "";
    if (tpli != null)
        action_activity_name = tpli.getActionActivityName();
    adapterActivityName.setTextColor(Color.BLACK);
    ProfileMaintenance.setSpinnerActivityName(mGlblParms, dialog, spinnerActivityName, adapterActivityName,
            action_activity_name);

    String action_activity_data_type = "";
    if (tpli != null)
        action_activity_data_type = tpli.getActionActivityDataType();
    adapterActivityDataType.setTextColor(Color.BLACK);
    setSpinnerActivityDataType(mGlblParms, dialog, spinnerActivityDataType, adapterActivityDataType,
            action_activity_data_type);

    adapterRingtoneType.setTextColor(Color.BLACK);
    String action_ringtone_type = "";
    if (tpli != null)
        action_ringtone_type = tpli.getActionRingtoneType();
    setSpinnerRingtoneType(mGlblParms, dialog, spinnerRingtoneType, adapterRingtoneType, action_ringtone_type);

    adapterRingtoneName.setTextColor(Color.BLACK);
    String action_ringtone_name = "";
    int action_ringtone_type_int = 0;
    if (tpli != null)
        action_ringtone_name = tpli.getActionRingtoneName();
    if (tpli != null)
        action_ringtone_type_int = tpli.getActionRingtoneTypeInt();
    ProfileMaintenance.setSpinnerRingtoneName(mGlblParms, dialog, spinnerRingtoneName, adapterRingtoneName,
            action_ringtone_name, action_ringtone_type_int);

    adapterCompareType.setTextColor(Color.BLACK);
    String action_compare_type = "";
    if (tpli != null)
        action_compare_type = tpli.getActionCompareType();
    setSpinnerCompareType(mGlblParms, dialog, spinnerCompareType, adapterCompareType, action_compare_type, true,
            true, true, true, true);

    lv_comp_data.setAdapter(mGlblParms.actionCompareDataAdapter);

    adapterCompareResult.setTextColor(Color.BLACK);
    et_comp_value2.setVisibility(EditText.GONE);
    String action_compare_result = "";
    if (tpli != null && tpli.getActionCompareValue() != null) {
        action_compare_result = tpli.getActionCompareResultAction();
        et_comp_value1.setText(tpli.getActionCompareValue(0));
        et_comp_value2.setText(tpli.getActionCompareValue(1));
    } else {
        et_comp_value1.setText("");
        et_comp_value2.setText("");
    }
    setSpinnerCompareResult(mGlblParms, dialog, spinnerCompareResult, adapterCompareResult,
            action_compare_result);

    adapterCompareTarget.setTextColor(Color.BLACK);
    String action_compare_target = "";
    if (tpli != null)
        action_compare_target = tpli.getActionCompareTarget();
    setSpinnerCompareTarget(mGlblParms, dialog, spinnerCompareTarget, adapterCompareTarget,
            action_compare_target);
    setCompareEditTextAttr(mGlblParms, action_compare_target, et_comp_value1, et_comp_value1);

    adapterMessageType.setTextColor(Color.BLACK);
    String action_message_type = "";
    if (tpli != null)
        action_message_type = tpli.getActionMessageType();
    setSpinnerMessageType(mGlblParms, dialog, spinnerMessageType, adapterMessageType, action_message_type);

    et_msg_text.setText("");
    rb_msg_blue.setChecked(true);
    cb_vib_used.setChecked(false);
    cb_led_used.setChecked(false);
    if (tpli != null) {
        et_msg_text.setText(tpli.getActionMessageText());
        rb_msg_blue.setChecked(true);
        if (tpli.getActionMessageLedColor().equals(PROFILE_ACTION_TYPE_MESSAGE_LED_RED))
            rb_msg_red.setChecked(true);
        else if (tpli.getActionMessageLedColor().equals(PROFILE_ACTION_TYPE_MESSAGE_LED_GREEN))
            rb_msg_green.setChecked(true);
        cb_vib_used.setChecked(tpli.isActionMessageUseVibration());
        cb_led_used.setChecked(tpli.isActionMessageUseLed());
    }

    adapterTimeType.setTextColor(Color.BLACK);
    String action_time_type = "";
    if (tpli != null)
        action_time_type = tpli.getActionTimeType();
    ProfileMaintenance.setSpinnerTimeType(mGlblParms, dialog, spinnerTimeType, adapterTimeType,
            action_time_type);

    adapterTimeTarget.setTextColor(Color.BLACK);
    String action_time_target = "";
    if (tpli != null)
        action_time_target = tpli.getActionTimeTarget();
    ProfileMaintenance.setSpinnerTimeTarget(mGlblParms, dialog, spinnerTimeTarget, adapterTimeTarget, pfla,
            curr_grp, action_time_target);

    adapterTaskType.setTextColor(Color.BLACK);
    adapterTaskTarget.setTextColor(Color.BLACK);
    String action_task_type = "";
    if (tpli != null)
        action_task_type = tpli.getActionTaskType();
    ProfileMaintenance.setSpinnerTaskType(mGlblParms, dialog, spinnerTaskType, adapterTaskType,
            action_task_type);

    String action_task_target = "";
    if (tpli != null)
        action_task_target = tpli.getActionTaskTarget();
    ProfileMaintenance.setSpinnerTaskTarget(mGlblParms, true, dialog, spinnerTaskTarget, adapterTaskTarget,
            pfla, curr_grp, action_task_target);

    adapterWaitTarget.setTextColor(Color.BLACK);
    String action_wait_target = "";
    if (tpli != null)
        action_wait_target = tpli.getActionWaitTarget();
    ProfileMaintenance.setSpinnerWaitTarget(mGlblParms, dialog, spinnerWaitTarget, adapterWaitTarget, pfla,
            curr_grp, action_wait_target);

    adapterWaitTimeoutType.setTextColor(Color.BLACK);
    String to_sel = PROFILE_ACTION_TYPE_WAIT_TIMEOUT_TYPE_NOTIMEOUT;
    if (tpli != null && !tpli.getActionWaitTimeoutValue().equals(""))
        to_sel = PROFILE_ACTION_TYPE_WAIT_TIMEOUT_TYPE_TIMEOUTIS;
    ProfileMaintenance.setSpinnerWaitTimeoutType(mGlblParms, dialog, spinnerWaitTimeoutType,
            adapterWaitTimeoutType, pfla, curr_grp, to_sel);

    adapterWaitTimeoutValue.setTextColor(Color.BLACK);
    String action_wait_timeout_value = "";
    if (tpli != null)
        action_wait_timeout_value = tpli.getActionWaitTimeoutValue();
    ProfileMaintenance.setSpinnerWaitTimeoutValue(mGlblParms, dialog, spinnerWaitTimeoutValue,
            adapterWaitTimeoutValue, pfla, curr_grp, action_wait_timeout_value);

    adapterWaitTimeoutUnits.setTextColor(Color.BLACK);
    String action_wait_timeout_units = "";
    if (tpli != null)
        action_wait_timeout_units = tpli.getActionWaitTimeoutUnits();
    ProfileMaintenance.setSpinnerWaitTimeoutUnits(mGlblParms, dialog, spinnerWaitTimeoutUnits,
            adapterWaitTimeoutUnits, pfla, curr_grp, action_wait_timeout_units);

    //        CommonDialog.setDlgBoxSizeLimit(dialog,true);
}