Search in sources :

Example 1 with RegistrationViewModel

use of org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel 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)

Aggregations

Intent (android.content.Intent)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 MultiDeviceProfileContentUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob)1 MultiDeviceProfileKeyUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob)1 ProfileUploadJob (org.thoughtcrime.securesms.jobs.ProfileUploadJob)1 PinRestoreActivity (org.thoughtcrime.securesms.pin.PinRestoreActivity)1 RegistrationViewModel (org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel)1