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