List of usage examples for android.app Dialog Dialog
public Dialog(@NonNull Context context)
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number, boolean scan_start) { //??/*ww w .j av a 2s. co m*/ final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.scan_remote_ntwk_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_title_view); final TextView title = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok); final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel); final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_msg); final TextView tv_result = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_title); tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_press_scan_btn)); tv_result.setVisibility(TextView.GONE); final String from = CommonUtilities.getLocalIpAddress(); String subnet = from.substring(0, from.lastIndexOf(".")); String subnet_o1, subnet_o2, subnet_o3; subnet_o1 = subnet.substring(0, subnet.indexOf(".")); subnet_o2 = subnet.substring(subnet.indexOf(".") + 1, subnet.lastIndexOf(".")); subnet_o3 = subnet.substring(subnet.lastIndexOf(".") + 1, subnet.length()); final EditText baEt1 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o1); final EditText baEt2 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o2); final EditText baEt3 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o3); final EditText baEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o4); final EditText eaEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_end_address_o4); baEt1.setText(subnet_o1); baEt2.setText(subnet_o2); baEt3.setText(subnet_o3); baEt4.setText("1"); baEt4.setSelection(1); eaEt4.setText("254"); baEt4.requestFocus(); final CheckedTextView ctv_use_port_number = (CheckedTextView) dialog .findViewById(R.id.scan_remote_ntwk_ctv_use_port); final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number); CommonDialog.setDlgBoxSizeLimit(dialog, true); if (port_number.equals("")) { et_port_number.setEnabled(false); ctv_use_port_number.setChecked(false); } else { et_port_number.setEnabled(true); et_port_number.setText(port_number); ctv_use_port_number.setChecked(true); } ctv_use_port_number.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctv_use_port_number.toggle(); boolean isChecked = ctv_use_port_number.isChecked(); et_port_number.setEnabled(isChecked); } }); final NotifyEvent ntfy_lv_click = new NotifyEvent(mContext); ntfy_lv_click.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { dialog.dismiss(); p_ntfy.notifyToListener(true, o); } @Override public void negativeResponse(Context c, Object[] o) { } }); final ArrayList<ScanAddressResultListItem> ipAddressList = new ArrayList<ScanAddressResultListItem>(); // ScanAddressResultListItem li=new ScanAddressResultListItem(); // li.server_name=mContext.getString(R.string.msgs_ip_address_no_address); // ipAddressList.add(li); final ListView lv = (ListView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_list); final AdapterScanAddressResultList adap = new AdapterScanAddressResultList(mContext, R.layout.scan_address_result_list_item, ipAddressList, ntfy_lv_click); lv.setAdapter(adap); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); //SCAN? btn_scan.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ipAddressList.clear(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { if (ipAddressList.size() < 1) { tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_not_detected)); tv_result.setVisibility(TextView.GONE); } else { tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_select_detected_host)); tv_result.setVisibility(TextView.VISIBLE); } // adap.clear(); // for (int i=0;i<ipAddressList.size();i++) // adap.add(ipAddressList.get(i)); } @Override public void negativeResponse(Context c, Object[] o) { } }); if (auditScanAddressRangeValue(dialog)) { tv_result.setVisibility(TextView.GONE); String ba1 = baEt1.getText().toString(); String ba2 = baEt2.getText().toString(); String ba3 = baEt3.getText().toString(); String ba4 = baEt4.getText().toString(); String ea4 = eaEt4.getText().toString(); String subnet = ba1 + "." + ba2 + "." + ba3; int begin_addr = Integer.parseInt(ba4); int end_addr = Integer.parseInt(ea4); scanRemoteNetwork(dialog, lv, adap, ipAddressList, subnet, begin_addr, end_addr, ntfy); } else { //error } } }); //CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); if (scan_start) btn_scan.performClick(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void createItem(final FileListAdapter fla, final String item_optyp, final String base_dir) { sendDebugLogMsg(1, "I", "createItem entered."); // ??/* w w w . ja v a 2 s .com*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.file_rename_create_dlg); final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname); final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn); final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn); CommonDialog.setDlgBoxSizeCompact(dialog); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Create directory"); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name"); // newName.setText(item_name); btnOk.setEnabled(false); // btnCancel.setEnabled(false); newName.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().length() < 1) btnOk.setEnabled(false); else btnOk.setEnabled(true); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); if (!checkDuplicateDir(fla, newName.getText().toString())) { commonDlg.showCommonDialog(false, "E", "Create", "Duplicate directory name specified", null); } else { int cmd = 0; if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "", newName.getText().toString(), "", smbUser, smbPass, true); cmd = FILEIO_PARM_LOCAL_CREATE; } else { cmd = FILEIO_PARM_REMOTE_CREATE; fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "", newName.getText().toString(), "", smbUser, smbPass, true); } sendDebugLogMsg(1, "I", "createItem FILEIO task invoked."); startFileioTask(fla, cmd, fileioLinkParm, newName.getText().toString(), null, null); } } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); sendDebugLogMsg(1, "W", "createItem cancelled."); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // setFixedOrientation(true); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void renameItem(final FileListAdapter fla, final String item_optyp, final String item_name, final boolean item_isdir, final int item_num) { sendDebugLogMsg(1, "I", "renameItem entered."); // ??/*w ww . j a v a 2 s. c om*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.file_rename_create_dlg); final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname); final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn); final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn); CommonDialog.setDlgBoxSizeCompact(dialog); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Rename"); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name"); newName.setText(item_name); btnOk.setEnabled(false); newName.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().length() < 1 || item_name.equals(s.toString())) btnOk.setEnabled(false); else btnOk.setEnabled(true); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // setFixedOrientation(false); if (item_name.equals(newName.getText().toString())) { commonDlg.showCommonDialog(false, "E", "Rename", "Duplicate file name specified", null); } else { int cmd = 0; if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(), fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), "", "", true); cmd = FILEIO_PARM_LOCAL_RENAME; } else { cmd = FILEIO_PARM_REMOTE_RENAME; if (item_isdir) fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(), fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), smbUser, smbPass, true); else fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(), fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), smbUser, smbPass, true); } sendDebugLogMsg(1, "I", "renameItem FILEIO task invoked."); startFileioTask(fla, cmd, fileioLinkParm, item_name, null, null); } } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // setFixedOrientation(false); sendDebugLogMsg(1, "W", "renameItem cancelled."); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // setFixedOrientation(true); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void selectLocalDirDlg(final String url, final String dir, String p_dir, final NotifyEvent p_ntfy) { //??// w w w . j a v a 2s. c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title); final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_select_local_dir)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + url + dir); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); // if (rows.size()<=2) // ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer)) // .setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); ListView lv = (ListView) dialog.findViewById(android.R.id.list); final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, true, false); lv.setAdapter(tfa); ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, url, dir); if (tfl.size() < 1) tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); tfa.setDataList(tfl); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); lv.setFastScrollEnabled(true); if (p_dir.length() != 0) for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).getName().equals(p_dir)) lv.setSelection(i); } lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { final int pos = tfa.getItem(idx); final TreeFilelistItem tfi = tfa.getDataItem(pos); if (tfi.getName().startsWith("---")) return; expandHideLocalDirTree(true, url, pos, tfi, tfa); } }); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) { final int t_pos = tfa.getItem(position); if (tfa.getDataItem(t_pos).isChecked()) { ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " " + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName()) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return; tfa.setDataItemIsUnselected(t_pos); if (tfa.isDataItemIsSelected()) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); } else { ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " " + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName()) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return; tfa.setDataItemIsSelected(t_pos); btn_ok.setEnabled(true); } }); } ccMenu.createMenu(); return false; } }); NotifyEvent ctv_ntfy = new NotifyEvent(mContext); ctv_ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { if (o != null) { int pos = (Integer) o[0]; if (tfa.getDataItem(pos).isChecked()) btn_ok.setEnabled(true); } } @Override public void negativeResponse(Context c, Object[] o) { btn_ok.setEnabled(false); for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).isChecked()) { btn_ok.setEnabled(true); break; } } } }); tfa.setCbCheckListener(ctv_ntfy); //OK? btn_ok.setEnabled(false); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String sel = ""; for (int i = 0; i < tfa.getCount(); i++) { if (tfa.getDataItem(i).isChecked() && !tfa.getDataItem(i).getName().equals(mContext.getString(R.string.msgs_dir_empty))) { if (tfa.getDataItem(i).getPath().length() == 1) sel = tfa.getDataItem(i).getName(); else sel = tfa.getDataItem(i).getPath().substring(1, tfa.getDataItem(i).getPath().length()) + tfa.getDataItem(i).getName(); break; } } if (sel.equals("")) { } dialog.dismiss(); p_ntfy.notifyToListener(true, new Object[] { sel }); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); return; }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
private void confirmUseAppSpecificDir(final ArrayList<SyncTaskItem> alp, final NotifyEvent p_ntfy) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); if (!prefs.getBoolean(getString(R.string.settings_suppress_warning_app_specific_dir), false)) { boolean app_specific_used = false; String prof_list = "", sep = ""; for (int i = 0; i < alp.size(); i++) { if (alp.get(i).getTargetFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_INTERNAL) || alp.get(i).getTargetFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_SDCARD)) { if (alp.get(i).getTargetDirectoryName().startsWith(APP_SPECIFIC_DIRECTORY)) { app_specific_used = true; prof_list += sep + alp.get(i).getSyncTaskName(); sep = ","; }// w w w .j a v a2s. co m } } if (app_specific_used) { final Dialog dialog = new Dialog(mActivity);//, android.R.style.Theme_Black); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_app_specific_dir_dlg); final LinearLayout title_view = (LinearLayout) dialog .findViewById(R.id.confirm_app_specific_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.confirm_app_specific_dlg_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setText(mContext.getString(R.string.msgs_local_mount_point_app_specific_dir_used_title)); title.setTextColor(mGp.themeColorList.text_color_warning); ((TextView) dialog.findViewById(R.id.confirm_app_specific_dlg_msg)) .setText(mContext.getString(R.string.msgs_local_mount_point_app_specific_dir_used_msg) + "\n\n" + prof_list + "\n"); final Button btnOk = (Button) dialog.findViewById(R.id.confirm_app_specific_dlg_ok); final Button btnCancel = (Button) dialog.findViewById(R.id.confirm_app_specific_dlg_cancel); final CheckedTextView ctvSuppr = (CheckedTextView) dialog .findViewById(R.id.confirm_app_specific_dlg_ctv_suppress); CommonUtilities.setCheckedTextView(ctvSuppr); CommonDialog.setDlgBoxSizeCompact(dialog); ctvSuppr.setChecked(false); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); if (ctvSuppr.isChecked()) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); prefs.edit().putBoolean(getString(R.string.settings_suppress_warning_app_specific_dir), true).commit(); } p_ntfy.notifyToListener(true, null); } }); // Cancel? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(mContext)); // dialog.setCancelable(false); dialog.show(); } else { p_ntfy.notifyToListener(true, null); } } else { p_ntfy.notifyToListener(true, null); } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void editDataArrayListItem(final GlobalParameters mGlblParms, final String edit_data, final int pos) { final Dialog dialog = new Dialog(mGlblParms.context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // dialog.getWindow().setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.setContentView(R.layout.data_array_item_edit_dlg); // final TextView dlg_msg = (TextView) dialog.findViewById(R.id.data_array_item_edit_dlg_msg); final TextView dlg_title = (TextView) dialog.findViewById(R.id.data_array_item_edit_dlg_title); dlg_title.setText("Edit data"); final EditText dlg_value = (EditText) dialog.findViewById(R.id.data_array_item_edit_dlg_value); final Button dlg_apply = (Button) dialog.findViewById(R.id.data_array_item_edit_dlg_apply); final Button dlg_cancel = (Button) dialog.findViewById(R.id.data_array_item_edit_dlg_cancel); // CommonDialog.setDlgBoxSizeCompact(dialog); dlg_value.setText(edit_data);/*from w ww .jav a 2 s . c o m*/ // CANCEL? dlg_cancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { mGlblParms.actionCompareDataAdapter.getItem(pos).while_edit = false; mGlblParms.actionCompareDataAdapter.notifyDataSetChanged(); dialog.dismiss(); } }); // Apply? dlg_apply.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { mGlblParms.actionCompareDataAdapter.getItem(pos).while_edit = false; mGlblParms.actionCompareDataAdapter.getItem(pos).data_value = dlg_value.getText().toString(); mGlblParms.actionCompareDataAdapter.notifyDataSetChanged(); dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { dlg_cancel.performClick(); } }); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void createRemoteFileList(String remurl, String remdir, final NotifyEvent p_event, boolean readSubDirCnt) { final ArrayList<TreeFilelistItem> remoteFileList = new ArrayList<TreeFilelistItem>(); final ThreadCtrl tc = new ThreadCtrl(); tc.setEnabled();//from www . j av a 2 s . c o m tc.setThreadResultSuccess(); // ?? final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.progress_spin_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.progress_spin_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.progress_spin_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.progress_spin_dlg_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(R.string.msgs_progress_spin_dlg_filelist_getting); final Button btn_cancel = (Button) dialog.findViewById(R.id.progress_spin_dlg_btn_cancel); btn_cancel.setText(R.string.msgs_progress_spin_dlg_filelist_cancel); // (dialog.context.findViewById(R.id.progress_spin_dlg)).setVisibility(TextView.GONE); // (dialog.context.findViewById(R.id.progress_spin_dlg)).setEnabled(false); CommonDialog.setDlgBoxSizeCompact(dialog); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { tc.setDisabled();//disableAsyncTask(); btn_cancel.setText(mContext.getString(R.string.msgs_progress_dlg_canceling)); btn_cancel.setEnabled(false); util.addDebugMsg(1, "W", "Sharelist is cancelled."); } }); dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); // dialog.show(); showDelayedProgDlg? final Handler hndl = new Handler(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { hndl.post(new Runnable() { @Override public void run() { dialog.dismiss(); String err; util.addDebugMsg(1, "I", "FileListThread result=" + tc.getThreadResult() + "," + "msg=" + tc.getThreadMessage() + ", enable=" + tc.isEnabled()); if (tc.isThreadResultSuccess()) { p_event.notifyToListener(true, new Object[] { remoteFileList }); } else { if (tc.isThreadResultCancelled()) err = mContext.getString(R.string.msgs_filelist_cancel); else err = mContext.getString(R.string.msgs_filelist_error) + "\n" + tc.getThreadMessage(); p_event.notifyToListener(false, new Object[] { err }); } } }); } @Override public void negativeResponse(Context c, Object[] o) { } }); Thread tf = new Thread(new ReadSmbFilelist(mContext, tc, remurl, remdir, remoteFileList, smbUser, smbPass, ntfy, true, readSubDirCnt, mGp)); tf.start(); // showDelayedProgDlg(200,dialog, tc); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void selectRemoteShareDlg(final String remurl, String remdir, final NotifyEvent p_ntfy) { NotifyEvent ntfy = new NotifyEvent(mContext); // set thread response ntfy.setListener(new NotifyEventListener() { @Override//from ww w . ja va 2 s . co m public void positiveResponse(Context c, Object[] o) { final ArrayList<String> rows = new ArrayList<String>(); @SuppressWarnings("unchecked") ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0]; for (int i = 0; i < rfl.size(); i++) { if (rfl.get(i).isDir() && rfl.get(i).canRead() && !rfl.get(i).getName().endsWith("$")) // !rfl.get(i).getName().startsWith("IPC$")) rows.add(rfl.get(i).getName().replaceAll("/", "")); } boolean wk_list_empty = false; if (rows.size() < 1) { wk_list_empty = true; rows.add(mContext.getString(R.string.msgs_dir_empty)); } final boolean list_empty = wk_list_empty; Collections.sort(rows, String.CASE_INSENSITIVE_ORDER); //?? final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog .findViewById(R.id.item_select_list_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title); final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_select_remote_share)); subtitle.setVisibility(TextView.GONE); // if (rows.size()<=2) // ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer)) // .setVisibility(TextView.VISIBLE); final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); btn_ok.setEnabled(false); CommonDialog.setDlgBoxSizeLimit(dialog, false); final ListView lv = (ListView) dialog.findViewById(android.R.id.list); if (!list_empty) { lv.setAdapter( new ArrayAdapter<String>(mContext, R.layout.custom_simple_list_item_checked, rows)); // android.R.layout.simple_list_item_checked,rows)); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } else { lv.setAdapter(new ArrayAdapter<String>(mContext, R.layout.simple_list_item_1o, rows)); } lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { if (rows.get(idx).startsWith("---")) return; if (!list_empty) btn_ok.setEnabled(true); } }); //CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); //OK? btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); SparseBooleanArray checked = lv.getCheckedItemPositions(); for (int i = 0; i <= rows.size(); i++) { if (checked.get(i) == true) { p_ntfy.notifyToListener(true, new Object[] { rows.get(i) }); break; } } } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); } @Override public void negativeResponse(Context c, Object[] o) { p_ntfy.notifyToListener(false, o); } }); createRemoteFileList(remurl, remdir, ntfy, false); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void setRemoteDir(final String remurl, final String curdir, final String p_dir, final NotifyEvent p_ntfy) { final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>(); NotifyEvent ntfy = new NotifyEvent(mContext); // set thread response ntfy.setListener(new NotifyEventListener() { @Override/*from ww w . j av a 2 s .c om*/ public void positiveResponse(Context c, Object[] o) { @SuppressWarnings("unchecked") ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0]; for (int i = 0; i < rfl.size(); i++) { if (rfl.get(i).isDir() && rfl.get(i).canRead()) rows.add(rfl.get(i)); } Collections.sort(rows); if (rows.size() < 1) rows.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); //?? final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog .findViewById(R.id.item_select_list_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title); final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_select_remote_dir)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + "/" + remurl); // if (rows.size()<1) { // TextView dlg_msg=(TextView)dialog.findViewById(R.id.item_select_list_dlg_msg); // dlg_msg.setText(msgs_dir_empty); // dlg_msg.setVisibility(TextView.VISIBLE); // } final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); // if (rows.size()<=2) // ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer)) // .setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); final ListView lv = (ListView) dialog.findViewById(android.R.id.list); final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, true, false); // tfa.setNotifyOnChange(true); tfa.setDataList(rows); lv.setAdapter(tfa); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); lv.setFastScrollEnabled(true); if (p_dir.length() != 0) for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).getName().equals(p_dir)) lv.setSelection(i); } lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { // ???????? final int pos = tfa.getItem(idx); final TreeFilelistItem tfi = tfa.getDataItem(pos); if (tfi.getName().startsWith("---")) return; expandHideRemoteDirTree(remurl, pos, tfi, tfa); } }); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) { final int t_pos = tfa.getItem(position); if (tfa.getDataItem(t_pos).isChecked()) { ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_unselect_this_entry) + " " + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName()) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return; tfa.setDataItemIsUnselected(t_pos); btn_ok.setEnabled(false); } }); } else { ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " " + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName()) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return; tfa.setDataItemIsSelected(t_pos); btn_ok.setEnabled(true); } }); } ccMenu.createMenu(); return false; } }); NotifyEvent ctv_ntfy = new NotifyEvent(mContext); // set file list thread response listener ctv_ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { if (o != null) { int pos = (Integer) o[0]; if (tfa.getDataItem(pos).isChecked()) btn_ok.setEnabled(true); } } @Override public void negativeResponse(Context c, Object[] o) { btn_ok.setEnabled(false); for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).isChecked()) { btn_ok.setEnabled(true); break; } } } }); tfa.setCbCheckListener(ctv_ntfy); //OK? btn_ok.setEnabled(false); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String sel = ""; for (int i = 0; i < tfa.getCount(); i++) { if (tfa.getDataItem(i).isChecked() && !tfa.getDataItem(i).getName() .equals(mContext.getString(R.string.msgs_dir_empty))) { if (tfa.getDataItem(i).getPath().length() == 1) sel = tfa.getDataItem(i).getName(); else sel = tfa.getDataItem(i).getPath().substring(1, tfa.getDataItem(i).getPath().length()) + tfa.getDataItem(i).getName(); break; } } dialog.dismiss(); p_ntfy.notifyToListener(true, new Object[] { sel }); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); } @Override public void negativeResponse(Context c, Object[] o) { p_ntfy.notifyToListener(false, o); } }); createRemoteFileList(remurl, curdir, ntfy, true); return; }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void setRemoteShare(final String prof_user, final String prof_pass, final String prof_addr, final NotifyEvent p_ntfy) { final ArrayList<String> rows = new ArrayList<String>(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override//from ww w.j a v a2 s . c om public void positiveResponse(Context c, Object[] o) { FileListAdapter tfl = (FileListAdapter) o[0]; for (int i = 0; i < tfl.getCount(); i++) { FileListItem item = tfl.getItem(i); if (item.isDir() && item.canRead() && !item.getName().startsWith("IPC$")) { String tmp = item.getName(); rows.add(tmp); } } if (rows.size() < 1) rows.add(getString(R.string.msgs_no_shared_resource)); //?? final Dialog dialog = new Dialog(c); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); ((TextView) dialog.findViewById(R.id.item_select_list_dlg_title)).setText("Select remote share"); ((TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle)).setText(""); CommonDialog.setDlgBoxSizeLimit(dialog, false); ListView lv = (ListView) dialog.findViewById(android.R.id.list); lv.setAdapter(new ArrayAdapter<String>(c, R.layout.simple_list_item_1m, rows)); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { if (rows.get(idx).startsWith("---")) return; dialog.dismiss(); // ???????? p_ntfy.notifyToListener(true, new Object[] { rows.get(idx).toString() }); } }); //CANCEL? final Button btnCancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, new Object[] { "" }); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // dialog.setCancelable(false); dialog.show(); } @Override public void negativeResponse(Context c, Object[] o) { p_ntfy.notifyToListener(false, new Object[] { "Remote file list creation error" }); } }); createRemoteFileList("smb://" + prof_addr + "/", ntfy); return; }