List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:co.taqat.call.LinphoneActivity.java
public Dialog displayWrongPasswordDialog(final String username, final String realm, final String domain) { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC)); d.setAlpha(200);// ww w . j av a 2s . c o m dialog.setContentView(R.layout.input_dialog); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); dialog.getWindow().setBackgroundDrawable(d); TextView customText = (TextView) dialog.findViewById(R.id.customText); customText.setText(getString(R.string.error_bad_credentials)); Button retry = (Button) dialog.findViewById(R.id.retry); Button cancel = (Button) dialog.findViewById(R.id.cancel); retry.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { String newPassword = ((EditText) dialog.findViewById(R.id.password)).getText().toString(); LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(username, null, newPassword, null, realm, domain); LinphoneManager.getLc().addAuthInfo(authInfo); LinphoneManager.getLc().refreshRegisters(); dialog.dismiss(); } }); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); return dialog; }
From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java
private void addRewardDetailsToUI() { // Logo/*from ww w. j a va 2 s . c o m*/ final ImageView logoImageView = (ImageView) findViewById(R.id.pd_reward_star_image_view); final String imageUrl = mReward.getCoverImage(); if (imageUrl == null || imageUrl.isEmpty() || imageUrl.contains("default")) { Glide.with(this).load(R.drawable.pd_ui_star_icon).error(R.drawable.pd_ui_star_icon).dontAnimate() .placeholder(R.drawable.pd_ui_star_icon).into(logoImageView); } else { Glide.with(this).load(imageUrl).error(R.drawable.pd_ui_star_icon).dontAnimate() .placeholder(R.drawable.pd_ui_star_icon).into(logoImageView); } // Reward Description TextView textView = (TextView) findViewById(R.id.pd_reward_offer_text_view); textView.setText(mReward.getDescription()); // Rules textView = (TextView) findViewById(R.id.pd_reward_item_rules_text_view); textView.setText(mReward.getRules()); if (mReward.getRules() == null || mReward.getRules().isEmpty()) { textView.setVisibility(View.GONE); } StringBuilder actionStringBuilder = new StringBuilder(""); // Action final boolean TWITTER_ACTION_REQUIRED = twitterShareForced(); if (mReward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_PHOTO)) { actionStringBuilder.append(getString(TWITTER_ACTION_REQUIRED ? R.string.pd_claim_action_tweet_photo : R.string.pd_claim_action_photo_camera)); } else if (mReward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_CHECKIN)) { actionStringBuilder.append(getString(TWITTER_ACTION_REQUIRED ? R.string.pd_claim_action_tweet_checkin : R.string.pd_claim_action_checkin)); } else { actionStringBuilder.append(getString(R.string.pd_claim_action_none)); } // End date long timeInSecs = PDNumberUtils.toLong(mReward.getAvailableUntilInSeconds(), -1); String convertedTimeString = PDUIUtils.convertTimeToDayAndMonth(timeInSecs); if (!convertedTimeString.isEmpty()) { actionStringBuilder.append(String.format(Locale.getDefault(), " | Exp %1s", convertedTimeString)); } textView = (TextView) findViewById(R.id.pd_reward_request_text_view); textView.setText(actionStringBuilder.toString()); textView.setVisibility(View.GONE); //add photo addPhotoView = findViewById(R.id.pd_share_view_icon_holder); addedPhotoView = findViewById(R.id.pd_share_view_taken_holder); TextView infoView = findViewById(R.id.pd_claim_info_text); //already shared button LinearLayout alreadySharedButton = findViewById(R.id.pd_claim_already_shared_view); TextView alreadySharedText = findViewById(R.id.pd_claim_already_shared_button); if (mReward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_PHOTO)) { alreadySharedText.setText(getResources().getString(R.string.pd_claim_scan_for_already_shared_text)); infoView.setText(String.format(getResources().getString(R.string.pd_claim_info_photo), mReward.getGlobalHashtag())); } else { alreadySharedText .setText(getResources().getString(R.string.pd_claim_scan_for_already_shared_activity_text)); infoView.setText(String.format(getResources().getString(R.string.pd_claim_info_check_in), mReward.getGlobalHashtag())); } alreadySharedButton.setOnClickListener(this); if (mReward.getGlobalHashtag() != null && !mReward.getGlobalHashtag().equalsIgnoreCase("")) { // alreadySharedButton.setText(String.format(getString(R.string.pd_claim_get_already_shared_text), mReward.getGlobalHashtag())); } else { // alreadySharedButton.setText(R.string.pd_claim_already_shared_default); } infoIcon.setVisibility(View.VISIBLE); infoIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog dialog = new Dialog(PDUIClaimActivity.this); PDUIDialogUtils.setMargins(dialog, 25, 100, 25, 100); dialog.setContentView(R.layout.claim_alert_dialog); Button claim = (Button) dialog.findViewById(R.id.button_claim); Button cancel = (Button) dialog.findViewById(R.id.button_cancel); ImageView icon = (ImageView) dialog.findViewById(R.id.icon); String imageUrl = mReward.getCoverImage(); if (imageUrl == null || imageUrl.isEmpty() || imageUrl.contains("default")) { Glide.with(PDUIClaimActivity.this).load(R.drawable.pd_ui_star_icon).dontAnimate() .error(R.drawable.pd_ui_star_icon).dontAnimate().placeholder(R.drawable.pd_ui_star_icon) .into(icon); } else { Glide.with(PDUIClaimActivity.this).load(imageUrl).dontAnimate() .error(R.drawable.pd_ui_star_icon).dontAnimate().placeholder(R.drawable.pd_ui_star_icon) .into(icon); } claim.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); claim.setText("Close"); cancel.setVisibility(View.GONE); TextView tvTitle = dialog.findViewById(R.id.alertTitle); tvTitle.setText(mReward.getDescription()); TextView message = dialog.findViewById(R.id.message); message.setText(mReward.getRules()); TextView detailsActionText = (TextView) dialog.findViewById(R.id.pd_action_text); setActionString(detailsActionText); dialog.show(); } }); }
From source file:com.mitre.holdshort.MainActivity.java
private void showDisclaimer() { final Dialog dialog = new Dialog(MainActivity.this); OnClickListener disclaimerBtnClick;//w ww. ja v a2 s .c om dialog.setContentView(R.layout.legal_stuff_dialog); dialog.setTitle("RIPPLE - Informed Consent"); dialog.setCancelable(false); dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); TextView consent = (TextView) dialog.findViewById(R.id.disclaimerAccept); TextView reject = (TextView) dialog.findViewById(R.id.disclaimerReject); disclaimerBtnClick = new OnClickListener() { @Override public void onClick(View v) { if (v.getId() == R.id.disclaimerAccept) { settings.edit().putBoolean("consent", true).commit(); dialog.dismiss(); waiverAccept = true; startUp(); } else { finish(); } } }; consent.setOnClickListener(disclaimerBtnClick); reject.setOnClickListener(disclaimerBtnClick); dialog.show(); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * "Coach mark" (help overlay image)/*from w w w . j a v a2s. c o m*/ * * @param context * @param coachMarkLayoutId Is "Help overlay" layout id in UX talk :-) * [coach_mark.xml is your coach mark layout] * @param coachMarkMasterViewId is the id of the top most view in coach_mark.xml */ public static void dialog_onCoachMark(Context context, int coachMarkLayoutId, int coachMarkMasterViewId, int bgColor) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(bgColor)); dialog.setContentView(coachMarkLayoutId); dialog.setCanceledOnTouchOutside(true); //for dismissing anywhere you touch View masterView = dialog.findViewById(coachMarkMasterViewId); masterView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java
@Override protected void onPrepareDialog(int id, Dialog dialog) { super.onPrepareDialog(id, dialog); StringBuilder sb;/* www. j a v a 2s. com*/ switch (id) { case Constants.DIALOG_LOGIN: if (mSettings.getUsername() != null) { final TextView loginUsernameInput = (TextView) dialog.findViewById(R.id.login_username_input); loginUsernameInput.setText(mSettings.getUsername()); } final TextView loginPasswordInput = (TextView) dialog.findViewById(R.id.login_password_input); loginPasswordInput.setText(""); break; case Constants.DIALOG_COMMENT_CLICK: if (mVoteTargetThing == null) break; Boolean likes; final TextView titleView = (TextView) dialog.findViewById(R.id.title); final TextView urlView = (TextView) dialog.findViewById(R.id.url); final TextView submissionStuffView = (TextView) dialog .findViewById(R.id.submissionTime_submitter_subreddit); final Button linkButton = (Button) dialog.findViewById(R.id.thread_link_button); if (mVoteTargetThing == getOpThingInfo()) { likes = mVoteTargetThing.getLikes(); titleView.setVisibility(View.VISIBLE); titleView.setText(getOpThingInfo().getTitle()); urlView.setVisibility(View.VISIBLE); urlView.setText(getOpThingInfo().getUrl()); submissionStuffView.setVisibility(View.VISIBLE); sb = new StringBuilder(Util.getTimeAgo(getOpThingInfo().getCreated_utc())).append(" by ") .append(getOpThingInfo().getAuthor()); submissionStuffView.setText(sb); // For self posts, you're already there! if (getOpThingInfo().getDomain().toLowerCase().startsWith("self.")) { linkButton.setText(R.string.comment_links_button); linkToEmbeddedURLs(linkButton); } else { final String url = getOpThingInfo().getUrl(); linkButton.setText(R.string.thread_link_button); linkButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_COMMENT_CLICK); setLinkClicked(getOpThingInfo()); Common.launchBrowser(CommentsListActivity.this, url, Util.createThreadUri(getOpThingInfo()).toString(), false, false, mSettings.isUseExternalBrowser(), mSettings.isSaveHistory()); } }); linkButton.setEnabled(true); } } else { titleView.setText("Comment by " + mVoteTargetThing.getAuthor()); likes = mVoteTargetThing.getLikes(); urlView.setVisibility(View.INVISIBLE); submissionStuffView.setVisibility(View.INVISIBLE); // Get embedded URLs linkButton.setText(R.string.comment_links_button); linkToEmbeddedURLs(linkButton); } final CheckBox voteUpButton = (CheckBox) dialog.findViewById(R.id.vote_up_button); final CheckBox voteDownButton = (CheckBox) dialog.findViewById(R.id.vote_down_button); final Button replyButton = (Button) dialog.findViewById(R.id.reply_button); final Button loginButton = (Button) dialog.findViewById(R.id.login_button); // Only show upvote/downvote if user is logged in if (mSettings.isLoggedIn()) { loginButton.setVisibility(View.GONE); voteUpButton.setVisibility(View.VISIBLE); voteDownButton.setVisibility(View.VISIBLE); replyButton.setEnabled(true); // Make sure the setChecked() actions don't actually vote just yet. voteUpButton.setOnCheckedChangeListener(null); voteDownButton.setOnCheckedChangeListener(null); // Set initial states of the vote buttons based on user's past actions if (likes == null) { // User is currently neutral voteUpButton.setChecked(false); voteDownButton.setChecked(false); } else if (likes == true) { // User currenty likes it voteUpButton.setChecked(true); voteDownButton.setChecked(false); } else { // User currently dislikes it voteUpButton.setChecked(false); voteDownButton.setChecked(true); } // Now we want the user to be able to vote. voteUpButton.setOnCheckedChangeListener(voteUpOnCheckedChangeListener); voteDownButton.setOnCheckedChangeListener(voteDownOnCheckedChangeListener); // The "reply" button replyButton.setOnClickListener(replyOnClickListener); } else { replyButton.setEnabled(false); voteUpButton.setVisibility(View.GONE); voteDownButton.setVisibility(View.GONE); loginButton.setVisibility(View.VISIBLE); loginButton.setOnClickListener(loginOnClickListener); } break; case Constants.DIALOG_REPLY: if (mVoteTargetThing != null) { if (mVoteTargetThing.getReplyDraft() != null && !mShouldClearReply) { EditText replyBodyView = (EditText) dialog.findViewById(R.id.body); replyBodyView.setText(mVoteTargetThing.getReplyDraft()); } else { EditText replyBodyView = (EditText) dialog.findViewById(R.id.body); replyBodyView.setText(""); mShouldClearReply = false; } } break; case Constants.DIALOG_EDIT: EditText replyBodyView = (EditText) dialog.findViewById(R.id.body); replyBodyView.setText(mEditTargetBody); break; default: // No preparation based on app state is required. break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void editActivityExtraDataItem(final GlobalParameters mGlblParms, final int sel_pos) { // ??/* w ww. j a v a2 s. c o m*/ 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(); }
From source file:de.ub0r.android.websms.WebSMS.java
/** * Create a Emoticons {@link Dialog}.//from w w w. j a v a2 s .c om * * @return Emoticons {@link Dialog} */ private Dialog createEmoticonsDialog() { final Dialog d = new Dialog(this); d.setTitle(R.string.emo_); d.setContentView(R.layout.emo); d.setCancelable(true); final String[] emoticons = this.getResources().getStringArray(R.array.emoticons); final GridView gridview = (GridView) d.findViewById(R.id.gridview); gridview.setAdapter(new BaseAdapter() { // references to our images // keep order and count synced with string-array! private Integer[] mThumbIds = { R.drawable.emo_im_angel, R.drawable.emo_im_cool, R.drawable.emo_im_crying, R.drawable.emo_im_foot_in_mouth, R.drawable.emo_im_happy, R.drawable.emo_im_kissing, R.drawable.emo_im_laughing, R.drawable.emo_im_lips_are_sealed, R.drawable.emo_im_money_mouth, R.drawable.emo_im_sad, R.drawable.emo_im_surprised, R.drawable.emo_im_tongue_sticking_out, R.drawable.emo_im_undecided, R.drawable.emo_im_winking, R.drawable.emo_im_wtf, R.drawable.emo_im_yelling }; @Override public long getItemId(final int position) { return 0; } @Override public Object getItem(final int position) { return null; } @Override public int getCount() { return this.mThumbIds.length; } @Override public View getView(final int position, final View convertView, final ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, // initialize some attributes imageView = new ImageView(WebSMS.this); imageView.setLayoutParams(new GridView.LayoutParams(EMOTICONS_SIZE, EMOTICONS_SIZE)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(EMOTICONS_PADDING, EMOTICONS_PADDING, EMOTICONS_PADDING, EMOTICONS_PADDING); } else { imageView = (ImageView) convertView; } imageView.setImageResource(this.mThumbIds[position]); return imageView; } }); gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapter, final View v, final int id, final long arg3) { EditText et = WebSMS.this.etText; final String e = emoticons[id]; int i = et.getSelectionStart(); int j = et.getSelectionEnd(); if (i > j) { int x = i; i = j; j = x; } String t = et.getText().toString(); et.setText(t.substring(0, i) + e + t.substring(j)); et.setSelection(i + e.length()); d.dismiss(); et.requestFocus(); } }); return d; }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
private void optionLegend() { // Show help//from w w w.ja va 2s .c o m Dialog dialog = new Dialog(ActivityMain.this); dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); dialog.setTitle(R.string.menu_legend); dialog.setContentView(R.layout.legend); dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher)); ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox()); ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox()); for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "details")) child.setVisibility(View.GONE); ((LinearLayout) dialog.findViewById(R.id.llUnsafe)) .setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE); dialog.setCancelable(true); dialog.show(); }
From source file:com.updetector.MainActivity.java
/** * Handle Setting click/*from w ww.j a va 2s . c o m*/ */ private void handleSettings() { final Dialog dialog = new Dialog(this); dialog.setTitle(R.string.menu_item_settings); dialog.setContentView(R.layout.settings); final SharedPreferences mPrefs = getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE); final Editor editor = mPrefs.edit(); final ToggleButton logOnButton = (ToggleButton) dialog.findViewById(R.id.log_on); logOnButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_ON, false)); final Button btDeviceSelectButton = (Button) dialog.findViewById(R.id.bt_device_button); btDeviceSelectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (mBluetoothAdapter.isEnabled()) { selectBluetoothDevice(); } else { Toast.makeText(getApplicationContext(), "Please enable your Bluetooth first.", Toast.LENGTH_SHORT).show(); } } }); final Button applyButton = (Button) dialog.findViewById(R.id.apply_button); final Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button); applyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (logOnButton.isChecked()) editor.putBoolean(Constants.LOGGING_ON, true); else editor.putBoolean(Constants.LOGGING_ON, false); editor.commit(); dialog.cancel(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dialog.cancel(); } }); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
private void confirmSendLog() { mGlblParms.util.flushLog();/*from w ww . j av a 2 s. c om*/ createTempLogFile(); final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_send_log_dlg); final Button btn_ok = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_cancel_btn); final Button btn_preview = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_preview); CommonDialog.setDlgBoxSizeLimit(dialog, false); btn_preview.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + mEnvParms.settingLogMsgDir + "temp_log.txt"), "text/plain"); startActivity(intent); } }); btn_ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mGlblParms.util.sendLogFileToDeveloper(mEnvParms.settingLogMsgDir + "temp_log.txt"); dialog.dismiss(); } }); btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); }