List of usage examples for android.app Dialog setOnCancelListener
public void setOnCancelListener(@Nullable OnCancelListener listener)
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void promptPasswordForImport(final String fpath, final NotifyEvent ntfy_pswd) { // ??// w ww . j av a2 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(); }
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."); // ??//from w ww . j av a2s . 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("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 promptPasswordForExport(final String fpath, final NotifyEvent ntfy_pswd) { // ??//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.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.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideSettingLayout() { SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE); // Bundle seek = getIntent().getExtras(); final Dialog settingdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); settingdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); settingdialog.setContentView(R.layout.settingdialoglayout); final SeekBar powerseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Powerbar); final SeekBar engineseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Enginebar); final SeekBar exteriorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Exteriorbar); // exteriorseekbar.setIndeterminate(false); final SeekBar interiorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Interiorbar); final SeekBar documentseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Documentbar); // seekbar.putInt("Powerbar", powerseekbarValue).commit(); // if(seek != null){ Log.i("insettings", "seekbar : power-> " + mSharedPrefs.getInt("Powerbar", 0)); Log.i("insettings", "seekbar : engine->" + mSharedPrefs.getInt("Enginebar", 0)); Log.i("insettings", "seekbar : exterior->" + mSharedPrefs.getInt("Exteriorbar", 0)); Log.i("insettings", "seekbar : interior->" + mSharedPrefs.getInt("Interiorbar", 0)); Log.i("insettings", "seekbar : document->" + mSharedPrefs.getInt("Documentbar", 0)); powerseekbar.setProgress(mSharedPrefs.getInt("Powerbar", 0)); engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0)); exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0)); interiorseekbar.setProgress(mSharedPrefs.getInt("Interiorbar", 0)); documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0)); /*/*from w ww . j a va2 s . c om*/ * for(Map.Entry<String, Integer> entry : mapSetting.entrySet()){ * if("interior".equals(entry.getKey())) edit.putInt("Interiorbar", * entry.getValue()); else if("power".equals(entry.getKey())) * edit.putInt("Powerbar", entry.getValue()); else * if("engine".equals(entry.getKey())) edit.putInt("Enginebar", * entry.getValue()); else if("exterior".equals(entry.getKey())) * edit.putInt("Exteriorbar", entry.getValue()); else * edit.putInt("Documentbar", entry.getValue()); * * //Log.i("checkSettingsName", "checkSettingsName : " + * entry.getKey()); } */ // ****************************************************check exist // current setting int powerBar = mSharedPrefs.getInt("Powerbar", 0); int engineBar = mSharedPrefs.getInt("Enginebar", 0); int exteriorBar = mSharedPrefs.getInt("Exteriorbar", 0); int interiorBar = mSharedPrefs.getInt("Interiorbar", 0); int documentBar = mSharedPrefs.getInt("Documentbar", 0); Log.i("power_setting", "*****in setting******power setting : " + powerBar); Log.i("engine_setting", "engine setting : " + engineBar); Log.i("exterior_setting", "exterior setting : " + exteriorBar); Log.i("interior_setting", "interior setting : " + interiorBar); Log.i("document_setting", "document setting : " + documentBar); // } TextView setting = (TextView) settingdialog.getWindow().findViewById(R.id.Setting); TextView priority = (TextView) settingdialog.getWindow().findViewById(R.id.Priority); TextView low = (TextView) settingdialog.getWindow().findViewById(R.id.Low); TextView high = (TextView) settingdialog.getWindow().findViewById(R.id.High); TextView textexterior = (TextView) settingdialog.getWindow().findViewById(R.id.textexterior); TextView textinterior = (TextView) settingdialog.getWindow().findViewById(R.id.textinterior); TextView textpower = (TextView) settingdialog.getWindow().findViewById(R.id.textpower); TextView textengine = (TextView) settingdialog.getWindow().findViewById(R.id.textengine); TextView textdocument = (TextView) settingdialog.getWindow().findViewById(R.id.textdocument); TextView one = (TextView) settingdialog.getWindow().findViewById(R.id.one); TextView two = (TextView) settingdialog.getWindow().findViewById(R.id.two); TextView three = (TextView) settingdialog.getWindow().findViewById(R.id.three); TextView four = (TextView) settingdialog.getWindow().findViewById(R.id.four); TextView five = (TextView) settingdialog.getWindow().findViewById(R.id.five); setting.setTypeface(type); priority.setTypeface(type); low.setTypeface(type); high.setTypeface(type); textexterior.setTypeface(type); textinterior.setTypeface(type); textpower.setTypeface(type); textengine.setTypeface(type); textdocument.setTypeface(type); one.setTypeface(type); two.setTypeface(type); three.setTypeface(type); four.setTypeface(type); five.setTypeface(type); settingdialog.getWindow().getAttributes().windowAnimations = R.style.SettingDialogAnimation; settingdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = settingdialog.getWindow().getAttributes(); lp.dimAmount = 0f; settingdialog.setCanceledOnTouchOutside(true); settingdialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468); slideoutheadsetting.setDuration(500); slideoutheadsetting.setFillAfter(true); headsetting.startAnimation(slideoutheadsetting); } }); Button btnsave = (Button) settingdialog.getWindow().findViewById(R.id.save); btnsave.setTypeface(type); btnsave.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { settingdialog.dismiss(); headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468); slideoutheadsetting.setDuration(500); slideoutheadsetting.setFillAfter(true); headsetting.startAnimation(slideoutheadsetting); powerseekbarValue = powerseekbar.getProgress(); engineseekbarValue = engineseekbar.getProgress(); exteriorseekbarValue = exteriorseekbar.getProgress(); interiorseekbarValue = interiorseekbar.getProgress(); documentseekbarValue = documentseekbar.getProgress(); Priority(); SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE); Editor seekbar = mSharedPrefs.edit(); seekbar.putInt("Powerbar", powerseekbarValue); seekbar.putInt("Enginebar", engineseekbarValue); seekbar.putInt("Exteriorbar", exteriorseekbarValue); seekbar.putInt("Interiorbar", interiorseekbarValue); seekbar.putInt("Documentbar", documentseekbarValue); seekbar.commit(); /* * int powerBar = shared2.getInt("Powerbar", 0); int engineBar = * shared2.getInt("Enginebar", 0); int exteriorBar = * shared2.getInt("Exteriorbar", 0); int interiorBar = * shared2.getInt("Interiorbar", 0); int documentBar = * shared2.getInt("Documentbar", 0); */ RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); Button btnreset = (Button) settingdialog.getWindow().findViewById(R.id.reset); btnreset.setTypeface(type); btnreset.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog alertDialog = new AlertDialog.Builder(CarCheckListActivity.this).setTitle("Reset") .setMessage("Do you really want to clear data?") .setPositiveButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = getIntent(); SharedPreferences sharedPreferences = getSharedPreferences("mysettings", Context.MODE_PRIVATE); sharedPreferences.edit().clear().commit(); /* * int CheckDocumentTotal, * CheckPowerTotal, CheckEngineTotal, * CheckExteriorTotal, * CheckInteriorTotal, PercenDocument, * PercenPower, PercenEngine, * PercenExterior, PercenInterior, * PercenRatio, Checknum, * powerseekbarValue, * engineseekbarValue, * exteriorseekbarValue, * interiorseekbarValue, * documentseekbarValue, sumPriority, * PowerPriority, EnginePriority, * ExteriorPriority, InteriorPriority, * DocumentPriority, * documentprogressValue; */ /* * Log.i("checkreset", * "BEFORE CLEAR -> CheckDocumentTotal : " * + CheckDocumentTotal); * Log.i("checkreset", * "CheckPowerTotal : " + * CheckPowerTotal); Log.i("checkreset", * "CheckEngineTotal : " + * CheckEngineTotal); * Log.i("checkreset", * "CheckExteriorTotal : " + * CheckExteriorTotal); * Log.i("checkreset", * "CheckInteriorTotal : " + * CheckInteriorTotal); * Log.i("checkreset", * "PercenDocument : " + * PercenDocument); Log.i("checkreset", * "PercenPower : " + PercenPower); * Log.i("checkreset", "PercenEngine : " * + PercenEngine); Log.i("checkreset", * "PercenExterior : " + * PercenExterior); Log.i("checkreset", * "PercenInterior : " + * PercenInterior); Log.i("checkreset", * "PercenRatio : " + PercenRatio); * Log.i("checkreset", "Checknum : " + * Checknum); Log.i("checkreset", * "powerseekbarValue : " + * powerseekbarValue); * Log.i("checkreset", * "engineseekbarValue : " + * engineseekbarValue); * Log.i("checkreset", * "interiorseekbarValue : " + * interiorseekbarValue); * Log.i("checkreset", * "exteriorseekbarValue : " + * exteriorseekbarValue); * Log.i("checkreset", * "documentseekbarValue : " + * documentseekbarValue); * Log.i("checkreset", "sumPriority : " * + sumPriority); Log.i("checkreset", * "PowerPriority : " + PowerPriority); * Log.i("checkreset", * "EnginePriority : " + * EnginePriority); Log.i("checkreset", * "ExteriorPriority : " + * ExteriorPriority); * Log.i("checkreset", * "InteriorPriority : " + * InteriorPriority); * Log.i("checkreset", * "DocumentPriority : " + * DocumentPriority); */ getIntent().removeExtra("power"); getIntent().removeExtra("engine"); getIntent().removeExtra("exterior"); getIntent().removeExtra("interior"); getIntent().removeExtra("document"); //startActivity(intent); Intent ii = new Intent(getApplicationContext(), CarCheckListActivity.class); startActivity(ii); finish(); } }).show(); } }); Button btnChangeLanguage = (Button) settingdialog.getWindow().findViewById(R.id.change_language); btnChangeLanguage.setTypeface(type); btnChangeLanguage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(CarCheckListActivity.this, ChangeLanguage.class); // th myIntent.putExtra("power", PercenPower); myIntent.putExtra("engine", PercenEngine); myIntent.putExtra("exterior", PercenExterior); myIntent.putExtra("interior", PercenInterior); myIntent.putExtra("document", PercenDocument); myIntent.putExtra("numpower", CheckPowerTotal); myIntent.putExtra("numengine", CheckEngineTotal); myIntent.putExtra("numexterior", CheckExteriorTotal); myIntent.putExtra("numinterior", CheckInteriorTotal); myIntent.putExtra("numdocument", CheckDocumentTotal); SharedPreferences shared = getSharedPreferences("mysettings", Context.MODE_PRIVATE); Editor editor = shared.edit(); int powerBar = shared.getInt("Powerbar", 0); int engineBar = shared.getInt("Enginebar", 0); int exteriorBar = shared.getInt("Exteriorbar", 0); int interiorBar = shared.getInt("Interiorbar", 0); int documentBar = shared.getInt("Documentbar", 0); Log.i("power_setting", "power setting : " + powerBar); Log.i("engine_setting", "engine setting : " + engineBar); Log.i("exterior_setting", "exterior setting : " + exteriorBar); Log.i("interior_setting", "interior setting : " + interiorBar); Log.i("document_setting", "document setting : " + documentBar); Log.i("checkInList", "Check in List : " + shared.getInt("checknum", 0)); CarCheckListActivity.this.startActivity(myIntent); finish(); } }); Button btnRecord = (Button) settingdialog.getWindow().findViewById(R.id.record); btnRecord.setTypeface(type); btnRecord.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.i("record", "record onClick"); final AlertDialog.Builder adb = new AlertDialog.Builder(getApplicationContext()); adb.setTitle("Warning Dialog"); adb.setMessage("you must select more than one checklist."); adb.setPositiveButton("Ok", null); SharedPreferences shared = getSharedPreferences("mysettings", MODE_PRIVATE); powerWeight = shared.getInt("Powerbar", 0); engineWeight = shared.getInt("Enginebar", 0); exteriorWeight = shared.getInt("Exteriorbar", 0); interiorWeight = shared.getInt("Interiorbar", 0); documentWeight = shared.getInt("Documentbar", 0); String display = "before record activity >> " + powerWeight + "|" + engineWeight + "|" + exteriorWeight + "|" + interiorWeight + "|" + documentWeight; Log.i("display", display); Log.i("checklist", "" + PercenPower); Log.i("checklist", "" + PercenEngine); Log.i("checklist", "" + PercenExterior); Log.i("checklist", "" + PercenInterior); Log.i("checklist", "" + PercenDocument); // checking scope isSaveCheckBox(); // progressCheckListLog(); // checking scope CarCheckListActivity.this.startActivity(intent); finish(); } }); Button btnList = (Button) settingdialog.getWindow().findViewById(R.id.list); btnList.setTypeface(type); btnList.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Checknumcheckbox(); Intent listSaving = new Intent(getApplicationContext(), ListSaveActivity.class); startActivity(listSaving); finish(); } }); headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadsetting = new TranslateAnimation(0, 0, -468, 0); slideheadsetting.setDuration(500); slideheadsetting.setFillAfter(true); headsetting.startAnimation(slideheadsetting); settingdialog.show(); WindowManager.LayoutParams params = settingdialog.getWindow().getAttributes(); params.y = 0; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; settingdialog.getWindow().setAttributes(params); powerseekbarValue = mSharedPrefs.getInt("Powerbar", 0); engineseekbarValue = mSharedPrefs.getInt("Enginebar", 0); exteriorseekbarValue = mSharedPrefs.getInt("Exteriorbar", 0); interiorseekbarValue = mSharedPrefs.getInt("Interiorbar", 0); documentseekbarValue = mSharedPrefs.getInt("Documentbar", 0); PowerPriority = powerseekbarValue + 1; EnginePriority = engineseekbarValue + 1; ExteriorPriority = exteriorseekbarValue + 1; InteriorPriority = interiorseekbarValue + 1; DocumentPriority = documentseekbarValue + 1; /* * powerseekbar.setProgress(mSharedPrefs.getInt("Powerbar", 0)); * engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0)); * exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0)); * interiorseekbar.setProgress(mSharedPrefs.getInt("Interior", 0)); * documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0)); */ powerseekbar.setProgress(powerseekbarValue); engineseekbar.setProgress(engineseekbarValue); exteriorseekbar.setProgress(exteriorseekbarValue); interiorseekbar.setProgress(interiorseekbarValue); documentseekbar.setProgress(documentseekbarValue); }
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 w w . j a v 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.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.xplink.android.carchecklist.CarCheckListActivity.java
private void SlidePowerLayout() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float height = metrics.heightPixels; float width = metrics.widthPixels; int left500 = (int) ((width / 100) * 39); int top200 = (int) ((width / 100) * 15.7); final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog powerdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); powerdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); powerdialog.setContentView(R.layout.powerdialoglayout); powerdialog.getWindow().getAttributes().windowAnimations = R.style.PowerDialogAnimation; powerdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = powerdialog.getWindow().getAttributes(); lp.dimAmount = 0f;//from w ww . jav a2s .c om final CheckBox chkpower_headLight = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_headLight); final CheckBox chkpower_dim = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_dim); final CheckBox chkpower_highBeam = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_highBeam); final CheckBox chkpower_dashBoardLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_dashBoardLight); final CheckBox chkpower_cabinSeatLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_cabinSeatLight); final CheckBox chkpower_sideDoorLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_sideDoorLight); final CheckBox chkpower_turnSignal = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_turnSignal); final CheckBox chkpower_air = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_air); final CheckBox chkpower_thermometer = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_thermometer); final CheckBox chkpower_horn = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_horn); final CheckBox chkpower_wipe = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_wipe); final CheckBox chkpower_rainSensor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_rainSensor); final CheckBox chkpower_thirdBrakeLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_thirdBrakeLight); final CheckBox chkpower_antiFoggyBack = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_antiFoggyBack); final CheckBox chkpower_antiFoggySide = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_antiFoggySide); final CheckBox chkpower_steeringWheelTest = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_steeringWheelTest); final CheckBox chkpower_steeringWheelSet = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_steeringWheelSet); final CheckBox chkpower_carStereo = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_carStereo); final CheckBox chkpower_electronicWindow = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_electronicWindow); final CheckBox chkpower_sideMirror = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_sideMirror); final CheckBox chkpower_warnDoor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_warnDoor); final CheckBox chkpower_warnSeatBelt = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_warnSeatBelt); final CheckBox chkpower_warnHandBrake = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_warnHandBrake); final CheckBox chkpower_clock = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_clock); final CheckBox chkpower_remoteKey = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_remoteKey); final CheckBox chkpower_centralLock = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_centralLock); final CheckBox chkpower_transmissionPosition = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_transmissionPosition); // change font chkpower_headLight.setTypeface(type); chkpower_dim.setTypeface(type); chkpower_highBeam.setTypeface(type); chkpower_dashBoardLight.setTypeface(type); chkpower_cabinSeatLight.setTypeface(type); chkpower_sideDoorLight.setTypeface(type); chkpower_turnSignal.setTypeface(type); chkpower_air.setTypeface(type); chkpower_thermometer.setTypeface(type); chkpower_horn.setTypeface(type); chkpower_wipe.setTypeface(type); chkpower_rainSensor.setTypeface(type); chkpower_thirdBrakeLight.setTypeface(type); chkpower_antiFoggyBack.setTypeface(type); chkpower_antiFoggySide.setTypeface(type); chkpower_steeringWheelTest.setTypeface(type); chkpower_steeringWheelSet.setTypeface(type); chkpower_carStereo.setTypeface(type); chkpower_electronicWindow.setTypeface(type); chkpower_sideMirror.setTypeface(type); chkpower_warnDoor.setTypeface(type); chkpower_warnSeatBelt.setTypeface(type); chkpower_warnHandBrake.setTypeface(type); chkpower_clock.setTypeface(type); chkpower_remoteKey.setTypeface(type); chkpower_centralLock.setTypeface(type); chkpower_transmissionPosition.setTypeface(type); powerdialog.setCanceledOnTouchOutside(true); powerdialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headpower.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800); slideoutheadpower.setDuration(500); slideoutheadpower.setFillAfter(true); headpower.startAnimation(slideoutheadpower); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("power_headLight", chkpower_headLight.isChecked()); mp.put("power_dim", chkpower_dim.isChecked()); mp.put("power_highBeam", chkpower_highBeam.isChecked()); mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked()); mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked()); mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked()); mp.put("power_turnSignal", chkpower_turnSignal.isChecked()); mp.put("power_air", chkpower_air.isChecked()); mp.put("power_thermometer", chkpower_thermometer.isChecked()); mp.put("power_horn", chkpower_horn.isChecked()); mp.put("power_wipe", chkpower_wipe.isChecked()); mp.put("power_rainSensor", chkpower_rainSensor.isChecked()); mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked()); mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked()); mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked()); mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked()); mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked()); mp.put("power_carStereo", chkpower_carStereo.isChecked()); mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked()); mp.put("power_sideMirror", chkpower_sideMirror.isChecked()); mp.put("power_warnDoor", chkpower_warnDoor.isChecked()); mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked()); mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked()); mp.put("power_clock", chkpower_clock.isChecked()); mp.put("power_remoteKey", chkpower_remoteKey.isChecked()); mp.put("power_centralLock", chkpower_centralLock.isChecked()); mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked()); filterStore("power", mp); save(mp); } }); TextView power = (TextView) powerdialog.getWindow().findViewById(R.id.Power); power.setTypeface(type); Button powerback = (Button) powerdialog.getWindow().findViewById(R.id.Powerback); powerback.setTypeface(type); powerback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { powerdialog.dismiss(); headpower.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800); slideoutheadpower.setDuration(500); slideoutheadpower.setFillAfter(true); headpower.startAnimation(slideoutheadpower); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("power_headLight", chkpower_headLight.isChecked()); mp.put("power_dim", chkpower_dim.isChecked()); mp.put("power_highBeam", chkpower_highBeam.isChecked()); mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked()); mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked()); mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked()); mp.put("power_turnSignal", chkpower_turnSignal.isChecked()); mp.put("power_air", chkpower_air.isChecked()); mp.put("power_thermometer", chkpower_thermometer.isChecked()); mp.put("power_horn", chkpower_horn.isChecked()); mp.put("power_wipe", chkpower_wipe.isChecked()); mp.put("power_rainSensor", chkpower_rainSensor.isChecked()); mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked()); mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked()); mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked()); mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked()); mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked()); mp.put("power_carStereo", chkpower_carStereo.isChecked()); mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked()); mp.put("power_sideMirror", chkpower_sideMirror.isChecked()); mp.put("power_warnDoor", chkpower_warnDoor.isChecked()); mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked()); mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked()); mp.put("power_clock", chkpower_clock.isChecked()); mp.put("power_remoteKey", chkpower_remoteKey.isChecked()); mp.put("power_centralLock", chkpower_centralLock.isChecked()); mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked()); filterStore("power", mp); save(mp); } }); chkpower_headLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_dim.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_highBeam.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_dashBoardLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_cabinSeatLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_sideDoorLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_turnSignal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_air.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_thermometer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_horn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_wipe.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_rainSensor.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_thirdBrakeLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_antiFoggyBack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_antiFoggySide.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_steeringWheelTest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_steeringWheelSet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_carStereo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_electronicWindow.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_sideMirror.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_warnDoor.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_warnSeatBelt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_warnHandBrake.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_clock.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_remoteKey.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_centralLock.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_transmissionPosition.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headpower.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadpower = new TranslateAnimation(0, 0, 800, 200); slideheadpower.setDuration(300); slideheadpower.setFillAfter(true); headpower.startAnimation(slideheadpower); powerdialog.show(); WindowManager.LayoutParams params = powerdialog.getWindow().getAttributes(); params.y = top200; params.x = left500; params.gravity = Gravity.TOP | Gravity.LEFT; powerdialog.getWindow().setAttributes(params); isSaveCheckBox(); chkpower_headLight.setChecked(load("power_headLight")); chkpower_dim.setChecked(load("power_dim")); chkpower_highBeam.setChecked(load("power_highBeam")); chkpower_dashBoardLight.setChecked(load("power_dashBoardLight")); chkpower_cabinSeatLight.setChecked(load("power_cabinSeatLight")); chkpower_sideDoorLight.setChecked(load("power_sideDoorLight")); chkpower_turnSignal.setChecked(load("power_turnSignal")); chkpower_air.setChecked(load("power_air")); chkpower_thermometer.setChecked(load("power_thermometer")); chkpower_horn.setChecked(load("power_horn")); chkpower_wipe.setChecked(load("power_wipe")); chkpower_rainSensor.setChecked(load("power_rainSensor")); chkpower_thirdBrakeLight.setChecked(load("power_thirdBrakeLight")); chkpower_antiFoggyBack.setChecked(load("power_antiFoggyBack")); chkpower_antiFoggySide.setChecked(load("power_antiFoggySide")); chkpower_steeringWheelTest.setChecked(load("power_steeringWheelTest")); chkpower_steeringWheelSet.setChecked(load("power_steeringWheelSet")); chkpower_carStereo.setChecked(load("power_carStereo")); chkpower_electronicWindow.setChecked(load("power_electronicWindow")); chkpower_sideMirror.setChecked(load("power_sideMirror")); chkpower_warnDoor.setChecked(load("power_warnDoor")); chkpower_warnSeatBelt.setChecked(load("power_warnSeatBelt")); chkpower_warnHandBrake.setChecked(load("power_warnHandBrake")); chkpower_clock.setChecked(load("power_clock")); chkpower_remoteKey.setChecked(load("power_remoteKey")); chkpower_centralLock.setChecked(load("power_centralLock")); chkpower_transmissionPosition.setChecked(load("power_transmissionPosition")); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void listDirFilterLocal(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter, final AdapterFilterList fla, final NotifyEvent p_ntfy) { final String cdir = sti.getMasterDirectoryName(); String localBaseDir_t = mGp.internalRootDirectory; if (sti.getMasterFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_SDCARD)) localBaseDir_t = mGp.sdcardRootDirectory; final String localBaseDir = localBaseDir_t; //??// w w 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.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_filter_list_dlg_add_dir_filter)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + localBaseDir + "/" + cdir); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select); ll_context.setVisibility(LinearLayout.VISIBLE); final ImageButton ib_select_all = (ImageButton) ll_context.findViewById(R.id.context_button_select_all); final ImageButton ib_unselect_all = (ImageButton) ll_context.findViewById(R.id.context_button_unselect_all); dlg_msg.setVisibility(TextView.VISIBLE); // 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, false, false); lv.setAdapter(tfa); ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, localBaseDir, "/" + cdir); if (tfl.size() < 1) tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); tfa.setDataList(tfl); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); ib_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { TreeFilelistItem tfli = tfa.getDataItem(i); if (!tfli.isHideListItem()) tfa.setDataItemIsSelected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(true); } }); ib_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { tfa.setDataItemIsUnselected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(false); } }); 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, localBaseDir, 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); final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return true; if (!tfa.getDataItem(t_pos).isChecked()) { tfa.setDataItemIsSelected(t_pos); } return true; } }); //OK? btn_ok.setEnabled(false); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { btn_ok.setEnabled(true); } @Override public void negativeResponse(Context arg0, Object[] arg1) { boolean checked = false; for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).isChecked()) { checked = true; break; } } if (checked) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); tfa.setCbCheckListener(ntfy); btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add)); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!addDirFilter(true, tfa, fla, "/" + cdir + "/", dlg_msg)) return; addDirFilter(false, tfa, fla, "/" + cdir + "/", dlg_msg); dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close)); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, 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.SyncTaskUtility.java
public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number, boolean scan_start) { //??//from w ww .j a v 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.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.SMBSync2.SyncTaskUtility.java
private void listDirFilterSMB(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter, final AdapterFilterList fla, final NotifyEvent p_ntfy) { setSmbUserPass(sti.getMasterRemoteUserID(), sti.getMasterRemotePassword()); String t_remurl = ""; if (sti.getMasterRemoteHostname().equals("")) t_remurl = sti.getMasterRemoteAddr(); else/*w w w . ja v a 2s. c o m*/ t_remurl = sti.getMasterRemoteHostname(); String h_port = ""; if (!sti.getMasterRemotePassword().equals("")) h_port = ":" + sti.getMasterRemotePort(); final String remurl = "smb://" + t_remurl + h_port + "/" + sti.getMasterRemoteSmbShareName(); final String remdir = "/" + sti.getMasterDirectoryName() + "/"; NotifyEvent ntfy = new NotifyEvent(mContext); // set thread response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>(); @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_filter_list_dlg_add_dir_filter)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + remurl + remdir); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg); final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select); ll_context.setVisibility(LinearLayout.VISIBLE); final ImageButton ib_select_all = (ImageButton) ll_context .findViewById(R.id.context_button_select_all); final ImageButton ib_unselect_all = (ImageButton) ll_context .findViewById(R.id.context_button_unselect_all); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); dlg_msg.setVisibility(TextView.VISIBLE); // 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, false, false); tfa.setDataList(rows); lv.setAdapter(tfa); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); // lv.setFastScrollEnabled(true); ib_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { TreeFilelistItem tfli = tfa.getDataItem(i); if (!tfli.isHideListItem()) tfa.setDataItemIsSelected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(true); } }); ib_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { tfa.setDataItemIsUnselected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(false); } }); 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); final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return true; if (!tfa.getDataItem(t_pos).isChecked()) { tfa.setDataItemIsSelected(t_pos); } return true; } }); //OK? btn_ok.setEnabled(false); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { btn_ok.setEnabled(true); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (tfa.isDataItemIsSelected()) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); tfa.setCbCheckListener(ntfy); btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add)); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!addDirFilter(true, tfa, fla, remdir, dlg_msg)) return; addDirFilter(false, tfa, fla, remdir, dlg_msg); dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close)); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, 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, remdir, ntfy, true); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void editRemoteProfile(String prof_act, String prof_name, String prof_user, String prof_pass, String prof_addr, final String prof_port, String prof_share, String msg_text, final int item_num) { // ??// w ww . j a v a 2s . c o m final Dialog dialog = new Dialog(this); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.edit_remote_profile); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.remote_profile_dlg_msg); if (msg_text.length() != 0) { dlg_msg.setText(msg_text); } dialog.setTitle("Edit remote profile"); CommonDialog.setDlgBoxSizeLimit(dialog, false); final EditText editname = (EditText) dialog.findViewById(R.id.remote_profile_name); editname.setText(prof_name); final EditText editaddr = (EditText) dialog.findViewById(R.id.remote_profile_addr); editaddr.setText(prof_addr); final EditText edituser = (EditText) dialog.findViewById(R.id.remote_profile_user); edituser.setText(prof_user); final EditText editpass = (EditText) dialog.findViewById(R.id.remote_profile_pass); editpass.setText(prof_pass); final EditText editshare = (EditText) dialog.findViewById(R.id.remote_profile_share); editshare.setText(prof_share); final EditText editport = (EditText) dialog.findViewById(R.id.remote_profile_port_number); editport.setText(prof_port); final CheckBox tg = (CheckBox) dialog.findViewById(R.id.remote_profile_active); if (prof_act.equals("A")) tg.setChecked(true); else tg.setChecked(false); // address? Button btnAddr = (Button) dialog.findViewById(R.id.remote_profile_addrbtn); btnAddr.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { editaddr.setText((String) arg1[1]); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (arg1 != null) dlg_msg.setText((String) arg1[0]); else dlg_msg.setText(""); } }); scanRemoteNetworkDlg(ntfy, editport.getText().toString()); } }); Button btnGet1 = (Button) dialog.findViewById(R.id.remote_profile_get_btn1); btnGet1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String prof_addr, prof_user, prof_pass; editaddr.selectAll(); prof_addr = editaddr.getText().toString(); edituser.selectAll(); prof_user = edituser.getText().toString(); editpass.selectAll(); prof_pass = editpass.getText().toString(); setJcifsProperties(prof_user, prof_pass); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { if (!((String) arg1[0]).equals("")) editshare.setText((String) arg1[0]); } @Override public void negativeResponse(Context arg0, Object[] arg1) { dlg_msg.setText((String) arg1[0]); } }); setRemoteShare(prof_user, prof_pass, prof_addr, ntfy); } }); // CANCEL? final Button btnCancel = (Button) dialog.findViewById(R.id.remote_profile_cancel); btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // setFixedOrientation(false); } }); // OK? Button btnOK = (Button) dialog.findViewById(R.id.remote_profile_ok); btnOK.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String new_user, new_pass, new_addr, new_share, new_act, new_name; dialog.dismiss(); // setFixedOrientation(false); new_addr = editaddr.getText().toString(); new_user = edituser.getText().toString(); new_pass = editpass.getText().toString(); new_share = editshare.getText().toString(); new_name = editname.getText().toString(); String new_port = editport.getText().toString(); if (tg.isChecked()) new_act = "A"; else new_act = "I"; int pos = profileListView.getFirstVisiblePosition(); int topPos = 0; if (profileListView.getChildAt(0) != null) profileListView.getChildAt(0).getTop(); ProfileListItem item = profileAdapter.getItem(item_num); profileAdapter.remove(item); profileAdapter.insert(new ProfileListItem("R", new_name, new_act, new_user, new_pass, new_addr, new_port, new_share, false), item_num); saveProfile(false, "", ""); // appendProfile(); // profileAdapter = // createProfileList(false); // create profile list profileListView.setSelectionFromTop(pos, topPos); profileAdapter.setNotifyOnChange(true); } }); // 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(); }