upload local profile to NS
This commit is contained in:
parent
421c2a955e
commit
599261081b
4 changed files with 25 additions and 1 deletions
|
@ -510,6 +510,21 @@ public class NSUpload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void uploadProfileStore(JSONObject profileStore) {
|
||||||
|
if (SP.getBoolean(R.string.key_ns_uploadlocalprofile, false)) {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("action", "dbAdd");
|
||||||
|
bundle.putString("collection", "profile");
|
||||||
|
bundle.putString("data", String.valueOf(profileStore));
|
||||||
|
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||||
|
DbLogger.dbAdd(intent, String.valueOf(profileStore));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void uploadEvent(String careportalEvent, long time, @Nullable String notes) {
|
public static void uploadEvent(String careportalEvent, long time, @Nullable String notes) {
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.interfaces.ProfileInterface
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.SP
|
import info.nightscout.androidaps.utils.SP
|
||||||
|
@ -89,6 +90,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
if (L.isEnabled(L.PROFILE))
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Storing settings: " + rawProfile?.data.toString())
|
log.debug("Storing settings: " + rawProfile?.data.toString())
|
||||||
RxBus.send(EventProfileStoreChanged())
|
RxBus.send(EventProfileStoreChanged())
|
||||||
|
rawProfile?.let { NSUpload.uploadProfileStore(it.data) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -167,7 +169,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
createAndStoreConvertedProfile()
|
createAndStoreConvertedProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isExistingName(name: String?) : Boolean {
|
private fun isExistingName(name: String?): Boolean {
|
||||||
for (p in profiles) {
|
for (p in profiles) {
|
||||||
if (p.name == name) return true
|
if (p.name == name) return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1639,5 +1639,7 @@
|
||||||
<string name="common_off">Off</string>
|
<string name="common_off">Off</string>
|
||||||
<string name="nopumpselected">No pump selected</string>
|
<string name="nopumpselected">No pump selected</string>
|
||||||
<string name="setupwizard_units_prompt">Select units you want to display values in</string>
|
<string name="setupwizard_units_prompt">Select units you want to display values in</string>
|
||||||
|
<string name="key_ns_uploadlocalprofile">ns_uploadlocalprofile</string>
|
||||||
|
<string name="ns_ploadlocalprofile">Upload local profile changes to NS</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
android:key="@string/key_ns_logappstartedevent"
|
android:key="@string/key_ns_logappstartedevent"
|
||||||
android:title="@string/ns_logappstartedevent" />
|
android:title="@string/ns_logappstartedevent" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/key_ns_uploadlocalprofile"
|
||||||
|
android:title="@string/ns_ploadlocalprofile" />
|
||||||
|
|
||||||
<PreferenceScreen android:title="@string/ns_alarmoptions">
|
<PreferenceScreen android:title="@string/ns_alarmoptions">
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
|
|
Loading…
Reference in a new issue