use of com.voipgrid.vialer.api.models.SystemUser in project vialer-android by VoIPGRID.
the class UpdateHelper method migrateCredentials.
/**
* Migrate credentials from systemuser to Account.
* V4_0
*/
private void migrateCredentials() {
SystemUser user = (SystemUser) mJsonStorage.get(SystemUser.class);
if (user != null && user.getPassword() != null) {
new AccountHelper(mContext).setCredentials(user.getEmail(), user.getPassword());
// Cleanup.
user.setPassword(null);
}
}
use of com.voipgrid.vialer.api.models.SystemUser in project vialer-android by VoIPGRID.
the class AnalyticsApplication method getDefaultTracker.
/**
* Gets the default {@link Tracker} for this {@link Application}.
* @return tracker
*/
public synchronized Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
// To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
mTracker = analytics.newTracker(R.xml.tracker);
}
JsonStorage storage = new JsonStorage(this);
SystemUser systemuser = (SystemUser) storage.get(SystemUser.class);
// Set client id as custom dimension on index 1.
if (systemuser != null) {
String clientId = systemuser.getClient();
if (clientId != null) {
mTracker.set("&cd1", clientId);
}
}
return mTracker;
}
use of com.voipgrid.vialer.api.models.SystemUser in project vialer-android by VoIPGRID.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle startBundle = getIntent().getExtras();
if (startBundle != null) {
boolean onBoot = startBundle.getBoolean("OnBoot");
if (onBoot) {
finish();
return;
}
}
JsonStorage jsonStorage = new JsonStorage(this);
ConnectivityHelper connectivityHelper = ConnectivityHelper.get(this);
Boolean hasSystemUser = jsonStorage.has(SystemUser.class);
SystemUser systemUser = (SystemUser) jsonStorage.get(SystemUser.class);
// on boarding part where the mobile number needs to be configured.
if (!hasSystemUser) {
// Start on boarding flow.
startActivity(new Intent(this, SetupActivity.class));
finish();
return;
} else if (UpdateHelper.requiresUpdate(this)) {
Intent intent = new Intent(this, UpdateActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
return;
} else if (systemUser.getMobileNumber() == null) {
Intent intent = new Intent(this, SetupActivity.class);
Bundle bundle = new Bundle();
bundle.putInt("fragment", R.id.fragment_account);
bundle.putString("activity", AccountFragment.class.getSimpleName());
intent.putExtras(bundle);
startActivity(intent);
finish();
return;
} else if (connectivityHelper.hasNetworkConnection()) {
// Update SystemUser and PhoneAccount on background thread.
new PhoneAccountHelper(this).executeUpdatePhoneAccountTask();
}
if (SyncUtils.requiresFullContactSync(this)) {
SyncUtils.requestContactSync(this);
} else {
startContactObserverService();
}
SyncUtils.setPeriodicSync(this);
setContentView(R.layout.activity_main);
// Set the Toolbar to use as ActionBar.
setActionBar(R.id.action_bar);
setNavigationDrawer(R.id.drawer_layout);
// Set tabs.
setupTabs();
FloatingActionButton openDialerFab = findViewById(R.id.floating_action_button);
openDialerFab.setOnClickListener(this);
requestCounter = 0;
mReachabilityReceiver = new ReachabilityReceiver(this);
}
use of com.voipgrid.vialer.api.models.SystemUser in project vialer-android by VoIPGRID.
the class SetUpVoipAccountFragment method onResponse.
@Override
public void onResponse(Call call, Response response) {
if (response.body() instanceof SystemUser) {
SystemUser systemUser = ((SystemUser) response.body());
// Update existing systemuser to avoid overriding values like password.
SystemUser currentSystemuser = mSystemUser;
currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
currentSystemuser.setClient(systemUser.getClient());
currentSystemuser.setAppAccountUri(systemUser.getAppAccountUri());
mJsonStorage.save(currentSystemuser);
mSystemUser = currentSystemuser;
// Check if a account has been set.
String phoneAccountId = mSystemUser.getPhoneAccountId();
if (phoneAccountId != null) {
// Request new phoneaccount object.
Call<PhoneAccount> apicall = mApi.phoneAccount(phoneAccountId);
apicall.enqueue(this);
} else {
// User has no phone account linked so remove it from the local storage.
mJsonStorage.remove(PhoneAccount.class);
}
} else if (response.body() instanceof PhoneAccount) {
mJsonStorage.save(response.body());
mListener.onFinish(this);
}
}
use of com.voipgrid.vialer.api.models.SystemUser in project vialer-android by VoIPGRID.
the class SetupActivity method onConfigure.
@Override
public void onConfigure(Fragment fragment, String mobileNumber, String outgoingNumber) {
enableProgressBar(true);
// Save mobile and outgoing number.
SystemUser systemUser = (SystemUser) mJsonStorage.get(SystemUser.class);
systemUser.setMobileNumber(mobileNumber);
systemUser.setOutgoingCli(outgoingNumber);
mJsonStorage.save(systemUser);
String phoneAccountId = systemUser.getPhoneAccountId();
if (phoneAccountId != null) {
Call<PhoneAccount> call = mApi.phoneAccount(phoneAccountId);
call.enqueue(this);
} else {
enableProgressBar(false);
onNextStep(WelcomeFragment.newInstance(((SystemUser) mJsonStorage.get(SystemUser.class)).getFullName()));
}
}
Aggregations