use of org.thoughtcrime.securesms.database.identity.IdentityRecordList in project Signal-Android by signalapp.
the class ConversationActivity method initializeIdentityRecords.
private ListenableFuture<Boolean> initializeIdentityRecords() {
final SettableFuture<Boolean> future = new SettableFuture<>();
new AsyncTask<Recipient, Void, Pair<IdentityRecordList, String>>() {
@Override
@NonNull
protected Pair<IdentityRecordList, String> doInBackground(Recipient... params) {
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(ConversationActivity.this);
IdentityRecordList identityRecordList = new IdentityRecordList();
List<Recipient> recipients = new LinkedList<>();
if (params[0].isGroupRecipient()) {
recipients.addAll(DatabaseFactory.getGroupDatabase(ConversationActivity.this).getGroupMembers(params[0].getAddress().toGroupString(), false));
} else {
recipients.add(params[0]);
}
for (Recipient recipient : recipients) {
Log.w(TAG, "Loading identity for: " + recipient.getAddress());
identityRecordList.add(identityDatabase.getIdentity(recipient.getAddress()));
}
String message = null;
if (identityRecordList.isUnverified()) {
message = IdentityUtil.getUnverifiedBannerDescription(ConversationActivity.this, identityRecordList.getUnverifiedRecipients(ConversationActivity.this));
}
return new Pair<>(identityRecordList, message);
}
@Override
protected void onPostExecute(@NonNull Pair<IdentityRecordList, String> result) {
Log.w(TAG, "Got identity records: " + result.first.isUnverified());
identityRecords.replaceWith(result.first);
if (result.second != null) {
Log.w(TAG, "Replacing banner...");
unverifiedBannerView.get().display(result.second, result.first.getUnverifiedRecords(), new UnverifiedClickedListener(), new UnverifiedDismissedListener());
} else if (unverifiedBannerView.resolved()) {
Log.w(TAG, "Clearing banner...");
unverifiedBannerView.get().hide();
}
titleView.setVerified(isSecureText && identityRecords.isVerified());
future.set(true);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient);
return future;
}
use of org.thoughtcrime.securesms.database.identity.IdentityRecordList in project Signal-Android by WhisperSystems.
the class ConversationParentFragment method initializeIdentityRecords.
private ListenableFuture<Boolean> initializeIdentityRecords() {
final SettableFuture<Boolean> future = new SettableFuture<>();
final Context context = requireContext().getApplicationContext();
if (SignalStore.account().getAci() == null || SignalStore.account().getPni() == null) {
Log.w(TAG, "Not registered! Skipping initializeIdentityRecords()");
future.set(false);
return future;
}
new AsyncTask<Recipient, Void, Pair<IdentityRecordList, String>>() {
@Override
@NonNull
protected Pair<IdentityRecordList, String> doInBackground(Recipient... params) {
List<Recipient> recipients;
if (params[0].isGroup()) {
recipients = SignalDatabase.groups().getGroupMembers(params[0].requireGroupId(), GroupDatabase.MemberSet.FULL_MEMBERS_EXCLUDING_SELF);
} else {
recipients = Collections.singletonList(params[0]);
}
long startTime = System.currentTimeMillis();
IdentityRecordList identityRecordList = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecords(recipients);
Log.i(TAG, String.format(Locale.US, "Loaded %d identities in %d ms", recipients.size(), System.currentTimeMillis() - startTime));
String message = null;
if (identityRecordList.isUnverified()) {
message = IdentityUtil.getUnverifiedBannerDescription(context, identityRecordList.getUnverifiedRecipients());
}
return new Pair<>(identityRecordList, message);
}
@Override
protected void onPostExecute(@NonNull Pair<IdentityRecordList, String> result) {
Log.i(TAG, "Got identity records: " + result.first().isUnverified());
identityRecords = result.first();
if (result.second() != null) {
Log.d(TAG, "Replacing banner...");
unverifiedBannerView.get().display(result.second(), result.first().getUnverifiedRecords(), new UnverifiedClickedListener(), new UnverifiedDismissedListener());
} else if (unverifiedBannerView.resolved()) {
Log.d(TAG, "Clearing banner...");
unverifiedBannerView.get().hide();
}
titleView.setVerified(isSecureText && identityRecords.isVerified());
future.set(true);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient.get());
return future;
}
use of org.thoughtcrime.securesms.database.identity.IdentityRecordList in project Signal-Android by WhisperSystems.
the class SignalBaseIdentityKeyStore method getIdentityRecords.
@NonNull
public IdentityRecordList getIdentityRecords(@NonNull List<Recipient> recipients) {
List<String> addressNames = recipients.stream().filter(Recipient::hasServiceId).map(Recipient::requireServiceId).map(ServiceId::toString).collect(Collectors.toList());
if (addressNames.isEmpty()) {
return IdentityRecordList.EMPTY;
}
List<IdentityRecord> records = new ArrayList<>(recipients.size());
for (Recipient recipient : recipients) {
if (recipient.hasServiceId()) {
IdentityStoreRecord record = cache.get(recipient.requireServiceId().toString());
if (record != null) {
records.add(record.toIdentityRecord(recipient.getId()));
}
} else {
Log.w(TAG, "[getIdentityRecords] No serviceId for " + recipient.getId());
}
}
return new IdentityRecordList(records);
}
use of org.thoughtcrime.securesms.database.identity.IdentityRecordList in project Signal-Android by signalapp.
the class SignalBaseIdentityKeyStore method getIdentityRecords.
@NonNull
public IdentityRecordList getIdentityRecords(@NonNull List<Recipient> recipients) {
List<String> addressNames = recipients.stream().filter(Recipient::hasServiceId).map(Recipient::requireServiceId).map(ServiceId::toString).collect(Collectors.toList());
if (addressNames.isEmpty()) {
return IdentityRecordList.EMPTY;
}
List<IdentityRecord> records = new ArrayList<>(recipients.size());
for (Recipient recipient : recipients) {
if (recipient.hasServiceId()) {
IdentityStoreRecord record = cache.get(recipient.requireServiceId().toString());
if (record != null) {
records.add(record.toIdentityRecord(recipient.getId()));
}
} else {
Log.w(TAG, "[getIdentityRecords] No serviceId for " + recipient.getId());
}
}
return new IdentityRecordList(records);
}
use of org.thoughtcrime.securesms.database.identity.IdentityRecordList in project Signal-Android by signalapp.
the class ConversationParentFragment method initializeIdentityRecords.
private ListenableFuture<Boolean> initializeIdentityRecords() {
final SettableFuture<Boolean> future = new SettableFuture<>();
final Context context = requireContext().getApplicationContext();
if (SignalStore.account().getAci() == null || SignalStore.account().getPni() == null) {
Log.w(TAG, "Not registered! Skipping initializeIdentityRecords()");
future.set(false);
return future;
}
new AsyncTask<Recipient, Void, Pair<IdentityRecordList, String>>() {
@Override
@NonNull
protected Pair<IdentityRecordList, String> doInBackground(Recipient... params) {
List<Recipient> recipients;
if (params[0].isGroup()) {
recipients = SignalDatabase.groups().getGroupMembers(params[0].requireGroupId(), GroupDatabase.MemberSet.FULL_MEMBERS_EXCLUDING_SELF);
} else {
recipients = Collections.singletonList(params[0]);
}
long startTime = System.currentTimeMillis();
IdentityRecordList identityRecordList = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecords(recipients);
Log.i(TAG, String.format(Locale.US, "Loaded %d identities in %d ms", recipients.size(), System.currentTimeMillis() - startTime));
String message = null;
if (identityRecordList.isUnverified()) {
message = IdentityUtil.getUnverifiedBannerDescription(context, identityRecordList.getUnverifiedRecipients());
}
return new Pair<>(identityRecordList, message);
}
@Override
protected void onPostExecute(@NonNull Pair<IdentityRecordList, String> result) {
Log.i(TAG, "Got identity records: " + result.first().isUnverified());
identityRecords = result.first();
if (result.second() != null) {
Log.d(TAG, "Replacing banner...");
unverifiedBannerView.get().display(result.second(), result.first().getUnverifiedRecords(), new UnverifiedClickedListener(), new UnverifiedDismissedListener());
} else if (unverifiedBannerView.resolved()) {
Log.d(TAG, "Clearing banner...");
unverifiedBannerView.get().hide();
}
titleView.setVerified(isSecureText && identityRecords.isVerified());
future.set(true);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient.get());
return future;
}
Aggregations