Merge pull request #1833 from jotomo/tidepool-fragement

Tidepool fragement
This commit is contained in:
Milos Kozak 2019-06-16 08:52:33 +02:00 committed by GitHub
commit 1cb0f27254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View file

@ -281,6 +281,7 @@ dependencies {
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}" androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}" androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// new for tidepool // new for tidepool

View file

@ -4,25 +4,30 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ScrollView
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.common.SubscriberFragment import info.nightscout.androidaps.plugins.common.SubscriberFragment
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData
import info.nightscout.androidaps.utils.SP
import kotlinx.android.synthetic.main.tidepool_fragment.* import kotlinx.android.synthetic.main.tidepool_fragment.*
class TidepoolFragment : SubscriberFragment() { class TidepoolFragment : SubscriberFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.tidepool_fragment, container, false)
val view = inflater.inflate(R.layout.tidepool_fragment, container, false)
tidepool_login.setOnClickListener {
TidepoolUploader.doLogin()
} }
tidepool_removeall.setOnClickListener { }
tidepool_uploadnow.setOnClickListener { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
return view super.onViewCreated(view, savedInstanceState)
tidepool_login.setOnClickListener { TidepoolUploader.doLogin(false) }
tidepool_uploadnow.setOnClickListener { RxBus.send(EventTidepoolDoUpload()) }
tidepool_removeall.setOnClickListener { RxBus.send(EventTidepoolResetData()) }
tidepool_resertstart.setOnClickListener { SP.putLong(R.string.key_tidepool_last_end, 0) }
} }
@Subscribe @Subscribe
@ -31,10 +36,12 @@ class TidepoolFragment : SubscriberFragment() {
} }
override fun updateGUI() { override fun updateGUI() {
val activity = activity this.activity?.runOnUiThread {
activity?.runOnUiThread { TidepoolPlugin.updateLog()
// TidepoolPlugin.updateLog() tidepool_log.text = TidepoolPlugin.textLog
// tidepool_log.text = TidepoolPlugin.textLog tidepool_status.text = TidepoolUploader.connectionStatus.name
tidepool_log.text = TidepoolPlugin.textLog
tidepool_logscrollview.fullScroll(ScrollView.FOCUS_DOWN)
} }
} }

View file

@ -35,7 +35,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
.pluginName(R.string.tidepool) .pluginName(R.string.tidepool)
.shortName(R.string.tidepool_shortname) .shortName(R.string.tidepool_shortname)
.fragmentClass(TidepoolJavaFragment::class.java.name) .fragmentClass(TidepoolFragment::class.qualifiedName)
.preferencesId(R.xml.pref_tidepool) .preferencesId(R.xml.pref_tidepool)
.description(R.string.description_tidepool) .description(R.string.description_tidepool)
) { ) {