warn if profile is not uploadable to NS
This commit is contained in:
parent
702e1f0675
commit
c0ad125934
3 changed files with 16 additions and 3 deletions
|
@ -192,7 +192,7 @@ class LocalProfileFragment : Fragment() {
|
||||||
if (!LocalProfilePlugin.isValidEditState()) {
|
if (!LocalProfilePlugin.isValidEditState()) {
|
||||||
return@setOnClickListener //Should not happen as saveButton should not be visible if not valid
|
return@setOnClickListener //Should not happen as saveButton should not be visible if not valid
|
||||||
}
|
}
|
||||||
LocalProfilePlugin.storeSettings()
|
LocalProfilePlugin.storeSettings(activity)
|
||||||
build()
|
build()
|
||||||
}
|
}
|
||||||
updateGUI()
|
updateGUI()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.profile.local
|
package info.nightscout.androidaps.plugins.profile.local
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
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.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.OKDialog
|
||||||
import info.nightscout.androidaps.utils.SP
|
import info.nightscout.androidaps.utils.SP
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -100,7 +102,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun storeSettings() {
|
fun storeSettings(activity: Activity? = null) {
|
||||||
for (i in 0 until numOfProfiles) {
|
for (i in 0 until numOfProfiles) {
|
||||||
profiles[i].run {
|
profiles[i].run {
|
||||||
val LOCAL_PROFILE_NUMBERED = LOCAL_PROFILE + "_" + i + "_"
|
val LOCAL_PROFILE_NUMBERED = LOCAL_PROFILE + "_" + i + "_"
|
||||||
|
@ -121,7 +123,17 @@ 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) }
|
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
|
@Synchronized
|
||||||
|
|
|
@ -1657,5 +1657,6 @@
|
||||||
<string name="saveorresetchangesfirst">Save or reset current changes first</string>
|
<string name="saveorresetchangesfirst">Save or reset current changes first</string>
|
||||||
<string name="deletecurrentprofile">Delete current profile?</string>
|
<string name="deletecurrentprofile">Delete current profile?</string>
|
||||||
<string name="copytolocalprofile">Create new local profile from this profile switch?</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>
|
</resources>
|
||||||
|
|
Loading…
Add table
Reference in a new issue