Fix issue with tracking registration state.
This commit is contained in:
parent
6515a6188b
commit
4b9277629c
7 changed files with 22 additions and 9 deletions
|
@ -136,7 +136,7 @@ public class ApplicationContext extends MultiDexApplication implements DefaultLi
|
||||||
RefreshPreKeysJob.scheduleIfNecessary();
|
RefreshPreKeysJob.scheduleIfNecessary();
|
||||||
StorageSyncHelper.scheduleRoutineSync();
|
StorageSyncHelper.scheduleRoutineSync();
|
||||||
RetrieveProfileJob.enqueueRoutineFetchIfNeccessary(this);
|
RetrieveProfileJob.enqueueRoutineFetchIfNeccessary(this);
|
||||||
RegistrationUtil.markRegistrationPossiblyComplete();
|
RegistrationUtil.markRegistrationPossiblyComplete(this);
|
||||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < 21) {
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class StorageSyncJob extends BaseJob {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRun() throws IOException, RetryLaterException {
|
protected void onRun() throws IOException, RetryLaterException {
|
||||||
if (!SignalStore.kbsValues().hasPin()) {
|
if (!SignalStore.kbsValues().hasPin() && !SignalStore.kbsValues().hasOptedOut()) {
|
||||||
Log.i(TAG, "Doesn't have a PIN. Skipping.");
|
Log.i(TAG, "Doesn't have a PIN. Skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.pin.PinOptOutDialog;
|
import org.thoughtcrime.securesms.pin.PinOptOutDialog;
|
||||||
import org.thoughtcrime.securesms.pin.PinState;
|
import org.thoughtcrime.securesms.pin.PinState;
|
||||||
|
import org.thoughtcrime.securesms.registration.RegistrationUtil;
|
||||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||||
import org.thoughtcrime.securesms.util.text.AfterTextChanged;
|
import org.thoughtcrime.securesms.util.text.AfterTextChanged;
|
||||||
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;
|
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;
|
||||||
|
@ -215,6 +216,9 @@ abstract class BaseKbsPinFragment<ViewModel extends BaseKbsPinViewModel> extends
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPinSkipped() {
|
private void onPinSkipped() {
|
||||||
PinOptOutDialog.show(requireContext(), this::closeNavGraphBranch);
|
PinOptOutDialog.show(requireContext(), () -> {
|
||||||
|
RegistrationUtil.markRegistrationPossiblyComplete(requireContext());
|
||||||
|
closeNavGraphBranch();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class ConfirmKbsPinFragment extends BaseKbsPinFragment<ConfirmKbsPinViewM
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
requireActivity().setResult(Activity.RESULT_OK);
|
requireActivity().setResult(Activity.RESULT_OK);
|
||||||
closeNavGraphBranch();
|
closeNavGraphBranch();
|
||||||
RegistrationUtil.markRegistrationPossiblyComplete();
|
RegistrationUtil.markRegistrationPossiblyComplete(requireContext());
|
||||||
StorageSyncHelper.scheduleSyncForDataChange();
|
StorageSyncHelper.scheduleSyncForDataChange();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -126,7 +126,7 @@ public class ConfirmKbsPinFragment extends BaseKbsPinFragment<ConfirmKbsPinViewM
|
||||||
startEndAnimationOnNextProgressRepetition(R.raw.lottie_kbs_failure, new AnimationCompleteListener() {
|
startEndAnimationOnNextProgressRepetition(R.raw.lottie_kbs_failure, new AnimationCompleteListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
RegistrationUtil.markRegistrationPossiblyComplete();
|
RegistrationUtil.markRegistrationPossiblyComplete(requireContext());
|
||||||
displayFailedDialog();
|
displayFailedDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||||
profile.putExtra("next_intent", main);
|
profile.putExtra("next_intent", main);
|
||||||
startActivity(profile);
|
startActivity(profile);
|
||||||
} else {
|
} else {
|
||||||
RegistrationUtil.markRegistrationPossiblyComplete();
|
RegistrationUtil.markRegistrationPossiblyComplete(requireContext());
|
||||||
ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
|
ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
|
||||||
startActivity(new Intent(activity, MainActivity.class));
|
startActivity(new Intent(activity, MainActivity.class));
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,7 +336,7 @@ public class EditProfileFragment extends LoggingFragment {
|
||||||
private void handleUpload() {
|
private void handleUpload() {
|
||||||
viewModel.submitProfile(uploadResult -> {
|
viewModel.submitProfile(uploadResult -> {
|
||||||
if (uploadResult == EditProfileRepository.UploadResult.SUCCESS) {
|
if (uploadResult == EditProfileRepository.UploadResult.SUCCESS) {
|
||||||
RegistrationUtil.markRegistrationPossiblyComplete();
|
RegistrationUtil.markRegistrationPossiblyComplete(requireContext());
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) handleFinishedLollipop();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) handleFinishedLollipop();
|
||||||
else handleFinishedLegacy();
|
else handleFinishedLegacy();
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package org.thoughtcrime.securesms.registration;
|
package org.thoughtcrime.securesms.registration;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
||||||
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
|
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
|
||||||
|
@ -7,6 +11,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.signalservice.internal.storage.protos.SignalStorage;
|
import org.whispersystems.signalservice.internal.storage.protos.SignalStorage;
|
||||||
|
|
||||||
public final class RegistrationUtil {
|
public final class RegistrationUtil {
|
||||||
|
@ -20,8 +25,12 @@ public final class RegistrationUtil {
|
||||||
* path a user has taken. This will only truly mark registration as complete if all of the
|
* path a user has taken. This will only truly mark registration as complete if all of the
|
||||||
* requirements are met.
|
* requirements are met.
|
||||||
*/
|
*/
|
||||||
public static void markRegistrationPossiblyComplete() {
|
public static void markRegistrationPossiblyComplete(@NonNull Context context) {
|
||||||
if (!SignalStore.registrationValues().isRegistrationComplete() && SignalStore.kbsValues().hasPin() && !Recipient.self().getProfileName().isEmpty()) {
|
if (!SignalStore.registrationValues().isRegistrationComplete() &&
|
||||||
|
TextSecurePreferences.isPushRegistered(context) &&
|
||||||
|
!Recipient.self().getProfileName().isEmpty() &&
|
||||||
|
(SignalStore.kbsValues().hasPin() || SignalStore.kbsValues().hasOptedOut()))
|
||||||
|
{
|
||||||
Log.i(TAG, "Marking registration completed.", new Throwable());
|
Log.i(TAG, "Marking registration completed.", new Throwable());
|
||||||
SignalStore.registrationValues().setRegistrationComplete();
|
SignalStore.registrationValues().setRegistrationComplete();
|
||||||
ApplicationDependencies.getJobManager().startChain(new StorageSyncJob())
|
ApplicationDependencies.getJobManager().startChain(new StorageSyncJob())
|
||||||
|
|
Loading…
Add table
Reference in a new issue