Search in sources :

Example 1 with LearnMoreTextView

use of org.thoughtcrime.securesms.util.views.LearnMoreTextView in project Signal-Android by WhisperSystems.

the class EditProxyFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    this.proxySwitch = view.findViewById(R.id.edit_proxy_switch);
    this.proxyTitle = view.findViewById(R.id.edit_proxy_address_title);
    this.proxyText = view.findViewById(R.id.edit_proxy_host);
    this.proxyStatus = view.findViewById(R.id.edit_proxy_status);
    this.saveButton = view.findViewById(R.id.edit_proxy_save);
    this.shareButton = view.findViewById(R.id.edit_proxy_share);
    proxyText.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void onTextChanged(String text) {
            onProxyTextChanged(text);
        }
    });
    this.proxyText.setText(Optional.fromNullable(SignalStore.proxy().getProxy()).transform(SignalProxy::getHost).or(""));
    this.proxySwitch.setChecked(SignalStore.proxy().isProxyEnabled());
    initViewModel();
    saveButton.setOnClickListener(v -> onSaveClicked());
    shareButton.setOnClickListener(v -> onShareClicked());
    proxySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.onToggleProxy(isChecked));
    LearnMoreTextView description = view.findViewById(R.id.edit_proxy_switch_title_description);
    description.setLearnMoreVisible(true);
    description.setOnLinkClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), "https://support.signal.org/hc/articles/360056052052"));
    requireActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
Also used : SimpleTextWatcher(org.thoughtcrime.securesms.contactshare.SimpleTextWatcher) SignalProxy(org.whispersystems.signalservice.internal.configuration.SignalProxy) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView)

Example 2 with LearnMoreTextView

use of org.thoughtcrime.securesms.util.views.LearnMoreTextView in project Signal-Android by WhisperSystems.

