Search in sources :

Example 1 with RecipientId

use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigration method migratePushGroupSendJob.

@NonNull
private JobData migratePushGroupSendJob(@NonNull JobData jobData) {
    // noinspection ConstantConditions
    Recipient queueRecipient = Recipient.external(application, jobData.getQueueKey());
    String address = jobData.getData().hasString("filter_address") ? jobData.getData().getString("filter_address") : null;
    RecipientId recipientId = address != null ? Recipient.external(application, address).getId() : null;
    Data updatedData = new Data.Builder().putString("filter_recipient", recipientId != null ? recipientId.serialize() : null).putLong("message_id", jobData.getData().getLong("message_id")).build();
    return jobData.withQueueKey(queueRecipient.getId().toQueueKey()).withData(updatedData);
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Data(org.thoughtcrime.securesms.jobmanager.Data) NonNull(androidx.annotation.NonNull)

Example 2 with RecipientId

use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.

the class EditSelfProfileRepository method getCurrentAvatar.

@Override
public void getCurrentAvatar(@NonNull Consumer<byte[]> avatarConsumer) {
    RecipientId selfId = Recipient.self().getId();
    if (AvatarHelper.hasAvatar(context, selfId)) {
        SimpleTask.run(() -> {
            try {
                return StreamUtil.readFully(AvatarHelper.getAvatar(context, selfId));
            } catch (IOException e) {
                Log.w(TAG, e);
                return null;
            }
        }, avatarConsumer::accept);
    } else if (!excludeSystem) {
        SystemProfileUtil.getSystemProfileAvatar(context, new ProfileMediaConstraints()).addListener(new ListenableFuture.Listener<byte[]>() {

            @Override
            public void onSuccess(byte[] result) {
                avatarConsumer.accept(result);
            }

            @Override
            public void onFailure(ExecutionException e) {
                Log.w(TAG, e);
                avatarConsumer.accept(null);
            }
        });
    }
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) ProfileMediaConstraints(org.thoughtcrime.securesms.profiles.ProfileMediaConstraints) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with RecipientId

use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.

the class ReviewUtil method getProfileChangeRecordsForGroup.

@WorkerThread
@NonNull
public static List<MessageRecord> getProfileChangeRecordsForGroup(@NonNull Context context, @NonNull GroupId.V2 groupId) {
    RecipientId recipientId = SignalDatabase.recipients().getByGroupId(groupId).get();
    Long threadId = SignalDatabase.threads().getThreadIdFor(recipientId);
    if (threadId == null) {
        return Collections.emptyList();
    } else {
        return SignalDatabase.sms().getProfileChangeDetailsRecords(threadId, System.currentTimeMillis() - TIMEOUT);
    }
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Example 4 with RecipientId

use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.

the class ReviewCardDialogFragment method getRepository.

@NonNull
private ReviewCardRepository getRepository() throws BadGroupIdException {
    RecipientId recipientId = getRecipientId();
    GroupId.V2 groupId = getGroupId();
    if (recipientId != null) {
        return new ReviewCardRepository(requireContext(), recipientId);
    } else if (groupId != null) {
        return new ReviewCardRepository(requireContext(), groupId);
    } else {
        throw new AssertionError();
    }
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) GroupId(org.thoughtcrime.securesms.groups.GroupId) NonNull(androidx.annotation.NonNull)

Example 5 with RecipientId

use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.

the class EditGroupProfileRepository method getCurrentName.

@Override
public void getCurrentName(@NonNull Consumer<String> nameConsumer) {
    SimpleTask.run(() -> {
        RecipientId recipientId = getRecipientId();
        Recipient recipient = Recipient.resolved(recipientId);
        return SignalDatabase.groups().getGroup(recipientId).transform(groupRecord -> {
            String title = groupRecord.getTitle();
            return title == null ? "" : title;
        }).or(() -> recipient.getGroupName(context));
    }, nameConsumer::accept);
}
Also used : AvatarColor(org.thoughtcrime.securesms.conversation.colors.AvatarColor) Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) NonNull(androidx.annotation.NonNull) StreamUtil(org.signal.core.util.StreamUtil) ProfileName(org.thoughtcrime.securesms.profiles.ProfileName) WorkerThread(androidx.annotation.WorkerThread) IOException(java.io.IOException) Optional(org.whispersystems.libsignal.util.guava.Optional) Consumer(androidx.core.util.Consumer) GroupChangeException(org.thoughtcrime.securesms.groups.GroupChangeException) Log(org.signal.core.util.logging.Log) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) Nullable(androidx.annotation.Nullable) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) GroupId(org.thoughtcrime.securesms.groups.GroupId) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Aggregations

RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)154 NonNull (androidx.annotation.NonNull)70 Recipient (org.thoughtcrime.securesms.recipients.Recipient)70 List (java.util.List)34 ArrayList (java.util.ArrayList)33 Nullable (androidx.annotation.Nullable)32 Context (android.content.Context)31 Log (org.signal.core.util.logging.Log)31 IOException (java.io.IOException)30 ApplicationDependencies (org.thoughtcrime.securesms.dependencies.ApplicationDependencies)29 WorkerThread (androidx.annotation.WorkerThread)28 Stream (com.annimon.stream.Stream)27 LinkedList (java.util.LinkedList)25 ContentValues (android.content.ContentValues)24 Cursor (android.database.Cursor)24 Collections (java.util.Collections)24 SignalDatabase (org.thoughtcrime.securesms.database.SignalDatabase)24 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)23 Optional (org.whispersystems.libsignal.util.guava.Optional)22 HashSet (java.util.HashSet)21