upload local profile to NS
This commit is contained in:
parent
421c2a955e
commit
599261081b
|
@ -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) {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.interfaces.ProfileInterface
|
|||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
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.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
|
@ -89,6 +90,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
|||
if (L.isEnabled(L.PROFILE))
|
||||
log.debug("Storing settings: " + rawProfile?.data.toString())
|
||||
RxBus.send(EventProfileStoreChanged())
|
||||
rawProfile?.let { NSUpload.uploadProfileStore(it.data) }
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
@ -167,7 +169,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
|||
createAndStoreConvertedProfile()
|
||||
}
|
||||
|
||||
private fun isExistingName(name: String?) : Boolean {
|
||||
private fun isExistingName(name: String?): Boolean {
|
||||
for (p in profiles) {
|
||||
if (p.name == name) return true
|
||||
}
|
||||
|
|
|
@ -1639,5 +1639,7 @@
|
|||
<string name="common_off">Off</string>
|
||||
<string name="nopumpselected">No pump selected</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>
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
android:key="@string/key_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">
|
||||
|
||||
<SwitchPreference
|
||||
|
|
Loading…
Reference in a new issue