@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); } }
@Override protected void onResume() { super.onResume(); checkEula(); _broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { if (intent.getAction().compareTo(Intent.ACTION_TIME_TICK) == 0) { updateCurrentBgInfo(); } } }; newDataReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { holdViewport.set(0, 0, 0, 0); setupCharts(); updateCurrentBgInfo(); } }; registerReceiver(_broadcastReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); registerReceiver(newDataReceiver, new IntentFilter(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA)); holdViewport.set(0, 0, 0, 0); setupCharts(); updateCurrentBgInfo(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); checkEula(); 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); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Intent intent = new Intent(); String packageName = getPackageName(); Log.d(TAG, "Maybe ignoring battery optimization"); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (!pm.isIgnoringBatteryOptimizations(packageName) && !prefs.getBoolean("requested_ignore_battery_optimizations", false)) { Log.d(TAG, "Requesting ignore battery optimization"); prefs.edit().putBoolean("requested_ignore_battery_optimizations", true).apply(); intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); startActivity(intent); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Sensor.isActive() == false) { Intent intent = new Intent(this, StartNewSensor.class); startActivity(intent); finish(); } else { setContentView(R.layout.activity_stop_sensor); button = (Button) findViewById(R.id.stop_sensor); addListenerOnButton(); } }
@Override public void onPause() { super.onPause(); if (_broadcastReceiver != null) { try { unregisterReceiver(_broadcastReceiver); } catch (IllegalArgumentException e) { UserError.Log.e(TAG, "_broadcast_receiver not registered", e); } } if (newDataReceiver != null) { try { unregisterReceiver(newDataReceiver); } catch (IllegalArgumentException e) { UserError.Log.e(TAG, "newDataReceiver not registered", e); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; setContentView(R.layout.activity_edit_alert); viewHeader = (TextView) findViewById(R.id.view_alert_header); buttonSave = (Button) findViewById(R.id.edit_alert_save); buttonRemove = (Button) findViewById(R.id.edit_alert_remove); buttonTest = (Button) findViewById(R.id.edit_alert_test); buttonalertMp3 = (Button) findViewById(R.id.Button_alert_mp3_file); buttonPreSnooze = (Button) findViewById(R.id.edit_alert_pre_snooze); alertText = (EditText) findViewById(R.id.edit_alert_text); alertThreshold = (EditText) findViewById(R.id.edit_alert_threshold); alertMp3File = (EditText) findViewById(R.id.edit_alert_mp3_file); checkboxAllDay = (CheckBox) findViewById(R.id.check_alert_time); layoutTimeBetween = (LinearLayout) findViewById(R.id.time_between); timeInstructions = (LinearLayout) findViewById(R.id.time_instructions); timeInstructionsStart = (TextView) findViewById(R.id.time_instructions_start); timeInstructionsEnd = (TextView) findViewById(R.id.time_instructions_end); viewTimeStart = (TextView) findViewById(R.id.view_alert_time_start); viewTimeEnd = (TextView) findViewById(R.id.view_alert_time_end); editSnooze = (EditText) findViewById(R.id.edit_snooze); reraise = (EditText) findViewById(R.id.reraise); viewAlertOverrideText = (TextView) findViewById(R.id.view_alert_override_silent); checkboxAlertOverride = (CheckBox) findViewById(R.id.check_override_silent); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); addListenerOnButtons(); if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) { viewHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); buttonSave.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); buttonRemove.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); buttonTest.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); buttonalertMp3.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); buttonSave.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); buttonPreSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); alertText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); alertThreshold.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); alertMp3File.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); checkboxAllDay.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); viewTimeStart.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); viewTimeEnd.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); editSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); reraise.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); viewAlertOverrideText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ((TextView) findViewById(R.id.view_alert_text)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ((TextView) findViewById(R.id.view_alert_threshold)) .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ((TextView) findViewById(R.id.view_alert_default_snooze)) .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ((TextView) findViewById(R.id.view_alert_mp3_file)) .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ((TextView) findViewById(R.id.view_alert_time)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ((TextView) findViewById(R.id.view_alert_time_between)) .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0); if (!doMgdl) { alertThreshold.setInputType(InputType.TYPE_CLASS_NUMBER); alertThreshold.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); alertThreshold.setKeyListener(DigitsKeyListener.getInstance(false, true)); } uuid = getExtra(savedInstanceState, "uuid"); String status; if (uuid == null) { // This is a new alert above = Boolean.parseBoolean(getExtra(savedInstanceState, "above")); checkboxAllDay.setChecked(true); checkboxAlertOverride.setChecked(true); audioPath = ""; alertMp3File.setText(shortPath(audioPath)); alertMp3File.setKeyListener(null); defaultSnooze = SnoozeActivity.getDefaultSnooze(above); buttonRemove.setVisibility(View.GONE); // One can not snooze an alert that is still not in the database... buttonPreSnooze.setVisibility(View.GONE); status = "Adding " + (above ? "high" : "low") + " alert"; startHour = 0; startMinute = 0; endHour = 23; endMinute = 59; alertReraise = 1; } else { // We are editing an alert AlertType at = AlertType.get_alert(uuid); if (at == null) { Log.wtf(TAG, "Error editing alert, when that alert does not exist..."); Intent returnIntent = new Intent(); setResult(RESULT_CANCELED, returnIntent); finish(); return; } above = at.above; alertText.setText(at.name); alertThreshold.setText(unitsConvert2Disp(doMgdl, at.threshold)); checkboxAllDay.setChecked(at.all_day); checkboxAlertOverride.setChecked(at.override_silent_mode); defaultSnooze = at.default_snooze; if (defaultSnooze == 0) { SnoozeActivity.getDefaultSnooze(above); } audioPath = at.mp3_file; alertMp3File.setText(shortPath(audioPath)); status = "editing " + (above ? "high" : "low") + " alert"; startHour = AlertType.time2Hours(at.start_time_minutes); startMinute = AlertType.time2Minutes(at.start_time_minutes); endHour = AlertType.time2Hours(at.end_time_minutes); endMinute = AlertType.time2Minutes(at.end_time_minutes); alertReraise = at.minutes_between; if (uuid.equals(AlertType.LOW_ALERT_55)) { // This is the 55 alert, can not be edited alertText.setKeyListener(null); alertThreshold.setKeyListener(null); buttonalertMp3.setEnabled(false); checkboxAllDay.setEnabled(false); checkboxAlertOverride.setEnabled(false); reraise.setEnabled(false); } } reraise.setText(String.valueOf(alertReraise)); alertMp3File.setKeyListener(null); viewHeader.setText(status); setDefaultSnoozeSpinner(); setPreSnoozeSpinner(); enableAllDayControls(); enableVibrateControls(); }