Search in sources :

Example 1 with Self

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

the class SingleOtrClientFragmentTest method launchFragmentWithoutParameters_shouldDisplayDefaultText.

@Test
public void launchFragmentWithoutParameters_shouldDisplayDefaultText() {
    Self mockSelf = mock(Self.class);
    Fingerprint mockFingerprint = mock(Fingerprint.class);
    setupMocksForCurrentOtrClient(mockSelf, mockFingerprint);
    attachFragment(SingleOtrClientFragment.newInstance(), SingleOtrClientFragment.TAG);
    String text = activity.getString(R.string.otr__participant__my_device__description);
    onView(withId(R.id.ttv__single_otr_client__description)).check(hasText(text));
}
Also used : Fingerprint(com.waz.api.Fingerprint) Self(com.waz.api.Self) FragmentTest(com.waz.zclient.testutils.FragmentTest) Test(org.junit.Test)

Example 2 with Self

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

the class DevicesPreferences method onCreatePreferences2.

@Override
public void onCreatePreferences2(Bundle savedInstanceState, String rootKey) {
    super.onCreatePreferences2(savedInstanceState, rootKey);
    addPreferencesFromResource(R.xml.preferences_devices);
    getStoreFactory().getZMessagingApiStore().getApi().onInit(new InitListener() {

        @Override
        public void onInitialized(Self user) {
            setupOtrDevices();
        }
    });
    trackViewingOtrClients();
}
Also used : InitListener(com.waz.api.InitListener) Self(com.waz.api.Self)

Example 3 with Self

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

the class DevicesPreferences method setupOtrDevices.

private void setupOtrDevices() {
    if (getStoreFactory() == null || getStoreFactory().isTornDown()) {
        return;
    }
    Self self = getStoreFactory().getZMessagingApiStore().getApi().getSelf();
    if (otrClient == null) {
        otrClient = self.getOtrClient();
    }
    if (otherClients == null) {
        otherClients = self.getOtherOtrClients();
        otherClients.addUpdateListener(otrClientsUpdateListener);
    }
    updateOtrDevices();
    final PreferenceGroup currentOtrClientPreferenceGroup = (PreferenceGroup) findPreference(getString(R.string.pref_devices_current_device_category_key));
    otrClientSubscription = otrClient.subscribe(new Subscriber<OtrClient>() {

        @Override
        public void next(OtrClient value) {
            if (getActivity() == null) {
                return;
            }
            currentOtrClientPreferenceGroup.setTitle(getString(R.string.pref_devices_current_device_category_title));
            currentOtrClientPreferenceGroup.removeAll();
            net.xpece.android.support.preference.Preference preference = new net.xpece.android.support.preference.Preference(getContext());
            preference.setTitle(DevicesPreferencesUtil.getTitle(getActivity(), value));
            preference.setSummary(DevicesPreferencesUtil.getSummary(getActivity(), value, false));
            preference.setKey(getString(R.string.pref_device_details_screen_key));
            final PreferenceScreen preferenceScreen = new PreferenceScreen(getContext(), null);
            preferenceScreen.getExtras().putParcelable(DeviceDetailPreferences.PREFS_OTR_CLIENT, value);
            preferenceScreen.getExtras().putBoolean(DeviceDetailPreferences.PREFS_CURRENT_DEVICE, true);
            preferenceScreen.setTitle(preference.getTitle());
            preferenceScreen.setKey(preference.getKey());
            preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    PreferenceManager preferenceManager = getPreferenceManager();
                    if (preferenceManager != null) {
                        PreferenceManager.OnNavigateToScreenListener listener = preferenceManager.getOnNavigateToScreenListener();
                        if (listener != null) {
                            listener.onNavigateToScreen(preferenceScreen);
                            return true;
                        }
                    }
                    return false;
                }
            });
            currentOtrClientPreferenceGroup.addPreference(preference);
        }
    });
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Self(com.waz.api.Self) PreferenceManager(android.support.v7.preference.PreferenceManager) Subscriber(com.waz.api.Subscriber) Preference(android.support.v7.preference.Preference) PreferenceGroup(android.support.v7.preference.PreferenceGroup) OtrClient(com.waz.api.OtrClient)

Example 4 with Self

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

the class AppEntryStore method acceptPhoneInvitation.

