Search in sources :

Example 1 with ProfileUploadJob

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

the class PinRestoreEntryFragment method handleSuccess.

private void handleSuccess() {
    cancelSpinning(pinButton);
    SignalStore.onboarding().clearAll();
    Activity activity = requireActivity();
    if (Recipient.self().getProfileName().isEmpty() || !AvatarHelper.hasAvatar(activity, Recipient.self().getId())) {
        final Intent main = MainActivity.clearTop(activity);
        final Intent profile = EditProfileActivity.getIntentForUserProfile(activity);
        profile.putExtra("next_intent", main);
        startActivity(profile);
    } else {
        RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
        ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
        startActivity(MainActivity.clearTop(activity));
    }
    activity.finish();
}
Also used : EditProfileActivity(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity) MainActivity(org.thoughtcrime.securesms.MainActivity) Activity(android.app.Activity) Intent(android.content.Intent) ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob)

Example 2 with ProfileUploadJob

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

the class RegistrationCompleteFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    FragmentActivity activity = requireActivity();
    RegistrationViewModel viewModel = new ViewModelProvider(activity).get(RegistrationViewModel.class);
    if (SignalStore.storageService().needsAccountRestore()) {
        Log.i(TAG, "Performing pin restore");
        activity.startActivity(new Intent(activity, PinRestoreActivity.class));
    } else if (!viewModel.isReregister()) {
        boolean needsProfile = Recipient.self().getProfileName().isEmpty() || !AvatarHelper.hasAvatar(activity, Recipient.self().getId());
        boolean needsPin = !SignalStore.kbsValues().hasPin();
        Log.i(TAG, "Pin restore flow not required." + " profile name: " + Recipient.self().getProfileName().isEmpty() + " profile avatar: " + !AvatarHelper.hasAvatar(activity, Recipient.self().getId()) + " needsPin:" + needsPin);
        Intent startIntent = MainActivity.clearTop(activity);
        if (needsPin) {
            startIntent = chainIntents(CreateKbsPinActivity.getIntentForPinCreate(requireContext()), startIntent);
        }
        if (needsProfile) {
            startIntent = chainIntents(EditProfileActivity.getIntentForUserProfile(activity), startIntent);
        }
        if (!needsProfile && !needsPin) {
            ApplicationDependencies.getJobManager().startChain(new ProfileUploadJob()).then(Arrays.asList(new MultiDeviceProfileKeyUpdateJob(), new MultiDeviceProfileContentUpdateJob())).enqueue();
            RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
        }
        activity.startActivity(startIntent);
    }
    activity.finish();
    ActivityNavigator.applyPopAnimationsToPendingTransition(activity);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Intent(android.content.Intent) MultiDeviceProfileKeyUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob) ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob) MultiDeviceProfileContentUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob) RegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) PinRestoreActivity(org.thoughtcrime.securesms.pin.PinRestoreActivity)

Example 3 with ProfileUploadJob

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

the class PaymentsHomeRepository method deactivatePayments.

public void deactivatePayments(@NonNull Consumer<Boolean> consumer) {
    SignalExecutors.BOUNDED.execute(() -> {
        SignalStore.paymentsValues().setMobileCoinPaymentsEnabled(false);
        ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
        consumer.accept(!SignalStore.paymentsValues().mobileCoinPaymentsEnabled());
    });
}
Also used : ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob)

Example 4 with ProfileUploadJob

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

the class ApplicationContext method ensureProfileUploaded.

private void ensureProfileUploaded() {
    if (SignalStore.account().isRegistered() && !SignalStore.registrationValues().hasUploadedProfile() && !Recipient.self().getProfileName().isEmpty()) {
        Log.w(TAG, "User has a profile, but has not uploaded one. Uploading now.");
        ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
    }
}
Also used : ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob)

Example 5 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)

Aggregations

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