use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class HelpFragment method initializeListeners.
private void initializeListeners() {
problem.addTextChangedListener(new AfterTextChanged(e -> helpViewModel.onProblemChanged(e.toString())));
Stream.of(emoji).forEach(view -> view.setOnClickListener(this::handleEmojiClicked));
faq.setOnClickListener(v -> launchFaq());
debugLogInfo.setOnClickListener(v -> launchDebugLogInfo());
next.setOnClickListener(v -> submitForm());
toaster.setOnClickListener(v -> {
if (helpViewModel.getCategoryIndex() == 0) {
categorySpinner.startAnimation(AnimationUtils.loadAnimation(requireContext(), R.anim.shake_horizontal));
}
Toast.makeText(requireContext(), R.string.HelpFragment__please_be_as_descriptive_as_possible, Toast.LENGTH_LONG).show();
});
categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
helpViewModel.onCategorySelected(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class BaseKbsPinFragment method initializeListeners.
private void initializeListeners() {
input.addTextChangedListener(new AfterTextChanged(s -> viewModel.setUserEntry(s.toString())));
input.setImeOptions(EditorInfo.IME_ACTION_NEXT);
input.setOnEditorActionListener(this::handleEditorAction);
keyboardToggle.setOnClickListener(v -> viewModel.toggleAlphaNumeric());
confirm.setOnClickListener(v -> viewModel.confirm());
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class PaymentsRecoveryPasteFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_recovery_paste_fragment_toolbar);
EditText input = view.findViewById(R.id.payments_recovery_paste_fragment_phrase);
View next = view.findViewById(R.id.payments_recovery_paste_fragment_next);
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
if (savedInstanceState == null) {
next.setEnabled(false);
}
input.addTextChangedListener(new AfterTextChanged(e -> {
next.setEnabled(!e.toString().isEmpty());
next.setAlpha(!e.toString().isEmpty() ? 1f : 0.5f);
}));
next.setOnClickListener(v -> {
String mnemonic = input.getText().toString();
String[] words = mnemonic.split("\\s+");
if (words.length != PaymentsConstants.MNEMONIC_LENGTH) {
showErrorDialog();
return;
}
SafeNavigation.safeNavigate(Navigation.findNavController(v), PaymentsRecoveryPasteFragmentDirections.actionPaymentsRecoveryEntryToPaymentsRecoveryPhrase(false).setWords(words));
});
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class EditProfileFragment method initializeResources.
private void initializeResources(@NonNull View view, @Nullable GroupId groupId) {
Bundle arguments = requireArguments();
boolean isEditingGroup = groupId != null;
this.toolbar = view.findViewById(R.id.toolbar);
this.title = view.findViewById(R.id.title);
this.avatar = view.findViewById(R.id.avatar);
this.givenName = view.findViewById(R.id.given_name);
this.familyName = view.findViewById(R.id.family_name);
this.finishButton = view.findViewById(R.id.finish_button);
this.reveal = view.findViewById(R.id.reveal);
this.preview = view.findViewById(R.id.name_preview);
this.avatarPreviewBackground = view.findViewById(R.id.avatar_background);
this.avatarPreview = view.findViewById(R.id.avatar_placeholder);
this.nextIntent = arguments.getParcelable(NEXT_INTENT);
this.avatar.setOnClickListener(v -> startAvatarSelection());
view.findViewById(R.id.mms_group_hint).setVisibility(isEditingGroup && groupId.isMms() ? View.VISIBLE : View.GONE);
if (isEditingGroup) {
EditTextUtil.addGraphemeClusterLimitFilter(givenName, FeatureFlags.getMaxGroupNameGraphemeLength());
givenName.addTextChangedListener(new AfterTextChanged(s -> viewModel.setGivenName(s.toString())));
givenName.setHint(R.string.EditProfileFragment__group_name);
givenName.requestFocus();
toolbar.setTitle(R.string.EditProfileFragment__edit_group);
preview.setVisibility(View.GONE);
if (groupId.isV2()) {
EditTextUtil.addGraphemeClusterLimitFilter(familyName, MAX_DESCRIPTION_GLYPHS);
familyName.addTextChangedListener(new AfterTextChanged(s -> {
EditProfileNameFragment.trimFieldToMaxByteLength(s, MAX_DESCRIPTION_BYTES);
viewModel.setFamilyName(s.toString());
}));
familyName.setHint(R.string.EditProfileFragment__group_description);
familyName.setSingleLine(false);
familyName.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
LearnMoreTextView descriptionText = view.findViewById(R.id.description_text);
descriptionText.setLearnMoreVisible(false);
descriptionText.setText(R.string.CreateProfileActivity_group_descriptions_will_be_visible_to_members_of_this_group_and_people_who_have_been_invited);
} else {
familyName.setVisibility(View.GONE);
familyName.setEnabled(false);
view.findViewById(R.id.description_text).setVisibility(View.GONE);
}
view.<ImageView>findViewById(R.id.avatar_placeholder).setImageResource(R.drawable.ic_group_outline_40);
} else {
EditTextUtil.addGraphemeClusterLimitFilter(givenName, EditProfileNameFragment.NAME_MAX_GLYPHS);
EditTextUtil.addGraphemeClusterLimitFilter(familyName, EditProfileNameFragment.NAME_MAX_GLYPHS);
this.givenName.addTextChangedListener(new AfterTextChanged(s -> {
EditProfileNameFragment.trimFieldToMaxByteLength(s);
viewModel.setGivenName(s.toString());
}));
this.familyName.addTextChangedListener(new AfterTextChanged(s -> {
EditProfileNameFragment.trimFieldToMaxByteLength(s);
viewModel.setFamilyName(s.toString());
}));
LearnMoreTextView descriptionText = view.findViewById(R.id.description_text);
descriptionText.setLearnMoreVisible(true);
descriptionText.setOnLinkClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), getString(R.string.EditProfileFragment__support_link)));
}
this.finishButton.setOnClickListener(v -> {
this.finishButton.setIndeterminateProgressMode(true);
this.finishButton.setProgress(50);
handleUpload();
});
this.finishButton.setText(arguments.getInt(NEXT_BUTTON_TEXT, R.string.CreateProfileActivity_next));
if (arguments.getBoolean(SHOW_TOOLBAR, true)) {
this.toolbar.setVisibility(View.VISIBLE);
this.toolbar.setNavigationOnClickListener(v -> requireActivity().finish());
this.title.setVisibility(View.GONE);
}
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class EditAboutFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
this.emojiView = view.findViewById(R.id.edit_about_emoji);
this.bodyView = view.findViewById(R.id.edit_about_body);
this.countView = view.findViewById(R.id.edit_about_count);
this.saveButton = view.findViewById(R.id.edit_about_save);
initializeViewModel();
view.<Toolbar>findViewById(R.id.toolbar).setNavigationOnClickListener(v -> Navigation.findNavController(view).popBackStack());
EditTextUtil.addGraphemeClusterLimitFilter(bodyView, ABOUT_MAX_GLYPHS);
this.bodyView.addTextChangedListener(new AfterTextChanged(editable -> {
trimFieldToMaxByteLength(editable);
presentCount(editable.toString());
}));
this.emojiView.setOnClickListener(v -> {
ReactWithAnyEmojiBottomSheetDialogFragment.createForAboutSelection().show(requireFragmentManager(), "BOTTOM");
});
view.findViewById(R.id.edit_about_clear).setOnClickListener(v -> onClearClicked());
saveButton.setOnClickListener(v -> viewModel.onSaveClicked(requireContext(), bodyView.getText().toString(), selectedEmoji));
RecyclerView presetList = view.findViewById(R.id.edit_about_presets);
PresetAdapter presetAdapter = new PresetAdapter();
presetList.setAdapter(presetAdapter);
presetList.setLayoutManager(new LinearLayoutManager(requireContext()));
presetAdapter.submitList(PRESETS);
if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SELECTED_EMOJI)) {
onEmojiSelectedInternal(savedInstanceState.getString(KEY_SELECTED_EMOJI, ""));
} else {
this.bodyView.setText(Recipient.self().getAbout());
onEmojiSelectedInternal(Optional.fromNullable(Recipient.self().getAboutEmoji()).or(""));
}
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(bodyView);
}
Aggregations