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));
}
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();
}
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);
}
});
}
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);
}
}
});
}
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;
}
});
}
Aggregations