Merge branch 'dev' into wear

This commit is contained in:
Milos Kozak 2022-04-25 16:37:02 +02:00 committed by GitHub
commit 78ac6e1a38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 285 additions and 273 deletions

View file

@ -1,15 +1,12 @@
package info.nightscout.androidaps.plugins.aps.loop package info.nightscout.androidaps.plugins.aps.loop
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.*
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.LoopFragmentBinding import info.nightscout.androidaps.databinding.LoopFragmentBinding
import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.Loop 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.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.plugins.bus.RxBus 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.HtmlHelper
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -34,6 +32,8 @@ class LoopFragment : DaggerFragment() {
@Inject lateinit var loop: Loop @Inject lateinit var loop: Loop
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
private val ID_MENU_RUN = 1
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
private var _binding: LoopFragmentBinding? = null private var _binding: LoopFragmentBinding? = null
@ -42,8 +42,11 @@ class LoopFragment : DaggerFragment() {
// onDestroyView. // onDestroyView.
private val binding get() = _binding!! private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
setHasOptionsMenu(true)
_binding = LoopFragmentBinding.inflate(inflater, container, false) _binding = LoopFragmentBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }
@ -51,12 +54,33 @@ class LoopFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.run.setOnClickListener { with(binding.swipeRefresh) {
binding.lastrun.text = rh.gs(R.string.executing) setColorSchemeColors(rh.gac(context, R.attr.colorPrimaryDark), rh.gac(context, R.attr.colorPrimary), rh.gac(context, R.attr.colorSecondary))
Thread { loop.invoke("Loop button", true) }.start() 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 @Synchronized
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
@ -64,16 +88,16 @@ class LoopFragment : DaggerFragment() {
.toObservable(EventLoopUpdateGui::class.java) .toObservable(EventLoopUpdateGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
updateGUI() updateGUI()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventLoopSetLastRunGui::class.java) .toObservable(EventLoopSetLastRunGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
clearGUI() clearGUI()
binding.lastrun.text = it.text binding.lastrun.text = it.text
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
updateGUI() updateGUI()
sp.putBoolean(R.string.key_objectiveuseloop, true) sp.putBoolean(R.string.key_objectiveuseloop, true)
@ -117,6 +141,7 @@ class LoopFragment : DaggerFragment() {
allConstraints.getMostLimitedReasons(aapsLogger) allConstraints.getMostLimitedReasons(aapsLogger)
} ?: "" } ?: ""
binding.constraints.text = constraints binding.constraints.text = constraints
binding.swipeRefresh.isRefreshing = false
} }
} }
@ -133,5 +158,6 @@ class LoopFragment : DaggerFragment() {
binding.tbrexecutionTime.text = "" binding.tbrexecutionTime.text = ""
binding.tbrsetbypump.text = "" binding.tbrsetbypump.text = ""
binding.smbsetbypump.text = "" binding.smbsetbypump.text = ""
binding.swipeRefresh.isRefreshing = false
} }
} }

View file

@ -2,14 +2,10 @@ package info.nightscout.androidaps.plugins.aps.openAPSAMA
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.view.LayoutInflater import android.view.*
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.OpenapsamaFragmentBinding 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.EventOpenAPSUpdateGui
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui
import info.nightscout.androidaps.plugins.bus.RxBus 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.JSONFormatter
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers 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.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import org.json.JSONArray import org.json.JSONArray
@ -37,14 +35,19 @@ class OpenAPSAMAFragment : DaggerFragment() {
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var jsonFormatter: JSONFormatter @Inject lateinit var jsonFormatter: JSONFormatter
private val ID_MENU_RUN = 1
private var _binding: OpenapsamaFragmentBinding? = null private var _binding: OpenapsamaFragmentBinding? = null
// This property is only valid between onCreateView and // This property is only valid between onCreateView and
// onDestroyView. // onDestroyView.
private val binding get() = _binding!! private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
setHasOptionsMenu(true)
_binding = OpenapsamaFragmentBinding.inflate(inflater, container, false) _binding = OpenapsamaFragmentBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }
@ -52,11 +55,34 @@ class OpenAPSAMAFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.run.setOnClickListener { with(binding.swipeRefresh) {
openAPSAMAPlugin.invoke("OpenAPSAMA button", false) 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 @Synchronized
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
@ -65,14 +91,14 @@ class OpenAPSAMAFragment : DaggerFragment() {
.toObservable(EventOpenAPSUpdateGui::class.java) .toObservable(EventOpenAPSUpdateGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
updateGUI() updateGUI()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventOpenAPSUpdateResultGui::class.java) .toObservable(EventOpenAPSUpdateResultGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
updateResultGUI(it.text) updateResultGUI(it.text)
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
updateGUI() updateGUI()
} }
@ -118,6 +144,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
openAPSAMAPlugin.lastAutosensResult.let { openAPSAMAPlugin.lastAutosensResult.let {
binding.autosensdata.text = jsonFormatter.format(it.json()) binding.autosensdata.text = jsonFormatter.format(it.json())
} }
binding.swipeRefresh.isRefreshing = false
} }
private fun updateResultGUI(text: String) { private fun updateResultGUI(text: String) {
@ -131,5 +158,6 @@ class OpenAPSAMAFragment : DaggerFragment() {
binding.scriptdebugdata.text = "" binding.scriptdebugdata.text = ""
binding.request.text = "" binding.request.text = ""
binding.lastrun.text = "" binding.lastrun.text = ""
binding.swipeRefresh.isRefreshing = false
} }
} }

