Skip to content

Commit

Permalink
Merge branch 'kskandis-update1' of https://github.com/NightscoutFound…
Browse files Browse the repository at this point in the history
…ation/xDrip into jamorhamvoice
  • Loading branch information
jamorham committed Nov 24, 2016
2 parents 0362aab + 8ac3451 commit de9e950
Show file tree
Hide file tree
Showing 25 changed files with 1,407 additions and 785 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
Expand All @@ -24,6 +27,7 @@
import com.eveningoutpost.dexdrip.utils.DatabaseUtil;
import com.eveningoutpost.dexdrip.utils.FileUtils;
import com.eveningoutpost.dexdrip.utils.ListActivityWithMenu;
import com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService;

import java.io.File;
import java.io.FileFilter;
Expand All @@ -39,11 +43,13 @@ public class ImportDatabaseActivity extends ListActivityWithMenu {
private ArrayList<String> databaseNames;
private ArrayList<File> databases;
private final static int MY_PERMISSIONS_REQUEST_STORAGE = 132;
private SharedPreferences mPrefs;

@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.OldAppTheme); // or null actionbar
super.onCreate(savedInstanceState);
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mHandler = new Handler();
setContentView(R.layout.activity_import_db);

Expand Down Expand Up @@ -217,6 +223,12 @@ public void importDB(int position) {
}

protected void postImportDB(String result) {

if (mPrefs.getBoolean("wear_sync", false)) {//KS
Log.d(TAG, "start WatchUpdaterService with ACTION_SYNC_DB");
startService(new Intent(this, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SYNC_DB));
}

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ public static BgReading create(double raw_data, double filtered_data, Context co
} else {
BgReading lastBgReading = BgReading.last();
if (lastBgReading != null && lastBgReading.calibration != null) {
Log.d(TAG, "Create calibration.uuid=" + calibration.uuid + " bgReading.uuid: " + bgReading.uuid + " lastBgReading.calibration_uuid: " + lastBgReading.calibration_uuid + " lastBgReading.calibration.uuid: " + lastBgReading.calibration.uuid);
Log.d(TAG, "Create lastBgReading.calibration_flag=" + lastBgReading.calibration_flag + " bgReading.timestamp: " + bgReading.timestamp + " lastBgReading.timestamp: " + lastBgReading.timestamp + " lastBgReading.calibration.timestamp: " + lastBgReading.calibration.timestamp);
Log.d(TAG, "Create lastBgReading.calibration_flag=" + lastBgReading.calibration_flag + " bgReading.timestamp: " + JoH.dateTimeText(bgReading.timestamp) + " lastBgReading.timestamp: " + JoH.dateTimeText(lastBgReading.timestamp) + " lastBgReading.calibration.timestamp: " + JoH.dateTimeText(lastBgReading.calibration.timestamp));
if (lastBgReading.calibration_flag == true && ((lastBgReading.timestamp + (60000 * 20)) > bgReading.timestamp) && ((lastBgReading.calibration.timestamp + (60000 * 20)) > bgReading.timestamp)) {
lastBgReading.calibration.rawValueOverride(BgReading.weightedAverageRaw(lastBgReading.timestamp, bgReading.timestamp, lastBgReading.calibration.timestamp, lastBgReading.age_adjusted_raw_value, bgReading.age_adjusted_raw_value), context);
newCloseSensorData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,71 +214,6 @@ public class Calibration extends Model {
@Column(name = "second_scale")
public double second_scale;

public static void createCalibration(//KS
/*int _ID, long timestamp, double sensor_age_at_time_of_estimation, Sensor sensor, double bg, double raw_value, double adjusted_raw_value,
double sensor_confidence, double slope_confidence, long raw_timestamp, double slope, double intercept, double distance_from_estimate,
double estimate_raw_at_time_of_calibration, double estimate_bg_at_time_of_calibration, String uuid,String sensor_uuid, Boolean possible_bad,
boolean check_in, double first_decay, double second_decay, double first_slope, double second_slope, double first_intercept,
double second_intercept, double first_scale, double second_scale*/
double adjusted_raw_value,
double bg,
boolean check_in,
double distance_from_estimate,
double estimate_bg_at_time_of_calibration,
double estimate_raw_at_time_of_calibration,
double first_decay,
double first_intercept,
double first_scale,
double first_slope,
double intercept,
Boolean possible_bad,
long raw_timestamp,
double raw_value,
double second_decay,
double second_intercept,
double second_scale,
double second_slope,
Sensor sensor,
double sensor_age_at_time_of_estimation,
double sensor_confidence,
String sensor_uuid,
double slope,
double slope_confidence,
long timestamp,
String uuid
)
{
Calibration newCalibration = new Calibration();
//newCalibration._ID = _ID ;
newCalibration.timestamp = timestamp ;
newCalibration.sensor_age_at_time_of_estimation = sensor_age_at_time_of_estimation ;
newCalibration.sensor = sensor ;
newCalibration.bg = bg ;
newCalibration.raw_value = raw_value ;
newCalibration.adjusted_raw_value = adjusted_raw_value ;
newCalibration.sensor_confidence = sensor_confidence ;
newCalibration.slope_confidence = slope_confidence ;
newCalibration.raw_timestamp = raw_timestamp ;
newCalibration.slope = slope ;
newCalibration.intercept = intercept ;
newCalibration.distance_from_estimate = distance_from_estimate ;
newCalibration.estimate_raw_at_time_of_calibration = estimate_raw_at_time_of_calibration ;
newCalibration.estimate_bg_at_time_of_calibration = estimate_bg_at_time_of_calibration ;
newCalibration.uuid = uuid ;
newCalibration.sensor_uuid = sensor_uuid ;
newCalibration.possible_bad = possible_bad ;
newCalibration.check_in = check_in ;
newCalibration.first_decay = first_decay ;
newCalibration.second_decay = second_decay ;
newCalibration.first_slope = first_slope ;
newCalibration.second_slope = second_slope ;
newCalibration.first_intercept = first_intercept ;
newCalibration.second_intercept = second_intercept ;
newCalibration.first_scale = first_scale ;
newCalibration.second_scale = second_scale ;
newCalibration.save();
}

public static void initialCalibration(double bg1, double bg2, Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String unit = prefs.getString("units", "mgdl");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,11 @@ public void onDestroy() {

Log.d(TAG, "onDestroy");
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (sharedPrefs.getBoolean("use_wear_connectG5", false)) {//KS
scan_interval_timer.cancel();
if (pendingIntent != null) {
Log.d(TAG, "onDestroy stop Alarm pendingIntent");
AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
alarm.cancel(pendingIntent);
}
scan_interval_timer.cancel();
if (pendingIntent != null) {
Log.d(TAG, "onDestroy stop Alarm pendingIntent");
AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
alarm.cancel(pendingIntent);
}

// close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ public void start(Context context, String collection_method) {
stopBtShareService();

if (prefs.getBoolean("wear_sync", false)) {//KS
boolean enable_wearG5 = prefs.getBoolean("enable_wearG5", false);
boolean force_wearG5 = prefs.getBoolean("force_wearG5", false);
this.mContext.startService(new Intent(context, WatchUpdaterService.class));
if (!prefs.getBoolean("use_wear_connectG5", false)) { //don't start if Wear G5 Collector Service is active
if (!enable_wearG5 || (enable_wearG5 && !force_wearG5)) { //don't start if Wear G5 Collector Service is active
startBtG5Service();
}
}
Expand Down
Loading

0 comments on commit de9e950

Please sign in to comment.