more update
This commit is contained in:
parent
cd337ecdc8
commit
2cb3c15d61
|
@ -83,6 +83,8 @@
|
|||
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" />
|
||||
<!-- Receiver from DexcomG5 -->
|
||||
<action android:name="com.dexcom.cgm.DATA" />
|
||||
<!-- Receiver from Poctech -->
|
||||
<action android:name="com.china.poctech.data" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- Receiver keepalive, scheduled every 30 min -->
|
||||
|
@ -170,7 +172,7 @@
|
|||
<activity
|
||||
android:name=".setupwizard.SetupWizardActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:theme="@style/AppTheme.SetupWizard"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/title_activity_setup_wizard" />
|
||||
|
||||
<activity android:name=".SingleFragmentActivity"
|
||||
|
|
|
@ -139,8 +139,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
AndroidPermission.notifyForStoragePermission(this);
|
||||
AndroidPermission.notifyForBatteryOptimizationPermission(this);
|
||||
AndroidPermission.notifyForLocationPermissions(this);
|
||||
AndroidPermission.notifyForSMSPermissions(this);
|
||||
if (BuildConfig.APS || BuildConfig.PUMPCONTROL) {
|
||||
AndroidPermission.notifyForLocationPermissions(this);
|
||||
AndroidPermission.notifyForSMSPermissions(this);
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN));
|
||||
}
|
||||
|
@ -200,13 +202,14 @@ public class MainActivity extends AppCompatActivity {
|
|||
menu.clear();
|
||||
for (PluginBase p : MainApp.getPluginsList()) {
|
||||
pageAdapter.registerNewFragment(p);
|
||||
if (p.hasFragment() && !p.isFragmentVisible() && p.isEnabled(p.pluginDescription.getType())) {
|
||||
if (p.hasFragment() && !p.isFragmentVisible() && p.isEnabled(p.pluginDescription.getType()) && !p.pluginDescription.neverVisible) {
|
||||
MenuItem menuItem = menu.add(p.getName());
|
||||
menuItem.setCheckable(true);
|
||||
menuItem.setOnMenuItemClickListener(item -> {
|
||||
Intent intent = new Intent(this, SingleFragmentActivity.class);
|
||||
intent.putExtra("plugin", MainApp.getPluginsList().indexOf(p));
|
||||
startActivity(intent);
|
||||
((DrawerLayout) findViewById(R.id.drawer_layout)).closeDrawers();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
|||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
|
@ -178,6 +179,8 @@ public class MainApp extends Application {
|
|||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||
if (!Config.NSCLIENT)
|
||||
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
|
||||
if (!Config.NSCLIENT)
|
||||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
|
@ -38,6 +39,7 @@ import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
|||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.utils.BundleLogger;
|
||||
|
@ -54,6 +56,7 @@ public class DataService extends IntentService {
|
|||
boolean mm640gEnabled = false;
|
||||
boolean glimpEnabled = false;
|
||||
boolean dexcomG5Enabled = false;
|
||||
boolean poctechEnabled = false;
|
||||
|
||||
public DataService() {
|
||||
super("DataService");
|
||||
|
@ -70,36 +73,49 @@ public class DataService extends IntentService {
|
|||
mm640gEnabled = false;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = false;
|
||||
poctechEnabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) {
|
||||
xDripEnabled = true;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = false;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = false;
|
||||
poctechEnabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) {
|
||||
xDripEnabled = false;
|
||||
nsClientEnabled = true;
|
||||
mm640gEnabled = false;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = false;
|
||||
poctechEnabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) {
|
||||
xDripEnabled = false;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = true;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = false;
|
||||
poctechEnabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) {
|
||||
xDripEnabled = false;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = false;
|
||||
glimpEnabled = true;
|
||||
dexcomG5Enabled = false;
|
||||
poctechEnabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) {
|
||||
xDripEnabled = false;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = false;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = true;
|
||||
poctechEnabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourcePoctechPlugin.class)) {
|
||||
xDripEnabled = false;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = false;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = false;
|
||||
poctechEnabled = true;
|
||||
}
|
||||
|
||||
boolean isNSProfile = MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
||||
|
@ -129,6 +145,10 @@ public class DataService extends IntentService {
|
|||
if (dexcomG5Enabled) {
|
||||
handleNewDataFromDexcomG5(intent);
|
||||
}
|
||||
} else if (Intents.POCTECH_BG.equals(action)) {
|
||||
if (poctechEnabled) {
|
||||
handleNewDataFromPoctech(intent);
|
||||
}
|
||||
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
|
||||
if (nsClientEnabled || SP.getBoolean(R.string.key_ns_autobackfill, true))
|
||||
handleNewDataFromNSClient(intent);
|
||||
|
@ -250,6 +270,41 @@ public class DataService extends IntentService {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleNewDataFromPoctech(Intent intent) {
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
String data = bundle.getString("data");
|
||||
log.debug("Received Poctech Data", data);
|
||||
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray(data);
|
||||
log.debug("Received Poctech Data size:" + jsonArray.length());
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject json = jsonArray.getJSONObject(i);
|
||||
bgReading.value = json.getDouble("current");
|
||||
bgReading.direction = json.getString("direction");
|
||||
bgReading.date = json.getLong("date");
|
||||
bgReading.raw = json.getDouble("raw");
|
||||
if (JsonHelper.safeGetString(json, "utils", Constants.MGDL).equals("mmol/L"))
|
||||
bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL;
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Poctech");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading);
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNewDataFromMM640g(Intent intent) {
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
|
|
@ -49,4 +49,6 @@ public interface Intents {
|
|||
String GLIMP_BG = "it.ct.glicemia.ACTION_GLUCOSE_MEASURED";
|
||||
|
||||
String DEXCOMG5_BG = "com.dexcom.cgm.DATA";
|
||||
|
||||
String POCTECH_BG = "com.china.poctech.data";
|
||||
}
|
||||
|
|
|
@ -57,6 +57,11 @@ public abstract class PluginBase {
|
|||
return getName();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
if (pluginDescription.description == -1) return null;
|
||||
else return MainApp.gs(pluginDescription.description);
|
||||
}
|
||||
|
||||
public PluginType getType() {
|
||||
return pluginDescription.mainType;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ public class PluginDescription {
|
|||
boolean showInList = true;
|
||||
int pluginName = -1;
|
||||
int shortName = -1;
|
||||
int description = -1;
|
||||
int preferencesId = -1;
|
||||
int advancedPreferencesId = -1;
|
||||
public boolean enableByDefault = false;
|
||||
|
@ -74,6 +75,11 @@ public class PluginDescription {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription description(int description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFragmentClass() {
|
||||
return fragmentClass;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public class ActionsPlugin extends PluginBase {
|
|||
.fragmentClass(ActionsFragment.class.getName())
|
||||
.pluginName(R.string.actions)
|
||||
.shortName(R.string.actions_shortname)
|
||||
.description(R.string.description_actions)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,10 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
private EditText notesEdit;
|
||||
|
||||
//one shot guards
|
||||
private boolean accepted;
|
||||
private boolean okClicked;
|
||||
|
||||
final private TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
@ -163,7 +167,14 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
}
|
||||
|
||||
private void confirmAndDeliver() {
|
||||
private synchronized void confirmAndDeliver() {
|
||||
if (okClicked) {
|
||||
log.debug("guarding: ok already clicked");
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
okClicked = true;
|
||||
|
||||
try {
|
||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||
|
||||
|
@ -198,32 +209,40 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) {
|
||||
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage)));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.primefill), (dialog, id) -> {
|
||||
if (finalInsulinAfterConstraints > 0) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||
detailedBolusInfo.notes = notes;
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.boluserror);
|
||||
i.putExtra("status", result.comment);
|
||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
synchronized (builder) {
|
||||
if (accepted) {
|
||||
log.debug("guarding: already accepted");
|
||||
return;
|
||||
}
|
||||
accepted = true;
|
||||
|
||||
if (finalInsulinAfterConstraints > 0) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||
detailedBolusInfo.notes = notes;
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.boluserror);
|
||||
i.putExtra("status", result.comment);
|
||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Fill"));
|
||||
});
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Fill"));
|
||||
}
|
||||
if (pumpSiteChangeCheckbox.isChecked())
|
||||
NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now(), notes);
|
||||
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||
NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now() + 1000, notes);
|
||||
}
|
||||
if (pumpSiteChangeCheckbox.isChecked())
|
||||
NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now(), notes);
|
||||
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||
NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now() + 1000, notes);
|
||||
});
|
||||
} else {
|
||||
builder.setMessage(MainApp.gs(R.string.no_action_selected));
|
||||
|
|
Loading…
Reference in a new issue