View file

@ -3,9 +3,7 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.view.LayoutInflater import android.view.*
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.OpenapsamaFragmentBinding import info.nightscout.androidaps.databinding.OpenapsamaFragmentBinding
@ -39,13 +37,16 @@ class OpenAPSSMBFragment : DaggerFragment() {
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var jsonFormatter: JSONFormatter @Inject lateinit var jsonFormatter: JSONFormatter
private val ID_MENU_RUN = 1
private var _binding: OpenapsamaFragmentBinding? = null private var _binding: OpenapsamaFragmentBinding? = null
// This property is only valid between onCreateView and // This property is only valid between onCreateView and
// onDestroyView. // onDestroyView.
private val binding get() = _binding!! 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) _binding = OpenapsamaFragmentBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }
@ -53,11 +54,34 @@ class OpenAPSSMBFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.run.setOnClickListener { with(binding.swipeRefresh) {
activePlugin.activeAPS.invoke("OpenAPSSMB button", false) 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 @Synchronized
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
@ -65,14 +89,14 @@ class OpenAPSSMBFragment : DaggerFragment() {
.toObservable(EventOpenAPSUpdateGui::class.java) .toObservable(EventOpenAPSUpdateGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
updateGUI() updateGUI()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventOpenAPSUpdateResultGui::class.java) .toObservable(EventOpenAPSUpdateResultGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
updateResultGUI(it.text) updateResultGUI(it.text)
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
updateGUI() updateGUI()
} }
@ -122,6 +146,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
openAPSSMBPlugin.lastAutosensResult.let { openAPSSMBPlugin.lastAutosensResult.let {
binding.autosensdata.text = jsonFormatter.format(it.json()) binding.autosensdata.text = jsonFormatter.format(it.json())
} }
binding.swipeRefresh.isRefreshing = false
} }
@Synchronized @Synchronized
@ -137,5 +162,6 @@ class OpenAPSSMBFragment : DaggerFragment() {
binding.scriptdebugdata.text = "" binding.scriptdebugdata.text = ""
binding.request.text = "" binding.request.text = ""
binding.lastrun.text = "" binding.lastrun.text = ""
binding.swipeRefresh.isRefreshing = false
} }
} }

View file

