List of usage examples for android.widget LinearLayout setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void editDirFilter(final int edit_idx, final AdapterFilterList fa, final FilterListItem fli, final String filter) { // ??/*from w w w.j a va 2 s .c o m*/ final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_edit_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_edit_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_edit_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_edit_dlg_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); CommonDialog.setDlgBoxSizeCompact(dialog); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_edit_dlg_filter); et_filter.setText(filter); // CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_edit_dlg_cancel_btn); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? Button btn_ok = (Button) dialog.findViewById(R.id.filter_edit_dlg_ok_btn); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_edit_dlg_msg); String newfilter = et_filter.getText().toString(); if (!filter.equals(newfilter)) { if (isFilterExists(newfilter, fa)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, newfilter)); return; } } dialog.dismiss(); fa.remove(fli); fa.insert(fli, edit_idx); fli.setFilter(newfilter); et_filter.setText(""); fa.setNotifyOnChange(true); fa.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); // p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // 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();/*w w w . ja v a 2 s . com*/ 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 renameProfile(final SyncTaskItem pli, final NotifyEvent p_ntfy) { // ??// ww w .j ava 2 s .com final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.single_item_input_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.single_item_input_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.single_item_input_title_view); final TextView title = (TextView) dialog.findViewById(R.id.single_item_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.single_item_input_msg); final TextView dlg_cmp = (TextView) dialog.findViewById(R.id.single_item_input_name); final Button btn_ok = (Button) dialog.findViewById(R.id.single_item_input_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn); final EditText etInput = (EditText) dialog.findViewById(R.id.single_item_input_dir); title.setText(mContext.getString(R.string.msgs_rename_profile)); dlg_cmp.setVisibility(TextView.GONE); CommonDialog.setDlgBoxSizeCompact(dialog); etInput.setText(pli.getSyncTaskName()); btn_ok.setEnabled(false); etInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { if (!arg0.toString().equals(pli.getSyncTaskName())) 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) { dialog.dismiss(); String new_name = etInput.getText().toString(); pli.setSyncTaskName(new_name); mGp.syncTaskAdapter.sort(); mGp.syncTaskAdapter.notifyDataSetChanged(); saveSyncTaskListToFile(mGp, mContext, util, false, "", "", mGp.syncTaskAdapter.getArrayList(), false); SyncTaskUtility.setAllSyncTaskToUnchecked(true, mGp.syncTaskAdapter); p_ntfy.notifyToListener(true, null); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // 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(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void promptPasswordForImport(final String fpath, final NotifyEvent ntfy_pswd) { // ??//from www. j a v a 2s .co 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(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void promptPasswordForExport(final String fpath, final NotifyEvent ntfy_pswd) { // ??/*from w w w. j a va 2 s.co 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); dlg_msg.setText(mContext.getString(R.string.msgs_export_import_pswd_specify_password)); CommonDialog.setDlgBoxSizeCompact(dialog); ctv_protect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctv_protect.toggle(); boolean isChecked = ctv_protect.isChecked(); setPasswordFieldVisibility(isChecked, et_password, et_confirm, btn_ok, dlg_msg); } }); ctv_protect.setChecked(mGp.settingExportedProfileEncryptRequired); setPasswordFieldVisibility(mGp.settingExportedProfileEncryptRequired, et_password, et_confirm, btn_ok, dlg_msg); et_password.setEnabled(true); et_confirm.setEnabled(false); et_password.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { btn_ok.setEnabled(false); setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); et_confirm.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { btn_ok.setEnabled(false); setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg); } @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(); if ((ctv_protect.isChecked() && !mGp.settingExportedProfileEncryptRequired) || (!ctv_protect.isChecked() && mGp.settingExportedProfileEncryptRequired)) { mGp.settingExportedProfileEncryptRequired = ctv_protect.isChecked(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); prefs.edit().putBoolean(mContext.getString(R.string.settings_exported_profile_encryption), ctv_protect.isChecked()).commit(); } if (!ctv_protect.isChecked()) { dialog.dismiss(); ntfy_pswd.notifyToListener(true, new Object[] { "" }); } else { if (!passwd.equals(et_confirm.getText().toString())) { //Unmatch dlg_msg.setText( mContext.getString(R.string.msgs_export_import_pswd_unmatched_confirm_pswd)); } else { 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(); }
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 w w w .j ava 2 s. c om*/ 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 logonToRemoteDlg(final String host, final String addr, final String port, final String user, final String pass, final NotifyEvent p_ntfy) { final ThreadCtrl tc = new ThreadCtrl(); tc.setEnabled();/* www .j a v a 2 s . com*/ 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_test_logon); final Button btn_cancel = (Button) dialog.findViewById(R.id.progress_spin_dlg_btn_cancel); btn_cancel.setText(R.string.msgs_progress_spin_dlg_test_logon_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", "Logon 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? Thread th = new Thread() { @Override public void run() { util.addDebugMsg(1, "I", "Test logon started, host=" + host + ", addr=" + addr + ", port=" + port + ", user=" + user); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, user, pass); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { dialog.dismiss(); String err_msg = (String) o[0]; if (tc.isEnabled()) { if (err_msg != null) { commonDlg.showCommonDialog(false, "E", mContext.getString(R.string.msgs_remote_profile_dlg_logon_error), err_msg, null); if (p_ntfy != null) p_ntfy.notifyToListener(false, null); } else { commonDlg.showCommonDialog(false, "I", "", mContext.getString(R.string.msgs_remote_profile_dlg_logon_success), null); if (p_ntfy != null) p_ntfy.notifyToListener(true, null); } } else { commonDlg.showCommonDialog(false, "I", "", mContext.getString(R.string.msgs_remote_profile_dlg_logon_cancel), null); if (p_ntfy != null) p_ntfy.notifyToListener(true, null); } } @Override public void negativeResponse(Context c, Object[] o) { } }); if (host.equals("")) { boolean reachable = false; if (port.equals("")) { if (NetworkUtil.isIpAddressAndPortConnected(addr, 139, 3500) || NetworkUtil.isIpAddressAndPortConnected(addr, 445, 3500)) { reachable = true; } } else { reachable = NetworkUtil.isIpAddressAndPortConnected(addr, Integer.parseInt(port), 3500); } if (reachable) { testAuth(auth, addr, port, ntfy); } else { util.addDebugMsg(1, "I", "Test logon failed, remote server not connected"); String unreachble_msg = ""; if (port.equals("")) { unreachble_msg = String .format(mContext.getString(R.string.msgs_mirror_smb_addr_not_connected), addr); } else { unreachble_msg = String.format( mContext.getString(R.string.msgs_mirror_smb_addr_not_connected_with_port), addr, port); } ntfy.notifyToListener(true, new Object[] { unreachble_msg }); } } else { if (NetworkUtil.getSmbHostIpAddressFromName(host) != null) testAuth(auth, host, port, ntfy); else { util.addDebugMsg(1, "I", "Test logon failed, remote server not connected"); String unreachble_msg = ""; unreachble_msg = mContext.getString(R.string.msgs_mirror_smb_name_not_found) + host; ntfy.notifyToListener(true, new Object[] { unreachble_msg }); } } } }; th.start(); dialog.show(); }
From source file:com.infigent.stocksense.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startService(new Intent(this, BackGround.class)); // setSlidingActionBarEnabled(true); Intent n = getIntent();// w w w . java 2 s. c o m if (getIntent() != null) { Bundle bundle = n.getExtras(); if (bundle != null) { Log.e("ARG", "EXIST"); if (bundle.containsKey("eq")) { Log.e("EQ", "EXIST"); if (bundle.getBoolean("eq")) { Log.e("eq", "true"); Bundle data = new Bundle(); Fragment4 eq = new Fragment4(); mContent = eq; data.putString("q", bundle.getString("q")); data.putString("type", bundle.getString("type")); data.putString("name", bundle.getString("name")); data.putString("f", gId()); eq.setArguments(data); switchContent(eq); } } } } if (savedInstanceState != null) mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new Fragment1(); ScrollView scrollView = new ScrollView(this); LinearLayout l = new LinearLayout(this); TextView one = new TextView(this); one.setText(getResources().getString(R.string.intro)); one.setPadding(0, 0, 0, 20); TextView two = new TextView(this); two.setText("Limited License"); two.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView three = new TextView(this); three.setText(getResources().getString(R.string.l1)); TextView four = new TextView(this); four.setText(getResources().getString(R.string.l2)); four.setPadding(0, 0, 0, 20); TextView five = new TextView(this); five.setText("Disclaimer"); five.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView six = new TextView(this); six.setText(getResources().getString(R.string.disclaimer1)); TextView seven = new TextView(this); seven.setText(getResources().getString(R.string.disclaimer2)); TextView eight = new TextView(this); eight.setText(getResources().getString(R.string.disclaimer3)); eight.setPadding(0, 0, 0, 20); TextView nine = new TextView(this); nine.setText("Liability For Our Services"); nine.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView ten = new TextView(this); ten.setText(getResources().getString(R.string.liability1)); TextView eleven = new TextView(this); eleven.setText(getResources().getString(R.string.liability2)); eleven.setPadding(0, 0, 0, 20); TextView twelve = new TextView(this); twelve.setText("Maintenance And Support"); twelve.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView thirteen = new TextView(this); thirteen.setText(getResources().getString(R.string.ms)); thirteen.setPadding(0, 0, 0, 20); TextView fourteen = new TextView(this); fourteen.setText("Links To Third Party Website"); fourteen.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView fifteen = new TextView(this); fifteen.setText(getResources().getString(R.string.p3)); l.addView(one); l.addView(two); l.addView(three); l.addView(four); l.addView(five); l.addView(six); l.addView(seven); l.addView(eight); l.addView(nine); l.addView(ten); l.addView(eleven); l.addView(twelve); l.addView(thirteen); l.addView(fourteen); l.addView(fifteen); one.setTextColor(getResources().getColor(R.color.White)); two.setTextColor(getResources().getColor(R.color.White)); three.setTextColor(getResources().getColor(R.color.White)); four.setTextColor(getResources().getColor(R.color.White)); five.setTextColor(getResources().getColor(R.color.White)); six.setTextColor(getResources().getColor(R.color.White)); seven.setTextColor(getResources().getColor(R.color.White)); eight.setTextColor(getResources().getColor(R.color.White)); nine.setTextColor(getResources().getColor(R.color.White)); ten.setTextColor(getResources().getColor(R.color.White)); eleven.setTextColor(getResources().getColor(R.color.White)); twelve.setTextColor(getResources().getColor(R.color.White)); thirteen.setTextColor(getResources().getColor(R.color.White)); fourteen.setTextColor(getResources().getColor(R.color.White)); fifteen.setTextColor(getResources().getColor(R.color.White)); l.setOrientation(LinearLayout.VERTICAL); l.setBackgroundColor(getResources().getColor(R.color.bg)); l.setPadding(10, 10, 10, 10); scrollView.addView(l); boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE).getBoolean("firstboot", true); if (firstboot) { LayoutInflater inflater = getLayoutInflater(); View vvv = inflater.inflate(R.layout.alerttitle, null); AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Terms of Service") .setView(scrollView).setCustomTitle(vvv) .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit().putBoolean("firstboot", false) .commit(); } }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Close the activity as they have declined the EULA MainActivity.this.finish(); } }).setCancelable(false); builder.create().show(); } ime = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); ActionBar actionBar = getSupportActionBar(); getSupportActionBar().setCustomView(R.layout.search); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); sb = (ImageButton) actionBar.getCustomView().findViewById(R.id.sb); title = (TextView) actionBar.getCustomView().findViewById(R.id.title); sb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // only will trigger it if no physical keyboard is open search.setVisibility(View.VISIBLE); search.requestFocus(); ime.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT); search.setSelection(search.getText().length()); sb.setVisibility(View.GONE); title.setVisibility(View.GONE); } }); search = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.et); search.setThreshold(2); search.setAdapter(new SuggestionsAdapter(this, search.getText().toString())); search.setSelectAllOnFocus(true); search.clearFocus(); search.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) { String term = parent.getItemAtPosition(pos).toString(); String[] lines = term.split("\\r?\\n"); String name = lines[0]; String code = lines[1].substring(lines[1].indexOf(":") + 1, lines[1].length()).trim(); String type = lines[1].substring(0, lines[1].indexOf(":")); Log.d("DATA", name + " " + type + ":" + code); search.setText(""); if (isNetworkAvailable()) { if (term.replace(" ", "") != null) { Bundle data = new Bundle(); data.putString("q", code); data.putString("type", type); data.putString("name", name); data.putString("f", gId()); Fragment4 eq = new Fragment4(); eq.setArguments(data); Log.d("C", gId() + " frag"); mContent = eq; getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, eq).commit(); getSlidingMenu().showContent(); search.setVisibility(View.GONE); sb.setVisibility(View.VISIBLE); title.setVisibility(View.VISIBLE); ime.hideSoftInputFromWindow(search.getApplicationWindowToken(), 0); } else { Toast.makeText(getApplicationContext(), "Enter a search term!", Toast.LENGTH_LONG).show(); } } else Toast.makeText(getApplicationContext(), "Internet not available", Toast.LENGTH_LONG).show(); } }); search.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { return false; } }); // set the Above View setContentView(R.layout.content_frame); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); AdView mAdView; mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); // set the Behind View setBehindContentView(R.layout.menu_frame); getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SampleListFragment()).commit(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void editFileFilterDlg(final ArrayList<String> file_filter, final NotifyEvent p_ntfy) { ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>(); final AdapterFilterList filterAdapter; // ??//from w ww . ja v a 2 s.co m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn); dirbtn.setVisibility(Button.GONE); filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList); ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview); for (int i = 0; i < file_filter.size(); i++) { String inc = file_filter.get(i).substring(0, 1); String filter = file_filter.get(i).substring(1, file_filter.get(i).length()); boolean b_inc = false; if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE)) b_inc = true; filterAdapter.add(new FilterListItem(filter, b_inc)); } if (filterAdapter.getCount() == 0) filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false)); lv.setAdapter(filterAdapter); // filterAdapter.getFileFilter().filter("D"); // lv.setTextFilterEnabled(false); // lv.setDivider(new ColorDrawable(Color.WHITE)); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_file_filter)); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg); CommonDialog.setDlgBoxSizeLimit(dialog, true); // CommonDialog.setDlgBoxSizeCompact(dialog); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter); final Button addBtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { FilterListItem fli = filterAdapter.getItem(idx); if (fli.getFilter().startsWith("---") || fli.isDeleted()) return; // ???????? editDirFilter(idx, filterAdapter, fli, fli.getFilter()); } }); // Add? addBtn.setEnabled(false); et_filter.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() != 0) { if (isFilterExists(s.toString().trim(), filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, s.toString().trim())); addBtn.setEnabled(false); btn_ok.setEnabled(true); } else { dlg_msg.setText(""); addBtn.setEnabled(true); btn_ok.setEnabled(false); } } else { addBtn.setEnabled(false); btn_ok.setEnabled(true); } // et_filter.setText(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); addBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dlg_msg.setText(""); String newfilter = et_filter.getText().toString().trim(); et_filter.setText(""); if (filterAdapter.getItem(0).getFilter().startsWith("---")) filterAdapter.remove(filterAdapter.getItem(0)); filterAdapter.add(new FilterListItem(newfilter, true)); filterAdapter.setNotifyOnChange(true); filterAdapter.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); btn_ok.setEnabled(true); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); file_filter.clear(); if (filterAdapter.getCount() > 0) { for (int i = 0; i < filterAdapter.getCount(); i++) { if (!filterAdapter.getItem(i).isDeleted() && !filterAdapter.getItem(i).getFilter().startsWith("---")) { String inc = SMBSYNC_PROF_FILTER_EXCLUDE; if (filterAdapter.getItem(i).getInc()) inc = SMBSYNC_PROF_FILTER_INCLUDE; file_filter.add(inc + filterAdapter.getItem(i).getFilter()); } } } p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number, boolean scan_start) { //??/*from w w w . ja va 2s . c o 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(); }