swiperefresh for loop and aps
This commit is contained in:
parent
4a991e4f38
commit
dc4febb6e4
|
@ -1,15 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.LoopFragmentBinding
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.interfaces.Loop
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
|
@ -18,6 +15,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -34,6 +32,8 @@ class LoopFragment : DaggerFragment() {
|
|||
@Inject lateinit var loop: Loop
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
private val ID_MENU_RUN = 1
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private var _binding: LoopFragmentBinding? = null
|
||||
|
@ -42,8 +42,11 @@ class LoopFragment : DaggerFragment() {
|
|||
// onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
setHasOptionsMenu(true)
|
||||
_binding = LoopFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -51,11 +54,32 @@ class LoopFragment : DaggerFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.run.setOnClickListener {
|
||||
binding.lastrun.text = rh.gs(R.string.executing)
|
||||
Thread { loop.invoke("Loop button", true) }.start()
|
||||
with(binding.swipeRefresh) {
|
||||
setColorSchemeColors(rh.gac(context, R.attr.colorPrimaryDark), rh.gac(context, R.attr.colorPrimary), rh.gac(context, R.attr.colorSecondary))
|
||||
setOnRefreshListener {
|
||||
binding.lastrun.text = rh.gs(info.nightscout.androidaps.R.string.executing)
|
||||
Thread { loop.invoke("Loop swiperefresh", true) }.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
when (item.itemId) {
|
||||
ID_MENU_RUN -> {
|
||||
binding.lastrun.text = rh.gs(R.string.executing)
|
||||
Thread { loop.invoke("Loop menu", true) }.start()
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
|
@ -117,6 +141,7 @@ class LoopFragment : DaggerFragment() {
|
|||
allConstraints.getMostLimitedReasons(aapsLogger)
|
||||
} ?: ""
|
||||
binding.constraints.text = constraints
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,5 +158,6 @@ class LoopFragment : DaggerFragment() {
|
|||
binding.tbrexecutionTime.text = ""
|
||||
binding.tbrsetbypump.text = ""
|
||||
binding.smbsetbypump.text = ""
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,10 @@ package info.nightscout.androidaps.plugins.aps.openAPSAMA
|
|||
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.OpenapsamaFragmentBinding
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
|
||||
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
|
@ -18,6 +14,8 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.JSONFormatter
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import org.json.JSONArray
|
||||
|
@ -37,14 +35,19 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var jsonFormatter: JSONFormatter
|
||||
|
||||
private val ID_MENU_RUN = 1
|
||||
|
||||
private var _binding: OpenapsamaFragmentBinding? = null
|
||||
|
||||
// This property is only valid between onCreateView and
|
||||
// onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
setHasOptionsMenu(true)
|
||||
_binding = OpenapsamaFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -52,11 +55,34 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.run.setOnClickListener {
|
||||
openAPSAMAPlugin.invoke("OpenAPSAMA button", false)
|
||||
with(binding.swipeRefresh) {
|
||||
setColorSchemeColors(rh.gac(context, R.attr.colorPrimaryDark), rh.gac(context, R.attr.colorPrimary), rh.gac(context, R.attr.colorSecondary))
|
||||
setOnRefreshListener {
|
||||
binding.lastrun.text = rh.gs(info.nightscout.androidaps.R.string.executing)
|
||||
openAPSAMAPlugin.invoke("OpenAPSAMA swiperefresh", false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
when (item.itemId) {
|
||||
ID_MENU_RUN -> {
|
||||
binding.lastrun.text = rh.gs(R.string.executing)
|
||||
openAPSAMAPlugin.invoke("OpenAPSAMA menu", false)
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
@ -118,6 +144,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
openAPSAMAPlugin.lastAutosensResult.let {
|
||||
binding.autosensdata.text = jsonFormatter.format(it.json())
|
||||
}
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
|
||||
private fun updateResultGUI(text: String) {
|
||||
|
@ -131,5 +158,6 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
binding.scriptdebugdata.text = ""
|
||||
binding.request.text = ""
|
||||
binding.lastrun.text = ""
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB
|
|||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.OpenapsamaFragmentBinding
|
||||
|
@ -39,6 +37,8 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var jsonFormatter: JSONFormatter
|
||||
|
||||
private val ID_MENU_RUN = 1
|
||||
|
||||
private var _binding: OpenapsamaFragmentBinding? = null
|
||||
|
||||
// This property is only valid between onCreateView and
|
||||
|
@ -46,6 +46,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
setHasOptionsMenu(true)
|
||||
_binding = OpenapsamaFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -53,11 +54,34 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.run.setOnClickListener {
|
||||
activePlugin.activeAPS.invoke("OpenAPSSMB button", false)
|
||||
with(binding.swipeRefresh) {
|
||||
setColorSchemeColors(rh.gac(context, R.attr.colorPrimaryDark), rh.gac(context, R.attr.colorPrimary), rh.gac(context, R.attr.colorSecondary))
|
||||
setOnRefreshListener {
|
||||
binding.lastrun.text = rh.gs(info.nightscout.androidaps.R.string.executing)
|
||||
activePlugin.activeAPS.invoke("OpenAPSSMB swiperefresh", false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
when (item.itemId) {
|
||||
ID_MENU_RUN -> {
|
||||
binding.lastrun.text = rh.gs(R.string.executing)
|
||||
activePlugin.activeAPS.invoke("OpenAPSSMB menu", false)
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
@ -122,6 +146,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
openAPSSMBPlugin.lastAutosensResult.let {
|
||||
binding.autosensdata.text = jsonFormatter.format(it.json())
|
||||
}
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
@ -137,5 +162,6 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
binding.scriptdebugdata.text = ""
|
||||
binding.request.text = ""
|
||||
binding.lastrun.text = ""
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools = "http://schemas.android.com/tools"
|
||||
android:id = "@+id/swipeRefresh"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent"
|
||||
tools:context=".plugins.aps.loop.LoopFragment">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="2dp"
|
||||
tools:context=".plugins.aps.loop.LoopFragment">
|
||||
android:paddingTop="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/GrayButton"
|
||||
android:id="@+id/run"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/openapsma_run" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -515,4 +513,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
|
|
|
@ -1,29 +1,20 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools = "http://schemas.android.com/tools"
|
||||
android:id = "@+id/swipeRefresh"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent"
|
||||
tools:context=".plugins.aps.openAPSAMA.OpenAPSAMAFragment">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="2dp"
|
||||
tools:context=".plugins.aps.openAPSAMA.OpenAPSAMAFragment">
|
||||
android:paddingTop="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/GrayButton"
|
||||
android:id="@+id/run"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/openapsma_run" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -580,4 +571,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
|
Loading…
Reference in a new issue