List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:com.pdmanager.views.patient.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_technician) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); alertDialog.setTitle("PASSWORD"); alertDialog.setMessage("Enter Password"); final EditText input = new EditText(MainActivity.this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); input.setLayoutParams(lp);/*w ww . j ava 2 s . c o m*/ alertDialog.setView(input); alertDialog.setIcon(R.drawable.pdmanager); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String pass = "pdmanager"; String password = input.getText().toString(); if (password.compareTo("") != 0) { if (pass.equals(password)) { Toast.makeText(getApplicationContext(), "Password Matched", Toast.LENGTH_SHORT).show(); Intent mainIntent = new Intent(MainActivity.this, TechnicianActivity.class); MainActivity.this.startActivity(mainIntent); finish(); } else { Toast.makeText(getApplicationContext(), "Wrong Password!", Toast.LENGTH_SHORT).show(); } } } }); alertDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); } else if (id == R.id.action_termsandconditions) { Intent mainIntent = new Intent(MainActivity.this, TermsAndConds.class); MainActivity.this.startActivity(mainIntent); // finish(); } return super.onOptionsItemSelected(item); }
From source file:at.tomtasche.reader.ui.activity.DocumentActivity.java
public void handleError(Throwable error, final Uri uri) { Log.e("OpenDocument Reader", "Error opening file at " + uri.toString(), error); final Uri cacheUri = AndroidFileCache.getCacheFileUri(); for (LoadingListener listener : loadingListeners) { listener.onError(error, uri);//from w w w . ja v a2 s . co m // TODO: return here, but only if the listener was registered by a // JUnit test } int errorDescription; if (error == null) { return; } else if (error instanceof EncryptedDocumentException) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.toast_error_password_protected); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); builder.setView(input); builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { loadUri(cacheUri, input.getText().toString()); dialog.dismiss(); } }); builder.setNegativeButton(getString(android.R.string.cancel), null); builder.show(); return; } else if (error instanceof IllegalMimeTypeException || error instanceof ZipException || error instanceof ZipEntryNotFoundException || error instanceof UnsupportedMimeTypeException) { /*AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.toast_error_illegal_file); builder.setMessage(R.string.dialog_upload_file); builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { uploadUri(cacheUri); dialog.dismiss(); } }); builder.setNegativeButton(getString(android.R.string.cancel), null); builder.show();*/ return; } else if (error instanceof FileNotFoundException) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY) || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { errorDescription = R.string.toast_error_find_file; } else { errorDescription = R.string.toast_error_storage; } } else if (error instanceof IllegalArgumentException) { errorDescription = R.string.toast_error_illegal_file; } else if (error instanceof OutOfMemoryError) { errorDescription = R.string.toast_error_out_of_memory; } else { errorDescription = R.string.toast_error_generic; } showCrouton(errorDescription, null, AppMsg.STYLE_ALERT); }
From source file:com.example.sadashivsinha.mprosmart.Activities.AllVendors.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.fab_add: { Intent intent = new Intent(AllVendors.this, AddVendorsActivity.class); startActivity(intent);//from w ww. ja va 2 s.com } break; case R.id.fab_search: { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Search Vendor by Vendor Name or ID !"); // Set an EditText view to get user input final EditText input = new EditText(this); input.setMaxLines(1); input.setImeOptions(EditorInfo.IME_ACTION_DONE); alert.setView(input); alert.setPositiveButton("Search", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (input.getText().toString().isEmpty()) { input.setError("Enter Search Field"); } else { Intent intent = new Intent(AllVendors.this, AllVendors.class); intent.putExtra("search", "yes"); intent.putExtra("searchText", input.getText().toString()); Log.d("SEARCH TEXT", input.getText().toString()); startActivity(intent); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(AllVendors.this, "Search cancelled .", Toast.LENGTH_SHORT).show(); } }); alert.show(); } break; case R.id.exportBtn: { //csv export int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion > android.os.Build.VERSION_CODES.LOLLIPOP) { if (ContextCompat.checkSelfPermission(AllVendors.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(AllVendors.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1); } Environment.getExternalStorageState(); String vendorId = null, vendorName = null, vendorTypeId = null, decipline = null, taxID = null, license = null, companyName = null; int listSize = vendorList.size(); String cvsValues = "Vendor ID" + "," + "Vendor Name" + "," + "Vendor Type ID" + "," + "Discipline" + "Tax ID" + "," + "Licence" + "," + "Company Name" + "\n"; for (int i = 0; i < listSize; i++) { AllVendorList items = vendorList.get(i); vendorId = items.getVendor_id(); vendorName = items.getVendor_name(); vendorTypeId = items.getVendor_type(); decipline = items.getDiscipline(); taxID = items.getText_tax_id(); license = items.getText_licence_no(); companyName = items.getText_company_name(); switch (decipline) { case "1": decipline = "Electrical"; break; case "2": decipline = "Mechanical"; break; case "3": decipline = "Civil"; break; case "4": decipline = "Architectural"; break; } cvsValues = cvsValues + vendorId + "," + vendorName + "," + vendorTypeId + "," + decipline + taxID + "," + license + companyName + "\n"; } CsvCreateUtility.generateNoteOnSD(getApplicationContext(), "Vendors-data.csv", cvsValues); } else { Environment.getExternalStorageState(); String vendorId = null, vendorName = null, vendorTypeId = null, decipline = null, taxID = null, license = null, companyName = null; int listSize = vendorList.size(); String cvsValues = "Vendor ID" + "," + "Vendor Name" + "," + "Vendor Type ID" + "," + "Discipline" + "Tax ID" + "," + "Licence" + "," + "Company Name" + "\n"; for (int i = 0; i < listSize; i++) { AllVendorList items = vendorList.get(i); vendorId = items.getVendor_id(); vendorName = items.getVendor_name(); vendorTypeId = items.getVendor_type(); decipline = items.getDiscipline(); taxID = items.getText_tax_id(); license = items.getText_licence_no(); companyName = items.getText_company_name(); switch (decipline) { case "1": decipline = "Electrical"; break; case "2": decipline = "Mechanical"; break; case "3": decipline = "Civil"; break; case "4": decipline = "Architectural"; break; } cvsValues = cvsValues + vendorId + "," + vendorName + "," + vendorTypeId + "," + decipline + taxID + "," + license + companyName + "\n"; } CsvCreateUtility.generateNoteOnSD(getApplicationContext(), "Vendors-data.csv", cvsValues); } } break; } }
From source file:com.orange.ocara.ui.activity.SetupAuditPathActivity.java
private void updateAuditObject(final AuditObject auditObject) { // Use an EditText view to get user input. final EditText input = new EditText(this); input.setText(auditObject.getName()); AlertDialog updateDialog = new OcaraDialogBuilder(this) .setTitle(com.orange.ocara.R.string.audit_object_update_object_title) // title .setView(input).setPositiveButton(com.orange.ocara.R.string.audit_object_update_object_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String name = input.getText().toString(); if (StringUtils.isNotBlank(name)) { updateAuditObjectName(auditObject, name); }//ww w . ja v a 2 s . c om } }) .setNegativeButton(com.orange.ocara.R.string.action_cancel, null).create(); updateDialog.show(); }
From source file:com.ichi2.anki.ModelFieldEditor.java
private void repositionFieldDialog() { mFieldNameInput = new EditText(this); mFieldNameInput.setRawInputType(InputType.TYPE_CLASS_NUMBER); new MaterialDialog.Builder(this) .title(String.format(getResources().getString(R.string.model_field_editor_reposition), 1, mFieldLabels.size())) .positiveText(R.string.dialog_ok).customView(mFieldNameInput, true) .callback(new MaterialDialog.ButtonCallback() { @Override//ww w . ja v a 2 s.com public void onPositive(MaterialDialog dialog) { String newPosition = mFieldNameInput.getText().toString(); int pos; try { pos = Integer.parseInt(newPosition); } catch (NumberFormatException n) { showToast(getResources().getString(R.string.toast_out_of_range)); return; } if (pos < 1 || pos > mFieldLabels.size()) { showToast(getResources().getString(R.string.toast_out_of_range)); } else { // Input is valid, now attempt to modify try { mCol.modSchema(); DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REPOSITION_FIELD, mChangeFieldHandler, new DeckTask.TaskData(new Object[] { mMod, mNoteFields.getJSONObject(mCurrentPos), pos - 1 })); } catch (ConfirmModSchemaException e) { // Handle mod schema confirmation ConfirmationDialog c = new ConfirmationDialog() { public void confirm() { try { mCol.modSchemaNoCheck(); String newPosition = mFieldNameInput.getText().toString(); int pos = Integer.parseInt(newPosition); DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REPOSITION_FIELD, mChangeFieldHandler, new DeckTask.TaskData(new Object[] { mMod, mNoteFields.getJSONObject(mCurrentPos), pos - 1 })); dismissContextMenu(); } catch (JSONException e) { throw new RuntimeException(e); } } public void cancel() { dismissContextMenu(); } }; c.setArgs(getResources().getString(R.string.full_sync_confirmation)); ModelFieldEditor.this.showDialogFragment(c); } catch (JSONException e) { throw new RuntimeException(e); } } } }).negativeText(R.string.dialog_cancel).show(); }
From source file:butter.droid.tv.fragments.TVOverviewFragment.java
private void openPlayerTestDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final String[] file_types = getResources().getStringArray(R.array.file_types); final String[] files = getResources().getStringArray(R.array.files); builder.setTitle("Player Tests").setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override// w w w .j a v a 2s . c om public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).setSingleChoiceItems(file_types, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int index) { dialogInterface.dismiss(); final String location = files[index]; if (location.equals("dialog")) { final EditText dialogInput = new EditText(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(dialogInput) .setPositiveButton("Start", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Movie media = new Movie(new MoviesProvider(), new YSubsProvider()); media.videoId = "dialogtestvideo"; media.title = "User input test video"; TVVideoPlayerActivity.startActivity(getActivity(), new StreamInfo(media, null, null, null, null, location), 0); } }); builder.show(); } final Movie media = new Movie(new MoviesProvider(), new YSubsProvider()); media.videoId = "bigbucksbunny"; media.title = file_types[index]; media.subtitles = new HashMap<>(); media.subtitles.put("en", "http://sv244.cf/bbb-subs.srt"); SubsProvider.download(getActivity(), media, "en", new Callback() { @Override public void onFailure(Request request, IOException e) { TVVideoPlayerActivity.startActivity(getActivity(), new StreamInfo(media, null, null, null, null, location)); } @Override public void onResponse(Response response) throws IOException { TVVideoPlayerActivity.startActivity(getActivity(), new StreamInfo(media, null, null, null, null, location)); } }); } }); builder.show(); }
From source file:edumsg.edumsg_android_app.RVAdapter.java
@Override public void onBindViewHolder(final TweetViewHolder holder, final int position) { View hoverView = LayoutInflater.from(context).inflate(R.layout.tweet_hover_view, null); ButterKnife.bind(this, hoverView); holder.tweetBlurLayout.setHoverView(hoverView); holder.tweetBlurLayout.addChildAppearAnimator(hoverView, R.id.retweet_button, Techniques.FlipInX); holder.tweetBlurLayout.addChildAppearAnimator(hoverView, R.id.reply_button, Techniques.FlipInX); holder.tweetBlurLayout.addChildAppearAnimator(hoverView, R.id.favorite_button, Techniques.FlipInX); holder.tweetBlurLayout.addChildAppearAnimator(hoverView, R.id.more_button, Techniques.FlipInX); holder.tweetBlurLayout.addChildDisappearAnimator(hoverView, R.id.retweet_button, Techniques.FlipOutX); holder.tweetBlurLayout.addChildDisappearAnimator(hoverView, R.id.reply_button, Techniques.FlipOutX); holder.tweetBlurLayout.addChildDisappearAnimator(hoverView, R.id.favorite_button, Techniques.FlipOutX); holder.tweetBlurLayout.addChildDisappearAnimator(hoverView, R.id.more_button, Techniques.FlipOutX); try {//w w w .ja v a 2s .co m holder.tweetBlurLayout.dismissHover(); } catch (Exception e) { } final Tweet tweetObject = tweetObjects.get(position); holder.repliesProgress.setIndeterminate(true); Picasso.with(context).load(tweetObject.getImgUrl()).placeholder(R.mipmap.ic_launcher).fit() .into(holder.userImage); holder.userImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyAppCompatActivity main = (MyAppCompatActivity) context; Intent intent = new Intent(main, ProfileActivity.class); intent.putExtra("username", tweetObject.getCreator().getUsername()); // intent.putExtra("name", tweetObject.getCreator().getName()); // intent.putExtra("avatar_url", tweetObject.getCreator().getAvatar_url()); // intent.putExtra("bio", tweetObject.getCreator().getBio()); intent.putExtra("creatorId", tweetObject.getCreator().getId()); main.startActivity(intent); } }); String info = context.getString(R.string.user_info, tweetObject.getCreator().getName(), tweetObject.getCreator().getUsername()); holder.creatorInfo.setText(info); holder.tweet.setText(tweetObject.getTweet()); replyBtn.setColorFilter(Color.rgb(128, 128, 128)); setButtonStates(tweetObject, retweetBtn, favoriteBtn); retweetBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { retweet(tweetObject.getId()); tweetObject.setIsRetweeted(true); } else { unretweet(tweetObject.getId()); tweetObject.setIsRetweeted(false); } } }); // retweetBtn.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { //// String btnTag = (String) retweetBtn.getTag(); // if (!retweetBtn.isChecked()) { // retweetBtn.setChecked(true); // retweet(tweetObject.getId()); // tweetObject.setIsRetweeted(true); // int colorFilter2 = Color.rgb(111, 229, 98); //// retweetBtn.setColorFilter(colorFilter2); //// retweetBtn.setTag("R"); // } else { // retweetBtn.setChecked(false); // unretweet(tweetObject.getId()); // tweetObject.setIsRetweeted(false); // int colorFilter1 = Color.rgb(128, 128, 128); //// retweetBtn.setColorFilter(colorFilter1); //// retweetBtn.setTag("notR"); // } // } // }); if (tweetObject.getCreator().getUsername().equals(MyAppCompatActivity.username)) { // retweetBtn.setColorFilter(Color.rgb(210, 210, 210)); retweetBtn.setClickable(false); } favoriteBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { favorite(tweetObject.getId()); tweetObject.setIsFavorited(true); } else { unfavorite(tweetObject.getId()); tweetObject.setIsFavorited(false); } } }); // favoriteBtn.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // //// String btnTag = (String) favoriteBtn.getTag(); // if (!favoriteBtn.isChecked()) { // favoriteBtn.setChecked(true); // favorite(tweetObject.getId()); // tweetObject.setIsFavorited(true); // int colorFilter2 = Color.rgb(128, 128, 128); //// favoriteBtn.setColorFilter(colorFilter2); // favoriteBtn.setTag("F"); // } else { // favoriteBtn.setChecked(false); // unfavorite(tweetObject.getId()); // tweetObject.setIsFavorited(false); // int colorFilter1 = Color.rgb(206, 45, 79); //// favoriteBtn.setColorFilter(colorFilter1); // favoriteBtn.setTag("notF"); // } // } // }); replyBtn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: replyBtn.setColorFilter(Color.rgb(55, 58, 60)); return true; case MotionEvent.ACTION_UP: holder.tweetBlurLayout.toggleHover(); replyBtn.setColorFilter(Color.rgb(128, 128, 128)); AlertDialog.Builder builder = new AlertDialog.Builder(context); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); input.setLines(4); input.setSingleLine(false); input.setBackgroundDrawable(null); builder.setView(input); builder.setPositiveButton("Reply", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { reply(tweetObject.getId(), input.getText().toString()); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { Button posBtn = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); posBtn.setBackgroundColor(cPrimary); posBtn.setTextColor(Color.WHITE); final float scale = context.getApplicationContext().getResources() .getDisplayMetrics().density; int pixels = (int) (10 * scale + 0.5f); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, 0, pixels, 0); posBtn.setLayoutParams(layoutParams); Button negBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE); negBtn.setBackgroundColor(cPrimary); negBtn.setTextColor(Color.WHITE); } }); dialog.show(); return true; } return false; } }); moreBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // holder.tweetBlurLayout.toggleHover(); if (holder.repliesLayout.getVisibility() == View.VISIBLE) { holder.repliesLayout.setVisibility(View.GONE); } else { MyAppCompatActivity main = (MyAppCompatActivity) context; Map<String, String> jsonParams = new HashMap<>(); jsonParams.put("queue", "TWEET"); jsonParams.put("method", "get_earliest_replies"); jsonParams.put("tweet_id", tweetObject.getId() + ""); jsonParams.put("session_id", sessionId); JSONObject jsonRequest = new JSONObject(jsonParams); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, MainActivity.requestUrl, jsonRequest, new Response.Listener<JSONObject>() { @Override public void onResponse(final JSONObject response) { final ObjectMapper mapper = new ObjectMapper(); try { final Map<String, Object> responseMap = mapper.readValue( response.toString(), new TypeReference<HashMap<String, Object>>() { }); if (responseMap.get("code").equals("200")) { ArrayList repliesMap = (ArrayList) responseMap.get("earliest_replies"); ArrayList<Tweet> replies = getEarliestReplies(repliesMap); tweetObject.setReplies(replies); if (!replies.isEmpty()) { Tweet firstReply = replies.get(0); holder.reply1.setText(firstReply.getTweet()); String info = context.getString(R.string.user_info, firstReply.getCreator().getName(), firstReply.getCreator().getUsername()); holder.replyCreatorInfo1.setText(info); Picasso.with(context).load(firstReply.getCreator().getAvatar_url()) .placeholder(R.mipmap.ic_launcher).fit() .into(holder.replyUserImg1); holder.replyBtn1.setColorFilter(Color.rgb(128, 128, 128)); // setButtonStates(firstReply, holder.retweetBtn1, holder.favoriteBtn1); if (replies.size() > 1) { Tweet secondReply = replies.get(1); holder.reply2.setText(secondReply.getTweet()); info = context.getString(R.string.user_info, secondReply.getCreator().getName(), secondReply.getCreator().getUsername()); holder.replyCreatorInfo2.setText(info); Picasso.with(context) .load(secondReply.getCreator().getAvatar_url()) .placeholder(R.mipmap.ic_launcher).fit() .into(holder.replyUserImg2); holder.replyBtn2.setColorFilter(Color.rgb(128, 128, 128)); // setButtonStates(secondReply, holder.retweetBtn2, holder.favoriteBtn2); holder.replyLayout2.setVisibility(View.VISIBLE); } if (replies.size() > 2) { Tweet thirdReply = replies.get(2); holder.reply3.setText(thirdReply.getTweet()); info = context.getString(R.string.user_info, thirdReply.getCreator().getName(), thirdReply.getCreator().getUsername()); holder.replyCreatorInfo3.setText(info); Picasso.with(context) .load(thirdReply.getCreator().getAvatar_url()) .placeholder(R.mipmap.ic_launcher).fit() .into(holder.replyUserImg3); holder.replyBtn3.setColorFilter(Color.rgb(128, 128, 128)); // setButtonStates(thirdReply, holder.retweetBtn3, holder.favoriteBtn3); holder.replyLayout3.setVisibility(View.VISIBLE); } if (replies.size() > 3) { holder.showMoreBtn.setVisibility(View.VISIBLE); } holder.repliesProgress.setVisibility(View.GONE); holder.repliesLayout.setVisibility(View.VISIBLE); } else { holder.repliesProgress.setVisibility(View.GONE); holder.repliesLayout.setVisibility(View.GONE); } } } catch (Exception e) { // Log.e("JSONMapper", e.getMessage()); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { if (volleyError.networkResponse != null && volleyError.networkResponse.data != null && volleyError.networkResponse.statusCode == 400) { try { String errorJson = new String(volleyError.networkResponse.data); JSONObject errorObj = new JSONObject(errorJson); String error = errorObj.getString("message"); } catch (JSONException e) { // Log.e("Response Error Msg", e.getMessage()); } } else { // Log.e("Volley", volleyError.toString()); } } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json; charset=utf-8"); return headers; } ; }; jsonObjectRequest.setTag("Request"); main.getVolleyRequestQueue().add(jsonObjectRequest); holder.repliesProgress.setVisibility(View.VISIBLE); } } }); final Handler handler = new Handler(); holder.replyBtn1.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: holder.replyBtn1.setColorFilter(Color.rgb(55, 58, 60)); return true; case MotionEvent.ACTION_UP: holder.replyBtn1.setColorFilter(Color.rgb(128, 128, 128)); AlertDialog.Builder builder = new AlertDialog.Builder(context); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); input.setLines(4); input.setSingleLine(false); input.setBackgroundDrawable(null); builder.setView(input); builder.setPositiveButton("Reply", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.post(new Runnable() { @Override public void run() { if (holder.replyBtn1.getVisibility() == View.VISIBLE) { while (tweetObject.getReplies() == null) ; reply(tweetObject.getReplies().get(0).getId(), input.getText().toString()); } } }); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setBackgroundColor(cPrimary); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setBackgroundColor(cPrimary); } }); dialog.show(); return true; } return false; } }); holder.replyBtn2.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: holder.replyBtn2.setColorFilter(Color.rgb(55, 58, 60)); return true; case MotionEvent.ACTION_UP: holder.replyBtn2.setColorFilter(Color.rgb(128, 128, 128)); AlertDialog.Builder builder = new AlertDialog.Builder(context); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); input.setLines(4); input.setSingleLine(false); input.setBackgroundDrawable(null); builder.setView(input); builder.setPositiveButton("Reply", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.post(new Runnable() { @Override public void run() { if (holder.replyBtn2.getVisibility() == View.VISIBLE) { while (tweetObject.getReplies() == null) ; reply(tweetObject.getReplies().get(1).getId(), input.getText().toString()); } } }); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setBackgroundColor(cPrimary); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setBackgroundColor(cPrimary); } }); dialog.show(); return true; } return false; } }); holder.replyBtn3.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: holder.replyBtn3.setColorFilter(Color.rgb(55, 58, 60)); return true; case MotionEvent.ACTION_UP: holder.replyBtn3.setColorFilter(Color.rgb(128, 128, 128)); AlertDialog.Builder builder = new AlertDialog.Builder(context); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); input.setLines(4); input.setSingleLine(false); input.setBackgroundDrawable(null); builder.setView(input); builder.setPositiveButton("Reply", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.post(new Runnable() { @Override public void run() { if (holder.replyBtn3.getVisibility() == View.VISIBLE) { while (tweetObject.getReplies() == null) ; reply(tweetObject.getReplies().get(2).getId(), input.getText().toString()); } } }); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setBackgroundColor(cPrimary); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setBackgroundColor(cPrimary); } }); dialog.show(); return true; } return false; } }); holder.retweetBtn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String btnTag = (String) holder.retweetBtn1.getTag(); if (holder.retweetBtn1.getVisibility() == View.VISIBLE) { handler.post(new Runnable() { @Override public void run() { while (tweetObject.getReplies() == null) ; Tweet reply = tweetObject.getReplies().get(0); if (btnTag.equals("notR")) { retweet(reply.getId()); reply.setIsRetweeted(true); int colorFilter2 = Color.rgb(0, 0, 0); holder.retweetBtn1.setColorFilter(colorFilter2); holder.retweetBtn1.setTag("R"); } else if (btnTag.equals("R")) { unretweet(reply.getId()); reply.setIsRetweeted(false); int colorFilter1 = Color.rgb(128, 128, 128); holder.retweetBtn1.setColorFilter(colorFilter1); holder.retweetBtn1.setTag("notR"); } } }); } } }); holder.favoriteBtn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String btnTag = (String) holder.favoriteBtn1.getTag(); if (holder.favoriteBtn1.getVisibility() == View.VISIBLE) { handler.post(new Runnable() { @Override public void run() { while (tweetObject.getReplies() == null) ; Tweet reply = tweetObject.getReplies().get(0); if (btnTag.equals("notF")) { favorite(reply.getId()); reply.setIsFavorited(true); int colorFilter2 = Color.rgb(0, 0, 0); holder.favoriteBtn1.setColorFilter(colorFilter2); holder.favoriteBtn1.setTag("F"); } else if (btnTag.equals("F")) { unfavorite(reply.getId()); reply.setIsFavorited(false); int colorFilter1 = Color.rgb(128, 128, 128); holder.favoriteBtn1.setColorFilter(colorFilter1); holder.favoriteBtn1.setTag("notF"); } } }); } } }); holder.retweetBtn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String btnTag = (String) holder.retweetBtn2.getTag(); if (holder.retweetBtn2.getVisibility() == View.VISIBLE) { handler.post(new Runnable() { @Override public void run() { while (tweetObject.getReplies() == null) ; Tweet reply = tweetObject.getReplies().get(1); if (btnTag.equals("notR")) { retweet(reply.getId()); reply.setIsRetweeted(true); int colorFilter2 = Color.rgb(0, 0, 0); holder.retweetBtn2.setColorFilter(colorFilter2); holder.retweetBtn2.setTag("R"); } else if (btnTag.equals("R")) { unretweet(reply.getId()); reply.setIsRetweeted(false); int colorFilter1 = Color.rgb(128, 128, 128); holder.retweetBtn2.setColorFilter(colorFilter1); holder.retweetBtn2.setTag("notR"); } } }); } } }); holder.favoriteBtn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String btnTag = (String) holder.favoriteBtn2.getTag(); if (holder.favoriteBtn2.getVisibility() == View.VISIBLE) { handler.post(new Runnable() { @Override public void run() { while (tweetObject.getReplies() == null) ; Tweet reply = tweetObject.getReplies().get(1); if (btnTag.equals("notF")) { favorite(reply.getId()); reply.setIsFavorited(true); int colorFilter2 = Color.rgb(0, 0, 0); holder.favoriteBtn2.setColorFilter(colorFilter2); holder.favoriteBtn2.setTag("F"); } else if (btnTag.equals("F")) { unfavorite(reply.getId()); reply.setIsFavorited(false); int colorFilter1 = Color.rgb(128, 128, 128); holder.favoriteBtn2.setColorFilter(colorFilter1); holder.favoriteBtn2.setTag("notF"); } } }); } } }); holder.retweetBtn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String btnTag = (String) holder.retweetBtn3.getTag(); if (holder.retweetBtn3.getVisibility() == View.VISIBLE) { handler.post(new Runnable() { @Override public void run() { while (tweetObject.getReplies() == null) ; Tweet reply = tweetObject.getReplies().get(2); if (btnTag.equals("notR")) { retweet(reply.getId()); reply.setIsRetweeted(true); int colorFilter2 = Color.rgb(0, 0, 0); holder.retweetBtn3.setColorFilter(colorFilter2); holder.retweetBtn3.setTag("R"); } else if (btnTag.equals("R")) { unretweet(reply.getId()); reply.setIsRetweeted(false); int colorFilter1 = Color.rgb(128, 128, 128); holder.retweetBtn3.setColorFilter(colorFilter1); holder.retweetBtn3.setTag("notR"); } } }); } } }); holder.favoriteBtn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String btnTag = (String) holder.favoriteBtn3.getTag(); if (holder.favoriteBtn3.getVisibility() == View.VISIBLE) { handler.post(new Runnable() { @Override public void run() { while (tweetObject.getReplies() == null) ; Tweet reply = tweetObject.getReplies().get(2); if (btnTag.equals("notF")) { favorite(reply.getId()); reply.setIsFavorited(true); int colorFilter2 = Color.rgb(0, 0, 0); holder.favoriteBtn3.setColorFilter(colorFilter2); holder.favoriteBtn3.setTag("F"); } else if (btnTag.equals("F")) { unfavorite(reply.getId()); reply.setIsFavorited(false); int colorFilter1 = Color.rgb(128, 128, 128); holder.favoriteBtn3.setColorFilter(colorFilter1); holder.favoriteBtn3.setTag("notF"); } } }); } } }); holder.showMoreBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyAppCompatActivity main = (MyAppCompatActivity) context; FragmentManager fragmentManager = main.getSupportFragmentManager(); MainActivityFragment mainActivityFragment = new MainActivityFragment(); Bundle bundle = new Bundle(); bundle.putInt("tweetId", tweetObject.getId()); bundle.putString("username", MyAppCompatActivity.username); bundle.putString("sessionId", main.getSessionId()); mainActivityFragment.setArguments(bundle); fragmentManager.beginTransaction().add(android.R.id.content, mainActivityFragment) .addToBackStack("replies").commit(); } }); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a prompt to the user to rename the argument <tt>device</tt>. * //from ww w . j a va2 s . co m * @param device * the device to be renamed * @param activity * the parent activity */ public static void promptForNewDeviceName(final PairedDevice device, final MainActivity activity) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { DialogFragment prompt = new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = getBuilder(activity); final EditText input = new EditText(getContext()); input.setInputType(InputType.TYPE_CLASS_TEXT); input.setText(device.name); input.setSelection(device.name.length()); // @formatter:off builder.setTitle(R.string.device_name_chooser_title).setView(input) .setPositiveButton(android.R.string.ok, null); // @formatter:on final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener( new DeviceNameChooserPrompt(alertDialog, input, activity, new Callback<String>() { @Override public void run() { // @formatter:off device.rename(getParam()); activity.onSelectedDeviceRenamed(); ((InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); // @formatter:on } })); return alertDialog; } }; prompt.show(activity.getSupportFragmentManager(), "chooseName"); } }); }
From source file:com.shafiq.myfeedle.core.OAuthLogin.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);//w w w .j av a 2 s . c o m mHttpClient = MyfeedleHttpClient.getThreadSafeClient(getApplicationContext()); mLoadingDialog = new ProgressDialog(this); mLoadingDialog.setMessage(getString(R.string.loading)); mLoadingDialog.setCancelable(true); mLoadingDialog.setOnCancelListener(this); mLoadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), this); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { int service = extras.getInt(Myfeedle.Accounts.SERVICE, Myfeedle.INVALID_SERVICE); mServiceName = Myfeedle.getServiceName(getResources(), service); mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); mAccountId = extras.getLong(Myfeedle.EXTRA_ACCOUNT_ID, Myfeedle.INVALID_ACCOUNT_ID); mMyfeedleWebView = new MyfeedleWebView(); final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... args) { try { return mMyfeedleOAuth.getAuthUrl(args[0], args[1], args[2], args[3], Boolean.parseBoolean(args[4]), mHttpClient); } catch (OAuthMessageSignerException e) { e.printStackTrace(); } catch (OAuthNotAuthorizedException e) { e.printStackTrace(); } catch (OAuthExpectationFailedException e) { e.printStackTrace(); } catch (OAuthCommunicationException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String url) { if (loadingDialog.isShowing()) loadingDialog.dismiss(); // load the webview if (url != null) { mMyfeedleWebView.open(url); } else { (Toast.makeText(OAuthLogin.this, String.format(getString(R.string.oauth_error), mServiceName), Toast.LENGTH_LONG)).show(); OAuthLogin.this.finish(); } } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); dialog.cancel(); OAuthLogin.this.finish(); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); dialog.cancel(); OAuthLogin.this.finish(); } }); switch (service) { case TWITTER: mMyfeedleOAuth = new MyfeedleOAuth(TWITTER_KEY, TWITTER_SECRET); asyncTask.execute(String.format(TWITTER_URL_REQUEST, TWITTER_BASE_URL), String.format(TWITTER_URL_ACCESS, TWITTER_BASE_URL), String.format(TWITTER_URL_AUTHORIZE, TWITTER_BASE_URL), TWITTER_CALLBACK.toString(), Boolean.toString(true)); loadingDialog.show(); break; case FACEBOOK: mMyfeedleWebView.open(String.format(FACEBOOK_URL_AUTHORIZE, FACEBOOK_BASE_URL, FACEBOOK_ID, FACEBOOK_CALLBACK.toString())); break; // case MYSPACE: // mMyfeedleOAuth = new MyfeedleOAuth(MYSPACE_KEY, MYSPACE_SECRET); // asyncTask.execute(MYSPACE_URL_REQUEST, MYSPACE_URL_ACCESS, MYSPACE_URL_AUTHORIZE, MYSPACE_CALLBACK.toString(), Boolean.toString(true)); // loadingDialog.show(); // break; case FOURSQUARE: mMyfeedleWebView.open(String.format(FOURSQUARE_URL_AUTHORIZE, FOURSQUARE_KEY, FOURSQUARE_CALLBACK.toString())); break; case LINKEDIN: mMyfeedleOAuth = new MyfeedleOAuth(LINKEDIN_KEY, LINKEDIN_SECRET); asyncTask.execute(LINKEDIN_URL_REQUEST, LINKEDIN_URL_ACCESS, LINKEDIN_URL_AUTHORIZE, LINKEDIN_CALLBACK.toString(), Boolean.toString(true)); loadingDialog.show(); break; case SMS: Cursor c = getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID }, Accounts.SERVICE + "=?", new String[] { Integer.toString(SMS) }, null); if (c.moveToFirst()) { (Toast.makeText(OAuthLogin.this, "SMS has already been added.", Toast.LENGTH_LONG)).show(); } else { addAccount(getResources().getStringArray(R.array.service_entries)[SMS], null, null, 0, SMS, null); } c.close(); finish(); break; case RSS: // prompt for RSS url final EditText rss_url = new EditText(this); rss_url.setSingleLine(); new AlertDialog.Builder(OAuthLogin.this).setTitle(R.string.rss_url).setView(rss_url) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { // test the url and add if valid, else Toast error mLoadingDialog.show(); (new AsyncTask<String, Void, String>() { String url; @Override protected String doInBackground(String... params) { url = rss_url.getText().toString(); return MyfeedleHttpClient.httpResponse(mHttpClient, new HttpGet(url)); } @Override protected void onPostExecute(String response) { mLoadingDialog.dismiss(); if (response != null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(response)); Document doc = db.parse(is); // test parsing... NodeList nodes = doc.getElementsByTagName(Sitem); if (nodes.getLength() > 0) { // check for an image NodeList images = doc.getElementsByTagName(Simage); if (images.getLength() > 0) { NodeList imageChildren = images.item(0).getChildNodes(); Node n = imageChildren.item(0); if (n.getNodeName().toLowerCase().equals(Surl)) { if (n.hasChildNodes()) { n.getChildNodes().item(0).getNodeValue(); } } } NodeList children = nodes.item(0).getChildNodes(); String date = null; String title = null; String description = null; String link = null; int values_count = 0; for (int child = 0, c2 = children.getLength(); (child < c2) && (values_count < 4); child++) { Node n = children.item(child); if (n.getNodeName().toLowerCase().equals(Spubdate)) { values_count++; if (n.hasChildNodes()) { date = n.getChildNodes().item(0).getNodeValue(); } } else if (n.getNodeName().toLowerCase() .equals(Stitle)) { values_count++; if (n.hasChildNodes()) { title = n.getChildNodes().item(0) .getNodeValue(); } } else if (n.getNodeName().toLowerCase() .equals(Sdescription)) { values_count++; if (n.hasChildNodes()) { StringBuilder sb = new StringBuilder(); NodeList descNodes = n.getChildNodes(); for (int dn = 0, dn2 = descNodes .getLength(); dn < dn2; dn++) { Node descNode = descNodes.item(dn); if (descNode .getNodeType() == Node.TEXT_NODE) { sb.append(descNode.getNodeValue()); } } // strip out the html tags description = sb.toString() .replaceAll("\\<(.|\n)*?>", ""); } } else if (n.getNodeName().toLowerCase() .equals(Slink)) { values_count++; if (n.hasChildNodes()) { link = n.getChildNodes().item(0).getNodeValue(); } } } if (Myfeedle.HasValues( new String[] { title, description, link, date })) { final EditText url_name = new EditText(OAuthLogin.this); url_name.setSingleLine(); new AlertDialog.Builder(OAuthLogin.this) .setTitle(R.string.rss_channel) .setView(url_name) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog1, int which) { addAccount( url_name.getText() .toString(), null, null, 0, RSS, url); dialog1.dismiss(); dialog.dismiss(); finish(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog1, int which) { dialog1.dismiss(); dialog.dismiss(); finish(); } }) .show(); } else { (Toast.makeText(OAuthLogin.this, "Feed is missing standard fields", Toast.LENGTH_LONG)).show(); } } else { (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } } catch (ParserConfigurationException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } catch (SAXException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } catch (IOException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } } else { (Toast.makeText(OAuthLogin.this, "Invalid URL", Toast.LENGTH_LONG)) .show(); dialog.dismiss(); finish(); } } }).execute(rss_url.getText().toString()); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); break; // case IDENTICA: // mMyfeedleOAuth = new MyfeedleOAuth(IDENTICA_KEY, IDENTICA_SECRET); // asyncTask.execute(String.format(IDENTICA_URL_REQUEST, IDENTICA_BASE_URL), String.format(IDENTICA_URL_ACCESS, IDENTICA_BASE_URL), String.format(IDENTICA_URL_AUTHORIZE, IDENTICA_BASE_URL), IDENTICA_CALLBACK.toString(), Boolean.toString(true)); // loadingDialog.show(); // break; case GOOGLEPLUS: mMyfeedleWebView.open( String.format(GOOGLEPLUS_AUTHORIZE, GOOGLE_CLIENTID, "urn:ietf:wg:oauth:2.0:oob")); break; // case CHATTER: // mMyfeedleWebView.open(String.format(CHATTER_URL_AUTHORIZE, CHATTER_KEY, CHATTER_CALLBACK.toString())); // break; case PINTEREST: Cursor pinterestAccount = getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID }, Accounts.SERVICE + "=?", new String[] { Integer.toString(PINTEREST) }, null); if (pinterestAccount.moveToFirst()) { (Toast.makeText(OAuthLogin.this, "Pinterest has already been added.", Toast.LENGTH_LONG)) .show(); } else { (Toast.makeText(OAuthLogin.this, "Pinterest currently allows only public, non-authenticated viewing.", Toast.LENGTH_LONG)).show(); String[] values = getResources().getStringArray(R.array.service_values); String[] entries = getResources().getStringArray(R.array.service_entries); for (int i = 0, l = values.length; i < l; i++) { if (Integer.toString(PINTEREST).equals(values[i])) { addAccount(entries[i], null, null, 0, PINTEREST, null); break; } } } pinterestAccount.close(); finish(); break; default: this.finish(); } } } }
From source file:org.eatabrick.vecna.Vecna.java
private void getPassphrase() { final EditText pass = new EditText(this); pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.prompt)); builder.setView(pass);//from w ww.j ava2s .c o m builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { passphrase = pass.getText().toString(); if (passphrase.length() != 0) new ReadEntriesTask().execute(passphrase); } }); builder.show(); }