Search in sources :

Example 6 with SystemUser

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);
    }
}
Also used : SystemUser(com.voipgrid.vialer.api.models.SystemUser)

Example 7 with SystemUser

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;
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics) SystemUser(com.voipgrid.vialer.api.models.SystemUser) JsonStorage(com.voipgrid.vialer.util.JsonStorage)

Example 8 with SystemUser

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);
}
Also used : ConnectivityHelper(com.voipgrid.vialer.util.ConnectivityHelper) Bundle(android.os.Bundle) UpdateActivity(com.voipgrid.vialer.util.UpdateActivity) Intent(android.content.Intent) ReachabilityReceiver(com.voipgrid.vialer.reachability.ReachabilityReceiver) SetupActivity(com.voipgrid.vialer.onboarding.SetupActivity) PhoneAccountHelper(com.voipgrid.vialer.util.PhoneAccountHelper) SystemUser(com.voipgrid.vialer.api.models.SystemUser) FloatingActionButton(android.support.design.widget.FloatingActionButton) JsonStorage(com.voipgrid.vialer.util.JsonStorage) AccountFragment(com.voipgrid.vialer.onboarding.AccountFragment)

Example 9 with SystemUser

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);
    }
}
Also used : PhoneAccount(com.voipgrid.vialer.api.models.PhoneAccount) SystemUser(com.voipgrid.vialer.api.models.SystemUser)

Example 10 with SystemUser

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()));
    }
}
Also used : PhoneAccount(com.voipgrid.vialer.api.models.PhoneAccount) SystemUser(com.voipgrid.vialer.api.models.SystemUser)

Aggregations

SystemUser (com.voipgrid.vialer.api.models.SystemUser)13 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)5 JsonStorage (com.voipgrid.vialer.util.JsonStorage)5 Bundle (android.os.Bundle)3 AccountHelper (com.voipgrid.vialer.util.AccountHelper)3 PhoneAccountHelper (com.voipgrid.vialer.util.PhoneAccountHelper)3 IOException (java.io.IOException)3 Preferences (com.voipgrid.vialer.Preferences)2 RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)2 Fragment (android.app.Fragment)1 FragmentManager (android.app.FragmentManager)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 GoogleAnalytics (com.google.android.gms.analytics.GoogleAnalytics)1 Tracker (com.google.android.gms.analytics.Tracker)1 WebActivityHelper (com.voipgrid.vialer.WebActivityHelper)1 AnalyticsApplication (com.voipgrid.vialer.analytics.AnalyticsApplication)1