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);
}
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));
}
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();
}
});
}
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();
});
}
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);
}
Aggregations