the class AddGroupDetailsFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    create = view.findViewById(R.id.create);
    name = view.findViewById(R.id.name);
    toolbar = view.findViewById(R.id.toolbar);
    disappearingMessagesRow = view.findViewById(R.id.group_disappearing_messages_row);
    setCreateEnabled(false, false);
    GroupMemberListView members = view.findViewById(R.id.member_list);
    ImageView avatar = view.findViewById(R.id.group_avatar);
    View mmsWarning = view.findViewById(R.id.mms_warning);
    LearnMoreTextView gv2Warning = view.findViewById(R.id.gv2_warning);
    View addLater = view.findViewById(R.id.add_later);
    TextView disappearingMessageValue = view.findViewById(R.id.group_disappearing_messages_value);
    members.initializeAdapter(getViewLifecycleOwner());
    avatarPlaceholder = VectorDrawableCompat.create(getResources(), R.drawable.ic_camera_outline_32_ultramarine, requireActivity().getTheme());
    if (savedInstanceState == null) {
        avatar.setImageDrawable(new InsetDrawable(avatarPlaceholder, ViewUtil.dpToPx(AVATAR_PLACEHOLDER_INSET_DP)));
    }
    initializeViewModel();
    avatar.setOnClickListener(v -> showAvatarPicker());
    members.setRecipientClickListener(this::handleRecipientClick);
    EditTextUtil.addGraphemeClusterLimitFilter(name, FeatureFlags.getMaxGroupNameGraphemeLength());
    name.addTextChangedListener(new AfterTextChanged(editable -> viewModel.setName(editable.toString())));
    toolbar.setNavigationOnClickListener(unused -> callback.onNavigationButtonPressed());
    create.setOnClickListener(v -> handleCreateClicked());
    viewModel.getMembers().observe(getViewLifecycleOwner(), list -> {
        addLater.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
        members.setMembers(list);
    });
    viewModel.getCanSubmitForm().observe(getViewLifecycleOwner(), isFormValid -> setCreateEnabled(isFormValid, true));
    viewModel.getIsMms().observe(getViewLifecycleOwner(), isMms -> {
        disappearingMessagesRow.setVisibility(isMms ? View.GONE : View.VISIBLE);
        mmsWarning.setVisibility(isMms ? View.VISIBLE : View.GONE);
        name.setHint(isMms ? R.string.AddGroupDetailsFragment__group_name_optional : R.string.AddGroupDetailsFragment__group_name_required);
        toolbar.setTitle(isMms ? R.string.AddGroupDetailsFragment__create_group : R.string.AddGroupDetailsFragment__name_this_group);
    });
    viewModel.getNonGv2CapableMembers().observe(getViewLifecycleOwner(), nonGv2CapableMembers -> {
        gv2Warning.setVisibility(nonGv2CapableMembers.isEmpty() ? View.GONE : View.VISIBLE);
        gv2Warning.setText(requireContext().getResources().getQuantityString(R.plurals.AddGroupDetailsFragment__d_members_do_not_support_new_groups_so_this_group_cannot_be_created, nonGv2CapableMembers.size(), nonGv2CapableMembers.size()));
        gv2Warning.setLearnMoreVisible(true);
        gv2Warning.setOnLinkClickListener(v -> NonGv2MemberDialog.showNonGv2Members(requireContext(), getViewLifecycleOwner(), nonGv2CapableMembers));
    });
    viewModel.getAvatar().observe(getViewLifecycleOwner(), avatarBytes -> {
        if (avatarBytes == null) {
            avatar.setImageDrawable(new InsetDrawable(avatarPlaceholder, ViewUtil.dpToPx(AVATAR_PLACEHOLDER_INSET_DP)));
        } else {
            GlideApp.with(this).load(avatarBytes).circleCrop().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(avatar);
        }
    });
    viewModel.getDisappearingMessagesTimer().observe(getViewLifecycleOwner(), timer -> disappearingMessageValue.setText(ExpirationUtil.getExpirationDisplayValue(requireContext(), timer)));
    disappearingMessagesRow.setOnClickListener(v -> {
        startActivityForResult(RecipientDisappearingMessagesActivity.forCreateGroup(requireContext(), viewModel.getDisappearingMessagesTimer().getValue()), REQUEST_DISAPPEARING_TIMER);
    });
    name.requestFocus();
    getParentFragmentManager().setFragmentResultListener(AvatarPickerFragment.REQUEST_KEY_SELECT_AVATAR, getViewLifecycleOwner(), (key, bundle) -> handleMediaResult(bundle));
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Arrays(java.util.Arrays) Bundle(android.os.Bundle) EditTextUtil(org.signal.core.util.EditTextUtil) NonNull(androidx.annotation.NonNull) AvatarPickerFragment(org.thoughtcrime.securesms.avatar.picker.AvatarPickerFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ImageView(android.widget.ImageView) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) VectorDrawableCompat(androidx.vectordrawable.graphics.drawable.VectorDrawableCompat) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Media(org.thoughtcrime.securesms.mediasend.Media) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Recipient(org.thoughtcrime.securesms.recipients.Recipient) DecryptableStreamUriLoader(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader) RecipientDisappearingMessagesActivity(org.thoughtcrime.securesms.recipients.ui.disappearingmessages.RecipientDisappearingMessagesActivity) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) StringRes(androidx.annotation.StringRes) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toolbar(androidx.appcompat.widget.Toolbar) ExpireTimerSettingsFragment(org.thoughtcrime.securesms.components.settings.app.privacy.expire.ExpireTimerSettingsFragment) BitmapUtil(org.thoughtcrime.securesms.util.BitmapUtil) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) Context(android.content.Context) Intent(android.content.Intent) ExpirationUtil(org.thoughtcrime.securesms.util.ExpirationUtil) AvatarSelectionActivity(org.thoughtcrime.securesms.mediasend.AvatarSelectionActivity) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) CircularProgressButton(com.dd.CircularProgressButton) CustomTarget(com.bumptech.glide.request.target.CustomTarget) InsetDrawable(android.graphics.drawable.InsetDrawable) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) NonGv2MemberDialog(org.thoughtcrime.securesms.groups.ui.creategroup.dialogs.NonGv2MemberDialog) Bitmap(android.graphics.Bitmap) Transition(com.bumptech.glide.request.transition.Transition) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) Activity(android.app.Activity) EditText(android.widget.EditText) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) InsetDrawable(android.graphics.drawable.InsetDrawable) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView)

Example 3 with LearnMoreTextView

use of org.thoughtcrime.securesms.util.views.LearnMoreTextView in project Signal-Android by WhisperSystems.

