use of org.thoughtcrime.securesms.R 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.R in project Signal-Android by WhisperSystems.
the class DirectoryHelper method filterForUnlistedUsers.
/**
* Users can mark themselves as 'unlisted' in CDS, meaning that even if CDS says they're
* unregistered, they might actually be registered. We need to double-check users who we already
* have UUIDs for. Also, we only want to bother doing this for users we have conversations for,
* so we will also only check for users that have a thread.
*/
private static UnlistedResult filterForUnlistedUsers(@NonNull Context context, @NonNull Set<RecipientId> inactiveIds) {
List<Recipient> possiblyUnlisted = Stream.of(inactiveIds).map(Recipient::resolved).filter(Recipient::isRegistered).filter(Recipient::hasServiceId).filter(DirectoryHelper::hasCommunicatedWith).toList();
ProfileService profileService = new ProfileService(ApplicationDependencies.getGroupsV2Operations().getProfileOperations(), ApplicationDependencies.getSignalServiceMessageReceiver(), ApplicationDependencies.getSignalWebSocket());
List<Observable<Pair<Recipient, ServiceResponse<ProfileAndCredential>>>> requests = Stream.of(possiblyUnlisted).map(r -> ProfileUtil.retrieveProfile(context, r, SignalServiceProfile.RequestType.PROFILE, profileService).toObservable().timeout(5, TimeUnit.SECONDS).onErrorReturn(t -> new Pair<>(r, ServiceResponse.forUnknownError(t)))).toList();
return Observable.mergeDelayError(requests).observeOn(Schedulers.io(), true).scan(new UnlistedResult.Builder(), (builder, pair) -> {
Recipient recipient = pair.first();
ProfileService.ProfileResponseProcessor processor = new ProfileService.ProfileResponseProcessor(pair.second());
if (processor.hasResult()) {
builder.potentiallyActiveIds.add(recipient.getId());
} else if (processor.genericIoError() || !processor.notFound()) {
builder.retries.add(recipient.getId());
builder.potentiallyActiveIds.add(recipient.getId());
}
return builder;
}).lastOrError().map(UnlistedResult.Builder::build).blockingGet();
}
use of org.thoughtcrime.securesms.R in project Signal-Android by WhisperSystems.
the class CreateGroupActivity method handleNextPressed.
private void handleNextPressed() {
Stopwatch stopwatch = new Stopwatch("Recipient Refresh");
SimpleProgressDialog.DismissibleDialog dismissibleDialog = SimpleProgressDialog.showDelayed(this);
SimpleTask.run(getLifecycle(), () -> {
List<RecipientId> ids = contactsFragment.getSelectedContacts().stream().map(selectedContact -> selectedContact.getOrCreateRecipientId(this)).collect(Collectors.toList());
List<Recipient> resolved = Recipient.resolvedList(ids);
stopwatch.split("resolve");
Set<Recipient> registeredChecks = resolved.stream().filter(r -> r.getRegistered() == RecipientDatabase.RegisteredState.UNKNOWN).collect(Collectors.toSet());
Log.i(TAG, "Need to do " + registeredChecks.size() + " registration checks.");
for (Recipient recipient : registeredChecks) {
try {
DirectoryHelper.refreshDirectoryFor(this, recipient, false);
} catch (IOException e) {
Log.w(TAG, "Failed to refresh registered status for " + recipient.getId(), e);
}
}
if (registeredChecks.size() > 0) {
resolved = Recipient.resolvedList(ids);
}
stopwatch.split("registered");
List<Recipient> recipientsAndSelf = new ArrayList<>(resolved);
recipientsAndSelf.add(Recipient.self().resolve());
boolean neededRefresh = false;
if (!SignalStore.internalValues().gv2DoNotCreateGv2Groups()) {
try {
neededRefresh = GroupsV2CapabilityChecker.refreshCapabilitiesIfNecessary(recipientsAndSelf);
} catch (IOException e) {
Log.w(TAG, "Failed to refresh all recipient capabilities.", e);
}
}
if (neededRefresh) {
resolved = Recipient.resolvedList(ids);
}
stopwatch.split("capabilities");
Pair<Boolean, List<RecipientId>> result;
boolean gv2 = Stream.of(recipientsAndSelf).allMatch(r -> r.getGroupsV2Capability() == Recipient.Capability.SUPPORTED);
if (!gv2 && Stream.of(resolved).anyMatch(r -> !r.hasE164())) {
Log.w(TAG, "Invalid GV1 group...");
ids = Collections.emptyList();
result = Pair.create(false, ids);
} else {
result = Pair.create(true, ids);
}
stopwatch.split("gv1-check");
return result;
}, result -> {
dismissibleDialog.dismiss();
stopwatch.stop(TAG);
if (result.first) {
startActivityForResult(AddGroupDetailsActivity.newIntent(this, result.second), REQUEST_CODE_ADD_DETAILS);
} else {
new AlertDialog.Builder(this).setMessage(R.string.CreateGroupActivity_some_contacts_cannot_be_in_legacy_groups).setPositiveButton(android.R.string.ok, (d, w) -> d.dismiss()).show();
}
});
}
Aggregations