Example usage for android.widget CheckedTextView setVisibility

List of usage examples for android.widget CheckedTextView setVisibility

Introduction

In this page you can find the example usage for android.widget CheckedTextView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:com.sentaroh.android.Utilities.Dialog.SafFileSelectDialogFragment.java

private void fileSelectEditDialogCreateBtn(final Activity activity, final Context context, final String c_dir,
        String n_dir, final TreeFilelistAdapter tfa, final NotifyEvent p_ntfy, final ListView lv) {
    // ??//  w ww . ja v a  2 s  . co m
    mCreateDirDialog = new Dialog(activity);
    mCreateDirDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mCreateDirDialog.setContentView(R.layout.single_item_input_dlg);
    final TextView dlg_title = (TextView) mCreateDirDialog.findViewById(R.id.single_item_input_title);
    dlg_title.setText(context.getString(R.string.msgs_file_select_edit_dlg_create));
    final TextView dlg_msg = (TextView) mCreateDirDialog.findViewById(R.id.single_item_input_msg);
    final TextView dlg_cmp = (TextView) mCreateDirDialog.findViewById(R.id.single_item_input_name);
    final CheckedTextView dlg_type = (CheckedTextView) mCreateDirDialog
            .findViewById(R.id.single_item_input_type);
    setCheckedTextView(dlg_type);
    dlg_type.setVisibility(CheckedTextView.VISIBLE);
    dlg_type.setText(context.getString(R.string.msgs_file_select_edit_dlg_dir_create_file));
    final Button btnOk = (Button) mCreateDirDialog.findViewById(R.id.single_item_input_ok_btn);
    final Button btnCancel = (Button) mCreateDirDialog.findViewById(R.id.single_item_input_cancel_btn);
    final EditText etDir = (EditText) mCreateDirDialog.findViewById(R.id.single_item_input_dir);

    dlg_cmp.setText(context.getString(R.string.msgs_file_select_edit_parent_directory) + ":" + c_dir);
    CommonDialog.setDlgBoxSizeCompact(mCreateDirDialog);
    etDir.setText(n_dir.replaceAll(c_dir, ""));
    btnOk.setEnabled(false);
    etDir.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

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

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
                //               SafFile lf=mSafFileMgr.getSafFileBySdcardPath(mDialogSafRoot, c_dir+"/"+s.toString(), true);
                SafFile lf = mSafFileMgr.getSafFileBySdcardPath(mDialogSafRoot, c_dir, true);
                SafFile[] c_fl = lf.listFiles();
                boolean found = false;
                for (SafFile item : c_fl) {
                    if (item.getName().equals(s.toString())) {
                        found = true;
                        break;
                    }
                }
                //               Log.v("","fp="+lf.getPath());
                if (found) {
                    btnOk.setEnabled(false);
                    dlg_msg.setText(context.getString(R.string.msgs_single_item_input_dlg_duplicate_dir));
                } else {
                    btnOk.setEnabled(true);
                    dlg_msg.setText("");
                }
            }
        }

    });

    //OK button
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //            NotifyEvent 
            final String creat_dir = etDir.getText().toString();
            final String n_path = c_dir + "/" + creat_dir;
            NotifyEvent ntfy = new NotifyEvent(context);
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    boolean rc_create = false;
                    if (!dlg_type.isChecked()) {
                        Log.v("", "n_path=" + n_path);
                        SafFile sf = mSafFileMgr.getSafFileBySdcardPath(mSafFileMgr.getSdcardSafFile(), n_path,
                                true);
                        rc_create = sf.exists();
                    } else {
                        SafFile sf = mSafFileMgr.getSafFileBySdcardPath(mSafFileMgr.getSdcardSafFile(), n_path,
                                false);
                        rc_create = sf.exists();
                    }
                    if (!rc_create) {
                        dlg_msg.setText(String.format(
                                context.getString(R.string.msgs_file_select_edit_dlg_dir_not_created),
                                etDir.getText()));
                        return;
                    } else {
                        //                     String[] a_dir=creat_dir.startsWith("/")?creat_dir.substring(1).split("/"):creat_dir.split("/");
                        String[] a_dir = n_path.startsWith("/") ? n_path.substring(1).split("/")
                                : n_path.split("/");
                        String p_dir = "/", sep = "";
                        for (int i = 0; i < a_dir.length; i++) {
                            if (a_dir[i] != null && !a_dir[i].equals("")) {
                                //                           Log.v("","p_dir="+p_dir);
                                updateTreeFileList(p_dir, a_dir[i], c_dir, tfa, lv);
                                p_dir += sep + a_dir[i];
                                sep = "/";
                            }
                        }
                        mCreateDirDialog.dismiss();
                        mCreateDirDialog = null;
                        p_ntfy.notifyToListener(true, new Object[] { etDir.getText().toString() });
                    }
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                }
            });
            CommonDialog cd = new CommonDialog(context, getFragmentManager());
            if (dlg_type.isChecked())
                cd.showCommonDialog(true, "W",
                        context.getString(R.string.msgs_file_select_edit_confirm_create_file), n_path, ntfy);
            else
                cd.showCommonDialog(true, "W",
                        context.getString(R.string.msgs_file_select_edit_confirm_create_directory), n_path,
                        ntfy);
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mCreateDirDialog.dismiss();
            //            Log.v("","cancel create");
            mCreateDirDialog = null;
            p_ntfy.notifyToListener(false, null);
        }
    });
    mCreateDirDialog.show();
}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void promptPasswordForImport(final String fpath, final NotifyEvent ntfy_pswd) {

    // ??//  www  . j av a  2  s  .c  o  m
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.password_input_dlg);

    LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.password_input_dlg_view);
    ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.password_input_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.password_input_title);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);

    final TextView dlg_msg = (TextView) dialog.findViewById(R.id.password_input_msg);
    final CheckedTextView ctv_protect = (CheckedTextView) dialog.findViewById(R.id.password_input_ctv_protect);
    final Button btn_ok = (Button) dialog.findViewById(R.id.password_input_ok_btn);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.password_input_cancel_btn);
    final EditText et_password = (EditText) dialog.findViewById(R.id.password_input_password);
    final EditText et_confirm = (EditText) dialog.findViewById(R.id.password_input_password_confirm);
    et_confirm.setVisibility(EditText.GONE);
    btn_ok.setText(mContext.getString(R.string.msgs_export_import_pswd_btn_ok));
    ctv_protect.setVisibility(CheckedTextView.GONE);

    dlg_msg.setText(mContext.getString(R.string.msgs_export_import_pswd_password_required));

    CommonDialog.setDlgBoxSizeCompact(dialog);

    btn_ok.setEnabled(false);
    et_password.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            if (arg0.length() > 0)
                btn_ok.setEnabled(true);
            else
                btn_ok.setEnabled(false);
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }
    });

    //OK button
    btn_ok.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String passwd = et_password.getText().toString();
            BufferedReader br;
            String pl;
            boolean pswd_invalid = true;
            try {
                br = new BufferedReader(new FileReader(fpath), 8192);
                pl = br.readLine();
                if (pl != null) {
                    String enc_str = "";
                    if (pl.startsWith(SMBSYNC_PROF_VER1 + SMBSYNC_PROF_ENC)) {
                        enc_str = pl.replace(SMBSYNC_PROF_VER1 + SMBSYNC_PROF_ENC, "");
                    }
                    if (!enc_str.equals("")) {
                        CipherParms cp = EncryptUtil.initDecryptEnv(mGp.profileKeyPrefix + passwd);
                        byte[] enc_array = Base64Compat.decode(enc_str, Base64Compat.NO_WRAP);
                        String dec_str = EncryptUtil.decrypt(enc_array, cp);
                        if (!SMBSYNC_PROF_ENC.equals(dec_str)) {
                            dlg_msg.setText(
                                    mContext.getString(R.string.msgs_export_import_pswd_invalid_password));
                        } else {
                            pswd_invalid = false;
                        }
                    }
                }
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (!pswd_invalid) {
                dialog.dismiss();
                ntfy_pswd.notifyToListener(true, new Object[] { passwd });
            }
        }
    });
    // CANCEL?
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            ntfy_pswd.notifyToListener(false, null);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    //      dialog.setCancelable(false);
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    dialog.show();

}