Search in sources :

Example 11 with ProfileUploadJob

use of org.thoughtcrime.securesms.jobs.ProfileUploadJob in project Signal-Android by WhisperSystems.

the class EditSelfProfileRepository method uploadProfile.

@Override
public void uploadProfile(@NonNull ProfileName profileName, @NonNull String displayName, boolean displayNameChanged, @NonNull String description, boolean descriptionChanged, @Nullable byte[] avatar, boolean avatarChanged, @NonNull Consumer<UploadResult> uploadResultConsumer) {
    SimpleTask.run(() -> {
        SignalDatabase.recipients().setProfileName(Recipient.self().getId(), profileName);
        if (avatarChanged) {
            try {
                AvatarHelper.setAvatar(context, Recipient.self().getId(), avatar != null ? new ByteArrayInputStream(avatar) : null);
            } catch (IOException e) {
                return UploadResult.ERROR_IO;
            }
        }
        ApplicationDependencies.getJobManager().startChain(new ProfileUploadJob()).then(Arrays.asList(new MultiDeviceProfileKeyUpdateJob(), new MultiDeviceProfileContentUpdateJob())).enqueue();
        RegistrationUtil.maybeMarkRegistrationComplete(context);
        if (avatar != null) {
            SignalStore.misc().markHasEverHadAnAvatar();
        }
        return UploadResult.SUCCESS;
    }, uploadResultConsumer::accept);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) MultiDeviceProfileKeyUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob) IOException(java.io.IOException) ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob) MultiDeviceProfileContentUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob)

Example 12 with ProfileUploadJob

use of org.thoughtcrime.securesms.jobs.ProfileUploadJob in project Signal-Android by WhisperSystems.

the class ProfileMigrationJob method performMigration.

@Override
public void performMigration() {
    Log.i(TAG, "Scheduling profile upload job");
    ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
}
Also used : ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob)

Aggregations

ProfileUploadJob (org.thoughtcrime.securesms.jobs.ProfileUploadJob)12 Intent (android.content.Intent)4 MultiDeviceProfileContentUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob)4 MultiDeviceProfileKeyUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob)4 Activity (android.app.Activity)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 MainActivity (org.thoughtcrime.securesms.MainActivity)2 PinRestoreActivity (org.thoughtcrime.securesms.pin.PinRestoreActivity)2 EditProfileActivity (org.thoughtcrime.securesms.profiles.edit.EditProfileActivity)2 RegistrationViewModel (org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel)2