Search in sources :

Example 11 with MultiDeviceProfileContentUpdateJob

use of org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob in project Signal-Android by signalapp.

the class ManageProfileRepository method setAbout.

public void setAbout(@NonNull Context context, @NonNull String about, @NonNull String emoji, @NonNull Consumer<Result> callback) {
    SignalExecutors.UNBOUNDED.execute(() -> {
        try {
            ProfileUtil.uploadProfileWithAbout(context, about, emoji);
            SignalDatabase.recipients().setAbout(Recipient.self().getId(), about, emoji);
            ApplicationDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
            callback.accept(Result.SUCCESS);
        } catch (IOException e) {
            Log.w(TAG, "Failed to upload profile during about change.", e);
            callback.accept(Result.FAILURE_NETWORK);
        }
    });
}
Also used : IOException(java.io.IOException) MultiDeviceProfileContentUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob)

Example 12 with MultiDeviceProfileContentUpdateJob

use of org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob in project Signal-Android by signalapp.

the class ManageProfileRepository method setAvatar.

public void setAvatar(@NonNull Context context, @NonNull byte[] data, @NonNull String contentType, @NonNull Consumer<Result> callback) {
    SignalExecutors.UNBOUNDED.execute(() -> {
        try {
            ProfileUtil.uploadProfileWithAvatar(context, new StreamDetails(new ByteArrayInputStream(data), contentType, data.length));
            AvatarHelper.setAvatar(context, Recipient.self().getId(), new ByteArrayInputStream(data));
            SignalStore.misc().markHasEverHadAnAvatar();
            ApplicationDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
            callback.accept(Result.SUCCESS);
        } catch (IOException e) {
            Log.w(TAG, "Failed to upload profile during avatar change.", e);
            callback.accept(Result.FAILURE_NETWORK);
        }
    });
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) StreamDetails(org.whispersystems.signalservice.api.util.StreamDetails) IOException(java.io.IOException) MultiDeviceProfileContentUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob)

Aggregations

MultiDeviceProfileContentUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob)12 IOException (java.io.IOException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)4 MultiDeviceProfileKeyUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob)4 ProfileUploadJob (org.thoughtcrime.securesms.jobs.ProfileUploadJob)4 Intent (android.content.Intent)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 PinRestoreActivity (org.thoughtcrime.securesms.pin.PinRestoreActivity)2 RegistrationViewModel (org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel)2 StreamDetails (org.whispersystems.signalservice.api.util.StreamDetails)2