NSCv3: show correct version in About dialog
This commit is contained in:
parent
9769a01e6f
commit
d67e13e105
|
@ -51,7 +51,6 @@ import info.nightscout.interfaces.aps.Loop
|
|||
import info.nightscout.interfaces.constraints.Constraints
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
||||
import info.nightscout.interfaces.nsclient.NSSettingsStatus
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.plugin.PluginBase
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
|
@ -62,7 +61,6 @@ import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
|
|||
import info.nightscout.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.events.EventAppExit
|
||||
import info.nightscout.rx.events.EventInitializationChanged
|
||||
import info.nightscout.rx.events.EventPreferenceChange
|
||||
import info.nightscout.rx.events.EventRebuildTabs
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
@ -88,7 +86,6 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
@Inject lateinit var versionCheckerUtils: VersionCheckerUtils
|
||||
@Inject lateinit var smsCommunicator: SmsCommunicator
|
||||
@Inject lateinit var loop: Loop
|
||||
@Inject lateinit var nsSettingsStatus: NSSettingsStatus
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
|
@ -347,7 +344,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
R.id.nav_about -> {
|
||||
var message = "Build: ${BuildConfig.BUILDVERSION}\n"
|
||||
message += "Flavor: ${BuildConfig.FLAVOR}${BuildConfig.BUILD_TYPE}\n"
|
||||
message += "${rh.gs(info.nightscout.configuration.R.string.configbuilder_nightscoutversion_label)} ${nsSettingsStatus.getVersion()}"
|
||||
message += "${rh.gs(info.nightscout.configuration.R.string.configbuilder_nightscoutversion_label)} ${activePlugin.activeNsClient?.detectedNsVersion() ?: rh.gs(info.nightscout.plugins.R.string.not_available_full)}"
|
||||
if (config.isEngineeringMode()) message += "\n${rh.gs(info.nightscout.configuration.R.string.engineering_mode_enabled)}"
|
||||
if (config.isUnfinishedMode()) message += "\nUnfinished mode enabled"
|
||||
if (!fabricPrivacy.fabricEnabled()) message += "\n${rh.gs(R.string.fabric_upload_disabled)}"
|
||||
|
|
|
@ -3,20 +3,44 @@ package info.nightscout.interfaces.sync
|
|||
import android.text.Spanned
|
||||
import info.nightscout.interfaces.nsclient.NSAlarm
|
||||
|
||||
/**
|
||||
* Plugin providing communication with Nightscout server
|
||||
*/
|
||||
interface NsClient : Sync {
|
||||
enum class Version {
|
||||
NONE, V1, V3
|
||||
}
|
||||
|
||||
val version: Version
|
||||
/**
|
||||
* NS URL
|
||||
*/
|
||||
val address: String
|
||||
|
||||
/**
|
||||
* Set plugin in paused state
|
||||
*/
|
||||
fun pause(newState: Boolean)
|
||||
|
||||
/**
|
||||
* Initiate new round of upload/download
|
||||
*/
|
||||
fun resend(reason: String)
|
||||
|
||||
/**
|
||||
* @return List last of messages for fragment in HTML format
|
||||
*/
|
||||
fun textLog(): Spanned
|
||||
|
||||
/**
|
||||
* Clear list of stored messages displayed in fragment
|
||||
*/
|
||||
fun clearLog()
|
||||
|
||||
/**
|
||||
* Version of NS server
|
||||
* @return Returns detected version of NS server
|
||||
*/
|
||||
fun detectedNsVersion(): String?
|
||||
|
||||
enum class Collection { ENTRIES, TREATMENTS, FOODS, PROFILE }
|
||||
|
||||
/**
|
||||
* NSC v3 does first load of all data
|
||||
* next loads are using srvModified property for sync
|
||||
|
@ -34,6 +58,7 @@ interface NsClient : Sync {
|
|||
*
|
||||
*/
|
||||
fun updateLatestBgReceivedIfNewer(latestReceived: Long)
|
||||
|
||||
/**
|
||||
* Update newest loaded timestamp for treatments collection (first load or NSCv1)
|
||||
* Update newest srvModified (sync loads)
|
||||
|
@ -42,10 +67,37 @@ interface NsClient : Sync {
|
|||
*
|
||||
*/
|
||||
fun updateLatestTreatmentReceivedIfNewer(latestReceived: Long)
|
||||
|
||||
/**
|
||||
* Send alarm confirmation to NS
|
||||
*
|
||||
* @param originalAlarm alarm to be cleared
|
||||
* @param silenceTimeInMilliseconds silence alarm for specified duration
|
||||
*/
|
||||
fun handleClearAlarm(originalAlarm: NSAlarm, silenceTimeInMilliseconds: Long)
|
||||
|
||||
/**
|
||||
* Clear synchronization status
|
||||
*
|
||||
* Next synchronization will start from scratch
|
||||
*/
|
||||
fun resetToFullSync()
|
||||
|
||||
/**
|
||||
* Upload new record to NS
|
||||
*
|
||||
* @param collection target ns collection
|
||||
* @param dataPair data to upload (data.first) and id of changed record (data.second)
|
||||
* @param progress progress of sync in format "number/number". Only for display in fragment
|
||||
*/
|
||||
fun nsAdd(collection: String, dataPair: DataSyncSelector.DataPair, progress: String)
|
||||
|
||||
/**
|
||||
* Upload updated record to NS
|
||||
*
|
||||
* @param collection target ns collection
|
||||
* @param dataPair data to upload (data.first) and id of changed record (data.second)
|
||||
* @param progress progress of sync in format "number/number". Only for display in fragment
|
||||
*/
|
||||
fun nsUpdate(collection: String, dataPair: DataSyncSelector.DataPair, progress: String)
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package info.nightscout.plugins.sync.nsShared
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
|
@ -22,7 +20,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
|
|||
import info.nightscout.interfaces.plugin.PluginBase
|
||||
import info.nightscout.interfaces.plugin.PluginFragment
|
||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.sync.R
|
||||
import info.nightscout.plugins.sync.databinding.NsClientFragmentBinding
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
|
||||
|
@ -60,11 +57,9 @@ class NSClientFragment : DaggerFragment(), MenuProvider, PluginFragment {
|
|||
override var plugin: PluginBase? = null
|
||||
private val nsClientPlugin
|
||||
get() = activePlugin.activeNsClient
|
||||
private val version: NsClient.Version get() = nsClientPlugin?.version ?: NsClient.Version.NONE
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||
private var _binding: NsClientFragmentBinding? = null
|
||||
|
||||
// This property is only valid between onCreateView and
|
||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.core.validators.ValidatingEditTextPreference
|
|||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.nsclient.NSAlarm
|
||||
import info.nightscout.interfaces.nsclient.NSSettingsStatus
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.plugin.PluginBase
|
||||
import info.nightscout.interfaces.plugin.PluginDescription
|
||||
|
@ -71,7 +72,8 @@ class NSClientPlugin @Inject constructor(
|
|||
private val uiInteraction: UiInteraction,
|
||||
private val activePlugin: ActivePlugin,
|
||||
private val dateUtil: DateUtil,
|
||||
private val profileFunction: ProfileFunction
|
||||
private val profileFunction: ProfileFunction,
|
||||
private val nsSettingsStatus: NSSettingsStatus
|
||||
) : NsClient, Sync, PluginBase(
|
||||
PluginDescription()
|
||||
.mainType(PluginType.SYNC)
|
||||
|
@ -180,6 +182,8 @@ class NSClientPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun detectedNsVersion(): String? = nsSettingsStatus.getVersion()
|
||||
|
||||
private fun addToLog(ev: EventNSClientNewLog) {
|
||||
synchronized(listLog) {
|
||||
listLog.add(ev)
|
||||
|
@ -213,9 +217,6 @@ class NSClientPlugin @Inject constructor(
|
|||
rxBus.send(EventPreferenceChange(rh.gs(R.string.key_ns_client_paused)))
|
||||
}
|
||||
|
||||
override val version: NsClient.Version
|
||||
get() = NsClient.Version.V1
|
||||
|
||||
override val address: String get() = nsClientService?.nsURL ?: ""
|
||||
|
||||
override fun handleClearAlarm(originalAlarm: NSAlarm, silenceTimeInMilliseconds: Long) {
|
||||
|
|
|
@ -289,12 +289,12 @@ class NSClientV3Plugin @Inject constructor(
|
|||
executeLoop("RESEND", forceNew = false)
|
||||
}
|
||||
|
||||
override fun pause(newState: Boolean) {
|
||||
sp.putBoolean(R.string.key_ns_client_paused, newState)
|
||||
rxBus.send(EventPreferenceChange(rh.gs(R.string.key_ns_client_paused)))
|
||||
}
|
||||
override fun pause(newState: Boolean) {
|
||||
sp.putBoolean(R.string.key_ns_client_paused, newState)
|
||||
rxBus.send(EventPreferenceChange(rh.gs(R.string.key_ns_client_paused)))
|
||||
}
|
||||
|
||||
override val version: NsClient.Version get() = NsClient.Version.V3
|
||||
override fun detectedNsVersion(): String? = nsAndroidClient?.lastStatus?.version
|
||||
|
||||
override val address: String get() = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "")
|
||||
|
||||
|
|
Loading…
Reference in a new issue