use of com.voipgrid.vialer.WebActivityHelper in project vialer-android by VoIPGRID.
the class SetupActivity method onSetVoipAccount.
@Override
public void onSetVoipAccount(Fragment fragment) {
WebActivityHelper webHelper = new WebActivityHelper(this);
webHelper.startWebActivity(getString(R.string.user_change_title), getString(R.string.web_user_change), getString(R.string.analytics_user_change));
}
use of com.voipgrid.vialer.WebActivityHelper in project vialer-android by VoIPGRID.
the class SetupActivity method onResponse.
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
if (mServiceGen != null) {
mServiceGen.release();
}
if (response.isSuccessful()) {
enableProgressBar(false);
if (response.body() instanceof SystemUser) {
SystemUser systemUser = ((SystemUser) response.body());
if (systemUser.getPartner() != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
onAlertDialog(getString(R.string.user_is_partner_error_title), getString(R.string.user_is_partner_error_message));
}
});
} else {
if (systemUser.getOutgoingCli() == null || systemUser.getOutgoingCli().isEmpty()) {
mRemoteLogger.d("onResponse getOutgoingCli is null");
}
mPreferences.setSipPermission(true);
AccountHelper accountHelper = new AccountHelper(this);
accountHelper.setCredentials(systemUser.getEmail(), mPassword);
mJsonStorage.save(systemUser);
onNextStep(AccountFragment.newInstance(systemUser.getMobileNumber(), systemUser.getOutgoingCli()));
}
} else if (response.body() instanceof PhoneAccount) {
mJsonStorage.save(response.body());
if (mPreferences.hasSipPermission()) {
MiddlewareHelper.registerAtMiddleware(this);
}
SystemUser systemUser = (SystemUser) mJsonStorage.get(SystemUser.class);
onNextStep(WelcomeFragment.newInstance(systemUser.getFullName()));
} else {
FragmentManager fragmentManager = getFragmentManager();
// First see if an AccountFragment exists
AccountFragment fragment = (AccountFragment) fragmentManager.findFragmentByTag(AccountFragment.class.getSimpleName());
if (fragment != null) {
fragment.onNextStep();
}
// Check if the current fragment is the account fragment.
AccountFragment accountFragment = (AccountFragment) getCurrentFragment();
if (accountFragment != null) {
accountFragment.onNextStep();
}
ForgotPasswordFragment forgotFragment = (ForgotPasswordFragment) fragmentManager.findFragmentByTag(ForgotPasswordFragment.class.getSimpleName());
if (forgotFragment != null) {
onNextStep(LoginFragment.newInstance());
}
}
} else {
String errorString = "";
try {
errorString = response.errorBody().string();
} catch (IOException e) {
e.printStackTrace();
}
if (errorString.equals("You need to change your password in the portal")) {
WebActivityHelper webHelper = new WebActivityHelper(this);
webHelper.startWebActivity(getString(R.string.password_change_title), getString(R.string.web_password_change), getString(R.string.analytics_password_change));
Toast.makeText(this, R.string.change_password_webview_toast, Toast.LENGTH_LONG).show();
return;
}
failedFeedback(errorString);
}
}
Aggregations