Search in sources :

Example 6 with AfterTextChanged

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) {
        }
    });
}
Also used : Bundle(android.os.Bundle) SupportEmailUtil(org.thoughtcrime.securesms.util.SupportEmailUtil) Stream(com.annimon.stream.Stream) Util(org.thoughtcrime.securesms.util.Util) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) Intent(android.content.Intent) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) R(org.thoughtcrime.securesms.R) ArrayList(java.util.ArrayList) AnimationUtils(android.view.animation.AnimationUtils) CheckBox(android.widget.CheckBox) Toast(android.widget.Toast) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) AdapterView(android.widget.AdapterView) ResourceUtil(org.signal.core.util.ResourceUtil) CircularProgressButton(com.dd.CircularProgressButton) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) ArrayAdapter(android.widget.ArrayAdapter) IdRes(androidx.annotation.IdRes) StringRes(androidx.annotation.StringRes) List(java.util.List) Nullable(androidx.annotation.Nullable) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditText(android.widget.EditText) AdapterView(android.widget.AdapterView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 7 with AfterTextChanged

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());
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) PinOptOutDialog(org.thoughtcrime.securesms.pin.PinOptOutDialog) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) R(org.thoughtcrime.securesms.R) MenuItem(android.view.MenuItem) MenuInflater(android.view.MenuInflater) RegistrationUtil(org.thoughtcrime.securesms.registration.RegistrationUtil) Menu(android.view.Menu) View(android.view.View) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) InputType(android.text.InputType) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) ViewGroup(android.view.ViewGroup) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Toolbar(androidx.appcompat.widget.Toolbar) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 8 with AfterTextChanged

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));
    });
}
Also used : EditText(android.widget.EditText) PaymentsConstants(org.whispersystems.signalservice.api.payments.PaymentsConstants) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) R(org.thoughtcrime.securesms.R) AlertDialog(android.app.AlertDialog) Nullable(androidx.annotation.Nullable) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) Navigation(androidx.navigation.Navigation) EditText(android.widget.EditText) View(android.view.View) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) Toolbar(androidx.appcompat.widget.Toolbar)

Example 9 with AfterTextChanged

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);
    }
}
Also used : RequiresApi(androidx.annotation.RequiresApi) AvatarColor(org.thoughtcrime.securesms.conversation.colors.AvatarColor) Bundle(android.os.Bundle) EditTextUtil(org.signal.core.util.EditTextUtil) NonNull(androidx.annotation.NonNull) AvatarPickerFragment(org.thoughtcrime.securesms.avatar.picker.AvatarPickerFragment) ImageView(android.widget.ImageView) SHOW_TOOLBAR(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.SHOW_TOOLBAR) Animator(android.animation.Animator) R(org.thoughtcrime.securesms.R) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) Media(org.thoughtcrime.securesms.mediasend.Media) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) Avatars(org.thoughtcrime.securesms.avatar.Avatars) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) InputType(android.text.InputType) ViewAnimationUtils(android.view.ViewAnimationUtils) ViewGroup(android.view.ViewGroup) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) EXCLUDE_SYSTEM(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.EXCLUDE_SYSTEM) GroupId(org.thoughtcrime.securesms.groups.GroupId) Toolbar(androidx.appcompat.widget.Toolbar) GROUP_ID(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.GROUP_ID) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) Context(android.content.Context) NEXT_BUTTON_TEXT(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.NEXT_BUTTON_TEXT) Intent(android.content.Intent) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) Build(android.os.Build) NEXT_INTENT(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.NEXT_INTENT) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) CircularProgressButton(com.dd.CircularProgressButton) Parcelable(android.os.Parcelable) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) StreamUtil(org.signal.core.util.StreamUtil) BlobProvider(org.thoughtcrime.securesms.providers.BlobProvider) IOException(java.io.IOException) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditText(android.widget.EditText) EditProfileNameFragment(org.thoughtcrime.securesms.profiles.manage.EditProfileNameFragment) InputStream(java.io.InputStream) Bundle(android.os.Bundle) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 10 with AfterTextChanged

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);
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) EditTextUtil(org.signal.core.util.EditTextUtil) AlwaysChangedDiffUtil(org.thoughtcrime.securesms.util.adapter.AlwaysChangedDiffUtil) NonNull(androidx.annotation.NonNull) ImageView(android.widget.ImageView) StringUtil(org.thoughtcrime.securesms.util.StringUtil) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) BreakIteratorCompat(org.signal.core.util.BreakIteratorCompat) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) Editable(android.text.Editable) ProfileCipher(org.whispersystems.signalservice.api.crypto.ProfileCipher) Toast(android.widget.Toast) Fragment(androidx.fragment.app.Fragment) EmojiUtil(org.thoughtcrime.securesms.components.emoji.EmojiUtil) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Recipient(org.thoughtcrime.securesms.recipients.Recipient) RecyclerView(androidx.recyclerview.widget.RecyclerView) ListAdapter(androidx.recyclerview.widget.ListAdapter) CircularProgressButton(com.dd.CircularProgressButton) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewGroup(android.view.ViewGroup) Optional(org.whispersystems.libsignal.util.guava.Optional) StringRes(androidx.annotation.StringRes) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toolbar(androidx.appcompat.widget.Toolbar) Navigation(androidx.navigation.Navigation) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ReactWithAnyEmojiBottomSheetDialogFragment(org.thoughtcrime.securesms.reactions.any.ReactWithAnyEmojiBottomSheetDialogFragment) EditText(android.widget.EditText) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Aggregations

AfterTextChanged (org.thoughtcrime.securesms.util.text.AfterTextChanged)15 View (android.view.View)13 EditText (android.widget.EditText)12 Bundle (android.os.Bundle)11 NonNull (androidx.annotation.NonNull)11 Toolbar (androidx.appcompat.widget.Toolbar)11 R (org.thoughtcrime.securesms.R)11 Nullable (androidx.annotation.Nullable)10 TextView (android.widget.TextView)9 Toast (android.widget.Toast)8 ViewModelProviders (androidx.lifecycle.ViewModelProviders)8 Intent (android.content.Intent)7 LayoutInflater (android.view.LayoutInflater)7 ViewGroup (android.view.ViewGroup)7 Navigation (androidx.navigation.Navigation)7 Fragment (androidx.fragment.app.Fragment)6 CircularProgressButton (com.dd.CircularProgressButton)6 ViewUtil (org.thoughtcrime.securesms.util.ViewUtil)6 Context (android.content.Context)5 Recipient (org.thoughtcrime.securesms.recipients.Recipient)5