List of usage examples for android.app Dialog Dialog
public Dialog(@NonNull Context context)
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void editFileFilterDlg(final ArrayList<String> file_filter, final NotifyEvent p_ntfy) { ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>(); final AdapterFilterList filterAdapter; // ??//w w w . j ava 2 s . c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn); dirbtn.setVisibility(Button.GONE); filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList); ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview); for (int i = 0; i < file_filter.size(); i++) { String inc = file_filter.get(i).substring(0, 1); String filter = file_filter.get(i).substring(1, file_filter.get(i).length()); boolean b_inc = false; if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE)) b_inc = true; filterAdapter.add(new FilterListItem(filter, b_inc)); } if (filterAdapter.getCount() == 0) filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false)); lv.setAdapter(filterAdapter); // filterAdapter.getFileFilter().filter("D"); // lv.setTextFilterEnabled(false); // lv.setDivider(new ColorDrawable(Color.WHITE)); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_file_filter)); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg); CommonDialog.setDlgBoxSizeLimit(dialog, true); // CommonDialog.setDlgBoxSizeCompact(dialog); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter); final Button addBtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { FilterListItem fli = filterAdapter.getItem(idx); if (fli.getFilter().startsWith("---") || fli.isDeleted()) return; // ???????? editDirFilter(idx, filterAdapter, fli, fli.getFilter()); } }); // Add? addBtn.setEnabled(false); et_filter.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() != 0) { if (isFilterExists(s.toString().trim(), filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, s.toString().trim())); addBtn.setEnabled(false); btn_ok.setEnabled(true); } else { dlg_msg.setText(""); addBtn.setEnabled(true); btn_ok.setEnabled(false); } } else { addBtn.setEnabled(false); btn_ok.setEnabled(true); } // et_filter.setText(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); addBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dlg_msg.setText(""); String newfilter = et_filter.getText().toString().trim(); et_filter.setText(""); if (filterAdapter.getItem(0).getFilter().startsWith("---")) filterAdapter.remove(filterAdapter.getItem(0)); filterAdapter.add(new FilterListItem(newfilter, true)); filterAdapter.setNotifyOnChange(true); filterAdapter.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); btn_ok.setEnabled(true); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); file_filter.clear(); if (filterAdapter.getCount() > 0) { for (int i = 0; i < filterAdapter.getCount(); i++) { if (!filterAdapter.getItem(i).isDeleted() && !filterAdapter.getItem(i).getFilter().startsWith("---")) { String inc = SMBSYNC_PROF_FILTER_EXCLUDE; if (filterAdapter.getItem(i).getInc()) inc = SMBSYNC_PROF_FILTER_INCLUDE; file_filter.add(inc + filterAdapter.getItem(i).getFilter()); } } } p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void createNewProfileGroup() { // ??// w w w.j a v a2s . 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.xmobileapp.rockplayer.RockPlayer.java
/********************************************* * // ww w . j ava 2s .c o m * getCurrentPlaying * get what the player service is currently * playing and update UI * *********************************************/ public void getCurrentPlaying() { //if(true) return; /* * ask the player service if/what he is playing */ int albumCursorPosition = 0; int songCursorPosition = 0; try { albumCursorPosition = this.playerServiceIface.getAlbumCursorPosition(); songCursorPosition = this.playerServiceIface.getSongCursorPosition(); } catch (RemoteException e) { e.printStackTrace(); } if (albumCursorPosition == -1 || songCursorPosition == -1) { // Log.i("GETCURPLAY", "BOTH CURSORS ARE -1"); // try{ // Random rand = new Random(); // if(albumCursor != null && rand != null) // albumCursorPosition = rand.nextInt(albumCursor.getCount()-1); // else // albumCursorPosition = 1; // albumCursorPositionPlaying = albumCursorPosition; // songCursorPosition = 0; // } catch (Exception e) { // try{ // if(albumCursor != null) // Log.i("EXCP", ""+albumCursor.getCount()); // } catch (Exception ee){ // ee.printStackTrace(); // } // e.printStackTrace(); // albumCursorPosition = 0; // albumCursorPositionPlaying = albumCursorPosition; // songCursorPosition = 0; // } // try { // playerServiceIface.setAlbumCursorPosition(albumCursorPosition); // playerServiceIface.setSongCursorPosition(songCursorPosition); // playerServiceIface.play(albumCursorPosition, songCursorPosition); // playerServiceIface.pause(); // // HACKzzzzzzzzz we need a paused event from the service // this.stopSongProgress(); // } catch (RemoteException e) { // e.printStackTrace(); // } } else { try { if (playerServiceIface.isPlaying()) { TransitionDrawable playPauseTDrawable = (TransitionDrawable) playPauseImage.getDrawable(); playPauseTDrawable.setCrossFadeEnabled(true); playPauseTDrawable.startTransition(1); playPauseTDrawable.invalidateSelf(); // this.playPauseImage.setImageResource(android.R.drawable.ic_media_pause); } } else { albumCursorPosition = playerServiceIface.getAlbumCursorPosition(); songCursorPosition = playerServiceIface.getSongCursorPosition(); albumCursorPositionPlaying = albumCursorPosition; // Log.i("INIT", albumCursorPosition+" "+songCursorPosition); // playerServiceIface.play(albumCursorPositionPlaying, // songCursorPosition); // playerServiceIface.pause(); this.stopSongProgress(); } } catch (Exception e) { e.printStackTrace(); } } // TODO: ask if he is playing /* * If media Library is empty just show a popup */ if (albumCursor.getCount() == 0) { Dialog noMediaDialog = new Dialog(this); noMediaDialog.setTitle("No Media Available"); //TextView noMediaText = new TextView(this); //noMediaText.setText("Please add some Music to your SD Card"); //noMediaDialog.setContentView(noMediaText); noMediaDialog.show(); return; } /* * Go to the current playing Media */ Log.i("GETCURPLAY", "MOVING CURSORS"); try { albumCursor.moveToPosition(albumCursorPosition); albumCursorPositionPlaying = albumCursorPosition; songCursor = initializeSongCursor( albumCursor.getString(albumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM))); songCursor.moveToPosition(songCursorPosition); } catch (Exception e) { e.printStackTrace(); } Log.i("GETCURPLAY", "GET ALBUM ART"); try { // /* // * get albumArt // */ // String albumCoverPath = albumCursor.getString( // albumCursor.getColumnIndexOrThrow( // MediaStore.Audio.Albums.ALBUM_ART)); // // if it does not exist in database look for our dir // if(albumCoverPath == null){ // String artistName = albumCursor.getString( // albumCursor.getColumnIndexOrThrow( // MediaStore.Audio.Albums.ARTIST)); // String albumName = albumCursor.getString( // albumCursor.getColumnIndexOrThrow( // MediaStore.Audio.Albums.ALBUM)); // String path = this.FILEX_ALBUM_ART_PATH+ // validateFileName(artistName)+ // " - "+ // validateFileName(albumName)+ // FILEX_FILENAME_EXTENSION; // File albumCoverFilePath = new File(path); // if(albumCoverFilePath.exists() && albumCoverFilePath.length() > 0){ // albumCoverPath = path; // } // } // // Log.i("GETCURPLAY", "UPDATING UI COMPONENT"); // // /* // * Update currentPlaying albumArt UI component // */ // if(albumCoverPath != null){ // // TODO: // // adjust sample size // Options opts = new Options(); // opts.inSampleSize = 1; // Bitmap albumCoverBitmap = BitmapFactory.decodeFile(albumCoverPath, opts); // this.currentAlbumPlayingImageView.setImageBitmap(albumCoverBitmap); // } else { // // TODO: // // adjust sample size dynamically // Options opts = new Options(); // opts.inSampleSize = 1; // Bitmap albumCoverBitmap = BitmapFactory.decodeResource(this.context.getResources(), // R.drawable.albumart_mp_unknown, opts); // if(albumCoverBitmap != null) // this.currentAlbumPlayingImageView.setImageBitmap(albumCoverBitmap); // } if (VIEW_STATE == FULLSCREEN_VIEW) this.currentAlbumPlayingImageView.setImageBitmap( albumAdapter.getAlbumBitmap(albumCursor.getPosition(), BITMAP_SIZE_FULLSCREEN)); else this.currentAlbumPlayingImageView .setImageBitmap(albumAdapter.getAlbumBitmap(albumCursor.getPosition(), BITMAP_SIZE_NORMAL)); if (showFrame) this.currentAlbumPlayingOverlayImageView.setVisibility(View.VISIBLE); else this.currentAlbumPlayingOverlayImageView.setVisibility(View.GONE); Log.i("GETCURPLAY", "UPDATING REST OF UI"); /* * Update currentPlaying artist UI component */ this.updateArtistTextUI(); /* * Update currentPlaying song UI component */ this.updateSongTextUI(); /* * Update Song Progress */ this.updateSongProgress(); Log.i("GETCURPLAY", "CENTER ALBUMLIST"); /* * Center Album List */ albumNavigatorList.setSelectionFromTop(albumCursorPositionPlaying, (int) Math.round((display.getHeight() - 20) / 2.0 - (display.getWidth() * (1 - CURRENT_PLAY_SCREEN_FRACTION_LANDSCAPE)))); this.albumNavigatorScrollListener.onScrollStateChanged(this.albumNavigatorList, OnScrollListener.SCROLL_STATE_IDLE); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void renameProfileGroupDlg(final String old_loc) { // ??// ww w . j a v a 2 s.c om 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_rename_profile_group)); CommonDialog.setDlgBoxSizeCompact(dialog); dlg_et_name.setText(old_loc); 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 new_loc = dlg_et_name.getText().toString(); renameProfileGroup(true, old_loc, new_loc); } @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.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void editDirFilterDlg(final SyncTaskItem sti, final String prof_master, final ArrayList<String> dir_filter, final NotifyEvent p_ntfy) { ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>(); final AdapterFilterList filterAdapter; // ??// www. j av a 2 s. c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList); final ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview); for (int i = 0; i < dir_filter.size(); i++) { String inc = dir_filter.get(i).substring(0, 1); String filter = dir_filter.get(i).substring(1, dir_filter.get(i).length()); boolean b_inc = false; if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE)) b_inc = true; filterAdapter.add(new FilterListItem(filter, b_inc)); } if (filterAdapter.getCount() == 0) filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false)); lv.setAdapter(filterAdapter); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_dir_filter)); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg); final Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn); CommonDialog.setDlgBoxSizeLimit(dialog, true); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter); final Button addbtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { FilterListItem fli = filterAdapter.getItem(idx); if (fli.getFilter().startsWith("---") || fli.isDeleted()) return; // ???????? editDirFilter(idx, filterAdapter, fli, fli.getFilter()); } }); // Add? et_filter.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() != 0) { if (isFilterExists(s.toString().trim(), filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, s.toString().trim())); addbtn.setEnabled(false); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } else { dlg_msg.setText(""); addbtn.setEnabled(true); dirbtn.setEnabled(false); btn_ok.setEnabled(false); } } else { addbtn.setEnabled(false); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } // et_filter.setText(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); addbtn.setEnabled(false); addbtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dlg_msg.setText(""); String newfilter = et_filter.getText().toString(); if (isFilterExists(newfilter, filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, newfilter)); return; } dlg_msg.setText(""); et_filter.setText(""); if (filterAdapter.getItem(0).getFilter().startsWith("---")) filterAdapter.remove(filterAdapter.getItem(0)); filterAdapter.add(new FilterListItem(newfilter, true)); filterAdapter.setNotifyOnChange(true); filterAdapter.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } }); // Directory? // if (getProfileType(prof_master,prof_dapter).equals("L")) { // if (!mGp.externalStorageIsMounted) dirbtn.setEnabled(false); // } else if (getProfileType(prof_master,prof_dapter).equals("R")) { // if (util.isRemoteDisable()) dirbtn.setEnabled(false); // } else dirbtn.setEnabled(false); dirbtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { dlg_msg.setText(""); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (arg1 != null) dlg_msg.setText((String) arg1[0]); else dlg_msg.setText(""); } }); listDirFilter(sti, prof_master, dir_filter, filterAdapter, ntfy); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); dir_filter.clear(); if (filterAdapter.getCount() > 0) { for (int i = 0; i < filterAdapter.getCount(); i++) { if (!filterAdapter.getItem(i).isDeleted() && !filterAdapter.getItem(i).getFilter().startsWith("---")) { String inc = SMBSYNC_PROF_FILTER_EXCLUDE; if (filterAdapter.getItem(i).getInc()) inc = SMBSYNC_PROF_FILTER_INCLUDE; dir_filter.add(inc + filterAdapter.getItem(i).getFilter()); } } } p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void copyProfileGroupDlg(final String old_loc) { // ??//from www . j a v a2 s. com 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_copy_profile_group)); CommonDialog.setDlgBoxSizeCompact(dialog); dlg_et_name.setText(old_loc); 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 new_loc = dlg_et_name.getText().toString(); copyProfileGroup(true, old_loc, new_loc); } @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.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void editDirFilter(final int edit_idx, final AdapterFilterList fa, final FilterListItem fli, final String filter) { // ??//w w w .j av a 2s .c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_edit_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_edit_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_edit_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_edit_dlg_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); CommonDialog.setDlgBoxSizeCompact(dialog); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_edit_dlg_filter); et_filter.setText(filter); // CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_edit_dlg_cancel_btn); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? Button btn_ok = (Button) dialog.findViewById(R.id.filter_edit_dlg_ok_btn); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_edit_dlg_msg); String newfilter = et_filter.getText().toString(); if (!filter.equals(newfilter)) { if (isFilterExists(newfilter, fa)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, newfilter)); return; } } dialog.dismiss(); fa.remove(fli); fa.insert(fli, edit_idx); fli.setFilter(newfilter); et_filter.setText(""); fa.setNotifyOnChange(true); fa.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); // p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void listDirFilterLocal(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter, final AdapterFilterList fla, final NotifyEvent p_ntfy) { final String cdir = sti.getMasterDirectoryName(); String localBaseDir_t = mGp.internalRootDirectory; if (sti.getMasterFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_SDCARD)) localBaseDir_t = mGp.sdcardRootDirectory; final String localBaseDir = localBaseDir_t; //??//from w w w .j av a 2s . c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title); final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_add_dir_filter)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + localBaseDir + "/" + cdir); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select); ll_context.setVisibility(LinearLayout.VISIBLE); final ImageButton ib_select_all = (ImageButton) ll_context.findViewById(R.id.context_button_select_all); final ImageButton ib_unselect_all = (ImageButton) ll_context.findViewById(R.id.context_button_unselect_all); dlg_msg.setVisibility(TextView.VISIBLE); // if (rows.size()<=2) // ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer)) // .setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); final ListView lv = (ListView) dialog.findViewById(android.R.id.list); final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, false, false); lv.setAdapter(tfa); ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, localBaseDir, "/" + cdir); if (tfl.size() < 1) tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); tfa.setDataList(tfl); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); ib_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { TreeFilelistItem tfli = tfa.getDataItem(i); if (!tfli.isHideListItem()) tfa.setDataItemIsSelected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(true); } }); ib_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { tfa.setDataItemIsUnselected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(false); } }); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { final int pos = tfa.getItem(idx); final TreeFilelistItem tfi = tfa.getDataItem(pos); if (tfi.getName().startsWith("---")) return; expandHideLocalDirTree(true, localBaseDir, pos, tfi, tfa); } }); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) { final int t_pos = tfa.getItem(position); final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return true; if (!tfa.getDataItem(t_pos).isChecked()) { tfa.setDataItemIsSelected(t_pos); } return true; } }); //OK? btn_ok.setEnabled(false); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { btn_ok.setEnabled(true); } @Override public void negativeResponse(Context arg0, Object[] arg1) { boolean checked = false; for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).isChecked()) { checked = true; break; } } if (checked) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); tfa.setCbCheckListener(ntfy); btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add)); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!addDirFilter(true, tfa, fla, "/" + cdir + "/", dlg_msg)) return; addDirFilter(false, tfa, fla, "/" + cdir + "/", dlg_msg); dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close)); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); return; }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void listDirFilterSMB(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter, final AdapterFilterList fla, final NotifyEvent p_ntfy) { setSmbUserPass(sti.getMasterRemoteUserID(), sti.getMasterRemotePassword()); String t_remurl = ""; if (sti.getMasterRemoteHostname().equals("")) t_remurl = sti.getMasterRemoteAddr(); else/* www . j a v a2s . c om*/ t_remurl = sti.getMasterRemoteHostname(); String h_port = ""; if (!sti.getMasterRemotePassword().equals("")) h_port = ":" + sti.getMasterRemotePort(); final String remurl = "smb://" + t_remurl + h_port + "/" + sti.getMasterRemoteSmbShareName(); final String remdir = "/" + sti.getMasterDirectoryName() + "/"; NotifyEvent ntfy = new NotifyEvent(mContext); // set thread response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>(); @SuppressWarnings("unchecked") ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0]; for (int i = 0; i < rfl.size(); i++) { if (rfl.get(i).isDir() && rfl.get(i).canRead()) rows.add(rfl.get(i)); } Collections.sort(rows); if (rows.size() < 1) rows.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); //?? final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.item_select_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog .findViewById(R.id.item_select_list_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title); final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_add_dir_filter)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + remurl + remdir); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg); final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select); ll_context.setVisibility(LinearLayout.VISIBLE); final ImageButton ib_select_all = (ImageButton) ll_context .findViewById(R.id.context_button_select_all); final ImageButton ib_unselect_all = (ImageButton) ll_context .findViewById(R.id.context_button_unselect_all); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); dlg_msg.setVisibility(TextView.VISIBLE); // if (rows.size()<=2) // ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer)) // .setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); final ListView lv = (ListView) dialog.findViewById(android.R.id.list); final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, false, false); tfa.setDataList(rows); lv.setAdapter(tfa); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); // lv.setFastScrollEnabled(true); ib_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { TreeFilelistItem tfli = tfa.getDataItem(i); if (!tfli.isHideListItem()) tfa.setDataItemIsSelected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(true); } }); ib_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { tfa.setDataItemIsUnselected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(false); } }); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { // ???????? final int pos = tfa.getItem(idx); final TreeFilelistItem tfi = tfa.getDataItem(pos); if (tfi.getName().startsWith("---")) return; expandHideRemoteDirTree(remurl, pos, tfi, tfa); } }); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) { final int t_pos = tfa.getItem(position); final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return true; if (!tfa.getDataItem(t_pos).isChecked()) { tfa.setDataItemIsSelected(t_pos); } return true; } }); //OK? btn_ok.setEnabled(false); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { btn_ok.setEnabled(true); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (tfa.isDataItemIsSelected()) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); tfa.setCbCheckListener(ntfy); btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add)); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!addDirFilter(true, tfa, fla, remdir, dlg_msg)) return; addDirFilter(false, tfa, fla, remdir, dlg_msg); dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close)); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); } @Override public void negativeResponse(Context c, Object[] o) { p_ntfy.notifyToListener(false, o); } }); createRemoteFileList(remurl, remdir, ntfy, true); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void editActivityExtraDataItem(final GlobalParameters mGlblParms, final int sel_pos) { // ??//from w w w .j a va 2 s . com final Dialog dialog = new Dialog(mGlblParms.context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // dialog.getWindow().setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.setContentView(R.layout.edit_activity_extra_data_item_dlg); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_msg); // final TextView dlg_title = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_title); // CommonDialog.setDlgBoxSizeLimit(dialog,true); final Button btn_cancel = (Button) dialog.findViewById(R.id.edit_activity_extra_data_item_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.edit_activity_extra_data_item_ok_btn); final EditText et_key = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_key); final EditText et_string = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_data_string); final EditText et_int = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_data_int); final CheckBox cb_array = (CheckBox) dialog.findViewById(R.id.edit_activity_extra_data_item_array); final Button btn_add_array = (Button) dialog.findViewById(R.id.edit_activity_extra_data_item_add_array); final ListView lv_array = (ListView) dialog.findViewById(R.id.edit_activity_extra_data_item_array_listview); final TextView lv_spacer = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_array_spacer); final Spinner spinnerExtraDataType = (Spinner) dialog .findViewById(R.id.edit_activity_extra_data_item_data_type); final CustomSpinnerAdapter adapterExtraDataType = new CustomSpinnerAdapter(mGlblParms.context, R.layout.custom_simple_spinner_item); adapterExtraDataType.setTextColor(Color.BLACK); setSpinnerExtraDataType(mGlblParms, dialog, spinnerExtraDataType, adapterExtraDataType, PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING); final Spinner spinnerExtraDataBoolean = (Spinner) dialog .findViewById(R.id.edit_activity_extra_data_item_data_boolean); final CustomSpinnerAdapter adapterExtraDataBoolean = new CustomSpinnerAdapter(mGlblParms.context, R.layout.custom_simple_spinner_item); adapterExtraDataBoolean.setTextColor(Color.BLACK); setSpinnerExtraDataBoolean(mGlblParms, dialog, spinnerExtraDataBoolean, adapterExtraDataBoolean, "false"); final Button update_apply = (Button) dialog .findViewById(R.id.edit_activity_extra_data_item_data_update_apply); final Button update_cancel = (Button) dialog .findViewById(R.id.edit_activity_extra_data_item_data_update_cancel); update_apply.setVisibility(Button.GONE); update_cancel.setVisibility(Button.GONE); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.GONE); btn_add_array.setVisibility(Button.GONE); lv_array.setVisibility(ListView.GONE); lv_spacer.setVisibility(TextView.VISIBLE); final ArrayList<DataArrayEditListItem> aed_array_list = new ArrayList<DataArrayEditListItem>(); final AdapterDataArrayEditList aed_array_adapter = new AdapterDataArrayEditList(mGlblParms.context, R.layout.data_array_edit_list_item, aed_array_list); lv_array.setAdapter(aed_array_adapter); setActivityExtraDataEditItemViewVisibility(mGlblParms, dialog, aed_array_adapter, spinnerExtraDataType); cb_array.setChecked(false); if (sel_pos != -1) { et_key.setEnabled(false); et_key.setTextColor(Color.WHITE); et_key.selectAll(); et_key.setText(mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).key_value); if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { et_string.setText(mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value); spinnerExtraDataType.setSelection(0); } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { et_int.setText(mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value); spinnerExtraDataType.setSelection(1); } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { spinnerExtraDataType.setSelection(2); if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value.equals("false")) spinnerExtraDataBoolean.setSelection(0); else spinnerExtraDataBoolean.setSelection(1); } mGlblParms.currentSelectedExtraDataType = spinnerExtraDataType.getSelectedItem().toString(); if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value_array .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_YES)) { cb_array.setChecked(true); et_string.setText(""); et_int.setText(""); createActivityExtraDataArrayList(aed_array_adapter, mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos)); aed_array_adapter.notifyDataSetChanged(); update_apply.setVisibility(Button.GONE); update_cancel.setVisibility(Button.GONE); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.GONE); btn_add_array.setVisibility(Button.VISIBLE); lv_array.setVisibility(ListView.VISIBLE); lv_spacer.setVisibility(TextView.GONE); } else { cb_array.setChecked(false); update_apply.setVisibility(Button.GONE); update_cancel.setVisibility(Button.GONE); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.GONE); btn_add_array.setVisibility(Button.GONE); lv_array.setVisibility(ListView.GONE); lv_spacer.setVisibility(TextView.VISIBLE); if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { et_string.setVisibility(EditText.VISIBLE); } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { et_int.setVisibility(EditText.VISIBLE); } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { spinnerExtraDataBoolean.setVisibility(Spinner.VISIBLE); } } } btn_add_array.setOnClickListener(new OnClickListener() { @Override final public void onClick(View arg0) { String n_data = ""; if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { n_data = ""; } else if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { n_data = "0"; } else if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { n_data = "false"; } DataArrayEditListItem aeda_item = new DataArrayEditListItem(); aeda_item.data_value = n_data; aed_array_adapter.add(aeda_item); aed_array_adapter.notifyDataSetChanged(); } }); NotifyEvent ntfy = new NotifyEvent(mGlblParms.context); ntfy.setListener(new NotifyEventListener() { @Override final public void positiveResponse(Context c, Object[] o) { spinnerExtraDataType.setEnabled(false); String c_data = (String) o[0]; if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { et_string.setText(c_data); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); et_string.setVisibility(EditText.VISIBLE); et_int.setVisibility(EditText.GONE); et_string.requestFocus(); } else if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { et_int.setText(c_data); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.VISIBLE); et_int.requestFocus(); } else if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { if (c_data.equals("false")) spinnerExtraDataBoolean.setSelection(0); else spinnerExtraDataBoolean.setSelection(1); spinnerExtraDataBoolean.setVisibility(Spinner.VISIBLE); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.GONE); } update_apply.setVisibility(Button.VISIBLE); update_cancel.setVisibility(Button.VISIBLE); btn_ok.setEnabled(false); btn_cancel.setEnabled(false); cb_array.setEnabled(false); btn_add_array.setEnabled(false); } @Override final public void negativeResponse(Context c, Object[] o) { } }); aed_array_adapter.setEditBtnNotifyListener(ntfy); update_apply.setVisibility(Button.GONE); update_cancel.setVisibility(Button.GONE); update_apply.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { boolean no_err = auditActivityExtraData(mGlblParms, dialog, spinnerExtraDataType, spinnerExtraDataBoolean); if (!no_err) return; int pos = -1; for (int i = 0; i < aed_array_list.size(); i++) { if (aed_array_list.get(i).while_edit) { pos = i; break; } } if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { aed_array_list.get(pos).data_value = et_string.getText().toString(); aed_array_list.get(pos).while_edit = false; } else if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { aed_array_list.get(pos).data_value = et_int.getText().toString(); aed_array_list.get(pos).while_edit = false; } else if (spinnerExtraDataType.getSelectedItem() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { String n_boolean = "true"; if (spinnerExtraDataBoolean.getSelectedItem().toString().equals("false")) n_boolean = "false"; aed_array_list.get(pos).data_value = n_boolean; aed_array_list.get(pos).while_edit = false; } et_string.setText(""); et_int.setText(""); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.GONE); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); aed_array_adapter.notifyDataSetChanged(); update_apply.setVisibility(Button.GONE); update_cancel.setVisibility(Button.GONE); spinnerExtraDataType.setEnabled(true); btn_ok.setEnabled(true); btn_cancel.setEnabled(true); cb_array.setEnabled(true); btn_add_array.setEnabled(true); } }); update_cancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { for (int i = 0; i < aed_array_list.size(); i++) { aed_array_list.get(i).while_edit = false; } et_string.setText(""); et_int.setText(""); et_string.setVisibility(EditText.GONE); et_int.setVisibility(EditText.GONE); spinnerExtraDataBoolean.setVisibility(Spinner.GONE); aed_array_adapter.notifyDataSetChanged(); update_apply.setVisibility(Button.GONE); update_cancel.setVisibility(Button.GONE); spinnerExtraDataType.setEnabled(true); btn_ok.setEnabled(true); btn_cancel.setEnabled(true); cb_array.setEnabled(true); btn_add_array.setEnabled(true); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { dialog.dismiss(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { ActivityExtraDataItem aedi = null; if (sel_pos == -1) {//Add item if (et_key.getText().toString().equals("")) { dlg_msg.setText(mGlblParms.context .getString(R.string.msgs_edit_profile_action_activity_extra_data_key_name_missing)); return; } aedi = new ActivityExtraDataItem(); } else {//Edit item aedi = mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos); } aedi.key_value = et_key.getText().toString(); if (cb_array.isChecked()) { if (aed_array_list.size() == 0) { dlg_msg.setText(mGlblParms.context.getString( R.string.msgs_edit_profile_action_activity_extra_data_array_data_missing)); return; } aedi.data_value_array = PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_YES; aedi.data_type = spinnerExtraDataType.getSelectedItem().toString(); aedi.data_value = ""; // Log.v("","array size="+aed_array_list.size()); for (int i = 0; i < aed_array_list.size(); i++) { if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { // aedi.data_value+="\u00a0"+aed_array_list.get(i).array_data_value+"\u0003"; aedi.data_value += aed_array_list.get(i).data_value + "\u0003"; // GeneralUtilities.hexString("String",aed_array_list.get(i).array_data_value.getBytes(),0,aed_array_list.get(i).array_data_value.getBytes().length); } else { aedi.data_value += aed_array_list.get(i).data_value + "\u0003"; // GeneralUtilities.hexString("int",aed_array_list.get(i).data_value.getBytes(),0,aed_array_list.get(i).data_value.getBytes().length); } } // GeneralUtilities.hexString("test",aedi.data_value.getBytes(),0,aedi.data_value.getBytes().length); // Log.v("","dv="+aedi.data_value.replaceAll("\u0003", ";")); } else { boolean no_err = auditActivityExtraData(mGlblParms, dialog, spinnerExtraDataType, spinnerExtraDataBoolean); if (!no_err) return; else { aedi.data_value_array = PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_NO; aedi.data_type = spinnerExtraDataType.getSelectedItem().toString(); if (spinnerExtraDataType.getSelectedItem().toString() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { aedi.data_value = et_string.getText().toString(); } else if (spinnerExtraDataType.getSelectedItem().toString() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { aedi.data_value = et_int.getText().toString(); } else if (spinnerExtraDataType.getSelectedItem().toString() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { if (spinnerExtraDataBoolean.getSelectedItem().toString().equals("false")) aedi.data_value = "false"; else aedi.data_value = "true"; } } } if (sel_pos == -1) mGlblParms.activityExtraDataEditListAdapter.add(aedi); if (mGlblParms.activityExtraDataEditListAdapter.getItem(0).key_value.equals("")) mGlblParms.activityExtraDataEditListAdapter.remove(0); mGlblParms.activityExtraDataEditListAdapter.notifyDataSetChanged(); dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setCancelable(false); dialog.show(); }