the class PaymentsAddMoneyFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    PaymentsAddMoneyViewModel viewModel = ViewModelProviders.of(this, new PaymentsAddMoneyViewModel.Factory()).get(PaymentsAddMoneyViewModel.class);
    Toolbar toolbar = view.findViewById(R.id.payments_add_money_toolbar);
    QrView qrImageView = view.findViewById(R.id.payments_add_money_qr_image);
    TextView walletAddressAbbreviated = view.findViewById(R.id.payments_add_money_abbreviated_wallet_address);
    View copyAddress = view.findViewById(R.id.payments_add_money_copy_address_button);
    LearnMoreTextView info = view.findViewById(R.id.payments_add_money_info);
    info.setLearnMoreVisible(true);
    info.setLink(getString(R.string.PaymentsAddMoneyFragment__learn_more__information));
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
    viewModel.getSelfAddressAbbreviated().observe(getViewLifecycleOwner(), walletAddressAbbreviated::setText);
    viewModel.getSelfAddressB58().observe(getViewLifecycleOwner(), base58 -> copyAddress.setOnClickListener(v -> copyAddressToClipboard(base58)));
    // Note we are choosing to put Base58 directly into QR here
    viewModel.getSelfAddressB58().observe(getViewLifecycleOwner(), qrImageView::setQrText);
    viewModel.getErrors().observe(getViewLifecycleOwner(), error -> {
        switch(error) {
            case PAYMENTS_NOT_ENABLED:
                throw new AssertionError("Payments are not enabled");
            default:
                throw new AssertionError();
        }
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) R(org.thoughtcrime.securesms.R) ClipData(android.content.ClipData) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toast(android.widget.Toast) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) QrView(org.thoughtcrime.securesms.components.qr.QrView) QrView(org.thoughtcrime.securesms.components.qr.QrView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) View(android.view.View) QrView(org.thoughtcrime.securesms.components.qr.QrView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 4 with LearnMoreTextView

use of org.thoughtcrime.securesms.util.views.LearnMoreTextView in project Signal-Android by WhisperSystems.

the class DeactivateWalletFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.deactivate_wallet_fragment_toolbar);
    MoneyView balance = view.findViewById(R.id.deactivate_wallet_fragment_balance);
    View transferRemainingBalance = view.findViewById(R.id.deactivate_wallet_fragment_transfer);
    View deactivateWithoutTransfer = view.findViewById(R.id.deactivate_wallet_fragment_deactivate);
    LearnMoreTextView notice = view.findViewById(R.id.deactivate_wallet_fragment_notice);
    notice.setLearnMoreVisible(true);
    notice.setLink(getString(R.string.DeactivateWalletFragment__learn_more__we_recommend_transferring_your_funds));
    DeactivateWalletViewModel viewModel = ViewModelProviders.of(this).get(DeactivateWalletViewModel.class);
    viewModel.getBalance().observe(getViewLifecycleOwner(), balance::setMoney);
    viewModel.getDeactivationResults().observe(getViewLifecycleOwner(), r -> {
        if (r == DeactivateWalletViewModel.Result.SUCCESS) {
            Navigation.findNavController(requireView()).popBackStack();
        } else {
            Toast.makeText(requireContext(), R.string.DeactivateWalletFragment__error_deactivating_wallet, Toast.LENGTH_SHORT).show();
        }
    });
    transferRemainingBalance.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), R.id.action_deactivateWallet_to_paymentsTransfer));
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(requireView()).popBackStack());
    // noinspection CodeBlock2Expr
    deactivateWithoutTransfer.setOnClickListener(v -> {
        new AlertDialog.Builder(requireContext()).setTitle(R.string.DeactivateWalletFragment__deactivate_without_transferring_question).setMessage(R.string.DeactivateWalletFragment__your_balance_will_remain).setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss()).setPositiveButton(SpanUtil.color(ContextCompat.getColor(requireContext(), R.color.signal_alert_primary), getString(R.string.DeactivateWalletFragment__deactivate)), (dialog, which) -> {
            viewModel.deactivateWallet();
            dialog.dismiss();
        }).show();
    });
}
Also used : AlertDialog(android.app.AlertDialog) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) SpanUtil(org.thoughtcrime.securesms.util.SpanUtil) R(org.thoughtcrime.securesms.R) ViewGroup(android.view.ViewGroup) AlertDialog(android.app.AlertDialog) Nullable(androidx.annotation.Nullable) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) Toast(android.widget.Toast) Fragment(androidx.fragment.app.Fragment) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Navigation(androidx.navigation.Navigation) ContextCompat(androidx.core.content.ContextCompat) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar)

