use of com.waz.api.Self in project wire-android by wireapp.
the class RootPreferences method onCreatePreferences2.
@Override
public void onCreatePreferences2(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences2(savedInstanceState, rootKey);
if (BuildConfig.SHOW_DEVELOPER_OPTIONS) {
addPreferencesFromResource(R.xml.preference_root__developer);
findPreference(getString(R.string.pref_dev_avs_screen_key)).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
getChildFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).add(AvsOptionsDialogFragment.newInstance(), AvsOptionsDialogFragment.TAG).addToBackStack(AvsOptionsDialogFragment.TAG).commit();
return true;
}
});
} else {
addPreferencesFromResource(R.xml.preference_root);
}
inviteButtonPreference = (ButtonPreference) findPreference(getString(R.string.pref_invite_key));
inviteButtonPreference.setAccentColor(getControllerFactory().getAccentColorController().getColor());
inviteButtonPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
sendGenericInvite();
return true;
}
});
devicesPreferenceScreenLike = (BadgeablePreferenceScreenLike) findPreference(getString(R.string.pref_devices_screen_key));
devicesPreferenceScreenLike.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (otrClients != null) {
for (OtrClient client : otrClients) {
client.setVerified(false);
}
}
return false;
}
});
getStoreFactory().getZMessagingApiStore().getApi().onInit(new InitListener() {
@Override
public void onInitialized(Self user) {
otrClientsObserver.setAndUpdate(getStoreFactory().getZMessagingApiStore().getApi().getSelf().getIncomingOtrClients());
}
});
if (savedInstanceState == null) {
boolean showSpotifyLogin = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_SPOTIFY_LOGIN, false);
boolean showOtrDevices = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_OTR_DEVICES, false);
boolean showAccount = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_ACCOUNT, false);
boolean showUsernameEdit = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_USERNAME_EDIT);
final PreferenceManager.OnNavigateToScreenListener navigateToScreenListener = getPreferenceManager().getOnNavigateToScreenListener();
PreferenceScreen preference = null;
if (showAccount) {
preference = (PreferenceScreen) findPreference(getString(R.string.pref_account_screen_key));
} else if (showSpotifyLogin) {
preference = (PreferenceScreen) findPreference(getString(R.string.pref_options_screen_key));
getControllerFactory().getSpotifyController().login(getActivity());
} else if (showOtrDevices) {
preference = devicesPreferenceScreenLike.getPreferenceScreen();
} else if (showUsernameEdit) {
preference = ((BadgeablePreferenceScreenLike) findPreference(getString(R.string.pref_account_screen_key))).getPreferenceScreen();
}
if (preference != null) {
preference.getExtras().putAll(getArguments());
navigateToScreenListener.onNavigateToScreen(preference);
}
}
}
use of com.waz.api.Self in project wire-android by wireapp.
the class OTREmailSignInFragment method signIn.
private void signIn() {
getContainer().enableProgress(true);
KeyboardUtils.hideKeyboard(getActivity());
Credentials credentials = CredentialsFactory.emailCredentials(guidedEditTextEmail.getText(), guidedEditTextPassword.getText());
getStoreFactory().getZMessagingApiStore().getApi().login(credentials, new LoginListener() {
@Override
public void onSuccess(Self user) {
if (getContainer() == null) {
return;
}
getContainer().startMain();
}
@Override
public void onFailed(int code, String message, String label) {
if (getContainer() == null) {
return;
}
getContainer().enableProgress(false);
AppEntryUtil.showErrorDialog(OTREmailSignInFragment.this.getActivity(), AppEntryError.EMAIL_REGISTER_GENERIC_ERROR, new AppEntryUtil.ErrorDialogCallback() {
@Override
public void onOk() {
KeyboardUtils.showKeyboard(getActivity());
}
});
}
});
}
use of com.waz.api.Self in project wire-android by wireapp.
the class SingleOtrClientFragmentTest method launchFragmentWithoutParameters_shouldShowFormatterFingerprint.
@Test
public void launchFragmentWithoutParameters_shouldShowFormatterFingerprint() {
Self mockSelf = mock(Self.class);
Fingerprint mockFingerprint = mock(Fingerprint.class);
setupMocksForCurrentOtrClient(mockSelf, mockFingerprint);
attachFragment(SingleOtrClientFragment.newInstance(), SingleOtrClientFragment.TAG);
onView(withId(R.id.ttv__single_otr_client__fingerprint)).check(hasText("aa bb cc dd 11 22 33 44"));
}
use of com.waz.api.Self in project wire-android by wireapp.
the class SingleOtrClientFragmentTest method launchFragmentWithoutParameters_shouldDisplayCurrentOtrClient.
@Test
public void launchFragmentWithoutParameters_shouldDisplayCurrentOtrClient() {
Self mockSelf = mock(Self.class);
Fingerprint mockFingerprint = mock(Fingerprint.class);
setupMocksForCurrentOtrClient(mockSelf, mockFingerprint);
attachFragment(SingleOtrClientFragment.newInstance(), SingleOtrClientFragment.TAG);
onView(withId(R.id.os__single_otr_client__verify)).check(isGone());
onView(withId(R.id.gtv__single_otr_client__back)).check(isGone());
onView(withId(R.id.ttv__single_otr_client__my_fingerprint)).check(isGone());
onView(withId(R.id.gtv__single_otr_client__close)).check(isVisible());
onView(withId(R.id.ttv__single_otr_client__my_devices)).check(isVisible());
}
use of com.waz.api.Self in project wire-android by wireapp.
the class AppEntryStore method submitCode.
@Override
public void submitCode(String phoneVerificationCode, final ErrorCallback errorCallback) {
setAndStorePhoneVerificationCode(phoneVerificationCode);
if (entryPoint == AppEntryState.PHONE_REGISTER) {
zMessagingApi.verifyPhoneNumber(countryCode + phone, phoneVerificationCode, KindOfVerification.PREVERIFY_ON_REGISTRATION, new ZMessagingApi.PhoneNumberVerificationListener() {
@Override
public void onVerified(KindOfVerification kindOfVerification) {
appEntryStateCallback.tagAppEntryEvent(new VerifiedPhoneEvent(OutcomeAttribute.SUCCESS, "", "", getPhoneRegistrationContext()));
setState(AppEntryState.PHONE_SET_NAME);
}
@Override
public void onVerificationFailed(KindOfVerification kindOfVerification, int errorCode, String message, String label) {
appEntryStateCallback.tagAppEntryEvent(new VerifiedPhoneEvent(OutcomeAttribute.FAIL, String.valueOf(errorCode), message + "; " + label, getPhoneRegistrationContext()));
if (AppEntryError.PHONE_INVALID_REGISTRATION_CODE.correspondsTo(errorCode, label)) {
errorCallback.onError(AppEntryError.PHONE_INVALID_REGISTRATION_CODE);
} else {
errorCallback.onError(AppEntryError.PHONE_REGISTER_GENERIC_ERROR);
}
}
});
} else if (entryPoint == AppEntryState.PHONE_SIGN_IN) {
ignoreSelfUpdates = true;
zMessagingApi.login(CredentialsFactory.phoneCredentials(countryCode + phone, phoneVerificationCode), new LoginListener() {
@Override
public void onSuccess(Self self) {
appEntryStateCallback.tagAppEntryEvent(PhoneVerification.success(PhoneVerification.Context.SIGN_IN));
appEntryStateCallback.tagAppEntryEvent(new LoggedInEvent(true));
bindSelf(self);
setState(AppEntryState.PHONE_SIGNED_IN);
ignoreSelfUpdates = false;
}
@Override
public void onFailed(int errorCode, String message, String label) {
appEntryStateCallback.tagAppEntryEvent(PhoneVerification.error(PhoneVerification.Context.SIGN_IN));
if (AppEntryError.PHONE_INVALID_LOGIN_CODE.correspondsTo(errorCode, "")) {
errorCallback.onError(AppEntryError.PHONE_INVALID_LOGIN_CODE);
} else if (AppEntryError.TOO_MANY_ATTEMPTS.correspondsTo(errorCode, "")) {
errorCallback.onError(AppEntryError.TOO_MANY_ATTEMPTS);
} else {
errorCallback.onError(AppEntryError.PHONE_REGISTER_GENERIC_ERROR);
}
ignoreSelfUpdates = false;
}
});
} else if (entryPoint == AppEntryState.EMAIL_SIGN_IN) {
zMessagingApi.verifyPhoneNumber(countryCode + phone, phoneVerificationCode, KindOfVerification.VERIFY_ON_UPDATE, new ZMessagingApi.PhoneNumberVerificationListener() {
@Override
public void onVerified(KindOfVerification kindOfVerification) {
appEntryStateCallback.tagAppEntryEvent(PhoneVerification.success(PhoneVerification.Context.POST_LOGIN));
setState(AppEntryState.LOGGED_IN);
}
@Override
public void onVerificationFailed(KindOfVerification kindOfVerification, int errorCode, String message, String label) {
appEntryStateCallback.tagAppEntryEvent(PhoneVerification.error(PhoneVerification.Context.POST_LOGIN));
if (AppEntryError.PHONE_INVALID_ADD_CODE.correspondsTo(errorCode, label)) {
errorCallback.onError(AppEntryError.PHONE_INVALID_ADD_CODE);
} else {
errorCallback.onError(AppEntryError.PHONE_REGISTER_GENERIC_ERROR);
}
}
});
}
}
Aggregations