use of android.text.InputFilter in project seven_develop by seven123456.
the class RxTool method setEdDecimal.
public static void setEdDecimal(EditText editText, int count) {
if (count < 1) {
count = 1;
}
editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
// 设置字符过滤
final int finalCount = count;
editText.setFilters(new InputFilter[] { new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (source.equals(".") && dest.toString().length() == 0) {
return "0.";
}
if (dest.toString().contains(".")) {
int index = dest.toString().indexOf(".");
int mlength = dest.toString().substring(index).length();
if (mlength == finalCount) {
return "";
}
}
return null;
}
} });
}
use of android.text.InputFilter in project Roblu by wdavies973.
the class EventCreateMethodPicker method importPublicRobluCloudEvent.
private void importPublicRobluCloudEvent() {
// check for an internet connection
if (!Utils.hasInternetConnection(getApplicationContext())) {
Utils.showSnackbar(findViewById(R.id.advsettings), getApplicationContext(), "You are not connected to the internet", true, 0);
return;
}
/*
* We need to make sure that this thread has access to the internet
*/
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
StrictMode.setThreadPolicy(policy);
final RSettings settings = new IO(getApplicationContext()).loadSettings();
RUI rui = settings.getRui();
AlertDialog.Builder builder = new AlertDialog.Builder(EventCreateMethodPicker.this);
LinearLayout layout = new LinearLayout(EventCreateMethodPicker.this);
layout.setOrientation(LinearLayout.VERTICAL);
// this is the team code input edit text
final AppCompatEditText input = new AppCompatEditText(EventCreateMethodPicker.this);
Utils.setInputTextLayoutColor(rui.getAccent(), null, input);
input.setHighlightColor(rui.getAccent());
input.setHintTextColor(rui.getText());
input.setTextColor(rui.getText());
input.setInputType(InputType.TYPE_CLASS_NUMBER);
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(30);
input.setFilters(FilterArray);
layout.addView(input);
builder.setView(layout);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
importRobluCloudEvent(Integer.parseInt(input.getText().toString()));
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
TextView view = new TextView(EventCreateMethodPicker.this);
view.setTextSize(Utils.DPToPX(getApplicationContext(), 5));
view.setPadding(Utils.DPToPX(getApplicationContext(), 18), Utils.DPToPX(getApplicationContext(), 18), Utils.DPToPX(getApplicationContext(), 18), Utils.DPToPX(getApplicationContext(), 18));
view.setText("FRC team number:");
view.setTextColor(rui.getText());
AlertDialog dialog = builder.create();
dialog.setCustomTitle(view);
if (dialog.getWindow() != null) {
dialog.getWindow().getAttributes().windowAnimations = rui.getAnimation();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(rui.getBackground()));
}
dialog.show();
dialog.getButton(Dialog.BUTTON_NEGATIVE).setTextColor(rui.getAccent());
dialog.getButton(Dialog.BUTTON_POSITIVE).setTextColor(rui.getAccent());
}
use of android.text.InputFilter in project caronae-android by caronae.
the class MyProfileFrag method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my_profile, container, false);
ButterKnife.bind(this, view);
callbackManager = ((MainAct) getActivity()).getFbCallbackManager();
carOwner_sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
carOwnerSw();
}
});
carPlate_et.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
loginButton.setReadPermissions("user_friends");
loginButton.setFragment(this);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.i("face", "onSuccess = " + loginResult.toString());
Profile profile = Profile.getCurrentProfile();
if (profile != null) {
final String faceId = profile.getId();
CaronaeAPI.service(getContext()).saveFaceId(new IdForJson(faceId)).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
Log.i("saveFaceId", "face id saved");
User user = App.getUser();
user.setFaceId(faceId);
SharedPref.saveUser(user);
} else {
Util.treatResponseFromServer(response);
Util.toast(R.string.frag_myprofile_errorSaveFaceId);
Log.e("saveFaceId", response.message());
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Util.toast(R.string.frag_myprofile_errorSaveFaceId);
Log.e("saveFaceId", t.getMessage());
}
});
}
}
@Override
public void onCancel() {
Log.i("face", "onCancel");
}
@Override
public void onError(FacebookException exception) {
Util.toast(R.string.frag_myprofile_errorFaceLogin);
Log.e("face", "onError = " + exception.toString());
}
});
setFieldValidatorsListeners();
User user = App.getUser();
if (user != null) {
fillUserFields(user);
CaronaeAPI.service(getContext()).getRidesHistoryCount(user.getDbId() + "").enqueue(new Callback<HistoryRideCountForJson>() {
@Override
public void onResponse(Call<HistoryRideCountForJson> call, Response<HistoryRideCountForJson> response) {
if (response.isSuccessful()) {
HistoryRideCountForJson historyRideCountForJson = response.body();
ridesOffered_tv.setText(String.valueOf(historyRideCountForJson.getOfferedCount()));
ridesTaken_tv.setText(String.valueOf(historyRideCountForJson.getTakenCount()));
} else {
Util.treatResponseFromServer(response);
Util.toast(R.string.act_profile_errorCountRidesHistory);
Log.e("getRidesHistoryCount", response.message());
}
}
@Override
public void onFailure(Call<HistoryRideCountForJson> call, Throwable t) {
Util.toast(R.string.act_profile_errorCountRidesHistory);
Log.e("getRidesHistoryCount", t.getMessage());
}
});
}
setETFormat();
return view;
}
use of android.text.InputFilter in project Gadgetbridge by Freeyourgadget.
the class ReminderDetails method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reminder_details);
reminder = (Reminder) getIntent().getSerializableExtra(Reminder.EXTRA_REMINDER);
if (reminder == null) {
GB.toast("No reminder provided to ReminderDetails Activity", Toast.LENGTH_LONG, GB.ERROR);
finish();
return;
}
reminderRepeat = findViewById(R.id.reminder_repeat);
reminderDate = findViewById(R.id.reminder_date);
reminderTime = findViewById(R.id.reminder_time);
reminderText = findViewById(R.id.reminder_message);
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
final String[] repeatStrings = getResources().getStringArray(R.array.reminder_repeat);
repeatAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, repeatStrings);
final View cardRepeat = findViewById(R.id.card_repeat);
cardRepeat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new AlertDialog.Builder(ReminderDetails.this).setAdapter(repeatAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
reminder.setRepetition(i);
updateUiFromReminder();
}
}).create().show();
}
});
final View cardDate = findViewById(R.id.card_date);
cardDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Calendar date = new GregorianCalendar();
date.setTime(reminder.getDate());
new DatePickerDialog(ReminderDetails.this, ReminderDetails.this, date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)).show();
}
});
final View cardTime = findViewById(R.id.card_time);
cardTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new TimePickerDialog(ReminderDetails.this, ReminderDetails.this, reminder.getDate().getHours(), reminder.getDate().getMinutes(), DateFormat.is24HourFormat(GBApplication.getContext())).show();
}
});
reminderText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(coordinator.getMaximumReminderMessageLength()) });
reminderText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(final CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(final CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(final Editable s) {
reminder.setMessage(s.toString());
}
});
final FloatingActionButton fab = findViewById(R.id.fab_save);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateReminder();
ReminderDetails.this.setResult(1);
finish();
}
});
updateUiFromReminder();
}
use of android.text.InputFilter in project NoteText by ViWu.
the class MainMenu method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar();
initializeToolbar(toolbar, actionbar);
// set up grid and insert new set
gvItems = (GridView) findViewById(R.id.gvItems);
// Represents each item in gridView
Names = new ArrayList<String>();
newSet = new Set();
// set up adapter for grid
itemsAdapter = new ArrayAdapter<String>(MainMenu.this, R.layout.grid_item, Names);
gvItems.setAdapter(itemsAdapter);
setupListViewListener();
// create a floating action button to help the user
FloatingActionButton help = (FloatingActionButton) findViewById(R.id.help);
assert help != null;
help.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Click on the name of the set to edit. Hold down to delete/rename. To add sets, tap the button to the left.", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
// add button: Creates a popup window to type in name of new set
FloatingActionButton add = (FloatingActionButton) findViewById(R.id.add);
assert add != null;
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
AlertDialog.Builder alert = new AlertDialog.Builder(MainMenu.this);
final EditText setNameField = new EditText(MainMenu.this);
alert.setMessage("Enter Name of New Set");
alert.setTitle("Create New Set");
alert.setView(setNameField);
setNameField.requestFocus();
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
setNameField.setFilters(new InputFilter[] { new InputFilter.LengthFilter(25) });
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String itemText = setNameField.getText().toString();
if (itemText.length() > 0) {
fileCreate(itemText, view);
newSet.setName(itemText);
Sets.add(newSet);
gvItems.smoothScrollToPosition(itemsAdapter.getCount() - 1);
setCount++;
} else {
String msg = "Create set failed! Set names need to be at least one character long!";
errorDialog(msg);
}
checkNoSetExists();
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
});
alert.show();
}
});
loadInternalStorage();
checkNoSetExists();
}
Aggregations