List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:com.citrus.sample.WalletPaymentFragment.java
@OnClick(R.id.btnMasterpass) public void testMasterPass() { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); String message = null;//from ww w .j a va2 s . c o m String positiveButtonText = null; message = "Please enter the transaction amount."; positiveButtonText = "Make Payment"; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); alert.setTitle("Transaction Amount?"); alert.setMessage(message); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); alert.setView(input); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); input.clearFocus(); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); try { MasterPassOption masterPassOption = new MasterPassOption(); PaymentType.PGPayment pgPayment = new PaymentType.PGPayment(new Amount(value), Constants.BILL_URL, masterPassOption, null); mCitrusClient.simpliPay(pgPayment, new Callback<TransactionResponse>() { @Override public void success(TransactionResponse transactionResponse) { Toast.makeText(getActivity(), transactionResponse.getMessage(), Toast.LENGTH_SHORT) .show(); } @Override public void error(CitrusError error) { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); } }); } catch (CitrusException e) { e.printStackTrace(); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); input.requestFocus(); alert.show(); }
From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java
private void showHighlightEditDialog(final HighLight highLight) { final AlertDialog.Builder editalert = new AlertDialog.Builder(context); editalert.setTitle(R.string.text_note); final EditText input = new EditText(context); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); input.setLayoutParams(lp);/*from w ww . j av a 2 s .c o m*/ editalert.setView(input); input.setText(highLight.getTextNote()); editalert.setPositiveButton(R.string.save_note, (dialog, which) -> { highLight.setTextNote(input.getText().toString()); bookView.update(); highlightManager.saveHighLights(); }); editalert.setNegativeButton(android.R.string.cancel, (dialog, which) -> { }); editalert.setNeutralButton(R.string.clear_note, (dialog, which) -> { highLight.setTextNote(null); bookView.update(); highlightManager.saveHighLights(); }); editalert.show(); }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
private void showHighlightEditDialog(final HighLight highLight) { final AlertDialog.Builder editalert = new AlertDialog.Builder(context); editalert.setTitle(R.string.text_note); final EditText input = new EditText(context); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); input.setLayoutParams(lp);//from w ww. ja va 2 s . com editalert.setView(input); input.setText(highLight.getTextNote()); editalert.setPositiveButton(R.string.save_note, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { highLight.setTextNote(input.getText().toString()); bookView.update(); highlightManager.saveHighLights(); } }); editalert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); editalert.setNeutralButton(R.string.clear_note, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { highLight.setTextNote(null); bookView.update(); highlightManager.saveHighLights(); } }); editalert.show(); }
From source file:com.citrus.sample.WalletPaymentFragment.java
private void showUpdateSubscriptionPrompt(final boolean isUpdateToHigherValue) { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); // final String message = "Update Subscription to Lowe Amount"; String positiveButtonText = "Update Subscription "; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final TextView labelsubscriptionID = new TextView(getActivity()); final EditText edtAmount = new EditText(getActivity()); final TextView labelAmount = new TextView(getActivity()); final EditText editLoadAmount = new EditText(getActivity()); final TextView labelMobileNo = new TextView(getActivity()); final EditText editThresholdAmount = new EditText(getActivity()); editLoadAmount.setSingleLine(true);/*from w w w. j a va 2 s . c o m*/ editThresholdAmount.setSingleLine(true); edtAmount.setSingleLine(true); edtAmount.setInputType(InputType.TYPE_NULL); labelsubscriptionID.setText("Load Money Amount"); labelAmount.setText("Current Auto Load Amount"); editLoadAmount.setText(String.valueOf(activeSubscription.getLoadAmount())); labelMobileNo.setText("Current Threshold Amount"); editThresholdAmount.setText(String.valueOf(activeSubscription.getThresholdAmount())); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelsubscriptionID.setLayoutParams(layoutParams); edtAmount.setLayoutParams(layoutParams); labelAmount.setLayoutParams(layoutParams); labelMobileNo.setLayoutParams(layoutParams); editLoadAmount.setLayoutParams(layoutParams); editThresholdAmount.setLayoutParams(layoutParams); linearLayout.addView(labelAmount); linearLayout.addView(editLoadAmount); linearLayout.addView(labelMobileNo); linearLayout.addView(editThresholdAmount); linearLayout.addView(labelsubscriptionID); linearLayout.addView(edtAmount); edtAmount.setText("1.00"); int paddingPx = Utils.getSizeInPx(getActivity(), 32); linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); edtAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editLoadAmount.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { /* if (!hasFocus) { if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { labelsubscriptionID.setVisibility(View.VISIBLE); edtAmount.setVisibility(View.VISIBLE); edtAmount.setText("1.00"); } else { labelsubscriptionID.setVisibility(View.INVISIBLE); edtAmount.setVisibility(View.INVISIBLE); } }*/ } }); editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setTitle("Update Subscription "); alert.setMessage("Updating Load amount to higher will require Load Money transactions."); alert.setView(linearLayout); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String trAmount = edtAmount.getText().toString(); final String loadAmount = editLoadAmount.getText().toString(); final String thresHoldAmount = editThresholdAmount.getText().toString(); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edtAmount.getWindowToken(), 0); if (TextUtils.isEmpty(trAmount) && edtAmount.getVisibility() == View.VISIBLE) { Toast.makeText(getActivity(), " load amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(loadAmount)) { Toast.makeText(getActivity(), "Auto Load Amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(thresHoldAmount)) { Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(thresHoldAmount) < new Double("500")) { Toast.makeText(getActivity(), "thresHoldAmount should not be less than 500", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) { Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { //update to higher value mListener.onAutoLoadSelected(AUTO_LOAD_MONEY, new Amount(trAmount), editLoadAmount.getText().toString(), editThresholdAmount.getText().toString(), true); } else { //update to lower value mCitrusClient.updateSubScriptiontoLoweValue(new Amount(thresHoldAmount), new Amount(loadAmount), new Callback<SubscriptionResponse>() { @Override public void success(SubscriptionResponse subscriptionResponse) { Toast.makeText(getActivity(), subscriptionResponse.toString(), Toast.LENGTH_SHORT).show(); Logger.d("updateSubscription response **" + subscriptionResponse.toString()); activeSubscription = subscriptionResponse;//update the active subscription Object } @Override public void error(CitrusError error) { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); Logger.d("ERROR ***updateSubscription" + error.getMessage()); } }); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); editLoadAmount.requestFocus(); alert.show(); }
From source file:edu.oakland.festinfo.activities.MapPageActivity.java
@Override public void onMapLongClick(final LatLng point) { ParseACL acl = new ParseACL(); acl.setPublicReadAccess(true);//from ww w . ja va 2 s.c o m acl.setPublicWriteAccess(true); final ParseObject MapMarkers = new ParseObject("MapMarkers"); MapMarkers.setACL(acl); AlertDialog.Builder chooseColor = new AlertDialog.Builder(this); chooseColor.setTitle("Choose a Color: ").setItems(R.array.choose_color_array, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { markerColor = "Red"; } else if (which == 1) { markerColor = "Azure"; } else if (which == 2) { markerColor = "Orange"; } else if (which == 3) { markerColor = "Green"; } else if (which == 4) { markerColor = "Violet"; } else if (which == 5) { markerColor = "Blue"; } else if (which == 6) { markerColor = "Magenta"; } else if (which == 7) { markerColor = "Rose"; } else if (which == 8) { markerColor = "Yellow"; } else if (which == 9) { markerColor = "Cyan"; } } }); //tvLocInfo.setText("New marker added@" + point.toString()); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Custom Text:"); final EditText input = new EditText(this); builder.setView(input); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = input.getText().toString(); //tvLocInfo.setText(text + " marker added!"); if (markerColor.equals("Red")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "first aid"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_RED); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Azure")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "lost found"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_AZURE); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Orange")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "food"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_ORANGE); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Green")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "shuttle"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_GREEN); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); //tvLocInfo.setText("Green Stored"); } else if (markerColor.equals("Violet")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "atm"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_VIOLET); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Blue")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "hammock"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_BLUE); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Magenta")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "stage"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_MAGENTA); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Rose")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "hot air"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_ROSE); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Yellow")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "restrooms"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_YELLOW); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else if (markerColor.equals("Cyan")) { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "tents"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_CYAN); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } else { Marker newMarker = map.addMarker(new MarkerOptions().position(point).title(text).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); Circle newCircle = map.addCircle(new CircleOptions().center(point).radius(0)); newCircle.setStrokeWidth(2); newCircle.setStrokeColor(Color.RED); CombinedMarker cm = new CombinedMarker(newMarker, newCircle, newMarker.getId(), "first aid"); combinedArray.add(cm); ParseGeoPoint geoPoint = new ParseGeoPoint(point.latitude, point.longitude); MapMarkers.put("Title", text); MapMarkers.put("Location", geoPoint); MapMarkers.put("Color", BitmapDescriptorFactory.HUE_RED); MapMarkers.put("HasGeofence", false); MapMarkers.put("GeofenceID", newMarker.getId()); MapMarkers.put("GeofenceRadius", 0); MapMarkers.saveInBackground(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); chooseColor.show(); }
From source file:com.keylesspalace.tusky.ComposeActivity.java
private void makeCaptionDialog(QueuedMedia item) { LinearLayout dialogLayout = new LinearLayout(this); int padding = Utils.dpToPx(this, 8); dialogLayout.setPadding(padding, padding, padding, padding); dialogLayout.setOrientation(LinearLayout.VERTICAL); ImageView imageView = new ImageView(this); DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); Picasso.with(this).load(item.uri).resize(displayMetrics.widthPixels, displayMetrics.heightPixels) .onlyScaleDown().into(imageView); int margin = Utils.dpToPx(this, 4); dialogLayout.addView(imageView);//from w w w . ja va2 s . com ((LinearLayout.LayoutParams) imageView.getLayoutParams()).weight = 1; imageView.getLayoutParams().height = 0; ((LinearLayout.LayoutParams) imageView.getLayoutParams()).setMargins(0, margin, 0, 0); EditText input = new EditText(this); input.setHint(R.string.hint_describe_for_visually_impaired); dialogLayout.addView(input); ((LinearLayout.LayoutParams) input.getLayoutParams()).setMargins(margin, margin, margin, margin); input.setLines(1); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); input.setText(item.description); DialogInterface.OnClickListener okListener = (dialog, which) -> { mastodonApi.updateMedia(item.id, input.getText().toString()).enqueue(new Callback<Attachment>() { @Override public void onResponse(@NonNull Call<Attachment> call, @NonNull Response<Attachment> response) { Attachment attachment = response.body(); if (response.isSuccessful() && attachment != null) { item.description = attachment.getDescription(); item.preview.setChecked(item.description != null && !item.description.isEmpty()); dialog.dismiss(); } else { showFailedCaptionMessage(); } } @Override public void onFailure(@NonNull Call<Attachment> call, @NonNull Throwable t) { showFailedCaptionMessage(); } }); }; AlertDialog dialog = new AlertDialog.Builder(this).setView(dialogLayout) .setPositiveButton(android.R.string.ok, okListener).setNegativeButton(android.R.string.cancel, null) .create(); Window window = dialog.getWindow(); if (window != null) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } dialog.show(); }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void dynExport() { localfinished = false;/*from ww w . j av a2 s . com*/ if (Globals.isMidi(currSongName) && Globals.isPlaying == 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getResources().getString(R.string.dynex_alert1)); alert.setMessage(getResources().getString(R.string.dynex_alert1_msg)); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; final EditText input = new EditText(this); input.setFilters(new InputFilter[] { filter }); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (!value.toLowerCase(Locale.US).endsWith(".wav")) value += ".wav"; String parent = currSongName.substring(0, currSongName.lastIndexOf('/') + 1); boolean alreadyExists = new File(parent + value).exists(); boolean aWrite = true; String needRename = null; String probablyTheRoot = ""; String probablyTheDirectory = ""; try { new FileOutputStream(parent + value, true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } if (aWrite && !alreadyExists) new File(parent + value).delete(); if (aWrite && new File(parent).canWrite()) { value = parent + value; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null) { String[] tmp = Globals.getDocFilePaths(TimidityActivity.this, parent); probablyTheDirectory = tmp[0]; probablyTheRoot = tmp[1]; if (probablyTheDirectory.length() > 1) { needRename = parent .substring(parent.indexOf(probablyTheRoot) + probablyTheRoot.length()) + value; value = probablyTheDirectory + '/' + value; } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; } } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; } final String finalval = value; final boolean canWrite = aWrite; final String needToRename = needRename; final String probRoot = probablyTheRoot; if (new File(finalval).exists() || (new File(probRoot + needRename).exists() && needToRename != null)) { AlertDialog dialog2 = new AlertDialog.Builder(TimidityActivity.this).create(); dialog2.setTitle(getResources().getString(R.string.warning)); dialog2.setMessage(getResources().getString(R.string.dynex_alert2_msg)); dialog2.setCancelable(false); dialog2.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (needToRename != null) { Globals.tryToDeleteFile(TimidityActivity.this, probRoot + needToRename); Globals.tryToDeleteFile(TimidityActivity.this, finalval); } else { Globals.tryToDeleteFile(TimidityActivity.this, finalval); } } else { new File(finalval).delete(); } saveWavPart2(finalval, needToRename); } }); dialog2.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog2.show(); } else { saveWavPart2(finalval, needToRename); } } }); alert.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alerty = alert.show(); } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeNoteBox() { RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height noteBox = new SkyBox(this); noteBox.setBoxColor(currentColor);/*from ww w . j av a 2s.c om*/ noteBox.setArrowHeight(ps(25)); noteBox.setArrowDirection(false); param.leftMargin = ps(50); param.topMargin = ps(400); int minWidth = Math.min(this.getWidth(), this.getHeight()); noteBoxWidth = (int) (minWidth * 0.8); param.width = noteBoxWidth; param.height = ps(300); noteBox.setLayoutParams(param); noteBox.setArrowDirection(false); noteEditor = new EditText(this); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; noteEditor.setLayoutParams(params); noteEditor.setBackgroundColor(Color.TRANSPARENT); noteEditor.setMaxLines(1000); noteEditor.setGravity(Gravity.TOP | Gravity.LEFT); noteEditor.setOnFocusChangeListener(focusListener); noteBox.contentView.addView(noteEditor); ePubView.addView(noteBox); this.hideNoteBox(); }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public static AlertDialog getaddtextdialog(String title, final int itemnumber, Context ctx) { AlertDialog.Builder getaddtext = new AlertDialog.Builder(ctx); final LinearLayout linearlayout = new LinearLayout(ctx); linearlayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); linearlayout.setOrientation(LinearLayout.VERTICAL); final EditText nameet = new EditText(ctx); nameet.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final TextView fontname = new TextView(ctx); fontname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final TextView colorname = new TextView(ctx); colorname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final Spinner fontsizespinner = new Spinner(ctx); fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final Spinner colorspinner = new Spinner(ctx); fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); List<String> fontsizelist = new ArrayList<String>(); for (int t = 1; t < 200; t++) { fontsizelist.add(u.s(t));//from w w w . ja v a 2 s.c o m } ArrayAdapter<String> fontsizearrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview, fontsizelist); fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview); List<String> colorlist = new ArrayList<String>(); { colorlist.add("RED"); colorlist.add("BLACK"); colorlist.add("BLUE"); colorlist.add("GREEN"); colorlist.add("WHITE"); colorlist.add("GRAY"); } ArrayAdapter<String> colorlistarrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview, colorlist); fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview); colorspinner.setAdapter(colorlistarrayadapter); fontsizespinner.setAdapter(fontsizearrayadapter); fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, "25")); fontname.setText("Select Font Size"); fontname.setTextSize(20f); colorname.setText("Select Color"); colorname.setTextSize(20f); linearlayout.addView(nameet); linearlayout.addView(fontname); linearlayout.addView(fontsizespinner); linearlayout.addView(colorname); linearlayout.addView(colorspinner); if (!(itemnumber == view.i)) { nameet.setText(view.ITEMstring[itemnumber]); fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, u.s(view.ITEMfontsize[itemnumber]))); colorspinner.setSelection(getIndexofSpinner(colorspinner, u.s(view.ITEMfontcolor[itemnumber]))); } getaddtext.setView(linearlayout); getaddtext.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); getaddtext.setTitle(title); getaddtext.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub String string = nameet.getText().toString(); float fontsize = fontsizespinner.getSelectedItemPosition() + 1; //ITEMelcnumber[itemselectednumber]=u.i(string); int colpos = colorspinner.getSelectedItemPosition(); int[] col = new int[] { Color.RED, Color.BLACK, Color.BLUE, Color.GREEN, Color.WHITE, Color.GRAY }; int color = col[colpos]; Log.d("addtext", u.s((int) fontsize) + colpos + color); view.ITEMstring[itemnumber] = string; view.ITEMfontsize[itemnumber] = (int) fontsize; view.ITEMfontcolor[itemnumber] = color; view.itemname = string; view.fontsize = (int) fontsize; view.color = color; view.invalidate(); dialog.dismiss(); FloorPlanActivity.writeonedbitem(itemnumber); } }); return getaddtext.create(); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Change the name of the current row/* w w w . j a v a2s . c o m*/ * * @param context */ public static void displayChangeRowName(final Launcher context) { // Set an EditText view to get user input final EditText input = new EditText(context); new AlertDialog.Builder(context).setTitle(context.getString(R.string.dialog_row_name_title)) .setMessage(context.getString(R.string.dialog_row_name)).setView(input) .setPositiveButton(context.getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); context.changeCurrentRowName(value.toString()); } }).setNegativeButton(context.getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }) .show(); }