use of org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel in project Signal-Android by WhisperSystems.
the class ShareInterstitialActivity method initializeViews.
private void initializeViews(@NonNull MultiShareArgs args) {
confirm = findViewById(R.id.share_confirm);
toolbar = findViewById(R.id.toolbar);
preview = findViewById(R.id.link_preview);
confirm.setOnClickListener(unused -> onConfirm());
SelectionAwareEmojiEditText text = findViewById(R.id.text);
toolbar.setNavigationOnClickListener(unused -> finish());
text.addTextChangedListener(new AfterTextChanged(editable -> {
linkPreviewViewModel.onTextChanged(this, editable.toString(), text.getSelectionStart(), text.getSelectionEnd());
viewModel.onDraftTextChanged(editable.toString());
}));
// noinspection CodeBlock2Expr
text.setOnSelectionChangedListener(((selStart, selEnd) -> {
linkPreviewViewModel.onTextChanged(this, text.getText().toString(), text.getSelectionStart(), text.getSelectionEnd());
}));
preview.setCloseClickedListener(linkPreviewViewModel::onUserCancel);
int defaultRadius = getResources().getDimensionPixelSize(R.dimen.thumbnail_default_radius);
preview.setCorners(defaultRadius, defaultRadius);
text.setText(args.getDraftText());
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(text);
contactsRecycler = findViewById(R.id.selected_list);
contactsRecycler.setAdapter(adapter);
RecyclerView.ItemAnimator itemAnimator = Objects.requireNonNull(contactsRecycler.getItemAnimator());
ShareFlowConstants.applySelectedContactsRecyclerAnimationSpeeds(itemAnimator);
confirm.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
int pad = Math.abs(v.getWidth() + ViewUtil.dpToPx(16));
ViewUtil.setPaddingEnd(contactsRecycler, pad);
});
}
use of org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel in project Signal-Android by WhisperSystems.
the class ShareInterstitialActivity method initializeViewModels.
private void initializeViewModels(@NonNull MultiShareArgs args) {
ShareInterstitialRepository repository = new ShareInterstitialRepository();
ShareInterstitialViewModel.Factory factory = new ShareInterstitialViewModel.Factory(args, repository);
viewModel = ViewModelProviders.of(this, factory).get(ShareInterstitialViewModel.class);
LinkPreviewRepository linkPreviewRepository = new LinkPreviewRepository();
LinkPreviewViewModel.Factory linkPreviewViewModelFactory = new LinkPreviewViewModel.Factory(linkPreviewRepository);
linkPreviewViewModel = ViewModelProviders.of(this, linkPreviewViewModelFactory).get(LinkPreviewViewModel.class);
boolean hasSms = Stream.of(args.getShareContactAndThreads()).anyMatch(c -> {
Recipient recipient = Recipient.resolved(c.getRecipientId());
return !recipient.isRegistered() || recipient.isForceSmsSelection();
});
if (hasSms) {
linkPreviewViewModel.onTransportChanged(hasSms);
}
}
use of org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel in project Signal-Android by signalapp.
the class ShareInterstitialActivity method initializeViews.
private void initializeViews(@NonNull MultiShareArgs args) {
confirm = findViewById(R.id.share_confirm);
toolbar = findViewById(R.id.toolbar);
preview = findViewById(R.id.link_preview);
confirm.setOnClickListener(unused -> onConfirm());
SelectionAwareEmojiEditText text = findViewById(R.id.text);
toolbar.setNavigationOnClickListener(unused -> finish());
text.addTextChangedListener(new AfterTextChanged(editable -> {
linkPreviewViewModel.onTextChanged(this, editable.toString(), text.getSelectionStart(), text.getSelectionEnd());
viewModel.onDraftTextChanged(editable.toString());
}));
// noinspection CodeBlock2Expr
text.setOnSelectionChangedListener(((selStart, selEnd) -> {
linkPreviewViewModel.onTextChanged(this, text.getText().toString(), text.getSelectionStart(), text.getSelectionEnd());
}));
preview.setCloseClickedListener(linkPreviewViewModel::onUserCancel);
int defaultRadius = getResources().getDimensionPixelSize(R.dimen.thumbnail_default_radius);
preview.setCorners(defaultRadius, defaultRadius);
text.setText(args.getDraftText());
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(text);
contactsRecycler = findViewById(R.id.selected_list);
contactsRecycler.setAdapter(adapter);
RecyclerView.ItemAnimator itemAnimator = Objects.requireNonNull(contactsRecycler.getItemAnimator());
ShareFlowConstants.applySelectedContactsRecyclerAnimationSpeeds(itemAnimator);
confirm.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
int pad = Math.abs(v.getWidth() + ViewUtil.dpToPx(16));
ViewUtil.setPaddingEnd(contactsRecycler, pad);
});
}
use of org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel in project Signal-Android by signalapp.
the class ShareInterstitialActivity method initializeViewModels.
private void initializeViewModels(@NonNull MultiShareArgs args) {
ShareInterstitialRepository repository = new ShareInterstitialRepository();
ShareInterstitialViewModel.Factory factory = new ShareInterstitialViewModel.Factory(args, repository);
viewModel = ViewModelProviders.of(this, factory).get(ShareInterstitialViewModel.class);
LinkPreviewRepository linkPreviewRepository = new LinkPreviewRepository();
LinkPreviewViewModel.Factory linkPreviewViewModelFactory = new LinkPreviewViewModel.Factory(linkPreviewRepository);
linkPreviewViewModel = ViewModelProviders.of(this, linkPreviewViewModelFactory).get(LinkPreviewViewModel.class);
boolean hasSms = Stream.of(args.getShareContactAndThreads()).anyMatch(c -> {
Recipient recipient = Recipient.resolved(c.getRecipientId());
return !recipient.isRegistered() || recipient.isForceSmsSelection();
});
if (hasSms) {
linkPreviewViewModel.onTransportChanged(hasSms);
}
}
Aggregations