+ private void hookClearErrorOnFocusListener(TextView view, TextInputLayout layout) {
+ view.setOnFocusChangeListener((v, hasFocus) -> {
+ if (hasFocus) layout.setError(null);
+ });
+ view.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ layout.setError(null);
+ }
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ });
+ }
+ boolean checkValidity() {
+ boolean valid = true;
+
+ String val = String.valueOf(profileName.getText());
+ if (val.trim().isEmpty()) {
+ valid = false;
+ profileNameLayout.setError(getResources().getText(R.string.err_profile_name_empty));
+ }
+
+ val = String.valueOf(url.getText());
+ if (val.trim().isEmpty()) {
+ valid = false;
+ urlLayout.setError(getResources().getText(R.string.err_profile_url_empty));
+ }
+ if (useAuthentication.isChecked()) {
+ val = String.valueOf(userName.getText());
+ if (val.trim().isEmpty()) {
+ valid = false;
+ userNameLayout
+ .setError(getResources().getText(R.string.err_profile_user_name_empty));
+ }
+
+ val = String.valueOf(password.getText());
+ if (val.trim().isEmpty()) {
+ valid = false;
+ passwordLayout
+ .setError(getResources().getText(R.string.err_profile_password_empty));
+ }
+ }
+
+ return valid;
+ }
+ private class ColorListAdapter extends ArrayAdapter<String> {
+ public ColorListAdapter(@NonNull Context context, int resource) {
+ super(context, resource);
+ }
+ public ColorListAdapter(@NonNull Context context, int resource, int textViewResourceId) {
+ super(context, resource, textViewResourceId);
+ }
+ public ColorListAdapter(@NonNull Context context, int resource, @NonNull String[] objects) {
+ super(context, resource, objects);
+ }
+ public ColorListAdapter(@NonNull Context context, int resource, int textViewResourceId,
+ @NonNull String[] objects) {
+ super(context, resource, textViewResourceId, objects);
+ }
+ public ColorListAdapter(@NonNull Context context, int resource,
+ @NonNull List<String> objects) {
+ super(context, resource, objects);
+ }
+ public ColorListAdapter(@NonNull Context context, int resource, int textViewResourceId,
+ @NonNull List<String> objects) {
+ super(context, resource, textViewResourceId, objects);
+ }
+ @NotNull
+ @Override
+ public View getView(int position, View convertView, @NotNull ViewGroup parent) {
+ String hueStr = getItem(position);
+ int hue = (hueStr == null) ? -1 : Integer.valueOf(hueStr);
+ @ColorInt int primaryColor = Colors.getPrimaryColorForHue(hue);
+
+ View view = convertView;
+ if (convertView == null) {
+ view = getLayoutInflater().inflate(R.layout.color_selector_item, parent);
+ }
+
+ view.setBackgroundColor(primaryColor);
+ return view;
+ }
+ }