commit
7d1405c0eb
|
@ -96,7 +96,12 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
||||||
|
|
||||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||||
|
Bundle bundles = intent.getExtras();
|
||||||
|
if (bundles != null && bundles.containsKey("islocal")) {
|
||||||
|
acceptNSData = acceptNSData || bundles.getBoolean("islocal");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
|
@ -125,7 +130,7 @@ public class DataService extends IntentService {
|
||||||
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
|
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
|
||||||
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
|
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
|
||||||
handleNewDataFromNSClient(intent);
|
handleNewDataFromNSClient(intent);
|
||||||
} else if (!nsUploadOnly &&
|
} else if (acceptNSData &&
|
||||||
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
|
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
|
||||||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
|
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
|
||||||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
|
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
|
||||||
|
|
|
@ -64,14 +64,21 @@ public class GlucoseStatus {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static GlucoseStatus getGlucoseStatusData(){
|
public static GlucoseStatus getGlucoseStatusData(){
|
||||||
|
return getGlucoseStatusData(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
|
||||||
// load 45min
|
// load 45min
|
||||||
long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45);
|
long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45);
|
||||||
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
||||||
|
|
||||||
int sizeRecords = data.size();
|
int sizeRecords = data.size();
|
||||||
if (sizeRecords < 1 || data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L) {
|
if (sizeRecords < 1 || (data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L && !allowOldData)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useBG");
|
return storage.getInt("useBG");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useCOB");
|
return storage.getInt("useCOB");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useBolusIOB");
|
return storage.getInt("useBolusIOB");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useBasalIOB");
|
return storage.getInt("useBasalIOB");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useTrend");
|
return storage.getInt("useTrend");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useSuperBolus");
|
return storage.getInt("useSuperBolus");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ public class QuickWizardEntry {
|
||||||
try {
|
try {
|
||||||
return storage.getInt("useTempTarget");
|
return storage.getInt("useTempTarget");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
//log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,12 @@ import info.nightscout.utils.SP;
|
||||||
public class BroadcastTreatment {
|
public class BroadcastTreatment {
|
||||||
private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
|
private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
|
||||||
|
|
||||||
public static void handleNewTreatment(JSONObject treatment, boolean isDelta) {
|
public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
bundle.putBoolean("islocal", isLocalBypass);
|
||||||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
||||||
JSONObject data = new JSONObject(request.data);
|
JSONObject data = new JSONObject(request.data);
|
||||||
data.put("mills", DateUtil.fromISODateString(data.getString("created_at")).getTime());
|
data.put("mills", DateUtil.fromISODateString(data.getString("created_at")).getTime());
|
||||||
data.put("_id", data.get("NSCLIENT_ID")); // this is only fake id
|
data.put("_id", data.get("NSCLIENT_ID")); // this is only fake id
|
||||||
BroadcastTreatment.handleNewTreatment(data, false);
|
BroadcastTreatment.handleNewTreatment(data, false, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhadled exception", e);
|
log.error("Unhadled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
if (last_bg == null) return;
|
if (last_bg == null) return;
|
||||||
|
|
||||||
List<BgReading> graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true);
|
List<BgReading> graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true);
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(true);
|
||||||
|
|
||||||
if (!graph_bgs.isEmpty()) {
|
if (!graph_bgs.isEmpty()) {
|
||||||
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
|
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
|
||||||
|
|
|
@ -187,10 +187,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
if (!ruffyService.isConnected()) {
|
if (!ruffyService.isConnected()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - menuLastUpdated >= 1500) {
|
return ruffyService.isConnected() && System.currentTimeMillis() - menuLastUpdated < 10 * 1000;
|
||||||
waitForScreenUpdate();
|
|
||||||
}
|
|
||||||
return System.currentTimeMillis() - menuLastUpdated < 1500;
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -202,10 +199,12 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
log.debug("Disconnecting, requested by ...", new Exception());
|
log.debug("Disconnecting");
|
||||||
ruffyService.doRTDisconnect();
|
ruffyService.doRTDisconnect();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// ignore
|
// ignore
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Disconnect not happy", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -569,6 +569,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
|
||||||
|
|
||||||
|
if("delta_granularity".equals(key)){
|
||||||
|
ListenerService.requestData(this);
|
||||||
|
}
|
||||||
|
|
||||||
if(layoutSet){
|
if(layoutSet){
|
||||||
setDataFields();
|
setDataFields();
|
||||||
setColor();
|
setColor();
|
||||||
|
|
Loading…
Reference in a new issue