Example 5 with LearnMoreTextView

use of org.thoughtcrime.securesms.util.views.LearnMoreTextView in project Signal-Android by WhisperSystems.

the class PaymentsRecoveryStartFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.payments_recovery_start_fragment_toolbar);
    TextView title = view.findViewById(R.id.payments_recovery_start_fragment_title);
    LearnMoreTextView message = view.findViewById(R.id.payments_recovery_start_fragment_message);
    TextView startButton = view.findViewById(R.id.payments_recovery_start_fragment_start);
    TextView pasteButton = view.findViewById(R.id.payments_recovery_start_fragment_paste);
    PaymentsRecoveryStartFragmentArgs args = PaymentsRecoveryStartFragmentArgs.fromBundle(requireArguments());
    if (args.getIsRestore()) {
        title.setText(R.string.PaymentsRecoveryStartFragment__enter_recovery_phrase);
        message.setText(getString(R.string.PaymentsRecoveryStartFragment__your_recovery_phrase_is_a, PaymentsConstants.MNEMONIC_LENGTH));
        message.setLink(getString(R.string.PaymentsRecoveryStartFragment__learn_more__restore));
        startButton.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), PaymentsRecoveryStartFragmentDirections.actionPaymentsRecoveryStartToPaymentsRecoveryEntry()));
        startButton.setText(R.string.PaymentsRecoveryStartFragment__enter_manually);
        pasteButton.setVisibility(View.VISIBLE);
        pasteButton.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(v), PaymentsRecoveryStartFragmentDirections.actionPaymentsRecoveryStartToPaymentsRecoveryPaste()));
    } else {
        title.setText(R.string.PaymentsRecoveryStartFragment__view_recovery_phrase);
        message.setText(getString(R.string.PaymentsRecoveryStartFragment__your_balance_will_automatically_restore, PaymentsConstants.MNEMONIC_LENGTH));
        message.setLink(getString(R.string.PaymentsRecoveryStartFragment__learn_more__view));
        startButton.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), PaymentsRecoveryStartFragmentDirections.actionPaymentsRecoveryStartToPaymentsRecoveryPhrase(args.getFinishOnConfirm())));
        startButton.setText(R.string.PaymentsRecoveryStartFragment__start);
        pasteButton.setVisibility(View.GONE);
    }
    toolbar.setNavigationOnClickListener(v -> {
        if (args.getFinishOnConfirm()) {
            requireActivity().finish();
        } else {
            Navigation.findNavController(requireView()).popBackStack();
        }
    });
    if (args.getFinishOnConfirm()) {
        requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), onBackPressed);
    }
    message.setLearnMoreVisible(true);
}
Also used : LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

LearnMoreTextView (org.thoughtcrime.securesms.util.views.LearnMoreTextView)7 Toolbar (androidx.appcompat.widget.Toolbar)6 View (android.view.View)5 TextView (android.widget.TextView)5 Bundle (android.os.Bundle)4 Toast (android.widget.Toast)4 NonNull (androidx.annotation.NonNull)4 Nullable (androidx.annotation.Nullable)4 ViewModelProviders (androidx.lifecycle.ViewModelProviders)4 Navigation (androidx.navigation.Navigation)4 R (org.thoughtcrime.securesms.R)4 Context (android.content.Context)3 LayoutInflater (android.view.LayoutInflater)3 ViewGroup (android.view.ViewGroup)3 LoggingFragment (org.thoughtcrime.securesms.LoggingFragment)3 Intent (android.content.Intent)2 EditText (android.widget.EditText)2 ImageView (android.widget.ImageView)2 DiskCacheStrategy (com.bumptech.glide.load.engine.DiskCacheStrategy)2 CircularProgressButton (com.dd.CircularProgressButton)2