@ -17,7 +17,6 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.Food import info.nightscout.androidaps.database.entities.Food
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction
import info.nightscout.androidaps.databinding.FoodFragmentBinding import info.nightscout.androidaps.databinding.FoodFragmentBinding
import info.nightscout.androidaps.databinding.FoodItemBinding import info.nightscout.androidaps.databinding.FoodItemBinding
@ -26,7 +25,6 @@ import info.nightscout.androidaps.events.EventFoodDatabaseChanged
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck
@ -35,10 +33,8 @@ import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.ui.UIRunnable import info.nightscout.androidaps.utils.ui.UIRunnable
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import io.reactivex.rxjava3.kotlin.subscribeBy
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
@ -73,27 +69,7 @@ class FoodFragment : DaggerFragment() {
binding.recyclerview.setHasFixedSize(true) binding.recyclerview.setHasFixedSize(true)
binding.recyclerview.layoutManager = LinearLayoutManager(view.context) binding.recyclerview.layoutManager = LinearLayoutManager(view.context)
binding.refreshFromNightscout.setOnClickListener { binding.filterInputLayout.setEndIconOnClickListener {
context?.let { context ->
OKDialog.showConfirmation(context, rh.gs(R.string.refresheventsfromnightscout) + " ?", {
uel.log(
Action.FOOD, Sources.Food, rh.gs(R.string.refresheventsfromnightscout),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.refresheventsfromnightscout))
)
disposable += Completable.fromAction { repository.deleteAllFoods() }
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
.subscribeBy(
onError = { aapsLogger.error("Error removing foods", it) },
onComplete = { rxBus.send(EventFoodDatabaseChanged()) }
)
rxBus.send(EventNSClientRestart())
})
}
}
binding.filterinputLayout.setEndIconOnClickListener {
binding.filter.setText("") binding.filter.setText("")
binding.categoryList.setText(rh.gs(R.string.none), false) binding.categoryList.setText(rh.gs(R.string.none), false)
binding.subcategoryList.setText(rh.gs(R.string.none), false) binding.subcategoryList.setText(rh.gs(R.string.none), false)
@ -220,7 +196,6 @@ class FoodFragment : DaggerFragment() {
holder.binding.energy.text = rh.gs(R.string.shortenergy) + ": " + food.energy + rh.gs(R.string.shortkilojoul) holder.binding.energy.text = rh.gs(R.string.shortenergy) + ": " + food.energy + rh.gs(R.string.shortkilojoul)
holder.binding.energy.visibility = food.energy.isNotZero().toVisibility() holder.binding.energy.visibility = food.energy.isNotZero().toVisibility()
holder.binding.icRemove.tag = food holder.binding.icRemove.tag = food
holder.binding.foodItem.tag = food
holder.binding.icCalculator.tag = food holder.binding.icCalculator.tag = food
} }

View file

@ -15,10 +15,11 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Loop import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -31,19 +32,21 @@ class OverviewMenus @Inject constructor(
private val rxBus: RxBus, private val rxBus: RxBus,
private val buildHelper: BuildHelper, private val buildHelper: BuildHelper,
private val loop: Loop, private val loop: Loop,
private val config: Config private val config: Config,
private val fabricPrivacy: FabricPrivacy
) { ) {
enum class CharType(@StringRes val nameId: Int, @AttrRes val attrId: Int, @AttrRes val attrTextId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) { enum class CharType(@StringRes val nameId: Int, @AttrRes val attrId: Int, @AttrRes val attrTextId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) {
PRE(R.string.overview_show_predictions, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.prediction_shortname), PRE(R.string.overview_show_predictions, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.prediction_shortname),
TREAT(R.string.overview_show_treatments, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.treatments_shortname), TREAT(R.string.overview_show_treatments, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.treatments_shortname),
BAS(R.string.overview_show_basals, R.attr.basal, R.attr.menuTextColor, primary = true, secondary = false,shortnameId = R.string.basal_shortname), BAS(R.string.overview_show_basals, R.attr.basal, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.basal_shortname),
ABS(R.string.overview_show_absinsulin, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true,shortnameId = R.string.abs_insulin_shortname), ABS(R.string.overview_show_absinsulin, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.abs_insulin_shortname),
IOB(R.string.overview_show_iob, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true,shortnameId = R.string.iob), IOB(R.string.overview_show_iob, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.iob),
COB(R.string.overview_show_cob, R.attr.cobColor, R.attr.menuTextColor, primary = false, secondary = true,shortnameId = R.string.cob), COB(R.string.overview_show_cob, R.attr.cobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.cob),
DEV(R.string.overview_show_deviations, R.attr.bgiColor, R.attr.menuTextColor, primary = false, secondary = true,shortnameId = R.string.deviation_shortname), DEV(R.string.overview_show_deviations, R.attr.bgiColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.deviation_shortname),
BGI(R.string.overview_show_bgi, R.attr.bgiColor, R.attr.menuTextColor, primary = false, secondary = true,shortnameId = R.string.bgi_shortname), BGI(R.string.overview_show_bgi, R.attr.bgiColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.bgi_shortname),
SEN(R.string.overview_show_sensitivity, R.attr.ratioColor, R.attr.menuTextColorInverse, primary = false, secondary = true,shortnameId = R.string.sensitivity_shortname), SEN(R.string.overview_show_sensitivity, R.attr.ratioColor, R.attr.menuTextColorInverse, primary = false, secondary = true, shortnameId = R.string.sensitivity_shortname),
ACT(R.string.overview_show_activity, R.attr.activityColor, R.attr.menuTextColor, primary = true, secondary = false,shortnameId = R.string.activity_shortname), ACT(R.string.overview_show_activity, R.attr.activityColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.activity_shortname),
DEVSLOPE(R.string.overview_show_deviationslope, R.attr.devSlopePosColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.devslope_shortname) DEVSLOPE(R.string.overview_show_deviationslope, R.attr.devSlopePosColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.devslope_shortname)
} }
@ -138,21 +141,27 @@ class OverviewMenus @Inject constructor(
} }
popup.setOnMenuItemClickListener { popup.setOnMenuItemClickListener {
// id < 100 graph header - divider 1, 2, 3 ..... try {
when { // id < 100 graph header - divider 1, 2, 3 .....
it.itemId == numOfGraphs -> { when {
// add new empty it.itemId == numOfGraphs -> {
_setting.add(Array(CharType.values().size) { false }) // add new empty
} _setting.add(Array(CharType.values().size) { false })
it.itemId < 100 -> { }
// remove graph
_setting.removeAt(it.itemId) it.itemId < 100 -> {
} // remove graph
else -> { _setting.removeAt(it.itemId)
val graphNumber = it.itemId / 100 - 1 }
val item = it.itemId % 100
_setting[graphNumber][item] = !it.isChecked else -> {
val graphNumber = it.itemId / 100 - 1
val item = it.itemId % 100
_setting[graphNumber][item] = !it.isChecked
}
} }
} catch (exception: Exception) {
fabricPrivacy.logException(exception)
} }
storeGraphConfig() storeGraphConfig()
setupChartMenu(context, chartButton) setupChartMenu(context, chartButton)

