List of usage examples for android.app Dialog setContentView
public void setContentView(@NonNull View view)
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void showSelectSdcardMsg(final NotifyEvent ntfy, String msg) { final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.show_select_sdcard_dlg); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.show_select_sdcard_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.show_select_sdcard_dlg_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.show_select_sdcard_dlg_msg); dlg_msg.setText(msg);// w ww . j a v a 2s. c om ; final ImageView func_view = (ImageView) dialog.findViewById(R.id.show_select_sdcard_dlg_image); try { InputStream is = mContext.getResources().getAssets() .open(mContext.getString(R.string.msgs_main_external_sdcard_select_required_select_msg_file)); Bitmap bm = BitmapFactory.decodeStream(is); func_view.setImageBitmap(bm); } catch (IOException e) { /* ? */ } final Button btnOk = (Button) dialog.findViewById(R.id.show_select_sdcard_dlg_btn_ok); final Button btnCancel = (Button) dialog.findViewById(R.id.show_select_sdcard_dlg_btn_cancel); CommonDialog.setDlgBoxSizeLimit(dialog, true); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); ntfy.notifyToListener(true, null); } }); // Cancel? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); 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 . java2 s . co m*/ * 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
private void editDirFilter(final int edit_idx, final AdapterFilterList fa, final FilterListItem fli, final String filter) { // ??// ww w . ja v a 2 s. c om 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
public void renameProfile(final SyncTaskItem pli, final NotifyEvent p_ntfy) { // ??/* w w w .j a va 2s . 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.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideInteriorLayout() { final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog interiordialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); interiordialog.requestWindowFeature(Window.FEATURE_NO_TITLE); interiordialog.setContentView(R.layout.interiordialoglayout); interiordialog.getWindow().getAttributes().windowAnimations = R.style.InteriorDialogAnimation; interiordialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = interiordialog.getWindow().getAttributes(); lp.dimAmount = 0f;/*from w w w.j a v a 2 s . co m*/ final CheckBox chkinside_seat = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_seat); final CheckBox chkinside_console = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_console); final CheckBox chkinside_steeringWheel = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_steeringWheel); final CheckBox chkinside_transmission = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_transmission); final CheckBox chkinside_sideDoors = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_sideDoors); final CheckBox chkinside_dashBoard = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_dashBoard); final CheckBox chkinside_carpet = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_carpet); final CheckBox chkinside_curtain = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_curtain); final CheckBox chkinside_seatBelt = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_seatBelt); final CheckBox chkinside_backDoor = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_backDoor); final CheckBox chkinside_lidOil = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_lidOil); final CheckBox chkinside_setSeat = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_setSeat); final CheckBox chkinside_brakePedal = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_brakePedal); final CheckBox chkinside_accelerator = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_accelerator); final CheckBox chkinside_handBrake = (CheckBox) interiordialog.getWindow() .findViewById(R.id.inside_handBrake); // Change font chkinside_seat.setTypeface(type); chkinside_console.setTypeface(type); chkinside_steeringWheel.setTypeface(type); chkinside_transmission.setTypeface(type); chkinside_sideDoors.setTypeface(type); chkinside_dashBoard.setTypeface(type); chkinside_carpet.setTypeface(type); chkinside_curtain.setTypeface(type); chkinside_seatBelt.setTypeface(type); chkinside_backDoor.setTypeface(type); chkinside_lidOil.setTypeface(type); chkinside_setSeat.setTypeface(type); chkinside_brakePedal.setTypeface(type); chkinside_accelerator.setTypeface(type); chkinside_handBrake.setTypeface(type); interiordialog.setCanceledOnTouchOutside(true); interiordialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headinterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadinterior = new TranslateAnimation(0, 0, 180, 800); slideoutheadinterior.setDuration(500); slideoutheadinterior.setFillAfter(true); headinterior.startAnimation(slideoutheadinterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("inside_seat", chkinside_seat.isChecked()); mp.put("inside_console", chkinside_console.isChecked()); mp.put("inside_steeringWheel", chkinside_steeringWheel.isChecked()); mp.put("inside_transmission", chkinside_transmission.isChecked()); mp.put("inside_sideDoors", chkinside_sideDoors.isChecked()); mp.put("inside_dashBoard", chkinside_dashBoard.isChecked()); mp.put("inside_carpet", chkinside_carpet.isChecked()); mp.put("inside_curtain", chkinside_curtain.isChecked()); mp.put("inside_seatBelt", chkinside_seatBelt.isChecked()); mp.put("inside_backDoor", chkinside_backDoor.isChecked()); mp.put("inside_lidOil", chkinside_lidOil.isChecked()); mp.put("inside_setSeat", chkinside_setSeat.isChecked()); mp.put("inside_brakePedal", chkinside_brakePedal.isChecked()); mp.put("inside_accelerator", chkinside_accelerator.isChecked()); mp.put("inside_handBrake", chkinside_handBrake.isChecked()); filterStore("interior", mp); save(mp); } }); TextView interior = (TextView) interiordialog.getWindow().findViewById(R.id.Interior); interior.setTypeface(type); Button interiorback = (Button) interiordialog.getWindow().findViewById(R.id.Interiorback); interiorback.setTypeface(type); interiorback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { interiordialog.dismiss(); headinterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadinterior = new TranslateAnimation(0, 0, 180, 800); slideoutheadinterior.setDuration(500); slideoutheadinterior.setFillAfter(true); headinterior.startAnimation(slideoutheadinterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("inside_seat", chkinside_seat.isChecked()); mp.put("inside_console", chkinside_console.isChecked()); mp.put("inside_steeringWheel", chkinside_steeringWheel.isChecked()); mp.put("inside_transmission", chkinside_transmission.isChecked()); mp.put("inside_sideDoors", chkinside_sideDoors.isChecked()); mp.put("inside_dashBoard", chkinside_dashBoard.isChecked()); mp.put("inside_carpet", chkinside_carpet.isChecked()); mp.put("inside_curtain", chkinside_curtain.isChecked()); mp.put("inside_seatBelt", chkinside_seatBelt.isChecked()); mp.put("inside_backDoor", chkinside_backDoor.isChecked()); mp.put("inside_lidOil", chkinside_lidOil.isChecked()); mp.put("inside_setSeat", chkinside_setSeat.isChecked()); mp.put("inside_brakePedal", chkinside_brakePedal.isChecked()); mp.put("inside_accelerator", chkinside_accelerator.isChecked()); mp.put("inside_handBrake", chkinside_handBrake.isChecked()); filterStore("interior", mp); save(mp); } }); chkinside_seat.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_console.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_steeringWheel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_transmission.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_sideDoors.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_dashBoard.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_carpet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_curtain.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_seatBelt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_backDoor.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_lidOil.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_setSeat.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_brakePedal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_accelerator.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkinside_handBrake.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalInterior(increment); } else { increment = false; getTotalInterior(increment); } InteriorProgress.setProgress(PercenInterior); perceninterior.setText("" + PercenInterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headinterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadinterior = new TranslateAnimation(0, 0, 800, 180); slideheadinterior.setDuration(500); slideheadinterior.setFillAfter(true); headinterior.startAnimation(slideheadinterior); interiordialog.show(); WindowManager.LayoutParams params = interiordialog.getWindow().getAttributes(); params.y = 180; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; interiordialog.getWindow().setAttributes(params); chkinside_seat.setChecked(load("inside_seat")); chkinside_console.setChecked(load("inside_console")); chkinside_steeringWheel.setChecked(load("inside_steeringWheel")); chkinside_transmission.setChecked(load("inside_transmission")); chkinside_sideDoors.setChecked(load("inside_sideDoors")); chkinside_dashBoard.setChecked(load("inside_dashBoard")); chkinside_carpet.setChecked(load("inside_carpet")); chkinside_curtain.setChecked(load("inside_curtain")); chkinside_seatBelt.setChecked(load("inside_seatBelt")); chkinside_backDoor.setChecked(load("inside_backDoor")); chkinside_lidOil.setChecked(load("inside_lidOil")); chkinside_setSeat.setChecked(load("inside_setSeat")); chkinside_brakePedal.setChecked(load("inside_brakePedal")); chkinside_accelerator.setChecked(load("inside_accelerator")); chkinside_handBrake.setChecked(load("inside_handBrake")); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void createRemoteFileList(String remurl, String remdir, final NotifyEvent p_event, boolean readSubDirCnt) { final ArrayList<TreeFilelistItem> remoteFileList = new ArrayList<TreeFilelistItem>(); final ThreadCtrl tc = new ThreadCtrl(); tc.setEnabled();//from w w w . j av a 2s.c om 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 promptPasswordForImport(final String fpath, final NotifyEvent ntfy_pswd) { // ??// w w w.j a va 2s . 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.SMBSync2.SyncTaskUtility.java
public void promptPasswordForExport(final String fpath, final NotifyEvent ntfy_pswd) { // ??// www . jav a 2 s . c om 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 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();/*from www . j a v a2s . c om*/ 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.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/* w ww . ja va 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); }