use of com.voipgrid.vialer.reachability.ReachabilityReceiver 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.reachability.ReachabilityReceiver 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);
}
Aggregations