added all callbacks to sign up activities
This commit is contained in:
		
							parent
							
								
									2fa629d113
								
							
						
					
					
						commit
						584cf43b3d
					
				@ -761,10 +761,11 @@
 | 
				
			|||||||
    <string name="search_countries">Search countries</string>
 | 
					    <string name="search_countries">Search countries</string>
 | 
				
			||||||
    <string name="verify_x">Verify %s</string>
 | 
					    <string name="verify_x">Verify %s</string>
 | 
				
			||||||
    <string name="we_have_sent_you_an_sms_to_x"><![CDATA[We have sent you an SMS to <b>%s</b>.]]></string>
 | 
					    <string name="we_have_sent_you_an_sms_to_x"><![CDATA[We have sent you an SMS to <b>%s</b>.]]></string>
 | 
				
			||||||
    <string name="we_have_sent_you_the_sms_again">We have sent you the SMS again.</string>
 | 
					    <string name="we_have_sent_you_another_sms">We have sent you another SMS with a 6 digit code.</string>
 | 
				
			||||||
    <string name="please_enter_pin_below">Please enter the 6 digit pin below.</string>
 | 
					    <string name="please_enter_pin_below">Please enter the 6 digit pin below.</string>
 | 
				
			||||||
    <string name="resend_sms">Resend SMS</string>
 | 
					    <string name="resend_sms">Resend SMS</string>
 | 
				
			||||||
    <string name="resend_sms_in">Resend SMS (%s)</string>
 | 
					    <string name="resend_sms_in">Resend SMS (%s)</string>
 | 
				
			||||||
 | 
					    <string name="wait_x">Please wait (%s)</string>
 | 
				
			||||||
    <string name="back">back</string>
 | 
					    <string name="back">back</string>
 | 
				
			||||||
    <string name="possible_pin">Automatically pasted possible pin from clipboard.</string>
 | 
					    <string name="possible_pin">Automatically pasted possible pin from clipboard.</string>
 | 
				
			||||||
    <string name="please_enter_pin">Please enter your 6 digit pin.</string>
 | 
					    <string name="please_enter_pin">Please enter your 6 digit pin.</string>
 | 
				
			||||||
@ -773,4 +774,13 @@
 | 
				
			|||||||
    <string name="no">No</string>
 | 
					    <string name="no">No</string>
 | 
				
			||||||
    <string name="verifying">Verifying…</string>
 | 
					    <string name="verifying">Verifying…</string>
 | 
				
			||||||
    <string name="requesting_sms">Requesting SMS…</string>
 | 
					    <string name="requesting_sms">Requesting SMS…</string>
 | 
				
			||||||
 | 
					    <string name="incorrect_pin">The pin you have entered is incorrect.</string>
 | 
				
			||||||
 | 
					    <string name="unknown_api_error_network">Unknown network error.</string>
 | 
				
			||||||
 | 
					    <string name="unknown_api_error_response">Unknown response from server.</string>
 | 
				
			||||||
 | 
					    <string name="unable_to_connect_to_server">Unable to connect to server.</string>
 | 
				
			||||||
 | 
					    <string name="unable_to_establish_secure_connection">Unable to establish secure connection.</string>
 | 
				
			||||||
 | 
					    <string name="unable_to_find_server">Unable to find server.</string>
 | 
				
			||||||
 | 
					    <string name="invalid_user_input">Invalid user input</string>
 | 
				
			||||||
 | 
					    <string name="temporarily_unavailable">Temporarily unavailable. Try again later.</string>
 | 
				
			||||||
 | 
					    <string name="no_network_connection">No network connection.</string>
 | 
				
			||||||
</resources>
 | 
					</resources>
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,8 @@ import java.util.Set;
 | 
				
			|||||||
import java.util.WeakHashMap;
 | 
					import java.util.WeakHashMap;
 | 
				
			||||||
import java.util.concurrent.atomic.AtomicBoolean;
 | 
					import java.util.concurrent.atomic.AtomicBoolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.net.ssl.SSLHandshakeException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eu.siacs.conversations.Config;
 | 
					import eu.siacs.conversations.Config;
 | 
				
			||||||
import eu.siacs.conversations.crypto.sasl.Plain;
 | 
					import eu.siacs.conversations.crypto.sasl.Plain;
 | 
				
			||||||
