List of usage examples for android.widget CheckedTextView setChecked
public void setChecked(boolean checked)
From source file:com.open.file.manager.MainActivity.java
public void onLongclickfile(int position, int fragnum, View item, AdapterView<?> parent) { CheckedTextView tv = ((Gridviewholder) item.getTag()).filename; Gridviewholder holder = ((Gridviewholder) item.getTag()); if (!tv.isChecked()) { selectedfiles.add(holder.associatedfile); tv.setChecked(true); selectedcount++;// www . ja v a2 s . co m if (selectedcount == 2) { mMode.getMenu().getItem(Consts.INDEX_RENAME).setVisible(false); mMode.getMenu().getItem(Consts.INDEX_INFO).setVisible(false); } if (mMode == null) { mMode = startActionMode(getCutCopyCallback()); } } else { selectedfiles.remove(holder.associatedfile); tv.setChecked(false); selectedcount--; if (selectedcount == 1) { mMode.getMenu().getItem(Consts.INDEX_RENAME).setVisible(true); mMode.getMenu().getItem(Consts.INDEX_INFO).setVisible(true); } if (selectedcount == 0) { mMode.finish(); mMode = null; } } }
From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabPageIndicator.java
private void addTemporaryTab() { for (int i = 0; i < 3; i++) { CharSequence title = null; if (i == 0) title = "TAB ONE"; else if (i == 1) title = "TAB TWO"; else if (i == 2) title = "TAB THREE"; CheckedTextView tv = new CheckedTextView(getContext()); tv.setCheckMarkDrawable(null);/* w ww .j a v a2 s . co m*/ tv.setText(title); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(getContext(), mTextAppearance); tv.setSingleLine(true); tv.setEllipsize(TruncateAt.END); tv.setTag(i); tv.setChecked(i == 0); if (mMode == MODE_SCROLL) { tv.setPadding(mTabPadding, 0, mTabPadding, 0); mTabContainer.addView(tv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); } else if (mMode == MODE_FIXED) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT); params.weight = 1f; mTabContainer.addView(tv, params); } } }
From source file:universe.constellation.orion.viewer.OrionViewerActivity.java
public void initRotationScreen() { //if (getDevice() instanceof EdgeDevice) { if (false) {// ww w . jav a 2 s . c o m final RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup); rotationGroup.check(R.id.rotate0); if (Device.Info.NOOK2) { RadioButton r0 = (RadioButton) rotationGroup.findViewById(R.id.rotate0); RadioButton r90 = (RadioButton) rotationGroup.findViewById(R.id.rotate90); RadioButton r270 = (RadioButton) rotationGroup.findViewById(R.id.rotate270); TextView tv = (TextView) findMyViewById(R.id.navigation_title); int color = tv.getTextColors().getDefaultColor(); r0.setTextColor(color); r90.setTextColor(color); r270.setTextColor(color); } getSubscriptionManager().addDocListeners(new DocumentViewAdapter() { @Override public void documentOpened(Controller controller) { updateRotation(); } }); ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply); apply.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onApplyAction(true); int id = rotationGroup.getCheckedRadioButtonId(); controller.setRotation(id == R.id.rotate0 ? 0 : id == R.id.rotate90 ? -1 : 1); } }); ListView list = (ListView) findMyViewById(R.id.rotationList); list.setVisibility(View.GONE); } else { RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup); rotationGroup.setVisibility(View.GONE); final ListView list = (ListView) findMyViewById(R.id.rotationList); //set choices and replace 0 one with Application Default boolean isLevel9 = getOrionContext().getSdkVersion() >= 9; CharSequence[] values = getResources().getTextArray( isLevel9 ? R.array.screen_orientation_full_desc : R.array.screen_orientation_desc); CharSequence[] newValues = new CharSequence[values.length]; for (int i = 0; i < values.length; i++) { newValues[i] = values[i]; } newValues[0] = getResources().getString(R.string.orientation_default_rotation); list.setAdapter(Device.Info.NOOK2 ? new Nook2ListAdapter(this, android.R.layout.simple_list_item_single_choice, newValues, (TextView) findMyViewById(R.id.navigation_title)) : new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, newValues)); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemChecked(0, true); list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) { CheckedTextView check = (CheckedTextView) view; check.setChecked(!check.isChecked()); } }); final CharSequence[] ORIENTATION_ARRAY = getResources().getTextArray(R.array.screen_orientation_full); list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) { onApplyAction(true); String orientation = ORIENTATION_ARRAY[position].toString(); controller.changeOrinatation(orientation); } }); ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply); apply.setVisibility(View.GONE); // apply.setOnClickListener(new View.OnClickListener() { // public void onClick(View view) { // onApplyAction(true); // } // }); } ImageButton cancel = (ImageButton) findMyViewById(R.id.rotation_close); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onAnimatorCancel(); updateRotation(); } }); }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
private void displayTextSizeSelection(final Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); LayoutInflater inflater = activity.getLayoutInflater(); View layout = inflater.inflate(R.layout.text_size_selection, null); builder.setTitle(R.string.font_size); builder.setView(layout);//from w w w .j a v a 2 s .co m builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); final AlertDialog dialog = builder.create(); dialog.show(); LinearLayout linearLayout = layout.findViewById(R.id.text_selection_group_view); int childCount = linearLayout.getChildCount(); String scaleText = VectorApp.getFontScale(); for (int i = 0; i < childCount; i++) { View v = linearLayout.getChildAt(i); if (v instanceof CheckedTextView) { final CheckedTextView checkedTextView = (CheckedTextView) v; checkedTextView.setChecked(TextUtils.equals(checkedTextView.getText(), scaleText)); checkedTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); VectorApp.updateFontScale(checkedTextView.getText().toString()); activity.startActivity(activity.getIntent()); activity.finish(); } }); } } }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
private void confirmUseAppSpecificDir(final ArrayList<SyncTaskItem> alp, final NotifyEvent p_ntfy) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); if (!prefs.getBoolean(getString(R.string.settings_suppress_warning_app_specific_dir), false)) { boolean app_specific_used = false; String prof_list = "", sep = ""; for (int i = 0; i < alp.size(); i++) { if (alp.get(i).getTargetFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_INTERNAL) || alp.get(i).getTargetFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_SDCARD)) { if (alp.get(i).getTargetDirectoryName().startsWith(APP_SPECIFIC_DIRECTORY)) { app_specific_used = true; prof_list += sep + alp.get(i).getSyncTaskName(); sep = ","; }//from w w w . j a v a 2 s. c o m } } if (app_specific_used) { final Dialog dialog = new Dialog(mActivity);//, android.R.style.Theme_Black); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_app_specific_dir_dlg); final LinearLayout title_view = (LinearLayout) dialog .findViewById(R.id.confirm_app_specific_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.confirm_app_specific_dlg_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setText(mContext.getString(R.string.msgs_local_mount_point_app_specific_dir_used_title)); title.setTextColor(mGp.themeColorList.text_color_warning); ((TextView) dialog.findViewById(R.id.confirm_app_specific_dlg_msg)) .setText(mContext.getString(R.string.msgs_local_mount_point_app_specific_dir_used_msg) + "\n\n" + prof_list + "\n"); final Button btnOk = (Button) dialog.findViewById(R.id.confirm_app_specific_dlg_ok); final Button btnCancel = (Button) dialog.findViewById(R.id.confirm_app_specific_dlg_cancel); final CheckedTextView ctvSuppr = (CheckedTextView) dialog .findViewById(R.id.confirm_app_specific_dlg_ctv_suppress); CommonUtilities.setCheckedTextView(ctvSuppr); CommonDialog.setDlgBoxSizeCompact(dialog); ctvSuppr.setChecked(false); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); if (ctvSuppr.isChecked()) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); prefs.edit().putBoolean(getString(R.string.settings_suppress_warning_app_specific_dir), true).commit(); } p_ntfy.notifyToListener(true, null); } }); // Cancel? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(mContext)); // dialog.setCancelable(false); dialog.show(); } else { p_ntfy.notifyToListener(true, null); } } else { p_ntfy.notifyToListener(true, null); } }
From source file:com.dsdar.thosearoundme.util.MemberAddContactsListFragment.java
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // Gets the Cursor object currently bound to the ListView final Cursor cursor = mAdapter.getCursor(); Contact aContactToBeRemoved = null;/*from w w w. j a v a2 s. c om*/ String aContactCursorId; String aEmailId = null; String aPhoneNumber = null; boolean isExist = false; // Moves to the Cursor row corresponding to the ListView item that was // clicked cursor.moveToPosition(position); // Creates a contact lookup Uri from contact ID and lookup_key final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY)); // Notifies the parent activity that the user selected a contact. In a // two-pane layout, the // parent activity loads a ContactDetailFragment that displays the // details for the selected // contact. In a single-pane layout, the parent activity starts a new // activity that // displays contact details in its own Fragment. // niaz checking Log.d("positionI", String.valueOf(position)); CheckedTextView aCheckedTV = (CheckedTextView) v.findViewById(android.R.id.text1); mOnContactSelectedListener.onContactSelected(uri); HashMap<Integer, Boolean> aHashMap = new HashMap<Integer, Boolean>(); aHashMap.put(position, true); final Uri aContactUri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY)); String aName = cursor.getString(ContactsQuery.DISPLAY_NAME); TextView textName = (TextView) v.findViewById(R.id.phone); if (textName.getText() != null) { Log.d("FINAL", textName.getText().toString()); aPhoneNumber = textName.getText().toString(); // Toast.makeText(itsContext, "Contact Addded Successfully !", // Toast.LENGTH_LONG).show(); // Cursor aContactCursor = itsContext.getContentResolver().query( // aContactUri, null, null, null, null); // if (aContactCursor.moveToFirst()) { // int idx = cursor.getColumnIndex(ContactsContract.Contacts._ID); // aContactCursorId = cursor.getString(idx); // int aNameIdx = aContactCursor // .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); // // // // aEmailId = cursor.getString(ContactsQuery.LOOKUP_KEY); // // aPhoneNumber = cursor.getString(ContactsQuery.ID); // // Commented by Niaz for Multiple phone number // } JSONObject aContactJSONObject; // Notifies the parent activity that the user selected a contact. In // a two-pane layout, the // parent activity loads a ContactDetailFragment that displays the // details for the selected // contact. In a single-pane layout, the parent activity starts a // new activity that // displays contact details in its own Fragment. // aEmailId = "qwe"; // aPhoneNumber = "1234"; if (checkedTvStates.contains(aHashMap)) { checkedTvStates.remove(aHashMap); aContactToBeRemoved = new Contact(); aContactToBeRemoved.setEmail(aEmailId); aContactToBeRemoved.setName(aName); aContactToBeRemoved.setPhoneNumber(aPhoneNumber); aCheckedTV.setChecked(false); } else { checkedTvStates.add(aHashMap); aCheckedTV.setChecked(true); Contact aContact = new Contact(); aContact.setName(aName); aContact.setEmail(aEmailId); aContact.setPhoneNumber(aPhoneNumber); itsContactsList.add(aContact); } if (aContactToBeRemoved != null) { itsContactsList.remove(aContactToBeRemoved); } // aCheckBox.setButtonDrawable(R.drawable.checkbox_notify); try { aContactJSONObject = new JSONObject(); aMembersArray = new JSONArray(); for (int index = 0; index < itsContactsList.size(); index++) { aContactJSONObject = new JSONObject(); aContactJSONObject.put("emailId", itsContactsList.get(index).getEmail()); aContactJSONObject.put("phone", itsContactsList.get(index).getPhoneNumber()); aContactJSONObject.put("name", itsContactsList.get(index).getName()); aMembersArray.put(aContactJSONObject); } } catch (JSONException e) { Log.e("JsonException", "Json Exception occured ", e); } catch (Exception e) { Log.e("Exception", "Exception occured ", e); } // If two-pane layout sets the selected item to checked so it // remains // highlighted. In a // single-pane layout a new activity is started so this is not // needed. if (mIsTwoPaneLayout) { getListView().setItemChecked(position, true); } } else { Toast.makeText(itsContext, "Contact Not Addded! The Contact you selected does not have a Phone Number", Toast.LENGTH_LONG).show(); } }
From source file:com.dsdar.thosearoundme.util.ContactsListFragment.java
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // Gets the Cursor object currently bound to the ListView final Cursor cursor = mAdapter.getCursor(); Contact aContactToBeRemoved = null;// w w w . j av a 2 s . c om String aContactCursorId; String aEmailId = null; String aPhoneNumber = null; boolean isExist = false; // Moves to the Cursor row corresponding to the ListView item that was // clicked cursor.moveToPosition(position); // Creates a contact lookup Uri from contact ID and lookup_key final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY)); // Notifies the parent activity that the user selected a contact. In a // two-pane layout, the // parent activity loads a ContactDetailFragment that displays the // details for the selected // contact. In a single-pane layout, the parent activity starts a new // activity that // displays contact details in its own Fragment. // niaz checking Log.d("positionI", String.valueOf(position)); CheckedTextView aCheckedTV = (CheckedTextView) v.findViewById(android.R.id.text1); mOnContactSelectedListener.onContactSelected(uri); HashMap<Integer, Boolean> aHashMap = new HashMap<Integer, Boolean>(); aHashMap.put(position, true); final Uri aContactUri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY)); String aName = cursor.getString(ContactsQuery.DISPLAY_NAME); Cursor aContactCursor = itsContext.getContentResolver().query(aContactUri, null, null, null, null); if (aContactCursor.moveToFirst()) { int idx = cursor.getColumnIndex(ContactsContract.Contacts._ID); aContactCursorId = cursor.getString(idx); int aNameIdx = aContactCursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); // // aEmailId = cursor.getString(ContactsQuery.LOOKUP_KEY); // aPhoneNumber = cursor.getString(ContactsQuery.ID); Cursor aPhoneNumberCursor = itsContext.getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + aContactCursorId, null, null); if (aPhoneNumberCursor.moveToFirst()) { int colIdx = aPhoneNumberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); aPhoneNumber = aPhoneNumberCursor.getString(colIdx); } aPhoneNumberCursor.close(); if (aPhoneNumber == null || aPhoneNumber.equals("")) { Toast.makeText(itsContext, "Contact Not Addded! The Contact you selected does not have a Phone Number", Toast.LENGTH_LONG).show(); } Cursor aEmailIdCursor = itsContext.getContentResolver().query( ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + aContactCursorId, null, null); if (aEmailIdCursor.moveToFirst()) { int colIdx = aEmailIdCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS); aEmailId = aEmailIdCursor.getString(colIdx); } aEmailIdCursor.close(); Log.i("Phone&Email", aPhoneNumber + aEmailId); JSONObject aContactJSONObject; // Notifies the parent activity that the user selected a contact. In // a two-pane layout, the // parent activity loads a ContactDetailFragment that displays the // details for the selected // contact. In a single-pane layout, the parent activity starts a // new activity that // displays contact details in its own Fragment. if (checkedTvStates.contains(aHashMap)) { checkedTvStates.remove(aHashMap); aContactToBeRemoved = new Contact(); aContactToBeRemoved.setEmail(aEmailId); aContactToBeRemoved.setName(aName); aContactToBeRemoved.setPhoneNumber(aPhoneNumber); aCheckedTV.setChecked(false); } else { checkedTvStates.add(aHashMap); aCheckedTV.setChecked(true); Contact aContact = new Contact(); aContact.setName(aName); aContact.setEmail(aEmailId); aContact.setPhoneNumber(aPhoneNumber); itsContactsList.add(aContact); } if (aContactToBeRemoved != null) { itsContactsList.remove(aContactToBeRemoved); } // aCheckBox.setButtonDrawable(R.drawable.checkbox_notify); try { aContactJSONObject = new JSONObject(); aMembersArray = new JSONArray(); for (int index = 0; index < itsContactsList.size(); index++) { aContactJSONObject = new JSONObject(); aContactJSONObject.put("emailId", itsContactsList.get(index).getEmail()); aContactJSONObject.put("phone", itsContactsList.get(index).getPhoneNumber()); aContactJSONObject.put("name", itsContactsList.get(index).getName()); aMembersArray.put(aContactJSONObject); } } catch (JSONException e) { Log.e("JsonException", "Json Exception occured ", e); } catch (Exception e) { Log.e("Exception", "Exception occured ", e); } } // If two-pane layout sets the selected item to checked so it remains // highlighted. In a // single-pane layout a new activity is started so this is not needed. if (mIsTwoPaneLayout) { getListView().setItemChecked(position, true); } }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number, boolean scan_start) { //??// w w w .ja va2s. com final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.scan_remote_ntwk_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_title_view); final TextView title = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok); final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel); final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_msg); final TextView tv_result = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_title); tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_press_scan_btn)); tv_result.setVisibility(TextView.GONE); final String from = CommonUtilities.getLocalIpAddress(); String subnet = from.substring(0, from.lastIndexOf(".")); String subnet_o1, subnet_o2, subnet_o3; subnet_o1 = subnet.substring(0, subnet.indexOf(".")); subnet_o2 = subnet.substring(subnet.indexOf(".") + 1, subnet.lastIndexOf(".")); subnet_o3 = subnet.substring(subnet.lastIndexOf(".") + 1, subnet.length()); final EditText baEt1 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o1); final EditText baEt2 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o2); final EditText baEt3 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o3); final EditText baEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o4); final EditText eaEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_end_address_o4); baEt1.setText(subnet_o1); baEt2.setText(subnet_o2); baEt3.setText(subnet_o3); baEt4.setText("1"); baEt4.setSelection(1); eaEt4.setText("254"); baEt4.requestFocus(); final CheckedTextView ctv_use_port_number = (CheckedTextView) dialog .findViewById(R.id.scan_remote_ntwk_ctv_use_port); final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number); CommonDialog.setDlgBoxSizeLimit(dialog, true); if (port_number.equals("")) { et_port_number.setEnabled(false); ctv_use_port_number.setChecked(false); } else { et_port_number.setEnabled(true); et_port_number.setText(port_number); ctv_use_port_number.setChecked(true); } ctv_use_port_number.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctv_use_port_number.toggle(); boolean isChecked = ctv_use_port_number.isChecked(); et_port_number.setEnabled(isChecked); } }); final NotifyEvent ntfy_lv_click = new NotifyEvent(mContext); ntfy_lv_click.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { dialog.dismiss(); p_ntfy.notifyToListener(true, o); } @Override public void negativeResponse(Context c, Object[] o) { } }); final ArrayList<ScanAddressResultListItem> ipAddressList = new ArrayList<ScanAddressResultListItem>(); // ScanAddressResultListItem li=new ScanAddressResultListItem(); // li.server_name=mContext.getString(R.string.msgs_ip_address_no_address); // ipAddressList.add(li); final ListView lv = (ListView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_list); final AdapterScanAddressResultList adap = new AdapterScanAddressResultList(mContext, R.layout.scan_address_result_list_item, ipAddressList, ntfy_lv_click); lv.setAdapter(adap); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); //SCAN? btn_scan.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ipAddressList.clear(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { if (ipAddressList.size() < 1) { tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_not_detected)); tv_result.setVisibility(TextView.GONE); } else { tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_select_detected_host)); tv_result.setVisibility(TextView.VISIBLE); } // adap.clear(); // for (int i=0;i<ipAddressList.size();i++) // adap.add(ipAddressList.get(i)); } @Override public void negativeResponse(Context c, Object[] o) { } }); if (auditScanAddressRangeValue(dialog)) { tv_result.setVisibility(TextView.GONE); String ba1 = baEt1.getText().toString(); String ba2 = baEt2.getText().toString(); String ba3 = baEt3.getText().toString(); String ba4 = baEt4.getText().toString(); String ea4 = eaEt4.getText().toString(); String subnet = ba1 + "." + ba2 + "." + ba3; int begin_addr = Integer.parseInt(ba4); int end_addr = Integer.parseInt(ea4); scanRemoteNetwork(dialog, lv, adap, ipAddressList, subnet, begin_addr, end_addr, ntfy); } else { //error } } }); //CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); if (scan_start) btn_scan.performClick(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void promptPasswordForExport(final String fpath, final NotifyEvent ntfy_pswd) { // ??/*from w w w . j a v a 2 s. c o m*/ final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.password_input_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.password_input_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.password_input_title_view); final TextView title = (TextView) dialog.findViewById(R.id.password_input_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.password_input_msg); final CheckedTextView ctv_protect = (CheckedTextView) dialog.findViewById(R.id.password_input_ctv_protect); final Button btn_ok = (Button) dialog.findViewById(R.id.password_input_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.password_input_cancel_btn); final EditText et_password = (EditText) dialog.findViewById(R.id.password_input_password); final EditText et_confirm = (EditText) dialog.findViewById(R.id.password_input_password_confirm); dlg_msg.setText(mContext.getString(R.string.msgs_export_import_pswd_specify_password)); CommonDialog.setDlgBoxSizeCompact(dialog); ctv_protect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctv_protect.toggle(); boolean isChecked = ctv_protect.isChecked(); setPasswordFieldVisibility(isChecked, et_password, et_confirm, btn_ok, dlg_msg); } }); ctv_protect.setChecked(mGp.settingExportedProfileEncryptRequired); setPasswordFieldVisibility(mGp.settingExportedProfileEncryptRequired, et_password, et_confirm, btn_ok, dlg_msg); et_password.setEnabled(true); et_confirm.setEnabled(false); et_password.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { btn_ok.setEnabled(false); setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); et_confirm.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { btn_ok.setEnabled(false); setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); //OK button btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String passwd = et_password.getText().toString(); if ((ctv_protect.isChecked() && !mGp.settingExportedProfileEncryptRequired) || (!ctv_protect.isChecked() && mGp.settingExportedProfileEncryptRequired)) { mGp.settingExportedProfileEncryptRequired = ctv_protect.isChecked(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); prefs.edit().putBoolean(mContext.getString(R.string.settings_exported_profile_encryption), ctv_protect.isChecked()).commit(); } if (!ctv_protect.isChecked()) { dialog.dismiss(); ntfy_pswd.notifyToListener(true, new Object[] { "" }); } else { if (!passwd.equals(et_confirm.getText().toString())) { //Unmatch dlg_msg.setText( mContext.getString(R.string.msgs_export_import_pswd_unmatched_confirm_pswd)); } else { dialog.dismiss(); ntfy_pswd.notifyToListener(true, new Object[] { passwd }); } } } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); ntfy_pswd.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setCancelable(false); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void selectImportProfileItem(final AdapterSyncTask tfl, final NotifyEvent p_ntfy) { final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.export_import_profile_dlg); dialog.setCanceledOnTouchOutside(false); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.export_import_profile_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); ArrayList<ExportImportProfileListItem> eipl = new ArrayList<ExportImportProfileListItem>(); for (int i = 0; i < tfl.getCount(); i++) { SyncTaskItem pl = tfl.getItem(i); ExportImportProfileListItem eipli = new ExportImportProfileListItem(); eipli.isChecked = true;/*from w w w.j a v a 2 s. c om*/ eipli.item_name = pl.getSyncTaskName(); eipl.add(eipli); } // Collections.sort(eipl, new Comparator<ExportImportProfileListItem>(){ // @Override // public int compare(ExportImportProfileListItem arg0, // ExportImportProfileListItem arg1) { // if (arg0.item_name.equals(arg1.item_name)) return arg0.item_type.compareToIgnoreCase(arg1.item_type); // return arg0.item_name.compareToIgnoreCase(arg1.item_name); // } // }); // ExportImportProfileListItem eipli=new ExportImportProfileListItem(); // eipli.isChecked=true; // eipli.item_type="*"; // eipli.item_name=mContext.getString(R.string.msgs_export_import_profile_setting_parms); // eipl.add(eipli); final AdapterExportImportSyncTask imp_list_adapt = new AdapterExportImportSyncTask(mContext, R.layout.export_import_profile_list_item, eipl); ListView lv = (ListView) dialog.findViewById(R.id.export_import_profile_listview); lv.setAdapter(imp_list_adapt); CommonDialog.setDlgBoxSizeLimit(dialog, true); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.export_import_profile_title_view); final TextView title = (TextView) dialog.findViewById(R.id.export_import_profile_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_export_import_profile_title)); // TextView tv_msgx=(TextView)dialog.findViewById(R.id.export_import_profile_msg); // tv_msgx.setVisibility(LinearLayout.GONE); LinearLayout ll_filelist = (LinearLayout) dialog.findViewById(R.id.export_import_profile_file_list); ll_filelist.setVisibility(LinearLayout.GONE); final Button ok_btn = (Button) dialog.findViewById(R.id.export_import_profile_dlg_btn_ok); Button cancel_btn = (Button) dialog.findViewById(R.id.export_import_profile_dlg_btn_cancel); final Button rb_select_all = (Button) dialog.findViewById(R.id.export_import_profile_list_select_all); final Button rb_unselect_all = (Button) dialog.findViewById(R.id.export_import_profile_list_unselect_all); final CheckedTextView ctv_reset_profile = (CheckedTextView) dialog .findViewById(R.id.export_import_profile_list_ctv_reset_profile); final CheckedTextView ctv_import_settings = (CheckedTextView) dialog .findViewById(R.id.export_import_profile_list_ctv_import_settings); final CheckedTextView ctv_import_schedule = (CheckedTextView) dialog .findViewById(R.id.export_import_profile_list_ctv_import_schedule); ctv_reset_profile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); ctv_import_settings.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); ctv_import_schedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); ctv_import_settings.setChecked(true); ctv_import_schedule.setChecked(true); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { // imp_list_adapt.getItem(pos).isChecked=!imp_list_adapt.getItem(pos).isChecked; // imp_list_adapt.notifyDataSetChanged(); // if (imp_list_adapt.isItemSelected()) { // ok_btn.setEnabled(true); // } else { // ok_btn.setEnabled(false); // } setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); // lv.setOnItemLongClickListener(new OnItemLongClickListener(){ // @Override // public boolean onItemLongClick(AdapterView<?> arg0, View arg1, // int pos, long arg3) { // ccMenu.addMenuItem( // mContext.getString(R.string.msgs_export_import_profile_select_all),R.drawable.blank) // .setOnClickListener(new CustomContextMenuOnClickListener() { // @Override // final public void onClick(CharSequence menuTitle) { // for (int i=0;i<imp_list_adapt.getCount();i++) // imp_list_adapt.getItem(i).isChecked=true; // imp_list_adapt.notifyDataSetChanged(); // ok_btn.setEnabled(true); // } // }); // ccMenu.addMenuItem( // mContext.getString(R.string.msgs_export_import_profile_unselect_all),R.drawable.blank) // .setOnClickListener(new CustomContextMenuOnClickListener() { // @Override // final public void onClick(CharSequence menuTitle) { // for (int i=0;i<imp_list_adapt.getCount();i++) // imp_list_adapt.getItem(i).isChecked=false; // imp_list_adapt.notifyDataSetChanged(); // ok_btn.setEnabled(false); // } // }); // ccMenu.createMenu(); // return false; // } // }); rb_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < imp_list_adapt.getCount(); i++) imp_list_adapt.getItem(i).isChecked = true; ctv_import_settings.setChecked(true); ctv_import_schedule.setChecked(true); imp_list_adapt.notifyDataSetChanged(); ok_btn.setEnabled(true); } }); rb_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < imp_list_adapt.getCount(); i++) imp_list_adapt.getItem(i).isChecked = false; ctv_import_settings.setChecked(false); ctv_import_schedule.setChecked(false); imp_list_adapt.notifyDataSetChanged(); ok_btn.setEnabled(false); } }); NotifyEvent ntfy_ctv_listener = new NotifyEvent(mContext); ntfy_ctv_listener.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { // if (imp_list_adapt.isItemSelected()) { // ok_btn.setEnabled(true); // } else { // if (ctv_import_settings.isChecked()) ok_btn.setEnabled(true); // else ok_btn.setEnabled(false); // } setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } @Override public void negativeResponse(Context c, Object[] o) { } }); imp_list_adapt.setCheckButtonListener(ntfy_ctv_listener); ok_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (ctv_reset_profile.isChecked()) mGp.syncTaskAdapter.clear(); importSelectedSyncTaskItem(imp_list_adapt, tfl, ctv_import_settings.isChecked(), ctv_import_schedule.isChecked(), p_ntfy); dialog.dismiss(); } }); cancel_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.show(); }