View file

@ -14,27 +14,27 @@ import info.nightscout.androidaps.interfaces.BgSource
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.receivers.DataWorker import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.services.Intents import info.nightscout.androidaps.services.Intents
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.log
@Singleton @Singleton
class AidexPlugin @Inject constructor( class AidexPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,
rh: ResourceHelper, rh: ResourceHelper,
aapsLogger: AAPSLogger aapsLogger: AAPSLogger
) : PluginBase(PluginDescription() ) : PluginBase(
.mainType(PluginType.BGSOURCE) PluginDescription()
.fragmentClass(BGSourceFragment::class.java.name) .mainType(PluginType.BGSOURCE)
.pluginIcon((R.drawable.ic_blooddrop_48)) .fragmentClass(BGSourceFragment::class.java.name)
.pluginName(R.string.aidex) .pluginIcon((R.drawable.ic_blooddrop_48))
.shortName(R.string.aidex_short) .pluginName(R.string.aidex)
.description(R.string.description_source_aidex), .shortName(R.string.aidex_short)
.description(R.string.description_source_aidex),
aapsLogger, rh, injector aapsLogger, rh, injector
), BgSource { ), BgSource {
@ -43,7 +43,7 @@ class AidexPlugin @Inject constructor(
/** /**
* Aidex App doesn't have upload to NS * Aidex App doesn't have upload to NS
*/ */
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = true override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = true
override fun advancedFilteringSupported(): Boolean { override fun advancedFilteringSupported(): Boolean {
return advancedFiltering return advancedFiltering

View file

@ -6,39 +6,29 @@
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.plugins.general.food.FoodFragment"> tools:context="info.nightscout.androidaps.plugins.general.food.FoodFragment">
<info.nightscout.androidaps.utils.ui.SingleClickButton <com.google.android.material.textfield.TextInputLayout
android:id="@+id/refresh_from_nightscout" android:id="@+id/filter_input_layout"
style="@style/GrayButton" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:hint="@string/filter"
android:drawableStart="@drawable/ic_refresh" app:endIconMode="clear_text"
android:text="@string/refresheventsfromnightscout" app:startIconDrawable="@android:drawable/ic_menu_search">
tools:visibility="visible" />
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputEditText
android:id="@+id/filterinputLayout" android:id="@+id/filter"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/filter" android:layout_gravity="center_vertical"
app:startIconDrawable="@android:drawable/ic_menu_search" android:layout_marginStart="5dp"
app:endIconMode="clear_text"> android:layout_marginEnd="5dp"
android:layout_weight="1"
android:autofillHints="@string/notes_label"
android:gravity="start"
android:inputType="text|textCapSentences"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputEditText </com.google.android.material.textfield.TextInputLayout>
android:id="@+id/filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:autofillHints="@string/notes_label"
android:gravity="start"
android:textStyle="bold"
android:inputType="text|textCapSentences" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"

View file

@ -1,148 +1,111 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.MaterialComponents.CardView"
android:id="@+id/food_card" android:id="@+id/food_card"
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp" android:layout_gravity="center"
android:layout_marginEnd="4dp"
android:layout_marginTop="4dp"
app:strokeWidth="1dp"
app:cardCornerRadius="4dp" app:cardCornerRadius="4dp"
app:contentPadding="2dp" app:contentPadding="2dp"
app:cardElevation="4dp" app:cardElevation="2dp"
app:cardUseCompatPadding="true" app:cardUseCompatPadding="true" >
android:layout_gravity="center">
<LinearLayout <LinearLayout
android:id="@+id/food_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout <LinearLayout
android:id="@+id/left_right_split" android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_weight="1"
android:paddingStart="3dp" android:gravity="start"
android:paddingEnd="3dp"> android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="@dimen/twenty_four_dp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<LinearLayout <LinearLayout
android:id="@+id/name_and_info_container" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginStart="5dp"
android:layout_weight="1" android:gravity="start"
android:gravity="start"> android:orientation="horizontal">
<LinearLayout <TextView
android:id="@+id/name_container" android:id="@+id/carbs"
android:layout_width="match_parent" android:layout_width="50dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"> android:text="Carbs"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/name" android:id="@+id/portion"
android:layout_width="0dp" android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name"
android:textStyle="bold"
android:textSize="@dimen/twenty_four_dp"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout
android:id="@+id/info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:gravity="center"
android:gravity="start" android:text="Portion"
android:orientation="horizontal" tools:ignore="HardcodedText" />
android:layout_marginStart="5dp">
<TextView <TextView
android:id="@+id/carbs" android:id="@+id/fat"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="Carbs" android:text="Fat"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/portion" android:id="@+id/protein"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="Portion" android:text="Protein"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/fat" android:id="@+id/energy"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="Fat" android:text="Energy"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView
android:id="@+id/protein"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Protein"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/energy"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Energy"
tools:ignore="HardcodedText" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="end">
<ImageView
android:id="@+id/ic_calculator"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:padding="2dp"
android:orientation="horizontal"
android:src="@drawable/ic_calculator" />
<ImageView
android:id="@+id/ic_remove"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:padding="2dp"
android:orientation="horizontal"
android:src="@drawable/ic_trash_outline" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<ImageView
android:id="@+id/ic_calculator"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:contentDescription="@string/overview_calculator_label"
android:orientation="horizontal"
android:paddingStart="-5dp"
android:paddingEnd="-5dp"
android:scaleX=".5"
android:scaleY=".5"
android:src="@drawable/ic_calculator" />
<View <ImageView
android:layout_width="fill_parent" android:id="@+id/ic_remove"
android:layout_height="2dip" android:layout_width="wrap_content"
android:layout_marginBottom="5dp" android:layout_height="match_parent"
android:layout_marginTop="5dp" android:layout_gravity="center"
android:background="?android:attr/dividerHorizontal" /> android:contentDescription="@string/remove_label"
android:orientation="horizontal"
android:padding="2dp"
android:src="@drawable/ic_trash_outline" />
</LinearLayout> </LinearLayout>

View file

@ -1,22 +1,20 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingTop="2dp" android:paddingTop="2dp">
tools:context=".plugins.aps.loop.LoopFragment">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> 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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -515,4 +513,7 @@
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View file

@ -1,29 +1,20 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingTop="2dp" android:paddingTop="2dp">
tools:context=".plugins.aps.openAPSAMA.OpenAPSAMAFragment">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> 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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -580,4 +571,6 @@
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View file

@ -72,7 +72,8 @@
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:maxHeight="5dp" android:maxHeight="5dp"
android:minHeight="3dp" android:minHeight="3dp"
tools:progress="50"/> android:scaleY="5"
tools:progress="50" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/GrayButton" style="@style/GrayButton"

View file

@ -348,7 +348,7 @@
<color name="aaps_theme_dark_onErrorContainer">#F9DEDC</color> <color name="aaps_theme_dark_onErrorContainer">#F9DEDC</color>
<color name="aaps_theme_dark_background">#1D1B1E</color> <color name="aaps_theme_dark_background">#1D1B1E</color>
<color name="aaps_theme_dark_onBackground">#E7E1E5</color> <color name="aaps_theme_dark_onBackground">#E7E1E5</color>
<color name="aaps_theme_dark_surface">#1D1B1E</color> <color name="aaps_theme_dark_surface">#0F0F0F</color>
<color name="aaps_theme_dark_onSurface">#E7E1E5</color> <color name="aaps_theme_dark_onSurface">#E7E1E5</color>
<color name="aaps_theme_dark_surfaceVariant">#49454F</color> <color name="aaps_theme_dark_surfaceVariant">#49454F</color>
<color name="aaps_theme_dark_onSurfaceVariant">#CAC4D0</color> <color name="aaps_theme_dark_onSurfaceVariant">#CAC4D0</color>