import eu.siacs.conversations.entities.Account;
 | 
					import eu.siacs.conversations.entities.Account;
 | 
				
			||||||
@ -33,8 +35,10 @@ public class QuickConversationsService {
 | 
				
			|||||||
    public static final int API_ERROR_OTHER = -1;
 | 
					    public static final int API_ERROR_OTHER = -1;
 | 
				
			||||||
    public static final int API_ERROR_UNKNOWN_HOST = -2;
 | 
					    public static final int API_ERROR_UNKNOWN_HOST = -2;
 | 
				
			||||||
    public static final int API_ERROR_CONNECT = -3;
 | 
					    public static final int API_ERROR_CONNECT = -3;
 | 
				
			||||||
 | 
					    public static final int API_ERROR_SSL_HANDSHAKE = -4;
 | 
				
			||||||
 | 
					    public static final int API_ERROR_AIRPLANE_MODE = -5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static final String BASE_URL = "https://venus.fritz.box:4567";
 | 
					    private static final String BASE_URL = "http://venus.fritz.box:4567";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final XmppConnectionService service;
 | 
					    private final XmppConnectionService service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -145,7 +149,7 @@ public class QuickConversationsService {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void verify(Account account, String pin) {
 | 
					    public void verify(final Account account, String pin) {
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * POST /password
 | 
					         * POST /password
 | 
				
			||||||
         * authentication gesetzt mit telephone nummber und verification code
 | 
					         * authentication gesetzt mit telephone nummber und verification code
 | 
				
			||||||
@ -177,6 +181,9 @@ public class QuickConversationsService {
 | 
				
			|||||||
                    connection.connect();
 | 
					                    connection.connect();
 | 
				
			||||||
                    final int code = connection.getResponseCode();
 | 
					                    final int code = connection.getResponseCode();
 | 
				
			||||||
                    if (code == 200) {
 | 
					                    if (code == 200) {
 | 
				
			||||||
 | 
					                        account.setOption(Account.OPTION_UNVERIFIED, false);
 | 
				
			||||||
 | 
					                        account.setOption(Account.OPTION_DISABLED, false);
 | 
				
			||||||
 | 
					                        service.updateAccount(account);
 | 
				
			||||||
                        synchronized (mOnVerification) {
 | 
					                        synchronized (mOnVerification) {
 | 
				
			||||||
                            for (OnVerification onVerification : mOnVerification) {
 | 
					                            for (OnVerification onVerification : mOnVerification) {
 | 
				
			||||||
                                onVerification.onVerificationSucceeded();
 | 
					                                onVerification.onVerificationSucceeded();
 | 
				
			||||||
@ -210,11 +217,15 @@ public class QuickConversationsService {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static int getApiErrorCode(Exception e) {
 | 
					    private int getApiErrorCode(Exception e) {
 | 
				
			||||||
        if (e instanceof UnknownHostException) {
 | 
					        if (!service.hasInternetConnection()) {
 | 
				
			||||||
 | 
					            return API_ERROR_AIRPLANE_MODE;
 | 
				
			||||||
 | 
					        } else if (e instanceof UnknownHostException) {
 | 
				
			||||||
            return API_ERROR_UNKNOWN_HOST;
 | 
					            return API_ERROR_UNKNOWN_HOST;
 | 
				
			||||||
        } else if (e instanceof ConnectException) {
 | 
					        } else if (e instanceof ConnectException) {
 | 
				
			||||||
            return API_ERROR_CONNECT;
 | 
					            return API_ERROR_CONNECT;
 | 
				
			||||||
 | 
					        } else if (e instanceof SSLHandshakeException) {
 | 
				
			||||||
 | 
					            return API_ERROR_SSL_HANDSHAKE;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Log.d(Config.LOGTAG,e.getClass().getName());
 | 
					            Log.d(Config.LOGTAG,e.getClass().getName());
 | 
				
			||||||
            return API_ERROR_OTHER;
 | 
					            return API_ERROR_OTHER;
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@ import eu.siacs.conversations.R;
 | 
				
			|||||||
import eu.siacs.conversations.databinding.ActivityEnterNumberBinding;
 | 
					import eu.siacs.conversations.databinding.ActivityEnterNumberBinding;
 | 
				
			||||||
import eu.siacs.conversations.services.QuickConversationsService;
 | 
					import eu.siacs.conversations.services.QuickConversationsService;
 | 
				
			||||||
import eu.siacs.conversations.ui.drawable.TextDrawable;
 | 
					import eu.siacs.conversations.ui.drawable.TextDrawable;
 | 
				
			||||||
 | 
					import eu.siacs.conversations.ui.util.ApiErrorDialogHelper;
 | 
				
			||||||
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
 | 
					import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
 | 
				
			||||||
import io.michaelrocks.libphonenumber.android.NumberParseException;
 | 
					import io.michaelrocks.libphonenumber.android.NumberParseException;
 | 
				
			||||||
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil;
 | 
					import io.michaelrocks.libphonenumber.android.PhoneNumberUtil;
 | 
				
			||||||
@ -32,8 +33,6 @@ public class EnterPhoneNumberActivity extends XmppActivity implements QuickConve
 | 
				
			|||||||
    private ActivityEnterNumberBinding binding;
 | 
					    private ActivityEnterNumberBinding binding;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String region = null;
 | 
					    private String region = null;
 | 
				
			||||||
    private boolean requestingVerification = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final TextWatcher countryCodeTextWatcher = new TextWatcher() {
 | 
					    private final TextWatcher countryCodeTextWatcher = new TextWatcher() {
 | 
				
			||||||
        @Override
 | 
					        @Override
 | 
				
			||||||
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 | 
					        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 | 
				
			||||||
@ -65,6 +64,7 @@ public class EnterPhoneNumberActivity extends XmppActivity implements QuickConve
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					    private boolean requestingVerification = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void refreshUiReal() {
 | 
					    protected void refreshUiReal() {
 | 
				
			||||||
@ -159,6 +159,8 @@ public class EnterPhoneNumberActivity extends XmppActivity implements QuickConve
 | 
				
			|||||||
        this.binding.number.setEnabled(!requesting);
 | 
					        this.binding.number.setEnabled(!requesting);
 | 
				
			||||||
        this.binding.next.setEnabled(!requesting);
 | 
					        this.binding.next.setEnabled(!requesting);
 | 
				
			||||||
        this.binding.next.setText(requesting ? R.string.requesting_sms : R.string.next);
 | 
					        this.binding.next.setText(requesting ? R.string.requesting_sms : R.string.next);
 | 
				
			||||||
 | 
					        this.binding.progressBar.setVisibility(requesting ? View.VISIBLE : View.GONE);
 | 
				
			||||||
 | 
					        this.binding.progressBar.setIndeterminate(requesting);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@ -178,6 +180,7 @@ public class EnterPhoneNumberActivity extends XmppActivity implements QuickConve
 | 
				
			|||||||
    public void onVerificationRequestFailed(int code) {
 | 
					    public void onVerificationRequestFailed(int code) {
 | 
				
			||||||
        runOnUiThread(() -> {
 | 
					        runOnUiThread(() -> {
 | 
				
			||||||
            setRequestingVerificationState(false);
 | 
					            setRequestingVerificationState(false);
 | 
				
			||||||
 | 
					            ApiErrorDialogHelper.create(this, code).show();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -13,14 +13,13 @@ import android.os.SystemClock;
 | 
				
			|||||||
import android.support.design.widget.Snackbar;
 | 
					import android.support.design.widget.Snackbar;
 | 
				
			||||||
import android.support.v7.widget.Toolbar;
 | 
					import android.support.v7.widget.Toolbar;
 | 
				
			||||||
import android.text.Html;
 | 
					import android.text.Html;
 | 
				
			||||||
import android.util.Log;
 | 
					 | 
				
			||||||
import android.view.View;
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eu.siacs.conversations.Config;
 | 
					 | 
				
			||||||
import eu.siacs.conversations.R;
 | 
					import eu.siacs.conversations.R;
 | 
				
			||||||
import eu.siacs.conversations.databinding.ActivityVerifyBinding;
 | 
					import eu.siacs.conversations.databinding.ActivityVerifyBinding;
 | 
				
			||||||
import eu.siacs.conversations.entities.Account;
 | 
					import eu.siacs.conversations.entities.Account;
 | 
				
			||||||
import eu.siacs.conversations.services.QuickConversationsService;
 | 
					import eu.siacs.conversations.services.QuickConversationsService;
 | 
				
			||||||
 | 
					import eu.siacs.conversations.ui.util.ApiErrorDialogHelper;
 | 
				
			||||||
import eu.siacs.conversations.ui.util.PinEntryWrapper;
 | 
					import eu.siacs.conversations.ui.util.PinEntryWrapper;
 | 
				
			||||||
import eu.siacs.conversations.utils.AccountUtils;
 | 
					import eu.siacs.conversations.utils.AccountUtils;
 | 
				
			||||||
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
 | 
					import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
 | 
				
			||||||
@ -32,7 +31,8 @@ import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
 | 
				
			|||||||
public class VerifyActivity extends XmppActivity implements ClipboardManager.OnPrimaryClipChangedListener, QuickConversationsService.OnVerification, QuickConversationsService.OnVerificationRequested {
 | 
					public class VerifyActivity extends XmppActivity implements ClipboardManager.OnPrimaryClipChangedListener, QuickConversationsService.OnVerification, QuickConversationsService.OnVerificationRequested {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static final String EXTRA_RETRY_SMS_AFTER = "retry_sms_after";
 | 
					    public static final String EXTRA_RETRY_SMS_AFTER = "retry_sms_after";
 | 
				
			||||||
 | 
					    private static final String EXTRA_RETRY_VERIFICATION_AFTER = "retry_verification_after";
 | 
				
			||||||
 | 
					    private final Handler mHandler = new Handler();
 | 
				
			||||||
    private ActivityVerifyBinding binding;
 | 
					    private ActivityVerifyBinding binding;
 | 
				
			||||||
    private Account account;
 | 
					    private Account account;
 | 
				
			||||||
    private PinEntryWrapper pinEntryWrapper;
 | 
					    private PinEntryWrapper pinEntryWrapper;
 | 
				
			||||||
@ -41,10 +41,6 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
    private boolean verifying = false;
 | 
					    private boolean verifying = false;
 | 
				
			||||||
    private boolean requestingVerification = false;
 | 
					    private boolean requestingVerification = false;
 | 
				
			||||||
    private long retrySmsAfter = 0;
 | 
					    private long retrySmsAfter = 0;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final Handler mHandler = new Handler();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final Runnable SMS_TIMEOUT_UPDATER = new Runnable() {
 | 
					    private final Runnable SMS_TIMEOUT_UPDATER = new Runnable() {
 | 
				
			||||||
        @Override
 | 
					        @Override
 | 
				
			||||||
        public void run() {
 | 
					        public void run() {
 | 
				
			||||||
@ -53,6 +49,15 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					    private long retryVerificationAfter = 0;
 | 
				
			||||||
 | 
					    private final Runnable VERIFICATION_TIMEOUT_UPDATER = new Runnable() {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void run() {
 | 
				
			||||||
 | 
					            if (setTimeoutLabelInNextButton()) {
 | 
				
			||||||
 | 
					                mHandler.postDelayed(this, 300);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean setTimeoutLabelInResendButton() {
 | 
					    private boolean setTimeoutLabelInResendButton() {
 | 
				
			||||||
        if (retrySmsAfter != 0) {
 | 
					        if (retrySmsAfter != 0) {
 | 
				
			||||||
@ -68,6 +73,20 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean setTimeoutLabelInNextButton() {
 | 
				
			||||||
 | 
					        if (retryVerificationAfter != 0) {
 | 
				
			||||||
 | 
					            long remaining = retryVerificationAfter - SystemClock.elapsedRealtime();
 | 
				
			||||||
 | 
					            if (remaining >= 0) {
 | 
				
			||||||
 | 
					                binding.next.setEnabled(false);
 | 
				
			||||||
 | 
					                binding.next.setText(getString(R.string.wait_x, TimeframeUtils.resolve(VerifyActivity.this, remaining)));
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        this.binding.next.setEnabled(!verifying);
 | 
				
			||||||
 | 
					        this.binding.next.setText(verifying ? R.string.verifying : R.string.next);
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onCreate(final Bundle savedInstanceState) {
 | 
					    protected void onCreate(final Bundle savedInstanceState) {
 | 
				
			||||||
        super.onCreate(savedInstanceState);
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
@ -76,6 +95,7 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
        boolean requestingVerification = savedInstanceState != null && savedInstanceState.getBoolean("requesting_verification", false);
 | 
					        boolean requestingVerification = savedInstanceState != null && savedInstanceState.getBoolean("requesting_verification", false);
 | 
				
			||||||
        this.pasted = savedInstanceState != null ? savedInstanceState.getString("pasted") : null;
 | 
					        this.pasted = savedInstanceState != null ? savedInstanceState.getString("pasted") : null;
 | 
				
			||||||
        this.retrySmsAfter = savedInstanceState != null ? savedInstanceState.getLong(EXTRA_RETRY_SMS_AFTER, 0L) : 0L;
 | 
					        this.retrySmsAfter = savedInstanceState != null ? savedInstanceState.getLong(EXTRA_RETRY_SMS_AFTER, 0L) : 0L;
 | 
				
			||||||
 | 
					        this.retryVerificationAfter = savedInstanceState != null ? savedInstanceState.getLong(EXTRA_RETRY_VERIFICATION_AFTER, 0L) : 0L;
 | 
				
			||||||
        this.binding = DataBindingUtil.setContentView(this, R.layout.activity_verify);
 | 
					        this.binding = DataBindingUtil.setContentView(this, R.layout.activity_verify);
 | 
				
			||||||
        setSupportActionBar((Toolbar) this.binding.toolbar);
 | 
					        setSupportActionBar((Toolbar) this.binding.toolbar);
 | 
				
			||||||
        this.pinEntryWrapper = new PinEntryWrapper(binding.pinBox);
 | 
					        this.pinEntryWrapper = new PinEntryWrapper(binding.pinBox);
 | 
				
			||||||
@ -182,6 +202,7 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
        savedInstanceState.putBoolean("verifying", this.verifying);
 | 
					        savedInstanceState.putBoolean("verifying", this.verifying);
 | 
				
			||||||
        savedInstanceState.putBoolean("requesting_verification", this.requestingVerification);
 | 
					        savedInstanceState.putBoolean("requesting_verification", this.requestingVerification);
 | 
				
			||||||
        savedInstanceState.putLong(EXTRA_RETRY_SMS_AFTER, this.retrySmsAfter);
 | 
					        savedInstanceState.putLong(EXTRA_RETRY_SMS_AFTER, this.retrySmsAfter);
 | 
				
			||||||
 | 
					        savedInstanceState.putLong(EXTRA_RETRY_VERIFICATION_AFTER, this.retryVerificationAfter);
 | 
				
			||||||
        if (this.pasted != null) {
 | 
					        if (this.pasted != null) {
 | 
				
			||||||
            savedInstanceState.putString("pasted", this.pasted);
 | 
					            savedInstanceState.putString("pasted", this.pasted);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -192,15 +213,21 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
    public void onStart() {
 | 
					    public void onStart() {
 | 
				
			||||||
        super.onStart();
 | 
					        super.onStart();
 | 
				
			||||||
        clipboardManager.addPrimaryClipChangedListener(this);
 | 
					        clipboardManager.addPrimaryClipChangedListener(this);
 | 
				
			||||||
 | 
					        final Intent intent = getIntent();
 | 
				
			||||||
 | 
					        this.retrySmsAfter = intent != null ? intent.getLongExtra(EXTRA_RETRY_SMS_AFTER, this.retrySmsAfter) : this.retrySmsAfter;
 | 
				
			||||||
        if (this.retrySmsAfter > 0) {
 | 
					        if (this.retrySmsAfter > 0) {
 | 
				
			||||||
            mHandler.post(SMS_TIMEOUT_UPDATER);
 | 
					            mHandler.post(SMS_TIMEOUT_UPDATER);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (this.retryVerificationAfter > 0) {
 | 
				
			||||||
 | 
					            mHandler.post(VERIFICATION_TIMEOUT_UPDATER);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onStop() {
 | 
					    public void onStop() {
 | 
				
			||||||
        super.onStop();
 | 
					        super.onStop();
 | 
				
			||||||
        mHandler.removeCallbacks(SMS_TIMEOUT_UPDATER);
 | 
					        mHandler.removeCallbacks(SMS_TIMEOUT_UPDATER);
 | 
				
			||||||
 | 
					        mHandler.removeCallbacks(VERIFICATION_TIMEOUT_UPDATER);
 | 
				
			||||||
        clipboardManager.removePrimaryClipChangedListener(this);
 | 
					        clipboardManager.removePrimaryClipChangedListener(this);
 | 
				
			||||||
        if (xmppConnectionService != null) {
 | 
					        if (xmppConnectionService != null) {
 | 
				
			||||||
            xmppConnectionService.getQuickConversationsService().removeOnVerificationListener(this);
 | 
					            xmppConnectionService.getQuickConversationsService().removeOnVerificationListener(this);
 | 
				
			||||||
@ -233,6 +260,14 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void performPostVerificationRedirect() {
 | 
				
			||||||
 | 
					        Intent intent = new Intent(this, PublishProfilePictureActivity.class);
 | 
				
			||||||
 | 
					        intent.putExtra(PublishProfilePictureActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
 | 
				
			||||||
 | 
					        intent.putExtra("setup", true);
 | 
				
			||||||
 | 
					        startActivity(intent);
 | 
				
			||||||
 | 
					        finish();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onPrimaryClipChanged() {
 | 
					    public void onPrimaryClipChanged() {
 | 
				
			||||||
        this.pasted = null;
 | 
					        this.pasted = null;
 | 
				
			||||||
@ -242,21 +277,31 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onVerificationFailed(int code) {
 | 
					    public void onVerificationFailed(final int code) {
 | 
				
			||||||
        runOnUiThread(() -> {
 | 
					        runOnUiThread(() -> {
 | 
				
			||||||
            setVerifyingState(false);
 | 
					            setVerifyingState(false);
 | 
				
			||||||
 | 
					            if (code == 401) {
 | 
				
			||||||
 | 
					                AlertDialog.Builder builder = new AlertDialog.Builder(this);
 | 
				
			||||||
 | 
					                builder.setMessage(R.string.incorrect_pin);
 | 
				
			||||||
 | 
					                builder.setPositiveButton(R.string.ok, null);
 | 
				
			||||||
 | 
					                builder.create().show();
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                ApiErrorDialogHelper.create(this, code).show();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        Log.d(Config.LOGTAG,"code="+code);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onVerificationSucceeded() {
 | 
					    public void onVerificationSucceeded() {
 | 
				
			||||||
 | 
					        runOnUiThread(this::performPostVerificationRedirect);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onVerificationRetryAt(long timestamp) {
 | 
					    public void onVerificationRetryAt(long timestamp) {
 | 
				
			||||||
 | 
					        this.retryVerificationAfter = timestamp;
 | 
				
			||||||
 | 
					        runOnUiThread(() -> setVerifyingState(false));
 | 
				
			||||||
 | 
					        mHandler.removeCallbacks(VERIFICATION_TIMEOUT_UPDATER);
 | 
				
			||||||
 | 
					        runOnUiThread(VERIFICATION_TIMEOUT_UPDATER);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //send sms again button callback
 | 
					    //send sms again button callback
 | 
				
			||||||
@ -264,8 +309,8 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
    public void onVerificationRequestFailed(int code) {
 | 
					    public void onVerificationRequestFailed(int code) {
 | 
				
			||||||
        runOnUiThread(() -> {
 | 
					        runOnUiThread(() -> {
 | 
				
			||||||
            setRequestingVerificationState(false);
 | 
					            setRequestingVerificationState(false);
 | 
				
			||||||
 | 
					            ApiErrorDialogHelper.create(this, code).show();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        Log.d(Config.LOGTAG,"code="+code);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //send sms again button callback
 | 
					    //send sms again button callback
 | 
				
			||||||
@ -274,7 +319,7 @@ public class VerifyActivity extends XmppActivity implements ClipboardManager.OnP
 | 
				
			|||||||
        runOnUiThread(() -> {
 | 
					        runOnUiThread(() -> {
 | 
				
			||||||
            setRequestingVerificationState(false);
 | 
					            setRequestingVerificationState(false);
 | 
				
			||||||
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
 | 
					            AlertDialog.Builder builder = new AlertDialog.Builder(this);
 | 
				
			||||||
            builder.setMessage(R.string.we_have_sent_you_the_sms_again);
 | 
					            builder.setMessage(R.string.we_have_sent_you_another_sms);
 | 
				
			||||||
            builder.setPositiveButton(R.string.ok, null);
 | 
					            builder.setPositiveButton(R.string.ok, null);
 | 
				
			||||||
            builder.create().show();
 | 
					            builder.create().show();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					package eu.siacs.conversations.ui.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.app.AlertDialog;
 | 
				
			||||||
 | 
					import android.app.Dialog;
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.support.annotation.StringRes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import eu.siacs.conversations.R;
 | 
				
			||||||
 | 
					import eu.siacs.conversations.services.QuickConversationsService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ApiErrorDialogHelper {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static Dialog create(Context context, int code) {
 | 
				
			||||||
 | 
					        @StringRes final int res;
 | 
				
			||||||
 | 
					        switch (code) {
 | 
				
			||||||
 | 
					            case QuickConversationsService.API_ERROR_AIRPLANE_MODE:
 | 
				
			||||||
 | 
					                res = R.string.no_network_connection;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case QuickConversationsService.API_ERROR_OTHER:
 | 
				
			||||||
 | 
					                res = R.string.unknown_api_error_network;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case QuickConversationsService.API_ERROR_CONNECT:
 | 
				
			||||||
 | 
					                res = R.string.unable_to_connect_to_server;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case QuickConversationsService.API_ERROR_SSL_HANDSHAKE:
 | 
				
			||||||
 | 
					                res = R.string.unable_to_establish_secure_connection;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case QuickConversationsService.API_ERROR_UNKNOWN_HOST:
 | 
				
			||||||
 | 
					                res = R.string.unable_to_find_server;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case 400:
 | 
				
			||||||
 | 
					                res = R.string.invalid_user_input;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case 502:
 | 
				
			||||||
 | 
					            case 503:
 | 
				
			||||||
 | 
					            case 504:
 | 
				
			||||||
 | 
					                res = R.string.temporarily_unavailable;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                res = R.string.unknown_api_error_response;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        AlertDialog.Builder builder = new AlertDialog.Builder(context);
 | 
				
			||||||
 | 
					        builder.setMessage(res);
 | 
				
			||||||
 | 
					        builder.setPositiveButton(R.string.ok, null);
 | 
				
			||||||
 | 
					        return builder.create();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -33,7 +33,7 @@
 | 
				
			|||||||
                <LinearLayout
 | 
					                <LinearLayout
 | 
				
			||||||
                    android:id="@+id/phone_number_box"
 | 
					                    android:id="@+id/phone_number_box"
 | 
				
			||||||
                    android:layout_width="256dp"
 | 
					                    android:layout_width="256dp"
 | 
				
			||||||
                    android:layout_height="match_parent"
 | 
					                    android:layout_height="wrap_content"
 | 
				
			||||||
                    android:layout_above="@+id/next"
 | 
					                    android:layout_above="@+id/next"
 | 
				
			||||||
                    android:layout_below="@+id/instructions"
 | 
					                    android:layout_below="@+id/instructions"
 | 
				
			||||||
                    android:layout_centerHorizontal="true"
 | 
					                    android:layout_centerHorizontal="true"
 | 
				
			||||||
@ -82,6 +82,13 @@
 | 
				
			|||||||
                            android:longClickable="false"
 | 
					                            android:longClickable="false"
 | 
				
			||||||
                            android:maxLines="1" />
 | 
					                            android:maxLines="1" />
 | 
				
			||||||
                    </LinearLayout>
 | 
					                    </LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <ProgressBar
 | 
				
			||||||
 | 
					                        android:id="@+id/progressBar"
 | 
				
			||||||
 | 
					                        style="?android:attr/progressBarStyle"
 | 
				
			||||||
 | 
					                        android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					                        android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					                        android:layout_gravity="center" />
 | 
				
			||||||
                </LinearLayout>
 | 
					                </LinearLayout>
 | 
				
			||||||
                <Button
 | 
					                <Button
 | 
				
			||||||
                    android:id="@+id/next"
 | 
					                    android:id="@+id/next"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user