use of android.text.InputFilter in project xDrip by NightscoutFoundation.
the class BluetoothScan method requestTransmitterId.
private void requestTransmitterId(final SharedPreferences prefs) {
final Dialog dialog = new Dialog(BluetoothScan.this);
dialog.setContentView(R.layout.dialog_single_text_field);
Button saveButton = (Button) dialog.findViewById(R.id.saveButton);
Button cancelButton = (Button) dialog.findViewById(R.id.cancelButton);
dialog.findViewById(R.id.scannerButton).setVisibility(View.GONE);
final EditText serialNumberView = (EditText) dialog.findViewById(R.id.editTextField);
serialNumberView.setHint("00000");
serialNumberView.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
((TextView) dialog.findViewById(R.id.instructionsTextField)).setText("Enter Your Dexcom Transmitter ID");
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(serialNumberView.getText())) {
prefs.edit().putString("dex_txid", serialNumberView.getText().toString()).apply();
}
dialog.dismiss();
returnToHome();
}
});
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
use of android.text.InputFilter in project xDrip-plus by jamorham.
the class BluetoothScan method requestTransmitterId.
private void requestTransmitterId(final SharedPreferences prefs) {
final Dialog dialog = new Dialog(BluetoothScan.this);
dialog.setContentView(R.layout.dialog_single_text_field);
Button saveButton = (Button) dialog.findViewById(R.id.saveButton);
Button cancelButton = (Button) dialog.findViewById(R.id.cancelButton);
dialog.findViewById(R.id.scannerButton).setVisibility(View.GONE);
final EditText serialNumberView = (EditText) dialog.findViewById(R.id.editTextField);
serialNumberView.setHint("00000");
serialNumberView.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
((TextView) dialog.findViewById(R.id.instructionsTextField)).setText("Enter Your Dexcom Transmitter ID");
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(serialNumberView.getText())) {
prefs.edit().putString("dex_txid", serialNumberView.getText().toString()).apply();
}
dialog.dismiss();
returnToHome();
}
});
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
use of android.text.InputFilter in project android_packages_apps_Settings by omnirom.
the class WifiP2pSettings method onCreateDialog.
@Override
public Dialog onCreateDialog(int id) {
if (id == DIALOG_DISCONNECT) {
String deviceName = TextUtils.isEmpty(mSelectedWifiPeer.device.deviceName) ? mSelectedWifiPeer.device.deviceAddress : mSelectedWifiPeer.device.deviceName;
String msg;
if (mConnectedDevices > 1) {
msg = getActivity().getString(R.string.wifi_p2p_disconnect_multiple_message, deviceName, mConnectedDevices - 1);
} else {
msg = getActivity().getString(R.string.wifi_p2p_disconnect_message, deviceName);
}
AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.wifi_p2p_disconnect_title).setMessage(msg).setPositiveButton(getActivity().getString(R.string.dlg_ok), mDisconnectListener).setNegativeButton(getActivity().getString(R.string.dlg_cancel), null).create();
return dialog;
} else if (id == DIALOG_CANCEL_CONNECT) {
int stringId = R.string.wifi_p2p_cancel_connect_message;
String deviceName = TextUtils.isEmpty(mSelectedWifiPeer.device.deviceName) ? mSelectedWifiPeer.device.deviceAddress : mSelectedWifiPeer.device.deviceName;
AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.wifi_p2p_cancel_connect_title).setMessage(getActivity().getString(stringId, deviceName)).setPositiveButton(getActivity().getString(R.string.dlg_ok), mCancelConnectListener).setNegativeButton(getActivity().getString(R.string.dlg_cancel), null).create();
return dialog;
} else if (id == DIALOG_RENAME) {
mDeviceNameText = new EditText(getActivity());
mDeviceNameText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(30) });
if (mSavedDeviceName != null) {
mDeviceNameText.setText(mSavedDeviceName);
mDeviceNameText.setSelection(mSavedDeviceName.length());
} else if (mThisDevice != null && !TextUtils.isEmpty(mThisDevice.deviceName)) {
mDeviceNameText.setText(mThisDevice.deviceName);
mDeviceNameText.setSelection(0, mThisDevice.deviceName.length());
}
mSavedDeviceName = null;
AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.wifi_p2p_menu_rename).setView(mDeviceNameText).setPositiveButton(getActivity().getString(R.string.dlg_ok), mRenameListener).setNegativeButton(getActivity().getString(R.string.dlg_cancel), null).create();
return dialog;
} else if (id == DIALOG_DELETE_GROUP) {
int stringId = R.string.wifi_p2p_delete_group_message;
AlertDialog dialog = new AlertDialog.Builder(getActivity()).setMessage(getActivity().getString(stringId)).setPositiveButton(getActivity().getString(R.string.dlg_ok), mDeleteGroupListener).setNegativeButton(getActivity().getString(R.string.dlg_cancel), mDeleteGroupListener).create();
return dialog;
}
return null;
}
use of android.text.InputFilter in project samourai-wallet-android by Samourai-Wallet.
the class FeeActivity method doCustomFee.
private void doCustomFee() {
double sanitySat = (double) FeeUtil.getInstance().getHighFee().getDefaultPerKB().doubleValue() / 1000.0;
final long sanityValue = (long) (sanitySat * 1.5);
final EditText etCustomFee = new EditText(FeeActivity.this);
double d = FeeUtil.getInstance().getSuggestedFee().getDefaultPerKB().doubleValue() / 1000.0;
NumberFormat decFormat = NumberFormat.getInstance(Locale.US);
decFormat.setMaximumFractionDigits(3);
decFormat.setMinimumFractionDigits(0);
etCustomFee.setText(decFormat.format(d));
InputFilter filter = new InputFilter() {
String strCharset = "0123456789nollNOLL.";
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (strCharset.indexOf(source.charAt(i)) == -1) {
return "";
}
}
return null;
}
};
etCustomFee.setFilters(new InputFilter[] { filter });
AlertDialog.Builder dlg = new AlertDialog.Builder(FeeActivity.this).setTitle(R.string.app_name).setMessage(R.string.set_sat).setView(etCustomFee).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String strCustomFee = etCustomFee.getText().toString();
double customValue = 0.0;
if (strCustomFee.equalsIgnoreCase("noll") && PrefsUtil.getInstance(FeeActivity.this).getValue(PrefsUtil.USE_TRUSTED_NODE, false) == true) {
customValue = 0.0;
} else {
try {
customValue = Double.valueOf(strCustomFee);
} catch (Exception e) {
Toast.makeText(FeeActivity.this, R.string.custom_fee_too_low, Toast.LENGTH_SHORT).show();
return;
}
}
if (customValue < 1.0 && !strCustomFee.equalsIgnoreCase("noll")) {
Toast.makeText(FeeActivity.this, R.string.custom_fee_too_low, Toast.LENGTH_SHORT).show();
} else if (customValue > sanityValue) {
Toast.makeText(FeeActivity.this, R.string.custom_fee_too_high, Toast.LENGTH_SHORT).show();
} else {
SuggestedFee suggestedFee = new SuggestedFee();
suggestedFee.setStressed(false);
suggestedFee.setOK(true);
suggestedFee.setDefaultPerKB(BigInteger.valueOf((long) (customValue * 1000.0)));
Log.d("FeeActivity", "custom fee:" + BigInteger.valueOf((long) (customValue * 1000.0)));
FeeUtil.getInstance().setSuggestedFee(suggestedFee);
btLowFee.setBackgroundColor(FeeActivity.this.getResources().getColor(R.color.darkgrey));
btAutoFee.setBackgroundColor(FeeActivity.this.getResources().getColor(R.color.darkgrey));
btPriorityFee.setBackgroundColor(FeeActivity.this.getResources().getColor(R.color.darkgrey));
btCustomFee.setBackgroundColor(FeeActivity.this.getResources().getColor(R.color.blue));
btCustomFee.setText((FeeUtil.getInstance().getSuggestedFee().getDefaultPerKB().doubleValue() / 1000L) + "\n" + getString(R.string.sat_b));
btCustomFee.setTypeface(null, Typeface.BOLD);
btLowFee.setTypeface(null, Typeface.NORMAL);
btAutoFee.setTypeface(null, Typeface.NORMAL);
btPriorityFee.setTypeface(null, Typeface.NORMAL);
long lowFee = FeeUtil.getInstance().getLowFee().getDefaultPerKB().longValue() / 1000L;
long normalFee = FeeUtil.getInstance().getNormalFee().getDefaultPerKB().longValue() / 1000L;
long highFee = FeeUtil.getInstance().getHighFee().getDefaultPerKB().longValue() / 1000L;
double pct = 0.0;
int nbBlocks = 6;
if (customValue == 0.0) {
customValue = 1.0;
}
if (customValue <= (double) lowFee) {
pct = ((double) lowFee / customValue);
nbBlocks = ((Double) Math.ceil(pct * 24.0)).intValue();
} else if (customValue >= (double) highFee) {
pct = ((double) highFee / customValue);
nbBlocks = ((Double) Math.ceil(pct * 2.0)).intValue();
if (nbBlocks < 1) {
nbBlocks = 1;
}
} else {
pct = ((double) normalFee / customValue);
nbBlocks = ((Double) Math.ceil(pct * 6.0)).intValue();
}
tvFeePrompt.setText(getText(R.string.fee_custom_priority) + " " + nbBlocks + " " + getText(R.string.blocks_to_cf));
}
dialog.dismiss();
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
});
if (!isFinishing()) {
dlg.show();
}
}
use of android.text.InputFilter in project AndroidUtilLib by SiberiaDante.
the class SDVerificationCodeView method initTextViews.
private void initTextViews(Context context, int etNumber, int etWidth, Drawable etDividerDrawable, float etTextSize, int etTextColor) {
edtTransparent.setCursorVisible(false);
// maximum input length
edtTransparent.setFilters(new InputFilter[] { new InputFilter.LengthFilter(etNumber) });
// setting division line width
if (etDividerDrawable != null) {
etDividerDrawable.setBounds(0, 0, etDividerDrawable.getMinimumWidth(), etDividerDrawable.getMinimumHeight());
containerEt.setDividerDrawable(etDividerDrawable);
}
mPwdTextViews = new SDBlackCirclePsdView[etNumber];
for (int i = 0; i < mPwdTextViews.length; i++) {
SDBlackCirclePsdView textView = new SDBlackCirclePsdView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, etTextSize);
textView.setTextColor(etTextColor);
textView.setWidth(etWidth);
textView.setHeight(etWidth);
if (i == 0) {
textView.setBackgroundDrawable(mEtBackgroundDrawableFocus);
} else {
textView.setBackgroundDrawable(mEtBackgroundDrawableNormal);
}
textView.setGravity(Gravity.CENTER);
textView.setFocusable(false);
mPwdTextViews[i] = textView;
}
}
Aggregations