Search in sources :

Example 6 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage in project vialer-android by VoIPGRID.

the class DialerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dialer);
    // Set the AnalyticsHelper
    mAnalyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mJsonStorage = new JsonStorage(this);
    mConnectivityHelper = ConnectivityHelper.get(this);
    mReachabilityReceiver = new ReachabilityReceiver(this);
    mContactsListView = (ListView) findViewById(R.id.list_view);
    mEmptyView = (TextView) findViewById(R.id.message);
    mEmptyView.setText("");
    // This should be called before setupContactParts.
    setupKeypad();
    Intent intent = getIntent();
    String type = intent.getType();
    // Sadly HTC fails to include the mime-type in the intent in 4.4.2.
    Uri contactUri = intent.getData();
    mHasPermission = ContactsPermission.hasPermission(this);
    mAskForPermission = true;
    // Check for contact permissions before doing contact related work.
    if (mHasPermission) {
        // Handling this intent is only needed when we have contact permissions.
        // This should be called after setupKeyPad.
        setupContactParts();
        /**
         * The app added a "Vialer call <number>" to the native contacts app. clicking this
         * opens the app with the appname's profile and the data necessary for opening the app.
         */
        if ((!TextUtils.isEmpty(type) && type.equals(getString(R.string.profile_mimetype))) || contactUri != null) {
            // presses call with vialer in a contact.
            if (!mJsonStorage.has(SystemUser.class)) {
                startActivity(new Intent(this, SetupActivity.class));
                finish();
            }
            Cursor cursor = getContentResolver().query(contactUri, new String[] { ContactsContract.CommonDataKinds.StructuredName.PHONETIC_NAME, ContactsContract.Data.DATA3 }, null, null, null);
            cursor.moveToFirst();
            String number = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA3));
            mNumberInputView.setNumber(number);
            cursor.close();
        }
    } else {
        // Set the empty view for the contact list to inform the user this functionality will
        // not work.
        mEmptyView.setText(getString(R.string.permission_contact_dialer_list_message));
        mContactsListView.setEmptyView(mEmptyView);
    }
    // Make sure there is no keyboard popping up when pasting in the dialer input field.
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
Also used : ReachabilityReceiver(com.voipgrid.vialer.reachability.ReachabilityReceiver) AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) SetupActivity(com.voipgrid.vialer.onboarding.SetupActivity) SystemUser(com.voipgrid.vialer.api.models.SystemUser) Intent(android.content.Intent) JsonStorage(com.voipgrid.vialer.util.JsonStorage) Cursor(android.database.Cursor) Uri(android.net.Uri) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 7 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage 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 JsonStorage

use of com.voipgrid.vialer.util.JsonStorage in project vialer-android by VoIPGRID.

the class AccountActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account);
    mJsonStorage = new JsonStorage(this);
    mPhoneAccountHelper = new PhoneAccountHelper(this);
    mPreferences = new Preferences(this);
    /* set the Toolbar to use as ActionBar */
    setSupportActionBar((Toolbar) findViewById(R.id.action_bar));
    /* enabled home as up for the Toolbar */
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    /* enabled home button for the Toolbar */
    getSupportActionBar().setHomeButtonEnabled(true);
    mRemoteLogIdEditText = (EditText) findViewById(R.id.remote_logging_id_edit_text);
    mRemoteLogIdEditText.setVisibility(View.GONE);
    mSipIdEditText = ((EditText) findViewById(R.id.account_sip_id_edit_text));
    mVoipSwitch = (CompoundButton) findViewById(R.id.account_sip_switch);
    mVoipSwitch.setOnCheckedChangeListener(this);
    initConnectionSpinner();
    initRemoteLoggingSwitch();
    initUse3GSwitch();
}
Also used : EditText(android.widget.EditText) PhoneAccountHelper(com.voipgrid.vialer.util.PhoneAccountHelper) JsonStorage(com.voipgrid.vialer.util.JsonStorage)

Example 9 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage 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 10 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage in project vialer-android by VoIPGRID.

the class CallRecordFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /* set the AnalyticsHelper */
    mAnalyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getActivity().getApplication()).getDefaultTracker());
    mConnectivityHelper = ConnectivityHelper.get(getActivity());
    mJsonStorage = new JsonStorage(getActivity());
    mFilter = getArguments().getString(ARG_FILTER);
}
Also used : AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) JsonStorage(com.voipgrid.vialer.util.JsonStorage) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Aggregations

JsonStorage (com.voipgrid.vialer.util.JsonStorage)14 SystemUser (com.voipgrid.vialer.api.models.SystemUser)6 AnalyticsHelper (com.voipgrid.vialer.analytics.AnalyticsHelper)5 RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)5 AnalyticsApplication (com.voipgrid.vialer.analytics.AnalyticsApplication)4 AccountHelper (com.voipgrid.vialer.util.AccountHelper)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Preferences (com.voipgrid.vialer.Preferences)3 Api (com.voipgrid.vialer.api.Api)3 SetupActivity (com.voipgrid.vialer.onboarding.SetupActivity)3 SharedPreferences (android.content.SharedPreferences)2 View (android.view.View)2 TextView (android.widget.TextView)2 Registration (com.voipgrid.vialer.api.Registration)2 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)2 ReachabilityReceiver (com.voipgrid.vialer.reachability.ReachabilityReceiver)2 ConnectivityHelper (com.voipgrid.vialer.util.ConnectivityHelper)2 PhoneAccountHelper (com.voipgrid.vialer.util.PhoneAccountHelper)2 ResponseBody (okhttp3.ResponseBody)2