warn if profile is not uploadable to NS

This commit is contained in:
Milos Kozak 2019-12-01 21:59:12 +01:00
parent 702e1f0675
commit c0ad125934
3 changed files with 16 additions and 3 deletions

View file

@ -192,7 +192,7 @@ class LocalProfileFragment : Fragment() {
if (!LocalProfilePlugin.isValidEditState()) {
return@setOnClickListener //Should not happen as saveButton should not be visible if not valid
}
LocalProfilePlugin.storeSettings()
LocalProfilePlugin.storeSettings(activity)
build()
}
updateGUI()

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.profile.local
import android.app.Activity
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
@ -16,6 +17,7 @@ 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.OKDialog
import info.nightscout.androidaps.utils.SP
import org.json.JSONArray
import org.json.JSONException
@ -100,7 +102,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
}
@Synchronized
fun storeSettings() {
fun storeSettings(activity: Activity? = null) {
for (i in 0 until numOfProfiles) {
profiles[i].run {
val LOCAL_PROFILE_NUMBERED = LOCAL_PROFILE + "_" + i + "_"
@ -121,7 +123,17 @@ 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) }
var namesOK = true
profiles.forEach {
val name = it.name ?: "."
if (name.contains(".")) namesOK = false
}
if (namesOK)
rawProfile?.let { NSUpload.uploadProfileStore(it.data) }
else
activity?.let {
OKDialog.show(it,"", MainApp.gs(R.string.profilenamecontainsdot), null)
}
}
@Synchronized

View file

@ -1657,5 +1657,6 @@
<string name="saveorresetchangesfirst">Save or reset current changes first</string>
<string name="deletecurrentprofile">Delete current profile?</string>
<string name="copytolocalprofile">Create new local profile from this profile switch?</string>
<string name="profilenamecontainsdot">Profile name contains dots.\nThis is not supported by NS.\nProfile is not uploaded to NS.</string>
</resources>