Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CollectionServiceStarter collectionServiceStarter =
        new CollectionServiceStarter(getApplicationContext());
    collectionServiceStarter.start(getApplicationContext());
    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
    PreferenceManager.setDefaultValues(this, R.xml.pref_data_sync, false);
    PreferenceManager.setDefaultValues(this, R.xml.pref_notifications, false);
    PreferenceManager.setDefaultValues(this, R.xml.pref_data_source, false);
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    checkEula();
    new IdempotentMigrations(getApplicationContext()).performAll();
    setContentView(R.layout.activity_home);

    this.dexbridgeBattery = (TextView) findViewById(R.id.textBridgeBattery);
    this.currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
    if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
      this.currentBgValueText.setTextSize(100);
    }
    this.notificationText = (TextView) findViewById(R.id.notices);
    if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
      this.notificationText.setTextSize(40);
    }
  }
Esempio n. 2
0
 public void updateCurrentBgInfo() {
   final TextView notificationText = (TextView) findViewById(R.id.notices);
   if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
     notificationText.setTextSize(40);
   }
   notificationText.setText("");
   notificationText.setTextColor(Color.RED);
   isBTWixel = CollectionServiceStarter.isBTWixel(getApplicationContext());
   isDexbridgeWixel = CollectionServiceStarter.isDexbridgeWixel(getApplicationContext());
   isBTShare = CollectionServiceStarter.isBTShare(getApplicationContext());
   isWifiWixel = CollectionServiceStarter.isWifiWixel(getApplicationContext());
   if (isBTShare) {
     updateCurrentBgInfoForBtShare(notificationText);
   }
   if (isBTWixel || isDexbridgeWixel) {
     updateCurrentBgInfoForBtBasedWixel(notificationText);
   }
   if (isWifiWixel) {
     updateCurrentBgInfoForWifiWixel(notificationText);
   }
   if (prefs.getLong("alerts_disabled_until", 0) > new Date().getTime()) {
     notificationText.append("\n ALERTS CURRENTLY DISABLED");
   }
   mNavigationDrawerFragment =
       (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
   mNavigationDrawerFragment.setUp(
       R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this);
 }
Esempio n. 3
0
  @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.isDexbridgeWixel(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.isBTWixel(getApplicationContext())
          || CollectionServiceStarter.isWifiandBTWixel(getApplicationContext()))) {
        prefs.edit().putString("dex_collection_method", "BluetoothWixel").apply();
      }
      returnToHome();
    } else {
      returnToHome();
    }
  }
Esempio n. 4
0
 public void returnToHome() {
   if (is_scanning) {
     bluetooth_adapter.stopLeScan(mLeScanCallback);
     is_scanning = false;
   }
   Intent intent = new Intent(this, Home.class);
   CollectionServiceStarter.restartCollectionService(getApplicationContext());
   startActivity(intent);
   finish();
 }
Esempio n. 5
0
 private void updateCurrentBgInfo() {
   setupCharts();
   final TextView notificationText = (TextView) findViewById(R.id.notices);
   if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
     notificationText.setTextSize(40);
   }
   notificationText.setText("");
   notificationText.setTextColor(Color.RED);
   boolean isBTWixel = CollectionServiceStarter.isBTWixel(getApplicationContext());
   boolean isDexbridgeWixel = CollectionServiceStarter.isDexbridgeWixel(getApplicationContext());
   boolean isWifiBluetoothWixel =
       CollectionServiceStarter.isWifiandBTWixel(getApplicationContext());
   isBTShare = CollectionServiceStarter.isBTShare(getApplicationContext());
   boolean isWifiWixel = CollectionServiceStarter.isWifiWixel(getApplicationContext());
   alreadyDisplayedBgInfoCommon = false; // reset flag
   if (isBTShare) {
     updateCurrentBgInfoForBtShare(notificationText);
   }
   if (isBTWixel || isDexbridgeWixel || isWifiBluetoothWixel) {
     updateCurrentBgInfoForBtBasedWixel(notificationText);
   }
   if (isWifiWixel || isWifiBluetoothWixel) {
     updateCurrentBgInfoForWifiWixel(notificationText);
   }
   if (prefs.getLong("alerts_disabled_until", 0) > new Date().getTime()) {
     notificationText.append("\n ALL ALERTS CURRENTLY DISABLED");
   } else if (prefs.getLong("low_alerts_disabled_until", 0) > new Date().getTime()
       && prefs.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) {
     notificationText.append("\n LOW AND HIGH ALERTS CURRENTLY DISABLED");
   } else if (prefs.getLong("low_alerts_disabled_until", 0) > new Date().getTime()) {
     notificationText.append("\n LOW ALERTS CURRENTLY DISABLED");
   } else if (prefs.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) {
     notificationText.append("\n HIGH ALERTS CURRENTLY DISABLED");
   }
   NavigationDrawerFragment navigationDrawerFragment =
       (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
   navigationDrawerFragment.setUp(
       R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this);
 }
Esempio n. 6
0
  public void displayCurrentInfo() {
    DecimalFormat df = new DecimalFormat("#");
    df.setMaximumFractionDigits(0);

    boolean isDexbridge = CollectionServiceStarter.isDexbridgeWixel(getApplicationContext());
    int bridgeBattery = prefs.getInt("bridge_battery", 0);

    if (isDexbridge) {
      if (bridgeBattery == 0) {
        dexbridgeBattery.setText("Waiting for packet");
      } else {
        dexbridgeBattery.setText("Bridge Battery: " + bridgeBattery + "%");
      }
      if (bridgeBattery < 50) dexbridgeBattery.setTextColor(Color.YELLOW);
      if (bridgeBattery < 25) dexbridgeBattery.setTextColor(Color.RED);
      else dexbridgeBattery.setTextColor(Color.GREEN);
      dexbridgeBattery.setVisibility(View.VISIBLE);
    } else {
      dexbridgeBattery.setVisibility(View.INVISIBLE);
    }

    if ((currentBgValueText.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0) {
      currentBgValueText.setPaintFlags(
          currentBgValueText.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
      dexbridgeBattery.setPaintFlags(
          dexbridgeBattery.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    }
    BgReading lastBgReading = BgReading.lastNoSenssor();
    boolean predictive =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
            .getBoolean("predictive_bg", false);
    if (isBTShare) {
      predictive = false;
    }
    if (lastBgReading != null) {
      displayCurrentInfoFromReading(lastBgReading, predictive);
    }
    setupCharts();
  }