Search in sources :

Example 1 with ErrorResponse

use of com.waz.api.ErrorResponse in project wire-android by wireapp.

the class AppEntryStore method resumeAppEntry.

public void resumeAppEntry(Self self, String personalInvitationToken) {
    if (!bindSelf(self)) {
        return;
    }
    if (!TextUtils.isEmpty(personalInvitationToken)) {
        invitationToken = InvitationTokenFactory.personalTokenFromCode(personalInvitationToken);
        zMessagingApi.getInvitations().retrieveInvitationDetails(invitationToken, new Invitations.InvitationDetailsCallback() {

            @Override
            public void onEmailAdressRetrieved(String name, String email) {
                invitationName = name;
                invitationEmail = email;
                setState(AppEntryState.EMAIL_INVITATION);
            }

            @Override
            public void onPhoneNumberRetrieved(String name, String phone) {
                invitationName = name;
                invitationPhone = phone;
                setState(AppEntryState.PHONE_INVITATION);
            }

            @Override
            public void onRetrievalFailed(ErrorResponse errorResponse) {
                if (LayoutSpec.isPhone(context)) {
                    setState(AppEntryState.PHONE_REGISTER);
                } else {
                    setState(AppEntryState.EMAIL_WELCOME);
                }
            }
        });
        return;
    }
    // Resume phone registration
    if (entryPoint == AppEntryState.PHONE_REGISTER && self.isLoggedIn()) {
        if (self.getPicture().isEmpty()) {
            setState(AppEntryState.PHONE_SET_PICTURE);
            return;
        }
        setState(AppEntryState.LOGGED_IN);
        return;
    }
    //Resume at phone set name
    if (entryPoint == AppEntryState.PHONE_SET_NAME && self.isLoggedIn()) {
        setState(AppEntryState.PHONE_SET_NAME);
        return;
    }
    // Resume phone sign-in
    if (entryPoint == AppEntryState.PHONE_SIGN_IN && self.isLoggedIn()) {
        setState(AppEntryState.PHONE_SIGNED_IN_RESUMING);
        return;
    }
    // Resume email registration
    if (entryPoint == AppEntryState.EMAIL_REGISTER) {
        if (self.isLoggedIn() && !self.accountActivated()) {
            setState(AppEntryState.EMAIL_VERIFY_EMAIL);
            return;
        }
        if (self.accountActivated() && self.getPicture().isEmpty()) {
            setState(AppEntryState.EMAIL_SET_PICTURE);
            return;
        }
        if (self.accountActivated()) {
            appEntryStateCallback.tagAppEntryEvent(new VerifiedEmailEvent(OutcomeAttribute.SUCCESS, "", getEmailRegistrationContext()));
            appEntryStateCallback.tagAppEntryEvent(new SucceededWithRegistrationEvent(getEmailRegistrationContext()));
            setState(AppEntryState.LOGGED_IN);
            return;
        }
    }
    // Resume email sign-in
    if (entryPoint == AppEntryState.EMAIL_SIGN_IN && self.isLoggedIn()) {
        setState(AppEntryState.EMAIL_SIGNED_IN);
        return;
    }
    // Start registration
    if (LayoutSpec.isPhone(context)) {
        setState(AppEntryState.PHONE_REGISTER);
    } else {
        setState(AppEntryState.EMAIL_WELCOME);
    }
}
Also used : Invitations(com.waz.api.Invitations) SucceededWithRegistrationEvent(com.waz.zclient.core.controllers.tracking.events.registration.SucceededWithRegistrationEvent) VerifiedEmailEvent(com.waz.zclient.core.controllers.tracking.events.registration.VerifiedEmailEvent) ErrorResponse(com.waz.api.ErrorResponse)

Aggregations

ErrorResponse (com.waz.api.ErrorResponse)1 Invitations (com.waz.api.Invitations)1 SucceededWithRegistrationEvent (com.waz.zclient.core.controllers.tracking.events.registration.SucceededWithRegistrationEvent)1 VerifiedEmailEvent (com.waz.zclient.core.controllers.tracking.events.registration.VerifiedEmailEvent)1