use of android.text.InputFilter in project android_packages_apps_Settings by LineageOS.
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 RxTools by vondear.
the class ColorPickerDialogBuilder method build.
public AlertDialog build() {
Context context = builder.getContext();
colorPickerView.setInitialColors(initialColor, getStartOffset(initialColor));
if (isLightnessSliderEnabled) {
LinearLayout.LayoutParams layoutParamsForLightnessBar = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getDimensionAsPx(context, R.dimen.default_slider_height));
lightnessSlider = new LightnessSlider(context);
lightnessSlider.setLayoutParams(layoutParamsForLightnessBar);
pickerContainer.addView(lightnessSlider);
colorPickerView.setLightnessSlider(lightnessSlider);
lightnessSlider.setColor(getStartColor(initialColor));
}
if (isAlphaSliderEnabled) {
LinearLayout.LayoutParams layoutParamsForAlphaBar = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getDimensionAsPx(context, R.dimen.default_slider_height));
alphaSlider = new AlphaSlider(context);
alphaSlider.setLayoutParams(layoutParamsForAlphaBar);
pickerContainer.addView(alphaSlider);
colorPickerView.setAlphaSlider(alphaSlider);
alphaSlider.setColor(getStartColor(initialColor));
}
if (isColorEditEnabled) {
LinearLayout.LayoutParams layoutParamsForColorEdit = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
colorEdit = (EditText) View.inflate(context, R.layout.picker_edit, null);
colorEdit.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
colorEdit.setSingleLine();
colorEdit.setVisibility(View.GONE);
// limit number of characters to hexColors
int maxLength = isAlphaSliderEnabled ? 9 : 7;
colorEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) });
pickerContainer.addView(colorEdit, layoutParamsForColorEdit);
colorEdit.setText(RxImageTool.getHexString(getStartColor(initialColor), isAlphaSliderEnabled));
colorPickerView.setColorEdit(colorEdit);
}
if (isPreviewEnabled) {
colorPreview = (LinearLayout) View.inflate(context, R.layout.color_preview, null);
colorPreview.setVisibility(View.GONE);
pickerContainer.addView(colorPreview);
if (initialColor.length == 0) {
ImageView colorImage = (ImageView) View.inflate(context, R.layout.color_selector, null);
colorImage.setImageDrawable(new ColorDrawable(Color.WHITE));
} else {
for (int i = 0; i < initialColor.length && i < this.pickerCount; i++) {
if (initialColor[i] == null)
break;
LinearLayout colorLayout = (LinearLayout) View.inflate(context, R.layout.color_selector, null);
ImageView colorImage = (ImageView) colorLayout.findViewById(R.id.image_preview);
colorImage.setImageDrawable(new ColorDrawable(initialColor[i]));
colorPreview.addView(colorLayout);
}
}
colorPreview.setVisibility(View.VISIBLE);
colorPickerView.setColorPreview(colorPreview, getStartOffset(initialColor));
}
return builder.create();
}
use of android.text.InputFilter in project collect by opendatakit.
the class ServerPreferencesFragment method addOtherPreferences.
public void addOtherPreferences() {
addAggregatePreferences();
addPreferencesFromResource(R.xml.other_preferences);
formListUrlPreference = (EditTextPreference) findPreference(KEY_FORMLIST_URL);
submissionUrlPreference = (EditTextPreference) findPreference(KEY_SUBMISSION_URL);
InputFilter[] filters = { new ControlCharacterFilter(), new WhitespaceFilter() };
serverUrlPreference.getEditText().setFilters(filters);
formListUrlPreference.setOnPreferenceChangeListener(createChangeListener());
formListUrlPreference.setSummary(formListUrlPreference.getText());
formListUrlPreference.getEditText().setFilters(filters);
submissionUrlPreference.setOnPreferenceChangeListener(createChangeListener());
submissionUrlPreference.setSummary(submissionUrlPreference.getText());
submissionUrlPreference.getEditText().setFilters(filters);
}
use of android.text.InputFilter in project CreditCardView by Movile.
the class CreditCardFragment method restoreSavedCard.
public void restoreSavedCard(CreditCardPaymentMethod creditCardPaymentMethod) {
this.savedCard = creditCardPaymentMethod;
boolean canPayWithSaveCard = false;
int installments = 0;
if (creditCardPaymentMethod != null) {
for (PurchaseOption purchaseOption : purchaseOptions) {
if (creditCardPaymentMethod.getIssuerCode() == purchaseOption.getIssuerCode()) {
canPayWithSaveCard = true;
installments = purchaseOption.getInstallments();
break;
}
}
}
if (creditCardPaymentMethod != null && canPayWithSaveCard) {
cardRestored = true;
backFinish.set(true);
editNumberCard.setText(creditCardPaymentMethod.getCreditCardNumber());
creditCardView.setTextNumber(editNumberCard.getText());
creditCardView.setTextOwner(creditCardPaymentMethod.getCreditCardName());
editNameCard.setText(creditCardPaymentMethod.getCreditCardName());
String expireDateS = String.format("%s/%s", String.format("%02d", creditCardPaymentMethod.getExpireMonth() != null ? creditCardPaymentMethod.getExpireMonth() : 0), creditCardPaymentMethod.getExpireYear());
creditCardView.setTextExpDate(expireDateS);
editExpireCard.setText(expireDateS);
btEdit.setVisibility(View.VISIBLE);
switchSaveCard.setChecked(true);
switchSaveCard.setVisibility(View.GONE);
List<Integer> installmentsList = new ArrayList<>();
for (int i = 1; i <= installments; i++) {
installmentsList.add(i);
}
if (installmentsList.isEmpty()) {
spInstallments.setClickable(false);
} else {
spInstallments.setClickable(true);
}
installmentsCardAdapter = new InstallmentsCardAdapter(getActivity(), installmentsList);
spInstallments.setAdapter(installmentsCardAdapter);
selectedPurchaseOption = new PurchaseOption(creditCardPaymentMethod.getType(), creditCardPaymentMethod.getIssuerCode(), creditCardPaymentMethod.getInstallments());
if (creditCardPaymentMethod.getIssuerCode() == IssuerCode.AMEX) {
int maxLength = 4;
InputFilter[] fArray = new InputFilter[1];
fArray[0] = new InputFilter.LengthFilter(maxLength);
editCVVCard.setFilters(fArray);
} else {
int maxLength = 3;
InputFilter[] fArray = new InputFilter[1];
fArray[0] = new InputFilter.LengthFilter(maxLength);
editCVVCard.setFilters(fArray);
}
layoutPayment.setVisibility(View.VISIBLE);
layoutData.setVisibility(View.GONE);
pageChanged();
setIssuerCode(selectedPurchaseOption.getIssuerCode());
}
}
use of android.text.InputFilter in project android_packages_apps_OmniGears by omnirom.
the class ColorSelectDialog method setAlphaSliderVisible.
public void setAlphaSliderVisible(boolean visible) {
mHexColorInput.setFilters(new InputFilter[] { new InputFilter.LengthFilter(visible ? 8 : 6) });
mColorPicker.setAlphaSliderVisible(visible);
}
Aggregations