@Override
public void acceptPhoneInvitation(AccentColor accentColor) {
    Credentials credentials = CredentialsFactory.phoneInvitationCredentials(invitationPhone, invitationToken);
    zMessagingApi.register(credentials, invitationName, accentColor, new ZMessagingApi.RegistrationListener() {

        @Override
        public void onRegistered(Self self) {
            bindSelf(self);
            setState(AppEntryState.PHONE_SET_PICTURE);
            appEntryStateCallback.onInvitationSuccess();
            appEntryStateCallback.tagAppEntryEvent(new SucceededWithRegistrationEvent(RegistrationEventContext.PERSONAL_INVITE_PHONE));
        }

        @Override
        public void onRegistrationFailed(int i, String s, String s1) {
            Timber.e("Email invitation registration failed");
            appEntryStateCallback.onInvitationFailed();
            if (LayoutSpec.isPhone(context)) {
                setState(AppEntryState.PHONE_REGISTER);
            } else {
                setState(AppEntryState.EMAIL_WELCOME);
            }
        }
    });
}
Also used : ZMessagingApi(com.waz.api.ZMessagingApi) SucceededWithRegistrationEvent(com.waz.zclient.core.controllers.tracking.events.registration.SucceededWithRegistrationEvent) Self(com.waz.api.Self) Credentials(com.waz.api.Credentials)

Example 5 with Self

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

the class AppEntryStore method signInWithEmail.

@Override
public void signInWithEmail(String email, String password, final ErrorCallback errorCallback) {
    setAndStoreEmail(email);
    this.password = password;
    ignoreSelfUpdates = true;
    zMessagingApi.login(CredentialsFactory.emailCredentials(email, password), new LoginListener() {

        @Override
        public void onSuccess(Self self) {
            bindSelf(self);
            setState(AppEntryState.EMAIL_SIGNED_IN);
            ignoreSelfUpdates = false;
            appEntryStateCallback.tagAppEntryEvent(new LoggedInEvent(false));
        }

        @Override
        public void onFailed(int errorCode, String message, String label) {
            if (AppEntryError.EMAIL_INVALID_REQUEST.correspondsTo(errorCode, label)) {
                errorCallback.onError(AppEntryError.EMAIL_INVALID_REQUEST);
            } else if (AppEntryError.SERVER_CONNECTIVITY_ERROR.correspondsTo(errorCode, "")) {
                errorCallback.onError(AppEntryError.SERVER_CONNECTIVITY_ERROR);
            } else if (AppEntryError.EMAIL_INVALID_LOGIN_CREDENTIALS.correspondsTo(errorCode, "")) {
                errorCallback.onError(AppEntryError.EMAIL_INVALID_LOGIN_CREDENTIALS);
            } else if (AppEntryError.TOO_MANY_ATTEMPTS.correspondsTo(errorCode, "")) {
                errorCallback.onError(AppEntryError.TOO_MANY_ATTEMPTS);
            } else if (AppEntryError.NO_INTERNET.correspondsTo(errorCode, label)) {
                errorCallback.onError(AppEntryError.NO_INTERNET);
            } else {
                errorCallback.onError(AppEntryError.EMAIL_GENERIC_ERROR);
            }
            ignoreSelfUpdates = false;
        }
    });
}
Also used : LoggedInEvent(com.waz.zclient.core.controllers.tracking.events.session.LoggedInEvent) LoginListener(com.waz.api.LoginListener) Self(com.waz.api.Self)

Aggregations

Self (com.waz.api.Self)11 Credentials (com.waz.api.Credentials)3 Fingerprint (com.waz.api.Fingerprint)3 LoginListener (com.waz.api.LoginListener)3 ZMessagingApi (com.waz.api.ZMessagingApi)3 FragmentTest (com.waz.zclient.testutils.FragmentTest)3 Test (org.junit.Test)3 Preference (android.support.v7.preference.Preference)2 PreferenceManager (android.support.v7.preference.PreferenceManager)2 PreferenceScreen (android.support.v7.preference.PreferenceScreen)2 InitListener (com.waz.api.InitListener)2 OtrClient (com.waz.api.OtrClient)2 SucceededWithRegistrationEvent (com.waz.zclient.core.controllers.tracking.events.registration.SucceededWithRegistrationEvent)2 LoggedInEvent (com.waz.zclient.core.controllers.tracking.events.session.LoggedInEvent)2 PreferenceGroup (android.support.v7.preference.PreferenceGroup)1 KindOfVerification (com.waz.api.KindOfVerification)1 Subscriber (com.waz.api.Subscriber)1 VerifiedPhoneEvent (com.waz.zclient.core.controllers.tracking.events.registration.VerifiedPhoneEvent)1