List of usage examples for android.app Dialog setOnCancelListener
public void setOnCancelListener(@Nullable OnCancelListener listener)
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void createNewProfileGroup() { // ??// w ww. ja v a2 s . co m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // dialog.getWindow().setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.setContentView(R.layout.single_item_input_dlg); final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title); final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir); // final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg); final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn); final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn); btnOK.setEnabled(false); dlg_title.setText(mContext.getString(R.string.msgs_profile_group_create_new_profile_group)); CommonDialog.setDlgBoxSizeCompact(dialog); dlg_et_name.addTextChangedListener(new TextWatcher() { @Override final public void afterTextChanged(Editable s) { if (s.length() != 0) { // dlg_et_name.selectAll(); String newgrp = dlg_et_name.getText().toString(); if (!newgrp.startsWith("*")) { btnOK.setEnabled(true); for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) { if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) { btnOK.setEnabled(false); break; } } } else btnOK.setEnabled(false); } else btnOK.setEnabled(false); } @Override final public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override final public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override final public void positiveResponse(Context c, Object[] o) { dlg_et_name.selectAll(); String newloc = dlg_et_name.getText().toString(); mGlblParms.profileGroupAdapter.add(new ProfileGroupListItem(newloc, false, 0, 0, 0)); mGlblParms.profileGroupAdapter.sort(); mGlblParms.profileGroupAdapter.notifyDataSetChanged(); ProfileListItem tpli = new ProfileListItem(); tpli.setTaskEntry(PROFILE_VERSION_CURRENT, newloc, false, System.currentTimeMillis(), "", mContext.getString(R.string.msgs_no_profile_entry), "", "", "", "", null, null); mGlblParms.profileAdapter.addDataListItem(tpli); mGlblParms.profileAdapter.updateShowList(); setProfileGroupSelectorListener(); } @Override final public void negativeResponse(Context c, Object[] o) { } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { dialog.dismiss(); } }); // OK? btnOK.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { ntfy.notifyToListener(POSITIVE, null); dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideEngineLayout() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float height = metrics.heightPixels; float width = metrics.widthPixels; int left840 = (int) ((width / 100) * 65.625); final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog enginedialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); enginedialog.requestWindowFeature(Window.FEATURE_NO_TITLE); enginedialog.setContentView(R.layout.enginedialoglayout); enginedialog.getWindow().getAttributes().windowAnimations = R.style.EngineDialogAnimation; enginedialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = enginedialog.getWindow().getAttributes(); lp.dimAmount = 0f;//from w ww.jav a2 s .c o m final CheckBox chkengine_hood = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_hood); final CheckBox chkengine_backHood = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_backHood); final CheckBox chkengine_underEngine = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_underEngine); final CheckBox chkengine_brakeOil = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_brakeOil); final CheckBox chkengine_engineOil = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_engineOil); final CheckBox chkengine_waterCoolant = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_waterCoolant); final CheckBox chkengine_belt = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_belt); final CheckBox chkengine_gear = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_gear); final CheckBox chkengine_liquidLevel = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_liquidLevel); final CheckBox chkengine_soundOut = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_soundOut); final CheckBox chkengine_soundIn = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_soundIn); // Change font chkengine_hood.setTypeface(type); chkengine_backHood.setTypeface(type); chkengine_underEngine.setTypeface(type); chkengine_brakeOil.setTypeface(type); chkengine_engineOil.setTypeface(type); chkengine_waterCoolant.setTypeface(type); chkengine_belt.setTypeface(type); chkengine_gear.setTypeface(type); chkengine_liquidLevel.setTypeface(type); chkengine_soundOut.setTypeface(type); chkengine_soundIn.setTypeface(type); enginedialog.setCanceledOnTouchOutside(true); enginedialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headengine.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadengine = new TranslateAnimation(0, 0, 490, -500); slideoutheadengine.setDuration(300); slideoutheadengine.setFillAfter(true); headengine.startAnimation(slideoutheadengine); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("engine_hood", chkengine_hood.isChecked()); mp.put("engine_backHood", chkengine_backHood.isChecked()); mp.put("engine_underEngine", chkengine_underEngine.isChecked()); mp.put("engine_brakeOil", chkengine_brakeOil.isChecked()); mp.put("engine_engineOil", chkengine_engineOil.isChecked()); mp.put("engine_waterCoolant", chkengine_waterCoolant.isChecked()); mp.put("engine_belt", chkengine_belt.isChecked()); mp.put("engine_gear", chkengine_gear.isChecked()); mp.put("engine_liquidLevel", chkengine_liquidLevel.isChecked()); mp.put("engine_soundOut", chkengine_soundOut.isChecked()); mp.put("engine_soundIn", chkengine_soundIn.isChecked()); filterStore("engine", mp); save(mp); } }); TextView engine = (TextView) enginedialog.getWindow().findViewById(R.id.Engine); engine.setTypeface(type); Button engineback = (Button) enginedialog.getWindow().findViewById(R.id.Engineback); engineback.setTypeface(type); engineback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { enginedialog.dismiss(); headengine.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadengine = new TranslateAnimation(0, 0, 490, -500); slideoutheadengine.setDuration(300); slideoutheadengine.setFillAfter(true); headengine.startAnimation(slideoutheadengine); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("engine_hood", chkengine_hood.isChecked()); mp.put("engine_backHood", chkengine_backHood.isChecked()); mp.put("engine_underEngine", chkengine_underEngine.isChecked()); mp.put("engine_brakeOil", chkengine_brakeOil.isChecked()); mp.put("engine_engineOil", chkengine_engineOil.isChecked()); mp.put("engine_waterCoolant", chkengine_waterCoolant.isChecked()); mp.put("engine_belt", chkengine_belt.isChecked()); mp.put("engine_gear", chkengine_gear.isChecked()); mp.put("engine_liquidLevel", chkengine_liquidLevel.isChecked()); mp.put("engine_soundOut", chkengine_soundOut.isChecked()); mp.put("engine_soundIn", chkengine_soundIn.isChecked()); filterStore("engine", mp); save(mp); } }); chkengine_hood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_backHood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_underEngine.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_brakeOil.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_engineOil.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_waterCoolant.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_belt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_gear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_liquidLevel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_soundOut.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_soundIn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headengine.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadengine = new TranslateAnimation(0, 0, 0, 490); slideheadengine.setDuration(300); slideheadengine.setFillAfter(true); headengine.startAnimation(slideheadengine); enginedialog.show(); WindowManager.LayoutParams params = enginedialog.getWindow().getAttributes(); params.y = 1; params.x = left840; params.gravity = Gravity.TOP | Gravity.LEFT; enginedialog.getWindow().setAttributes(params); chkengine_hood.setChecked(load("engine_hood")); chkengine_backHood.setChecked(load("engine_backHood")); chkengine_underEngine.setChecked(load("engine_underEngine")); chkengine_brakeOil.setChecked(load("engine_brakeOil")); chkengine_engineOil.setChecked(load("engine_engineOil")); chkengine_waterCoolant.setChecked(load("engine_waterCoolant")); chkengine_belt.setChecked(load("engine_belt")); chkengine_gear.setChecked(load("engine_gear")); chkengine_liquidLevel.setChecked(load("engine_liquidLevel")); chkengine_soundOut.setChecked(load("engine_soundOut")); chkengine_soundIn.setChecked(load("engine_soundIn")); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
@SuppressLint("NewApi") final private void aboutTaskAutomation() { // common ??//from w w w. j a va2s. c o m final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); ((TextView) dialog.findViewById(R.id.about_dialog_title)) .setText(getString(R.string.msgs_about_dlg_title) + " Ver " + getApplVersionName()); final WebView func_view = (WebView) dialog.findViewById(R.id.about_dialog_function); // func_view.setWebViewClient(new WebViewClient()); // func_view.getSettings().setJavaScriptEnabled(true); func_view.getSettings().setSupportZoom(true); // func_view.setVerticalScrollbarOverlay(true); func_view.setBackgroundColor(Color.LTGRAY); // func_view.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); func_view.setVerticalScrollBarEnabled(true); func_view.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT > 10) { func_view.getSettings().setDisplayZoomControls(true); func_view.getSettings().setBuiltInZoomControls(true); } else { func_view.getSettings().setBuiltInZoomControls(true); } func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_about_dlg_func_html)); final WebView change_view = (WebView) dialog.findViewById(R.id.about_dialog_change_history); if (Build.VERSION.SDK_INT > 10) { func_view.getSettings().setDisplayZoomControls(true); func_view.getSettings().setBuiltInZoomControls(true); } else { func_view.getSettings().setBuiltInZoomControls(true); } change_view.loadDataWithBaseURL("file:///android_asset/", getString(R.string.msgs_about_dlg_change_desc), "text/html", "UTF-8", ""); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setSupportZoom(true); if (Build.VERSION.SDK_INT > 10) { change_view.getSettings().setDisplayZoomControls(true); change_view.getSettings().setBuiltInZoomControls(true); } else { change_view.getSettings().setBuiltInZoomControls(true); } final Button btnFunc = (Button) dialog.findViewById(R.id.about_dialog_btn_show_func); final Button btnChange = (Button) dialog.findViewById(R.id.about_dialog_btn_show_change); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); func_view.setVisibility(TextView.VISIBLE); change_view.setVisibility(TextView.GONE); btnChange.setBackgroundResource(R.drawable.button_back_ground_color_selector); btnFunc.setBackgroundResource(R.drawable.button_back_ground_color_selector); btnChange.setTextColor(Color.DKGRAY); btnFunc.setTextColor(Color.GREEN); btnFunc.setEnabled(false); CommonDialog.setDlgBoxSizeLimit(dialog, true); // func? btnFunc.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.GONE); func_view.setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); btnFunc.setTextColor(Color.GREEN); btnChange.setTextColor(Color.DKGRAY); btnChange.setEnabled(true); btnFunc.setEnabled(false); } }); // change? btnChange.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.VISIBLE); func_view.setVisibility(TextView.GONE); CommonDialog.setDlgBoxSizeLimit(dialog, true); btnChange.setTextColor(Color.GREEN); btnFunc.setTextColor(Color.DKGRAY); btnChange.setEnabled(false); btnFunc.setEnabled(true); } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java
private void aboutSMBSync() { // common ??/*from w w w. j a va 2 s . c om*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); ((TextView) dialog.findViewById(R.id.about_dialog_title)) .setText(getString(R.string.msgs_dlg_title_about) + "(Ver " + packageVersionName + ")"); final WebView func_view = (WebView) dialog.findViewById(R.id.about_dialog_function); // func_view.loadDataWithBaseURL("file:///android_asset/", // getString(R.string.msgs_dlg_title_about_func_desc),"text/html","UTF-8",""); func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_func_desc)); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); func_view.getSettings().setBuiltInZoomControls(true); final WebView change_view = (WebView) dialog.findViewById(R.id.about_dialog_change_history); change_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_change_desc)); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setBuiltInZoomControls(true); final Button btnFunc = (Button) dialog.findViewById(R.id.about_dialog_btn_show_func); final Button btnChange = (Button) dialog.findViewById(R.id.about_dialog_btn_show_change); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); func_view.setVisibility(TextView.VISIBLE); change_view.setVisibility(TextView.GONE); btnChange.setBackgroundResource(R.drawable.button_bg_color_selector); btnFunc.setBackgroundResource(R.drawable.button_bg_color_selector); btnChange.setTextColor(Color.DKGRAY); btnFunc.setTextColor(Color.GREEN); btnFunc.setEnabled(false); // btnOk.setTextColor(Color.DKGRAY); // btnOk.setTextColor(Color.GREEN); // btnOk.setBackgroundResource(R.drawable.button_back_ground_color_selector); CommonDialog.setDlgBoxSizeLimit(dialog, true); // func? btnFunc.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.GONE); func_view.setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); // func_view.setEnabled(true); // change_view.setEnabled(false); btnFunc.setTextColor(Color.GREEN); btnChange.setTextColor(Color.DKGRAY); btnChange.setEnabled(true); btnFunc.setEnabled(false); } }); // change? btnChange.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.VISIBLE); func_view.setVisibility(TextView.GONE); CommonDialog.setDlgBoxSizeLimit(dialog, true); // func_view.setEnabled(true); // change_view.setEnabled(false); btnChange.setTextColor(Color.GREEN); btnFunc.setTextColor(Color.DKGRAY); btnChange.setEnabled(false); btnFunc.setEnabled(true); } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(mContext)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void setRemoteShare(final String prof_user, final String prof_pass, final String prof_addr, final NotifyEvent p_ntfy) { final ArrayList<String> rows = new ArrayList<String>(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override// ww w. j ava 2 s . c om public void positiveResponse(Context c, Object[] o) { FileListAdapter tfl = (FileListAdapter) o[0]; for (int i = 0; i < tfl.getCount(); i++) { FileListItem item = tfl.getItem(i); if (item.isDir() && item.canRead() && !item.getName().startsWith("IPC$")) { String tmp = item.getName(); rows.add(tmp); } } if (rows.size() < 1) rows.add(getString(R.string.msgs_no_shared_resource)); //?? final Dialog dialog = new Dialog(c); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); ((TextView) dialog.findViewById(R.id.item_select_list_dlg_title)).setText("Select remote share"); ((TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle)).setText(""); CommonDialog.setDlgBoxSizeLimit(dialog, false); ListView lv = (ListView) dialog.findViewById(android.R.id.list); lv.setAdapter(new ArrayAdapter<String>(c, R.layout.simple_list_item_1m, rows)); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { if (rows.get(idx).startsWith("---")) return; dialog.dismiss(); // ???????? p_ntfy.notifyToListener(true, new Object[] { rows.get(idx).toString() }); } }); //CANCEL? final Button btnCancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, new Object[] { "" }); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // dialog.setCancelable(false); dialog.show(); } @Override public void negativeResponse(Context c, Object[] o) { p_ntfy.notifyToListener(false, new Object[] { "Remote file list creation error" }); } }); createRemoteFileList("smb://" + prof_addr + "/", ntfy); return; }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void renameProfile(final SyncTaskItem pli, final NotifyEvent p_ntfy) { // ??/* ww 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.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 ww w. j a v a 2s.c o 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.ActivityMain.java
@SuppressLint("InflateParams") private void aboutSMBSync() { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.about_dialog_title_view); final TextView title = (TextView) dialog.findViewById(R.id.about_dialog_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(getString(R.string.msgs_dlg_title_about) + "(Ver " + packageVersionName + ")"); // get our tabHost from the xml final TabHost tab_host = (TabHost) dialog.findViewById(R.id.about_tab_host); tab_host.setup();//from w w w. ja v a2 s.c o m final TabWidget tab_widget = (TabWidget) dialog.findViewById(android.R.id.tabs); if (Build.VERSION.SDK_INT >= 11) { tab_widget.setStripEnabled(false); tab_widget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); } CustomTabContentView tabViewProf = new CustomTabContentView(this, getString(R.string.msgs_about_dlg_func_btn)); tab_host.addTab(tab_host.newTabSpec("func").setIndicator(tabViewProf).setContent(android.R.id.tabcontent)); CustomTabContentView tabViewHist = new CustomTabContentView(this, getString(R.string.msgs_about_dlg_change_btn)); tab_host.addTab( tab_host.newTabSpec("change").setIndicator(tabViewHist).setContent(android.R.id.tabcontent)); LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout ll_func = (LinearLayout) vi.inflate(R.layout.about_dialog_func, null); LinearLayout ll_change = (LinearLayout) vi.inflate(R.layout.about_dialog_change, null); final WebView func_view = (WebView) ll_func.findViewById(R.id.about_dialog_function); func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_func_desc)); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); func_view.getSettings().setBuiltInZoomControls(true); final WebView change_view = (WebView) ll_change.findViewById(R.id.about_dialog_change_history); change_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_change_desc)); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setBuiltInZoomControls(true); final CustomViewPagerAdapter mAboutViewPagerAdapter = new CustomViewPagerAdapter(this, new WebView[] { func_view, change_view }); final CustomViewPager mAboutViewPager = (CustomViewPager) dialog.findViewById(R.id.about_view_pager); // mMainViewPager.setBackgroundColor(mThemeColorList.window_color_background); mAboutViewPager.setAdapter(mAboutViewPagerAdapter); mAboutViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // util.addDebugMsg(2,"I","onPageSelected entered, pos="+position); tab_widget.setCurrentTab(position); tab_host.setCurrentTab(position); } @Override public void onPageScrollStateChanged(int state) { // util.addDebugMsg(2,"I","onPageScrollStateChanged entered, state="+state); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // util.addDebugMsg(2,"I","onPageScrolled entered, pos="+position); } }); tab_host.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { util.addDebugMsg(2, "I", "onTabchanged entered. tab=" + tabId); mAboutViewPager.setCurrentItem(tab_host.getCurrentTab()); } }); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); CommonDialog.setDlgBoxSizeLimit(dialog, true); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void selectRemoteShareDlg(final String remurl, String remdir, final NotifyEvent p_ntfy) { NotifyEvent ntfy = new NotifyEvent(mContext); // set thread response ntfy.setListener(new NotifyEventListener() { @Override//from w w w . j av a 2s . c om public void positiveResponse(Context c, Object[] o) { final ArrayList<String> rows = new ArrayList<String>(); @SuppressWarnings("unchecked") ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0]; for (int i = 0; i < rfl.size(); i++) { if (rfl.get(i).isDir() && rfl.get(i).canRead() && !rfl.get(i).getName().endsWith("$")) // !rfl.get(i).getName().startsWith("IPC$")) rows.add(rfl.get(i).getName().replaceAll("/", "")); } boolean wk_list_empty = false; if (rows.size() < 1) { wk_list_empty = true; rows.add(mContext.getString(R.string.msgs_dir_empty)); } final boolean list_empty = wk_list_empty; Collections.sort(rows, String.CASE_INSENSITIVE_ORDER); //?? final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog .findViewById(R.id.item_select_list_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title); final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_select_remote_share)); subtitle.setVisibility(TextView.GONE); // if (rows.size()<=2) // ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer)) // .setVisibility(TextView.VISIBLE); final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); btn_ok.setEnabled(false); CommonDialog.setDlgBoxSizeLimit(dialog, false); final ListView lv = (ListView) dialog.findViewById(android.R.id.list); if (!list_empty) { lv.setAdapter( new ArrayAdapter<String>(mContext, R.layout.custom_simple_list_item_checked, rows)); // android.R.layout.simple_list_item_checked,rows)); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } else { lv.setAdapter(new ArrayAdapter<String>(mContext, R.layout.simple_list_item_1o, rows)); } lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { if (rows.get(idx).startsWith("---")) return; if (!list_empty) btn_ok.setEnabled(true); } }); //CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); //OK? btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); SparseBooleanArray checked = lv.getCheckedItemPositions(); for (int i = 0; i <= rows.size(); i++) { if (checked.get(i) == true) { p_ntfy.notifyToListener(true, new Object[] { rows.get(i) }); break; } } } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); } @Override public void negativeResponse(Context c, Object[] o) { p_ntfy.notifyToListener(false, o); } }); createRemoteFileList(remurl, remdir, ntfy, false); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void createItem(final FileListAdapter fla, final String item_optyp, final String base_dir) { sendDebugLogMsg(1, "I", "createItem entered."); // ??/*from w w w. j av a2 s .c o m*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.file_rename_create_dlg); final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname); final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn); final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn); CommonDialog.setDlgBoxSizeCompact(dialog); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Create directory"); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name"); // newName.setText(item_name); btnOk.setEnabled(false); // btnCancel.setEnabled(false); newName.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().length() < 1) btnOk.setEnabled(false); else btnOk.setEnabled(true); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); if (!checkDuplicateDir(fla, newName.getText().toString())) { commonDlg.showCommonDialog(false, "E", "Create", "Duplicate directory name specified", null); } else { int cmd = 0; if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "", newName.getText().toString(), "", smbUser, smbPass, true); cmd = FILEIO_PARM_LOCAL_CREATE; } else { cmd = FILEIO_PARM_REMOTE_CREATE; fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "", newName.getText().toString(), "", smbUser, smbPass, true); } sendDebugLogMsg(1, "I", "createItem FILEIO task invoked."); startFileioTask(fla, cmd, fileioLinkParm, newName.getText().toString(), null, null); } } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); sendDebugLogMsg(1, "W", "createItem cancelled."); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // setFixedOrientation(true); // dialog.setCancelable(false); dialog.show(); }