Java Code Examples for com.eveningoutpost.dexdrip.UtilityModels.CollectionServiceStarter#isBteWixelorWifiandBtWixel()
The following examples show how to use
com.eveningoutpost.dexdrip.UtilityModels.CollectionServiceStarter#isBteWixelorWifiandBtWixel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2){ stopSelf(); return START_NOT_STICKY; } if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { setFailoverTimer(); } else { stopSelf(); return START_NOT_STICKY; } lastdata = null; attemptConnection(); return START_STICKY; }
Example 2
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
public void setRetryTimer() { if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { long retry_in; if(CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { retry_in = (1000 * 25); }else { retry_in = (1000*65); } Log.d(TAG, "setRetryTimer: Restarting in: " + (retry_in / 1000) + " seconds"); Calendar calendar = Calendar.getInstance(); AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); long wakeTime = calendar.getTimeInMillis() + retry_in; PendingIntent serviceIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } }
Example 3
Source File: DexCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
public void setFailoverTimer() { if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) { long retry_in = (1000 * 60 * 6); Log.d(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes"); Calendar calendar = Calendar.getInstance(); AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); long wakeTime = calendar.getTimeInMillis() + retry_in; PendingIntent serviceIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent); } else { stopSelf(); } }
Example 4
Source File: BluetoothScan.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { Log.d(TAG, "Item Clicked"); final BluetoothDevice device = mLeDeviceListAdapter.getDevice(position); if (device == null || device.getName() == null) return; Toast.makeText(this, R.string.connecting_to_device, Toast.LENGTH_LONG).show(); ActiveBluetoothDevice btDevice = new Select().from(ActiveBluetoothDevice.class) .orderBy("_ID desc") .executeSingle(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); prefs.edit().putString("last_connected_device_address", device.getAddress()).apply(); if (btDevice == null) { ActiveBluetoothDevice newBtDevice = new ActiveBluetoothDevice(); newBtDevice.name = device.getName(); newBtDevice.address = device.getAddress(); newBtDevice.save(); } else { btDevice.name = device.getName(); btDevice.address = device.getAddress(); btDevice.save(); } if(device.getName().toLowerCase().contains("dexcom")) { if(!CollectionServiceStarter.isBTShare(getApplicationContext())) { prefs.edit().putString("dex_collection_method", "DexcomShare").apply(); prefs.edit().putBoolean("calibration_notifications", false).apply(); } if(prefs.getString("share_key", "SM00000000").compareTo("SM00000000") == 0 || prefs.getString("share_key", "SM00000000").length() < 10) { requestSerialNumber(prefs); } else returnToHome(); } else if(device.getName().toLowerCase().contains("bridge")) { if(!CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) prefs.edit().putString("dex_collection_method", "DexbridgeWixel").apply(); if(prefs.getString("dex_txid", "00000").compareTo("00000") == 0 || prefs.getString("dex_txid", "00000").length() < 5) { requestTransmitterId(prefs); } else returnToHome(); } else if(device.getName().toLowerCase().contains("drip")) { if (! (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()) ) || CollectionServiceStarter.isLimitter(getApplicationContext())) { prefs.edit().putString("dex_collection_method", "BluetoothWixel").apply(); } returnToHome(); } else if(device.getName().toLowerCase().contains("limitter")) { if (!CollectionServiceStarter.isLimitter(getApplicationContext())) { prefs.edit().putString("dex_collection_method", "LimiTTer").apply(); } returnToHome(); } else { returnToHome(); } }
Example 5
Source File: Home.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void updateCurrentBgInfo() { setupCharts(); final TextView notificationText = (TextView) findViewById(R.id.notices); notificationText.setText(""); notificationText.setTextColor(Color.parseColor("#FF0000")); boolean isBTWixel = CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext()); boolean isDexbridgeWixel = CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext()); isBTShare = CollectionServiceStarter.isBTShare(getApplicationContext()); isG5Share = CollectionServiceStarter.isBTG5(getApplicationContext()); boolean isWifiWixel = CollectionServiceStarter.isWifiWixel(getApplicationContext()); alreadyDisplayedBgInfoCommon = false; // reset flag boolean xDripViewer = XDripViewer.isxDripViewerMode(getApplicationContext()); if(xDripViewer) { updateCurrentBgInfoForxDripViewer(notificationText); } else if (isBTShare) { updateCurrentBgInfoForBtShare(notificationText); } else if (isBTWixel || isDexbridgeWixel) { updateCurrentBgInfoForBtBasedWixel(notificationText); } else if (isWifiWixel) { updateCurrentBgInfoForWifiWixel(notificationText); } if (isG5Share) { updateCurrentBgInfoCommon(notificationText); } if (mPreferences.getLong("alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\n ALL ALERTS DISABLED"); } else if (mPreferences.getLong("low_alerts_disabled_until", 0) > new Date().getTime() && mPreferences.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\nLOW AND HIGH ALERTS DISABLED"); } else if (mPreferences.getLong("low_alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\nLOW ALERTS DISABLED"); } else if (mPreferences.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) { notificationText.append("\nHIGH ALERTS DISABLED"); } if(mPreferences.getBoolean("extra_status_line", false)) { extraStatusLineText.setText(extraStatusLine(mPreferences)); extraStatusLineText.setVisibility(View.VISIBLE); } else { extraStatusLineText.setText(""); extraStatusLineText.setVisibility(View.GONE); } NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this); }
Example 6
Source File: NavDrawerBuilder.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public NavDrawerBuilder(Context aContext) { context = aContext; boolean xDripViewer = XDripViewer.isxDripViewerMode(aContext); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean IUnderstand = prefs.getBoolean("I_understand", false); if (IUnderstand == false) { this.nav_drawer_options.add("Settings"); this.nav_drawer_intents.add(new Intent(context, Preferences.class)); return; } this.nav_drawer_options.add(Home.menu_name); this.nav_drawer_intents.add(new Intent(context, Home.class)); if (is_active_sensor) { this.nav_drawer_options.add("Calibration Graph"); this.nav_drawer_intents.add(new Intent(context, CalibrationGraph.class)); } if (prefs.getBoolean("show_data_tables", false)) { this.nav_drawer_options.add("BG Data Table"); this.nav_drawer_intents.add(new Intent(context, BgReadingTable.class)); this.nav_drawer_options.add("Calibration Data Table"); this.nav_drawer_intents.add(new Intent(context, CalibrationDataTable.class)); } if(!xDripViewer) { if(is_active_sensor) { if(!CollectionServiceStarter.isBTShare(context)) { if (last_two_bgReadings.size() > 1) { if (last_two_calibrations.size() > 1) { if (bGreadings_in_last_30_mins.size() >= 2) { if (time_now - last_two_calibrations.get(0).timestamp < (1000 * 60 * 60)) { //Put steps in place to discourage over calibration this.nav_drawer_options.add(CalibrationOverride.menu_name); this.nav_drawer_intents.add(new Intent(context, CalibrationOverride.class)); } else { this.nav_drawer_options.add(AddCalibration.menu_name); this.nav_drawer_intents.add(new Intent(context, AddCalibration.class)); } } else { this.nav_drawer_options.add("Cannot Calibrate right now"); this.nav_drawer_intents.add(new Intent(context, Home.class)); } } else { this.nav_drawer_options.add(DoubleCalibrationActivity.menu_name); this.nav_drawer_intents.add(new Intent(context, DoubleCalibrationActivity.class)); } } } this.nav_drawer_options.add(StopSensor.menu_name); this.nav_drawer_intents.add(new Intent(context, StopSensor.class)); } else { this.nav_drawer_options.add(StartNewSensor.menu_name); this.nav_drawer_intents.add(new Intent(context, StartNewSensor.class)); } } if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { if(CollectionServiceStarter.isBteWixelorWifiandBtWixel(context) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(context)|| CollectionServiceStarter.isBTShare(context) ) { this.nav_drawer_options.add(BluetoothScan.menu_name); this.nav_drawer_intents.add(new Intent(context, BluetoothScan.class)); } } if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { this.nav_drawer_options.add(SystemStatus.menu_name); this.nav_drawer_intents.add(new Intent(context, SystemStatus.class)); } boolean bg_alerts = prefs.getBoolean("bg_alerts_from_main_menu", false); if (bg_alerts) { this.nav_drawer_options.add(AlertList.menu_name); this.nav_drawer_intents.add(new Intent(context, AlertList.class)); } this.nav_drawer_options.add(SnoozeActivity.menu_name); this.nav_drawer_intents.add(new Intent(context, SnoozeActivity.class)); this.nav_drawer_options.add(StatsActivity.MENU_NAME); this.nav_drawer_intents.add(new Intent(context, StatsActivity.class)); this.nav_drawer_options.add(BGHistory.menu_name); this.nav_drawer_intents.add(new Intent(context, BGHistory.class)); this.nav_drawer_options.add("Settings"); this.nav_drawer_intents.add(new Intent(context, Preferences.class)); }