2013-03-26 04:26:03 +00:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2017-11-25 06:00:30 +00:00
|
|
|
import android.Manifest;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.animation.Animator;
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.content.BroadcastReceiver;
|
2017-02-20 20:00:03 +00:00
|
|
|
import android.content.Context;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.content.Intent;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.os.AsyncTask;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.os.Bundle;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.design.widget.FloatingActionButton;
|
2015-05-20 21:36:30 +00:00
|
|
|
import android.support.v7.app.AlertDialog;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.text.Editable;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.text.SpannableString;
|
|
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.text.TextPaint;
|
2014-11-12 19:15:05 +00:00
|
|
|
import android.text.TextUtils;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.text.TextWatcher;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
import android.text.style.ClickableSpan;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.util.Log;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.util.Pair;
|
2015-07-09 15:03:45 +00:00
|
|
|
import android.view.KeyEvent;
|
2018-02-26 17:58:18 +00:00
|
|
|
import android.view.LayoutInflater;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
2017-11-08 20:20:11 +00:00
|
|
|
import android.view.animation.OvershootInterpolator;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.widget.ArrayAdapter;
|
2018-02-26 17:58:18 +00:00
|
|
|
import android.widget.EditText;
|
2013-03-26 04:26:03 +00:00
|
|
|
import android.widget.Spinner;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
import com.dd.CircularProgressButton;
|
2014-07-23 22:40:45 +00:00
|
|
|
import com.google.android.gms.common.ConnectionResult;
|
2017-02-20 20:00:03 +00:00
|
|
|
import com.google.android.gms.common.GoogleApiAvailability;
|
2017-11-08 20:20:11 +00:00
|
|
|
import com.google.android.gms.gcm.GoogleCloudMessaging;
|
2013-03-26 04:26:03 +00:00
|
|
|
import com.google.i18n.phonenumbers.AsYouTypeFormatter;
|
|
|
|
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
|
|
|
import com.google.i18n.phonenumbers.Phonenumber;
|
2014-01-08 22:29:05 +00:00
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
import net.sqlcipher.database.SQLiteDatabase;
|
|
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.animation.AnimationCompleteListener;
|
2018-02-26 17:58:18 +00:00
|
|
|
import org.thoughtcrime.securesms.backup.FullBackupBase;
|
|
|
|
import org.thoughtcrime.securesms.backup.FullBackupImporter;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.components.registration.CallMeCountDownView;
|
|
|
|
import org.thoughtcrime.securesms.components.registration.VerificationCodeView;
|
|
|
|
import org.thoughtcrime.securesms.components.registration.VerificationPinKeyboard;
|
2018-02-26 17:58:18 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
|
|
|
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
|
|
|
import org.thoughtcrime.securesms.crypto.SessionUtil;
|
|
|
|
import org.thoughtcrime.securesms.database.Address;
|
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
|
|
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
2018-02-26 17:58:18 +00:00
|
|
|
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
|
|
|
import org.thoughtcrime.securesms.jobs.GcmRefreshJob;
|
2017-11-25 06:00:30 +00:00
|
|
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.push.AccountManagerFactory;
|
|
|
|
import org.thoughtcrime.securesms.service.DirectoryRefreshListener;
|
|
|
|
import org.thoughtcrime.securesms.service.RotateSignedPreKeyListener;
|
2018-02-26 17:58:18 +00:00
|
|
|
import org.thoughtcrime.securesms.util.BackupUtil;
|
|
|
|
import org.thoughtcrime.securesms.util.DateUtils;
|
2014-03-01 00:32:00 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Dialogs;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.util.PlayServicesUtil;
|
|
|
|
import org.thoughtcrime.securesms.util.PlayServicesUtil.PlayServicesStatus;
|
|
|
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
2014-07-23 22:40:45 +00:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2014-11-12 19:15:05 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
|
|
|
import org.whispersystems.libsignal.IdentityKeyPair;
|
|
|
|
import org.whispersystems.libsignal.state.PreKeyRecord;
|
|
|
|
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|
|
|
import org.whispersystems.libsignal.util.KeyHelper;
|
2017-08-02 19:51:46 +00:00
|
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
2017-11-08 20:20:11 +00:00
|
|
|
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
2018-03-01 17:51:37 +00:00
|
|
|
import org.whispersystems.signalservice.api.push.exceptions.RateLimitException;
|
2016-03-23 17:34:41 +00:00
|
|
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
2018-03-01 17:51:37 +00:00
|
|
|
import org.whispersystems.signalservice.internal.push.LockedException;
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
2018-02-26 17:58:18 +00:00
|
|
|
import java.util.Locale;
|
2018-03-01 17:51:37 +00:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2017-11-08 20:20:11 +00:00
|
|
|
|
2013-03-26 04:26:03 +00:00
|
|
|
/**
|
2013-07-11 00:54:38 +00:00
|
|
|
* The register account activity. Prompts ths user for their registration information
|
|
|
|
* and begins the account registration process.
|
2013-03-26 04:26:03 +00:00
|
|
|
*
|
|
|
|
* @author Moxie Marlinspike
|
|
|
|
*
|
|
|
|
*/
|
2017-11-08 20:20:11 +00:00
|
|
|
public class RegistrationActivity extends BaseActionBarActivity implements VerificationCodeView.OnCodeEnteredListener {
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private static final int PICK_COUNTRY = 1;
|
|
|
|
private static final int SCENE_TRANSITION_DURATION = 250;
|
|
|
|
public static final String CHALLENGE_EVENT = "org.thoughtcrime.securesms.CHALLENGE_EVENT";
|
|
|
|
public static final String CHALLENGE_EXTRA = "CAAChallenge";
|
2018-02-26 17:58:18 +00:00
|
|
|
public static final String RE_REGISTRATION_EXTRA = "re_registration";
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private static final String TAG = RegistrationActivity.class.getSimpleName();
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private AsYouTypeFormatter countryFormatter;
|
|
|
|
private ArrayAdapter<String> countrySpinnerAdapter;
|
|
|
|
private Spinner countrySpinner;
|
|
|
|
private TextView countryCode;
|
|
|
|
private TextView number;
|
|
|
|
private CircularProgressButton createButton;
|
|
|
|
private TextView informationView;
|
|
|
|
private TextView informationToggleText;
|
|
|
|
private TextView title;
|
|
|
|
private TextView subtitle;
|
|
|
|
private View registrationContainer;
|
|
|
|
private View verificationContainer;
|
|
|
|
private FloatingActionButton fab;
|
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
private View restoreContainer;
|
|
|
|
private TextView restoreBackupTime;
|
|
|
|
private TextView restoreBackupSize;
|
|
|
|
private TextView restoreBackupProgress;
|
|
|
|
private CircularProgressButton restoreButton;
|
|
|
|
|
2018-03-01 17:51:37 +00:00
|
|
|
private View pinContainer;
|
|
|
|
private EditText pin;
|
|
|
|
private CircularProgressButton pinButton;
|
|
|
|
private TextView pinForgotButton;
|
|
|
|
private View pinClarificationContainer;
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private CallMeCountDownView callMeCountDownView;
|
|
|
|
private VerificationPinKeyboard keyboard;
|
|
|
|
private VerificationCodeView verificationCodeView;
|
|
|
|
private RegistrationState registrationState;
|
|
|
|
private ChallengeReceiver challengeReceiver;
|
|
|
|
private SignalServiceAccountManager accountManager;
|
2013-08-15 15:25:30 +00:00
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
|
2013-03-26 04:26:03 +00:00
|
|
|
@Override
|
2015-04-03 00:14:08 +00:00
|
|
|
public void onCreate(Bundle icicle) {
|
|
|
|
super.onCreate(icicle);
|
2013-03-26 04:26:03 +00:00
|
|
|
setContentView(R.layout.registration_activity);
|
|
|
|
|
|
|
|
initializeResources();
|
2013-07-11 00:54:38 +00:00
|
|
|
initializeSpinner();
|
2017-11-25 06:00:30 +00:00
|
|
|
initializePermissions();
|
2013-03-26 04:26:03 +00:00
|
|
|
initializeNumber();
|
2017-11-08 20:20:11 +00:00
|
|
|
initializeChallengeListener();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
shutdownChallengeListener();
|
|
|
|
markAsVerifying(false);
|
2018-02-26 17:58:18 +00:00
|
|
|
EventBus.getDefault().unregister(this);
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (requestCode == PICK_COUNTRY && resultCode == RESULT_OK && data != null) {
|
2017-11-08 20:20:11 +00:00
|
|
|
this.countryCode.setText(String.valueOf(data.getIntExtra("country_code", 1)));
|
2013-03-26 04:26:03 +00:00
|
|
|
setCountryDisplay(data.getStringExtra("country_name"));
|
|
|
|
setCountryFormatter(data.getIntExtra("country_code", 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-25 06:00:30 +00:00
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
|
|
|
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
|
|
|
}
|
|
|
|
|
2013-03-26 04:26:03 +00:00
|
|
|
private void initializeResources() {
|
2018-02-26 17:58:18 +00:00
|
|
|
TextView skipButton = findViewById(R.id.skip_button);
|
|
|
|
TextView restoreSkipButton = findViewById(R.id.skip_restore_button);
|
|
|
|
View informationToggle = findViewById(R.id.information_link_container);
|
2017-11-08 20:20:11 +00:00
|
|
|
|
|
|
|
this.countrySpinner = findViewById(R.id.country_spinner);
|
|
|
|
this.countryCode = findViewById(R.id.country_code);
|
|
|
|
this.number = findViewById(R.id.number);
|
|
|
|
this.createButton = findViewById(R.id.registerButton);
|
|
|
|
this.informationView = findViewById(R.id.registration_information);
|
|
|
|
this.informationToggleText = findViewById(R.id.information_label);
|
|
|
|
this.title = findViewById(R.id.verify_header);
|
|
|
|
this.subtitle = findViewById(R.id.verify_subheader);
|
|
|
|
this.registrationContainer = findViewById(R.id.registration_container);
|
|
|
|
this.verificationContainer = findViewById(R.id.verification_container);
|
|
|
|
this.fab = findViewById(R.id.fab);
|
|
|
|
|
|
|
|
this.verificationCodeView = findViewById(R.id.code);
|
|
|
|
this.keyboard = findViewById(R.id.keyboard);
|
|
|
|
this.callMeCountDownView = findViewById(R.id.call_me_count_down);
|
2018-02-26 17:58:18 +00:00
|
|
|
|
|
|
|
this.restoreContainer = findViewById(R.id.restore_container);
|
|
|
|
this.restoreBackupSize = findViewById(R.id.backup_size_text);
|
|
|
|
this.restoreBackupTime = findViewById(R.id.backup_created_text);
|
|
|
|
this.restoreBackupProgress = findViewById(R.id.backup_progress_text);
|
|
|
|
this.restoreButton = findViewById(R.id.restore_button);
|
|
|
|
|
2018-03-01 17:51:37 +00:00
|
|
|
this.pinContainer = findViewById(R.id.pin_container);
|
|
|
|
this.pin = findViewById(R.id.pin);
|
|
|
|
this.pinButton = findViewById(R.id.pinButton);
|
|
|
|
this.pinForgotButton = findViewById(R.id.forgot_button);
|
|
|
|
this.pinClarificationContainer = findViewById(R.id.pin_clarification_container);
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
this.registrationState = new RegistrationState(RegistrationState.State.INITIAL, null, null, null);
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2013-07-11 00:54:38 +00:00
|
|
|
this.countryCode.addTextChangedListener(new CountryCodeChangedListener());
|
|
|
|
this.number.addTextChangedListener(new NumberChangedListener());
|
2017-11-08 20:20:11 +00:00
|
|
|
this.createButton.setOnClickListener(v -> handleRegister());
|
|
|
|
this.callMeCountDownView.setOnClickListener(v -> handlePhoneCallRequest());
|
|
|
|
skipButton.setOnClickListener(v -> handleCancel());
|
|
|
|
informationToggle.setOnClickListener(new InformationToggleListener());
|
2014-11-04 14:19:48 +00:00
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
restoreSkipButton.setOnClickListener(v -> displayInitialView(true));
|
|
|
|
|
|
|
|
if (getIntent().getBooleanExtra(RE_REGISTRATION_EXTRA, false)) {
|
2017-11-08 20:20:11 +00:00
|
|
|
skipButton.setVisibility(View.VISIBLE);
|
2015-03-11 21:23:45 +00:00
|
|
|
} else {
|
2017-11-08 20:20:11 +00:00
|
|
|
skipButton.setVisibility(View.INVISIBLE);
|
2014-11-04 14:19:48 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
|
|
|
|
this.keyboard.setOnKeyPressListener(key -> {
|
|
|
|
if (key >= 0) verificationCodeView.append(key);
|
|
|
|
else verificationCodeView.delete();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.verificationCodeView.setOnCompleteListener(this);
|
2018-02-26 17:58:18 +00:00
|
|
|
EventBus.getDefault().register(this);
|
2013-07-11 00:54:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
2013-07-11 00:54:38 +00:00
|
|
|
private void initializeSpinner() {
|
2014-11-12 19:15:05 +00:00
|
|
|
this.countrySpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item);
|
2013-03-26 04:26:03 +00:00
|
|
|
this.countrySpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
2013-07-11 00:54:38 +00:00
|
|
|
|
2013-07-09 23:36:15 +00:00
|
|
|
setCountryDisplay(getString(R.string.RegistrationActivity_select_your_country));
|
2013-03-26 04:26:03 +00:00
|
|
|
|
|
|
|
this.countrySpinner.setAdapter(this.countrySpinnerAdapter);
|
2017-11-08 20:20:11 +00:00
|
|
|
this.countrySpinner.setOnTouchListener((v, event) -> {
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
|
|
|
Intent intent = new Intent(RegistrationActivity.this, CountrySelectionActivity.class);
|
|
|
|
startActivityForResult(intent, PICK_COUNTRY);
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
return true;
|
2013-03-26 04:26:03 +00:00
|
|
|
});
|
2017-11-08 20:20:11 +00:00
|
|
|
this.countrySpinner.setOnKeyListener((v, keyCode, event) -> {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && event.getAction() == KeyEvent.ACTION_UP) {
|
|
|
|
Intent intent = new Intent(RegistrationActivity.this, CountrySelectionActivity.class);
|
|
|
|
startActivityForResult(intent, PICK_COUNTRY);
|
|
|
|
return true;
|
2015-07-09 15:03:45 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
return false;
|
2015-07-09 15:03:45 +00:00
|
|
|
});
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
|
|
|
|
2017-11-25 06:00:30 +00:00
|
|
|
@SuppressLint("MissingPermission")
|
2013-03-26 04:26:03 +00:00
|
|
|
private void initializeNumber() {
|
2017-11-25 06:00:30 +00:00
|
|
|
Optional<Phonenumber.PhoneNumber> localNumber = Optional.absent();
|
|
|
|
|
|
|
|
if (Permissions.hasAll(this, Manifest.permission.READ_PHONE_STATE)) {
|
|
|
|
localNumber = Util.getDeviceNumber(this);
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-08-02 19:51:46 +00:00
|
|
|
if (localNumber.isPresent()) {
|
|
|
|
this.countryCode.setText(String.valueOf(localNumber.get().getCountryCode()));
|
|
|
|
this.number.setText(String.valueOf(localNumber.get().getNationalNumber()));
|
|
|
|
} else {
|
|
|
|
Optional<String> simCountryIso = Util.getSimCountryIso(this);
|
2014-06-04 02:16:27 +00:00
|
|
|
|
2017-08-02 19:51:46 +00:00
|
|
|
if (simCountryIso.isPresent() && !TextUtils.isEmpty(simCountryIso.get())) {
|
2017-11-08 20:20:11 +00:00
|
|
|
this.countryCode.setText(String.valueOf(PhoneNumberUtil.getInstance().getCountryCodeForRegion(simCountryIso.get())));
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-25 06:00:30 +00:00
|
|
|
@SuppressLint("InlinedApi")
|
|
|
|
private void initializePermissions() {
|
|
|
|
Permissions.with(RegistrationActivity.this)
|
|
|
|
.request(Manifest.permission.WRITE_CONTACTS, Manifest.permission.READ_CONTACTS,
|
|
|
|
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
|
Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_CALL_LOG,
|
2017-11-30 21:04:11 +00:00
|
|
|
Manifest.permission.PROCESS_OUTGOING_CALLS)
|
2017-11-25 06:00:30 +00:00
|
|
|
.ifNecessary()
|
|
|
|
.withRationaleDialog(getString(R.string.RegistrationActivity_signal_needs_access_to_your_contacts_and_media_in_order_to_connect_with_friends),
|
|
|
|
R.drawable.ic_contacts_white_48dp, R.drawable.ic_folder_white_48dp)
|
|
|
|
.onSomeGranted(permissions -> {
|
|
|
|
if (permissions.contains(Manifest.permission.READ_PHONE_STATE)) {
|
|
|
|
initializeNumber();
|
|
|
|
}
|
2018-02-26 17:58:18 +00:00
|
|
|
|
|
|
|
if (permissions.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
|
|
|
initializeBackupDetection();
|
|
|
|
}
|
2017-11-25 06:00:30 +00:00
|
|
|
})
|
|
|
|
.execute();
|
|
|
|
}
|
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private void initializeBackupDetection() {
|
|
|
|
if (getIntent().getBooleanExtra(RE_REGISTRATION_EXTRA, false)) return;
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, BackupUtil.BackupInfo>() {
|
|
|
|
@Override
|
|
|
|
protected @Nullable BackupUtil.BackupInfo doInBackground(Void... voids) {
|
|
|
|
try {
|
|
|
|
return BackupUtil.getLatestBackup();
|
|
|
|
} catch (NoExternalStorageException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(@Nullable BackupUtil.BackupInfo backup) {
|
|
|
|
if (backup != null) displayRestoreView(backup);
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
|
2013-03-26 04:26:03 +00:00
|
|
|
private void setCountryDisplay(String value) {
|
|
|
|
this.countrySpinnerAdapter.clear();
|
|
|
|
this.countrySpinnerAdapter.add(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setCountryFormatter(int countryCode) {
|
|
|
|
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
|
|
|
|
String regionCode = util.getRegionCodeForCountryCode(countryCode);
|
|
|
|
|
2013-07-09 23:36:15 +00:00
|
|
|
if (regionCode == null) this.countryFormatter = null;
|
|
|
|
else this.countryFormatter = util.getAsYouTypeFormatter(regionCode);
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private String getConfiguredE164Number() {
|
|
|
|
return PhoneNumberFormatter.formatE164(countryCode.getText().toString(),
|
|
|
|
number.getText().toString());
|
|
|
|
}
|
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private void handleRestore(BackupUtil.BackupInfo backup) {
|
|
|
|
View view = LayoutInflater.from(this).inflate(R.layout.enter_backup_passphrase_dialog, null);
|
|
|
|
EditText prompt = view.findViewById(R.id.restore_passphrase_input);
|
|
|
|
|
|
|
|
new AlertDialog.Builder(this)
|
|
|
|
.setTitle(R.string.RegistrationActivity_enter_backup_passphrase)
|
|
|
|
.setView(view)
|
|
|
|
.setPositiveButton(getString(R.string.RegistrationActivity_restore), (dialog, which) -> {
|
|
|
|
restoreButton.setIndeterminateProgressMode(true);
|
|
|
|
restoreButton.setProgress(50);
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, Boolean>() {
|
|
|
|
@Override
|
|
|
|
protected Boolean doInBackground(Void... voids) {
|
|
|
|
try {
|
|
|
|
Context context = RegistrationActivity.this;
|
|
|
|
String passphrase = prompt.getText().toString();
|
|
|
|
SQLiteDatabase database = DatabaseFactory.getBackupDatabase(context);
|
|
|
|
|
|
|
|
FullBackupImporter.importFile(context,
|
|
|
|
AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret(),
|
|
|
|
database, backup.getFile(), passphrase);
|
|
|
|
|
|
|
|
DatabaseFactory.upgradeRestored(context, database);
|
|
|
|
|
|
|
|
TextSecurePreferences.setBackupEnabled(context, true);
|
|
|
|
TextSecurePreferences.setBackupPassphrase(context, passphrase);
|
|
|
|
return true;
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(@NonNull Boolean result) {
|
|
|
|
restoreButton.setIndeterminateProgressMode(false);
|
|
|
|
restoreButton.setProgress(0);
|
|
|
|
restoreBackupProgress.setText("");
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
displayInitialView(true);
|
|
|
|
} else {
|
|
|
|
Toast.makeText(RegistrationActivity.this, R.string.RegistrationActivity_incorrect_backup_passphrase, Toast.LENGTH_LONG).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
|
|
|
|
})
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private void handleRegister() {
|
|
|
|
if (TextUtils.isEmpty(countryCode.getText())) {
|
|
|
|
Toast.makeText(this, getString(R.string.RegistrationActivity_you_must_specify_your_country_code), Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
if (TextUtils.isEmpty(number.getText())) {
|
|
|
|
Toast.makeText(this, getString(R.string.RegistrationActivity_you_must_specify_your_phone_number), Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-25 06:00:30 +00:00
|
|
|
Permissions.with(this)
|
|
|
|
.request(Manifest.permission.READ_SMS)
|
|
|
|
.ifNecessary()
|
|
|
|
.withRationaleDialog(getString(R.string.RegistrationActivity_to_easily_verify_your_phone_number_signal_can_automatically_detect_your_verification_code), R.drawable.ic_textsms_white_48dp)
|
|
|
|
.onAnyResult(this::handleRegisterWithPermissions)
|
|
|
|
.execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleRegisterWithPermissions() {
|
|
|
|
if (TextUtils.isEmpty(countryCode.getText())) {
|
|
|
|
Toast.makeText(this, getString(R.string.RegistrationActivity_you_must_specify_your_country_code), Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(number.getText())) {
|
|
|
|
Toast.makeText(this, getString(R.string.RegistrationActivity_you_must_specify_your_phone_number), Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
final String e164number = getConfiguredE164Number();
|
|
|
|
|
|
|
|
if (!PhoneNumberFormatter.isValidNumber(e164number)) {
|
|
|
|
Dialogs.showAlertDialog(this, getString(R.string.RegistrationActivity_invalid_number),
|
|
|
|
String.format(getString(R.string.RegistrationActivity_the_number_you_specified_s_is_invalid),
|
|
|
|
e164number));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayServicesStatus gcmStatus = PlayServicesUtil.getPlayServicesStatus(this);
|
|
|
|
|
|
|
|
if (gcmStatus == PlayServicesStatus.SUCCESS) {
|
|
|
|
handleRequestVerification(e164number, true);
|
|
|
|
} else if (gcmStatus == PlayServicesStatus.MISSING) {
|
|
|
|
handlePromptForNoPlayServices(e164number);
|
|
|
|
} else if (gcmStatus == PlayServicesStatus.NEEDS_UPDATE) {
|
|
|
|
GoogleApiAvailability.getInstance().getErrorDialog(this, ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED, 0).show();
|
|
|
|
} else {
|
|
|
|
Dialogs.showAlertDialog(this, getString(R.string.RegistrationActivity_play_services_error),
|
|
|
|
getString(R.string.RegistrationActivity_google_play_services_is_updating_or_unavailable));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private void handleRequestVerification(@NonNull String e164number, boolean gcmSupported) {
|
|
|
|
createButton.setIndeterminateProgressMode(true);
|
|
|
|
createButton.setProgress(50);
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, Pair<String, Optional<String>>> () {
|
|
|
|
@Override
|
|
|
|
protected @Nullable Pair<String, Optional<String>> doInBackground(Void... voids) {
|
|
|
|
try {
|
|
|
|
markAsVerifying(true);
|
|
|
|
|
|
|
|
String password = Util.getSecret(18);
|
|
|
|
|
|
|
|
Optional<String> gcmToken;
|
|
|
|
|
|
|
|
if (gcmSupported) {
|
|
|
|
gcmToken = Optional.of(GoogleCloudMessaging.getInstance(RegistrationActivity.this).register(GcmRefreshJob.REGISTRATION_ID));
|
|
|
|
} else {
|
|
|
|
gcmToken = Optional.absent();
|
|
|
|
}
|
|
|
|
|
|
|
|
accountManager = AccountManagerFactory.createManager(RegistrationActivity.this, e164number, password);
|
|
|
|
accountManager.requestSmsVerificationCode();
|
|
|
|
|
|
|
|
return new Pair<>(password, gcmToken);
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return null;
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
protected void onPostExecute(@Nullable Pair<String, Optional<String>> result) {
|
|
|
|
if (result == null) {
|
2017-11-25 06:00:30 +00:00
|
|
|
Toast.makeText(RegistrationActivity.this, R.string.RegistrationActivity_unable_to_connect_to_service, Toast.LENGTH_LONG).show();
|
2017-11-08 20:20:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
registrationState = new RegistrationState(RegistrationState.State.VERIFYING, e164number, result.first, result.second);
|
|
|
|
displayVerificationView(e164number, 64);
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private void handleChallengeReceived(@Nullable String challenge) {
|
|
|
|
if (challenge != null && challenge.length() == 6 && registrationState.state == RegistrationState.State.VERIFYING) {
|
|
|
|
verificationCodeView.clear();
|
2014-07-23 22:40:45 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
try {
|
|
|
|
for (int i=0;i<challenge.length();i++) {
|
|
|
|
final int index = i;
|
|
|
|
verificationCodeView.postDelayed(() -> verificationCodeView.append(Integer.parseInt(Character.toString(challenge.charAt(index)))), i * 200);
|
|
|
|
}
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
verificationCodeView.clear();
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
2017-02-20 20:00:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
@Override
|
|
|
|
public void onCodeComplete(@NonNull String code) {
|
|
|
|
this.registrationState = new RegistrationState(RegistrationState.State.CHECKING, this.registrationState);
|
|
|
|
callMeCountDownView.setVisibility(View.INVISIBLE);
|
|
|
|
keyboard.displayProgress();
|
|
|
|
|
2018-03-01 17:51:37 +00:00
|
|
|
new AsyncTask<Void, Void, Pair<Integer, Long>>() {
|
2017-11-08 20:20:11 +00:00
|
|
|
@Override
|
2018-03-01 17:51:37 +00:00
|
|
|
protected Pair<Integer, Long> doInBackground(Void... voids) {
|
2017-11-08 20:20:11 +00:00
|
|
|
try {
|
2018-03-01 17:51:37 +00:00
|
|
|
verifyAccount(code, null);
|
|
|
|
return new Pair<>(1, -1L);
|
|
|
|
} catch (LockedException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return new Pair<>(2, e.getTimeRemaining());
|
2017-11-08 20:20:11 +00:00
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
2018-03-01 17:51:37 +00:00
|
|
|
return new Pair<>(3, -1L);
|
2017-11-08 20:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-01 17:51:37 +00:00
|
|
|
protected void onPostExecute(Pair<Integer, Long> result) {
|
|
|
|
if (result.first == 1) {
|
2017-11-08 20:20:11 +00:00
|
|
|
keyboard.displaySuccess().addListener(new AssertedSuccessListener<Boolean>() {
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Boolean result) {
|
2018-03-01 17:51:37 +00:00
|
|
|
handleSuccessfulRegistration();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (result.first == 2) {
|
|
|
|
keyboard.displayLocked().addListener(new AssertedSuccessListener<Boolean>() {
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Boolean r) {
|
|
|
|
registrationState = new RegistrationState(RegistrationState.State.PIN, registrationState);
|
|
|
|
displayPinView(code, result.second);
|
2017-11-08 20:20:11 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
keyboard.displayFailure().addListener(new AssertedSuccessListener<Boolean>() {
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Boolean result) {
|
|
|
|
registrationState = new RegistrationState(RegistrationState.State.VERIFYING, registrationState);
|
|
|
|
callMeCountDownView.setVisibility(View.VISIBLE);
|
|
|
|
verificationCodeView.clear();
|
|
|
|
keyboard.displayKeyboard();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}
|
|
|
|
|
2018-03-01 17:51:37 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private void handleVerifyWithPinClicked(@NonNull String code, @Nullable String pin) {
|
|
|
|
if (TextUtils.isEmpty(pin) || TextUtils.isEmpty(pin.replace(" ", ""))) {
|
|
|
|
Toast.makeText(this, R.string.RegistrationActivity_you_must_enter_your_registration_lock_PIN, Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pinButton.setIndeterminateProgressMode(true);
|
|
|
|
pinButton.setProgress(50);
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, Integer>() {
|
|
|
|
@Override
|
|
|
|
protected Integer doInBackground(Void... voids) {
|
|
|
|
try {
|
|
|
|
verifyAccount(code, pin);
|
|
|
|
return 1;
|
|
|
|
} catch (LockedException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return 2;
|
|
|
|
} catch (RateLimitException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return 3;
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Integer result) {
|
|
|
|
pinButton.setIndeterminateProgressMode(false);
|
|
|
|
pinButton.setProgress(0);
|
|
|
|
|
|
|
|
if (result == 1) {
|
|
|
|
TextSecurePreferences.setRegistrationLockPin(RegistrationActivity.this, pin);
|
|
|
|
TextSecurePreferences.setRegistrationtLockEnabled(RegistrationActivity.this, true);
|
|
|
|
handleSuccessfulRegistration();
|
|
|
|
} else if (result == 2) {
|
|
|
|
RegistrationActivity.this.pin.setText("");
|
|
|
|
Toast.makeText(RegistrationActivity.this, R.string.RegistrationActivity_incorrect_registration_lock_pin, Toast.LENGTH_LONG).show();
|
|
|
|
} else if (result == 3) {
|
|
|
|
new AlertDialog.Builder(RegistrationActivity.this)
|
|
|
|
.setTitle(R.string.RegistrationActivity_too_many_attempts)
|
|
|
|
.setMessage(R.string.RegistrationActivity_you_have_made_too_many_incorrect_registration_lock_pin_attempts_please_try_again_in_a_day)
|
|
|
|
.setPositiveButton(android.R.string.ok, null)
|
|
|
|
.show();
|
|
|
|
} else if (result == 4) {
|
|
|
|
Toast.makeText(RegistrationActivity.this, R.string.RegistrationActivity_error_connecting_to_service, Toast.LENGTH_LONG).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleForgottenPin(long timeRemaining) {
|
|
|
|
new AlertDialog.Builder(RegistrationActivity.this)
|
|
|
|
.setTitle(R.string.RegistrationActivity_oh_no)
|
|
|
|
.setMessage(getString(R.string.RegistrationActivity_registration_of_this_phone_number_will_be_possible_without_your_registration_lock_pin_after_seven_days_have_passed, (TimeUnit.MILLISECONDS.toDays(timeRemaining) + 1)))
|
|
|
|
.setPositiveButton(android.R.string.ok, null)
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private void handlePhoneCallRequest() {
|
|
|
|
if (registrationState.state == RegistrationState.State.VERIFYING) {
|
|
|
|
callMeCountDownView.startCountDown(300);
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
2017-02-20 20:00:03 +00:00
|
|
|
@Override
|
2017-11-08 20:20:11 +00:00
|
|
|
protected Void doInBackground(Void... voids) {
|
|
|
|
try {
|
|
|
|
accountManager.requestVoiceVerificationCode();
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2017-02-20 20:00:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2017-02-20 20:00:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
}
|
2017-02-20 20:00:03 +00:00
|
|
|
|
2018-03-01 17:51:37 +00:00
|
|
|
private void verifyAccount(@NonNull String code, @Nullable String pin) throws IOException {
|
|
|
|
int registrationId = KeyHelper.generateRegistrationId(false);
|
|
|
|
TextSecurePreferences.setLocalRegistrationId(RegistrationActivity.this, registrationId);
|
|
|
|
SessionUtil.archiveAllSessions(RegistrationActivity.this);
|
|
|
|
|
|
|
|
String signalingKey = Util.getSecret(52);
|
|
|
|
|
|
|
|
accountManager.verifyAccountWithCode(code, signalingKey, registrationId, !registrationState.gcmToken.isPresent(), pin);
|
|
|
|
|
|
|
|
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(RegistrationActivity.this);
|
|
|
|
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(RegistrationActivity.this);
|
|
|
|
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(RegistrationActivity.this, identityKey, true);
|
|
|
|
|
|
|
|
accountManager.setPreKeys(identityKey.getPublicKey(), signedPreKey, records);
|
|
|
|
|
|
|
|
if (registrationState.gcmToken.isPresent()) {
|
|
|
|
accountManager.setGcmId(registrationState.gcmToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextSecurePreferences.setGcmRegistrationId(RegistrationActivity.this, registrationState.gcmToken.orNull());
|
|
|
|
TextSecurePreferences.setGcmDisabled(RegistrationActivity.this, !registrationState.gcmToken.isPresent());
|
|
|
|
TextSecurePreferences.setWebsocketRegistered(RegistrationActivity.this, true);
|
|
|
|
|
|
|
|
DatabaseFactory.getIdentityDatabase(RegistrationActivity.this)
|
|
|
|
.saveIdentity(Address.fromSerialized(registrationState.e164number),
|
|
|
|
identityKey.getPublicKey(), IdentityDatabase.VerifiedStatus.VERIFIED,
|
|
|
|
true, System.currentTimeMillis(), true);
|
|
|
|
|
|
|
|
TextSecurePreferences.setVerifying(RegistrationActivity.this, false);
|
|
|
|
TextSecurePreferences.setPushRegistered(RegistrationActivity.this, true);
|
|
|
|
TextSecurePreferences.setLocalNumber(RegistrationActivity.this, registrationState.e164number);
|
|
|
|
TextSecurePreferences.setPushServerPassword(RegistrationActivity.this, registrationState.password);
|
|
|
|
TextSecurePreferences.setSignalingKey(RegistrationActivity.this, signalingKey);
|
|
|
|
TextSecurePreferences.setSignedPreKeyRegistered(RegistrationActivity.this, true);
|
|
|
|
TextSecurePreferences.setPromptedPushRegistration(RegistrationActivity.this, true);
|
|
|
|
TextSecurePreferences.setUnauthorizedReceived(RegistrationActivity.this, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleSuccessfulRegistration() {
|
|
|
|
ApplicationContext.getInstance(RegistrationActivity.this).getJobManager().add(new DirectoryRefreshJob(RegistrationActivity.this, false));
|
|
|
|
|
|
|
|
DirectoryRefreshListener.schedule(RegistrationActivity.this);
|
|
|
|
RotateSignedPreKeyListener.schedule(RegistrationActivity.this);
|
|
|
|
|
|
|
|
Intent nextIntent = getIntent().getParcelableExtra("next_intent");
|
|
|
|
|
|
|
|
if (nextIntent == null) {
|
|
|
|
nextIntent = new Intent(RegistrationActivity.this, ConversationListActivity.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
startActivity(nextIntent);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
private void displayRestoreView(@NonNull BackupUtil.BackupInfo backup) {
|
2017-11-08 20:20:11 +00:00
|
|
|
title.animate().translationX(title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2018-02-26 17:58:18 +00:00
|
|
|
title.setText(R.string.RegistrationActivity_restore_from_backup);
|
2017-11-08 20:20:11 +00:00
|
|
|
title.clearAnimation();
|
|
|
|
title.setTranslationX(-1 * title.getWidth());
|
|
|
|
title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
2017-02-20 20:00:03 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
subtitle.animate().translationX(subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2018-02-26 17:58:18 +00:00
|
|
|
subtitle.setText(R.string.RegistrationActivity_restore_your_messages_and_media_from_a_local_backup);
|
2017-11-08 20:20:11 +00:00
|
|
|
subtitle.clearAnimation();
|
|
|
|
subtitle.setTranslationX(-1 * subtitle.getWidth());
|
|
|
|
subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
2017-02-20 20:00:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
}).start();
|
2017-02-20 20:00:03 +00:00
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
registrationContainer.animate().translationX(registrationContainer.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
registrationContainer.clearAnimation();
|
|
|
|
registrationContainer.setVisibility(View.INVISIBLE);
|
|
|
|
registrationContainer.setTranslationX(0);
|
|
|
|
|
|
|
|
restoreContainer.setTranslationX(-1 * registrationContainer.getWidth());
|
|
|
|
restoreContainer.setVisibility(View.VISIBLE);
|
|
|
|
restoreButton.setProgress(0);
|
|
|
|
restoreButton.setIndeterminateProgressMode(false);
|
|
|
|
restoreButton.setOnClickListener(v -> handleRestore(backup));
|
|
|
|
restoreBackupSize.setText(getString(R.string.RegistrationActivity_backup_size_s, Util.getPrettyFileSize(backup.getSize())));
|
|
|
|
restoreBackupTime.setText(getString(R.string.RegistrationActivity_backup_timestamp_s, DateUtils.getExtendedRelativeTimeSpanString(RegistrationActivity.this, Locale.US, backup.getTimestamp())));
|
|
|
|
restoreBackupProgress.setText("");
|
|
|
|
restoreContainer.animate().translationX(0).setDuration(SCENE_TRANSITION_DURATION).setListener(null).setInterpolator(new OvershootInterpolator()).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
fab.animate().rotationBy(375f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
fab.clearAnimation();
|
|
|
|
fab.setImageResource(R.drawable.ic_restore_white_24dp);
|
|
|
|
fab.animate().rotationBy(360f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayInitialView(boolean forwards) {
|
|
|
|
int startDirectionMultiplier = forwards ? -1 : 1;
|
|
|
|
int endDirectionMultiplier = forwards ? 1 : -1;
|
|
|
|
|
|
|
|
title.animate().translationX(startDirectionMultiplier * title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
title.setText(R.string.registration_activity__verify_your_number);
|
|
|
|
title.clearAnimation();
|
|
|
|
title.setTranslationX(endDirectionMultiplier * title.getWidth());
|
|
|
|
title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
subtitle.animate().translationX(startDirectionMultiplier * subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
subtitle.setText(R.string.registration_activity__please_enter_your_mobile_number_to_receive_a_verification_code_carrier_rates_may_apply);
|
|
|
|
subtitle.clearAnimation();
|
|
|
|
subtitle.setTranslationX(endDirectionMultiplier * subtitle.getWidth());
|
|
|
|
subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
View container;
|
|
|
|
|
|
|
|
if (verificationContainer.getVisibility() == View.VISIBLE) container = verificationContainer;
|
|
|
|
else container = restoreContainer;
|
|
|
|
|
|
|
|
container.animate().translationX(startDirectionMultiplier * container.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
2017-11-08 20:20:11 +00:00
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2018-02-26 17:58:18 +00:00
|
|
|
container.clearAnimation();
|
|
|
|
container.setVisibility(View.INVISIBLE);
|
|
|
|
container.setTranslationX(0);
|
2017-11-08 20:20:11 +00:00
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
registrationContainer.setTranslationX(endDirectionMultiplier * registrationContainer.getWidth());
|
2017-11-08 20:20:11 +00:00
|
|
|
registrationContainer.setVisibility(View.VISIBLE);
|
|
|
|
createButton.setProgress(0);
|
|
|
|
createButton.setIndeterminateProgressMode(false);
|
|
|
|
registrationContainer.animate().translationX(0).setDuration(SCENE_TRANSITION_DURATION).setListener(null).setInterpolator(new OvershootInterpolator()).start();
|
|
|
|
}
|
|
|
|
}).start();
|
2017-02-20 20:00:03 +00:00
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
fab.animate().rotationBy(startDirectionMultiplier * 360f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
2017-11-08 20:20:11 +00:00
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
fab.clearAnimation();
|
|
|
|
fab.setImageResource(R.drawable.ic_action_name);
|
2018-02-26 17:58:18 +00:00
|
|
|
fab.animate().rotationBy(startDirectionMultiplier * 375f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
|
2017-11-08 20:20:11 +00:00
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}
|
2017-06-02 16:59:23 +00:00
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private void displayVerificationView(@NonNull String e164number, int callCountdown) {
|
|
|
|
ServiceUtil.getInputMethodManager(this)
|
|
|
|
.hideSoftInputFromWindow(countryCode.getWindowToken(), 0);
|
|
|
|
|
|
|
|
ServiceUtil.getInputMethodManager(this)
|
|
|
|
.hideSoftInputFromWindow(number.getWindowToken(), 0);
|
|
|
|
|
|
|
|
title.animate().translationX(-1 * title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2018-02-26 17:58:18 +00:00
|
|
|
title.setText(getString(R.string.RegistrationActivity_verify_s, e164number));
|
2017-11-08 20:20:11 +00:00
|
|
|
title.clearAnimation();
|
|
|
|
title.setTranslationX(title.getWidth());
|
|
|
|
title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
subtitle.animate().translationX(-1 * subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2018-02-26 17:58:18 +00:00
|
|
|
SpannableString subtitleDescription = new SpannableString(getString(R.string.RegistrationActivity_please_enter_the_verification_code_sent_to_s, e164number));
|
|
|
|
SpannableString wrongNumber = new SpannableString(getString(R.string.RegistrationActivity_wrong_number));
|
2017-11-08 20:20:11 +00:00
|
|
|
|
|
|
|
ClickableSpan clickableSpan = new ClickableSpan() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View widget) {
|
2018-02-26 17:58:18 +00:00
|
|
|
displayInitialView(false);
|
2017-11-08 20:20:11 +00:00
|
|
|
registrationState = new RegistrationState(RegistrationState.State.INITIAL, null, null, null);
|
2017-06-02 16:59:23 +00:00
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
@Override
|
|
|
|
public void updateDrawState(TextPaint paint) {
|
|
|
|
paint.setColor(Color.WHITE);
|
|
|
|
paint.setUnderlineText(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
wrongNumber.setSpan(clickableSpan, 0, wrongNumber.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
|
|
subtitle.setText(new SpannableStringBuilder(subtitleDescription).append(" ").append(wrongNumber));
|
|
|
|
subtitle.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
subtitle.clearAnimation();
|
|
|
|
subtitle.setTranslationX(subtitle.getWidth());
|
|
|
|
subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
registrationContainer.animate().translationX(-1 * registrationContainer.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
registrationContainer.clearAnimation();
|
|
|
|
registrationContainer.setVisibility(View.INVISIBLE);
|
|
|
|
registrationContainer.setTranslationX(0);
|
|
|
|
|
|
|
|
verificationContainer.setTranslationX(verificationContainer.getWidth());
|
|
|
|
verificationContainer.setVisibility(View.VISIBLE);
|
|
|
|
verificationContainer.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
fab.animate().rotationBy(-360f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
fab.clearAnimation();
|
|
|
|
fab.setImageResource(R.drawable.ic_textsms_24dp);
|
|
|
|
fab.animate().rotationBy(-375f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
|
2017-02-20 20:00:03 +00:00
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
}).start();
|
|
|
|
|
|
|
|
this.callMeCountDownView.startCountDown(callCountdown);
|
|
|
|
}
|
|
|
|
|
2018-03-01 17:51:37 +00:00
|
|
|
private void displayPinView(String code, long lockedUntil) {
|
|
|
|
title.animate().translationX(-1 * title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
title.setText(R.string.RegistrationActivity_registration_lock_pin);
|
|
|
|
title.clearAnimation();
|
|
|
|
title.setTranslationX(title.getWidth());
|
|
|
|
title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
subtitle.animate().translationX(-1 * subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
subtitle.setText(R.string.RegistrationActivity_this_phone_number_has_registration_lock_enabled_please_enter_the_registration_lock_pin);
|
|
|
|
subtitle.clearAnimation();
|
|
|
|
subtitle.setTranslationX(subtitle.getWidth());
|
|
|
|
subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
verificationContainer.animate().translationX(-1 * verificationContainer.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
verificationContainer.clearAnimation();
|
|
|
|
verificationContainer.setVisibility(View.INVISIBLE);
|
|
|
|
verificationContainer.setTranslationX(0);
|
|
|
|
|
|
|
|
pinContainer.setTranslationX(pinContainer.getWidth());
|
|
|
|
pinContainer.setVisibility(View.VISIBLE);
|
|
|
|
pinContainer.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
fab.animate().rotationBy(-360f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
fab.clearAnimation();
|
|
|
|
fab.setImageResource(R.drawable.ic_lock_white_24dp);
|
|
|
|
fab.animate().rotationBy(-360f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
pinButton.setOnClickListener(v -> handleVerifyWithPinClicked(code, pin.getText().toString()));
|
|
|
|
pinForgotButton.setOnClickListener(v -> handleForgottenPin(lockedUntil));
|
|
|
|
pin.addTextChangedListener(new TextWatcher() {
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
if (s != null && code.equals(s.toString())) pinClarificationContainer.setVisibility(View.VISIBLE);
|
|
|
|
else if (pinClarificationContainer.getVisibility() == View.VISIBLE) pinClarificationContainer.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private void handleCancel() {
|
|
|
|
TextSecurePreferences.setPromptedPushRegistration(RegistrationActivity.this, true);
|
|
|
|
Intent nextIntent = getIntent().getParcelableExtra("next_intent");
|
|
|
|
|
|
|
|
if (nextIntent == null) {
|
|
|
|
nextIntent = new Intent(RegistrationActivity.this, ConversationListActivity.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
startActivity(nextIntent);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handlePromptForNoPlayServices(@NonNull String e164number) {
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
|
|
|
dialog.setTitle(R.string.RegistrationActivity_missing_google_play_services);
|
|
|
|
dialog.setMessage(R.string.RegistrationActivity_this_device_is_missing_google_play_services);
|
|
|
|
dialog.setPositiveButton(R.string.RegistrationActivity_i_understand, (dialog1, which) -> handleRequestVerification(e164number, false));
|
|
|
|
dialog.setNegativeButton(android.R.string.cancel, null);
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initializeChallengeListener() {
|
|
|
|
challengeReceiver = new ChallengeReceiver();
|
|
|
|
IntentFilter filter = new IntentFilter(CHALLENGE_EVENT);
|
|
|
|
registerReceiver(challengeReceiver, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void shutdownChallengeListener() {
|
|
|
|
if (challengeReceiver != null) {
|
|
|
|
unregisterReceiver(challengeReceiver);
|
|
|
|
challengeReceiver = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void markAsVerifying(boolean verifying) {
|
|
|
|
TextSecurePreferences.setVerifying(this, verifying);
|
|
|
|
|
|
|
|
if (verifying) {
|
|
|
|
TextSecurePreferences.setPushRegistered(this, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
public void onEvent(FullBackupBase.BackupEvent event) {
|
|
|
|
if (event.getCount() == 0) restoreBackupProgress.setText(R.string.RegistrationActivity_checking);
|
|
|
|
else restoreBackupProgress.setText(getString(R.string.RegistrationActivity_d_messages_so_far, event.getCount()));
|
|
|
|
}
|
|
|
|
|
2017-11-08 20:20:11 +00:00
|
|
|
private class ChallengeReceiver extends BroadcastReceiver {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Log.w(TAG, "Got a challenge broadcast...");
|
|
|
|
handleChallengeReceived(intent.getStringExtra(CHALLENGE_EXTRA));
|
2017-02-20 20:00:03 +00:00
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class CountryCodeChangedListener implements TextWatcher {
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
2017-08-07 19:40:40 +00:00
|
|
|
if (TextUtils.isEmpty(s) || !TextUtils.isDigitsOnly(s)) {
|
2013-07-09 23:36:15 +00:00
|
|
|
setCountryDisplay(getString(R.string.RegistrationActivity_select_your_country));
|
2013-03-26 04:26:03 +00:00
|
|
|
countryFormatter = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int countryCode = Integer.parseInt(s.toString());
|
|
|
|
String regionCode = PhoneNumberUtil.getInstance().getRegionCodeForCountryCode(countryCode);
|
2013-07-09 23:36:15 +00:00
|
|
|
|
2013-03-26 04:26:03 +00:00
|
|
|
setCountryFormatter(countryCode);
|
|
|
|
setCountryDisplay(PhoneNumberFormatter.getRegionDisplayName(regionCode));
|
|
|
|
|
2014-11-12 19:15:05 +00:00
|
|
|
if (!TextUtils.isEmpty(regionCode) && !regionCode.equals("ZZ")) {
|
2013-03-26 04:26:03 +00:00
|
|
|
number.requestFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class NumberChangedListener implements TextWatcher {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
if (countryFormatter == null)
|
|
|
|
return;
|
|
|
|
|
2014-11-12 19:15:05 +00:00
|
|
|
if (TextUtils.isEmpty(s))
|
2013-03-26 04:26:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
countryFormatter.clear();
|
|
|
|
|
|
|
|
String number = s.toString().replaceAll("[^\\d.]", "");
|
|
|
|
String formattedNumber = null;
|
|
|
|
|
|
|
|
for (int i=0;i<number.length();i++) {
|
|
|
|
formattedNumber = countryFormatter.inputDigit(number.charAt(i));
|
|
|
|
}
|
|
|
|
|
2014-05-08 22:18:35 +00:00
|
|
|
if (formattedNumber != null && !s.toString().equals(formattedNumber)) {
|
2013-03-26 04:26:03 +00:00
|
|
|
s.replace(0, s.length(), formattedNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2013-07-11 21:58:40 +00:00
|
|
|
|
2017-03-31 01:18:04 +00:00
|
|
|
private class InformationToggleListener implements View.OnClickListener {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
if (informationView.getVisibility() == View.VISIBLE) {
|
|
|
|
informationView.setVisibility(View.GONE);
|
|
|
|
informationToggleText.setText(R.string.RegistrationActivity_more_information);
|
|
|
|
} else {
|
|
|
|
informationView.setVisibility(View.VISIBLE);
|
|
|
|
informationToggleText.setText(R.string.RegistrationActivity_less_information);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-11-08 20:20:11 +00:00
|
|
|
|
|
|
|
private static class RegistrationState {
|
|
|
|
private enum State {
|
2018-03-01 17:51:37 +00:00
|
|
|
INITIAL, VERIFYING, CHECKING, PIN
|
2017-11-08 20:20:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final State state;
|
|
|
|
private final String e164number;
|
|
|
|
private final String password;
|
|
|
|
private final Optional<String> gcmToken;
|
|
|
|
|
|
|
|
RegistrationState(State state, String e164number, String password, Optional<String> gcmToken) {
|
|
|
|
this.state = state;
|
|
|
|
this.e164number = e164number;
|
|
|
|
this.password = password;
|
|
|
|
this.gcmToken = gcmToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegistrationState(State state, RegistrationState previous) {
|
|
|
|
this.state = state;
|
|
|
|
this.e164number = previous.e164number;
|
|
|
|
this.password = previous.password;
|
|
|
|
this.gcmToken = previous.gcmToken;
|
|
|
|
}
|
|
|
|
}
|
2013-03-26 04:26:03 +00:00
|
|
|
}
|