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);
}
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;
}
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();
}
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);
}
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);
}
Aggregations