Widget -> ui module

This commit is contained in:
Milos Kozak 2022-11-02 11:22:34 +01:00
parent c80e29f626
commit ae29621c11
58 changed files with 169 additions and 125 deletions

View file

@ -46,27 +46,6 @@
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".widget.WidgetConfigureActivity"
android:theme="@android:style/Theme.Material.Dialog.NoActionBar"
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver
android:name=".widget.Widget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAI3JiApyMrbP2QFzZ2fYfCPsgjkRp53Dm2S1-zPQ" />

View file

@ -45,10 +45,10 @@ import info.nightscout.androidaps.utils.ActivityMonitor
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.ProcessLifecycleListener
import info.nightscout.androidaps.utils.locale.LocaleHelper
import info.nightscout.androidaps.widget.updateWidget
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.widget.Widget
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.exceptions.UndeliverableException
import io.reactivex.rxjava3.kotlin.plusAssign
@ -155,7 +155,7 @@ class MainApp : DaggerApplication() {
// schedule widget update
refreshWidget = Runnable {
handler.postDelayed(refreshWidget, 60000)
updateWidget(this)
Widget.updateWidget(this)
}
handler.postDelayed(refreshWidget, 60000)
}

View file

@ -49,8 +49,7 @@ class HistoryBrowserData @Inject constructor(
activePlugin,
defaultValueHelper,
profileFunction,
repository,
fabricPrivacy
repository
)
iobCobCalculator =
IobCobCalculatorPlugin(

View file

@ -8,7 +8,7 @@ import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.androidaps.widget.updateWidget
import info.nightscout.ui.widget.Widget
import io.reactivex.rxjava3.disposables.Disposable
import javax.inject.Inject
import javax.inject.Singleton
@ -25,7 +25,7 @@ class CompatDBHelper @Inject constructor(
.changeObservable()
.doOnSubscribe {
rxBus.send(EventNewBG(null))
updateWidget(context)
Widget.updateWidget(context)
}
.subscribe {
/**
@ -38,7 +38,7 @@ class CompatDBHelper @Inject constructor(
it.filterIsInstance<GlucoseValue>().maxByOrNull { gv -> gv.timestamp }?.let { gv ->
aapsLogger.debug(LTag.DATABASE, "Firing EventNewBg $gv")
rxBus.send(EventNewBG(gv))
updateWidget(context)
Widget.updateWidget(context)
newestGlucoseValue = gv
}
it.filterIsInstance<GlucoseValue>().minOfOrNull { gv -> gv.timestamp }?.let { timestamp ->

View file

@ -8,7 +8,9 @@ import dagger.Provides
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.implementations.ActivityNamesImpl
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.AndroidPermission
import info.nightscout.androidaps.interfaces.Autotune
import info.nightscout.androidaps.interfaces.BolusTimer
@ -40,7 +42,6 @@ import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsI
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.plugins.general.nsclient.DataSyncSelectorImplementation
import info.nightscout.androidaps.plugins.general.nsclient.data.DeviceStatusData
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.pump.PumpSyncImplementation
import info.nightscout.androidaps.utils.DateUtil
@ -60,6 +61,7 @@ import info.nightscout.implementation.CarbTimerImpl
import info.nightscout.implementation.LocalAlertUtilsImpl
import info.nightscout.implementation.XDripBroadcastImpl
import info.nightscout.implementation.queue.CommandQueueImplementation
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Singleton
@ -136,6 +138,7 @@ open class AppModule {
@Binds fun bindBolusTimerInterface(bolusTimer: BolusTimerImpl): BolusTimer
@Binds fun bindAndroidPermissionInterface(androidPermission: AndroidPermissionImpl): AndroidPermission
@Binds fun bindLocalAlertUtilsInterface(localAlertUtils: LocalAlertUtilsImpl): LocalAlertUtils
@Binds fun bindActivityNamesInterface(activityNames: ActivityNamesImpl): ActivityNames
}
}

View file

@ -2,9 +2,9 @@ package info.nightscout.androidaps.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.widget.WidgetConfigureActivity
import info.nightscout.ui.widget.WidgetConfigureActivity
import info.nightscout.androidaps.skins.SkinListPreference
import info.nightscout.androidaps.widget.Widget
import info.nightscout.ui.widget.Widget
@Module
@Suppress("unused")

View file

@ -0,0 +1,11 @@
package info.nightscout.androidaps.implementations
import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.interfaces.ActivityNames
import javax.inject.Inject
class ActivityNamesImpl @Inject constructor() : ActivityNames {
override val mainActivityClass: Class<*>
get() = MainActivity::class.java
}

View file

@ -1,16 +1,17 @@
package info.nightscout.androidaps.plugins.aps.openAPSSMB
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.interfaces.VariableSensitivityResult
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.APSResult
import org.json.JSONException
import org.json.JSONObject
class DetermineBasalResultSMB private constructor(injector: HasAndroidInjector) : APSResult(injector) {
class DetermineBasalResultSMB private constructor(injector: HasAndroidInjector) : APSResult(injector), VariableSensitivityResult {
private var eventualBG = 0.0
private var snoozeBG = 0.0
var variableSens: Double? = null
override var variableSens: Double? = null
internal constructor(injector: HasAndroidInjector, result: JSONObject) : this(injector) {
date = dateUtil.now()

View file

@ -136,6 +136,6 @@ class NSClientFragment : DaggerFragment(), MenuProvider {
binding.url.text = nsClientPlugin.url()
binding.status.text = nsClientPlugin.status
val size = dataSyncSelector.queueSize()
binding.queue.text = if (size >= 0) size.toString() else rh.gs(R.string.notavailable)
binding.queue.text = if (size >= 0) size.toString() else rh.gs(R.string.value_unavailable_short)
}
}

View file

@ -35,8 +35,6 @@ import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
import info.nightscout.ui.dialogs.CalibrationDialog
import info.nightscout.ui.dialogs.CarbsDialog
import info.nightscout.androidaps.dialogs.InsulinDialog
import info.nightscout.androidaps.dialogs.LoopDialog
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
@ -108,6 +106,8 @@ import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.weardata.EventData
import info.nightscout.ui.dialogs.CalibrationDialog
import info.nightscout.ui.dialogs.CarbsDialog
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.Locale
@ -799,7 +799,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
runOnUiThread {
_binding ?: return@runOnUiThread
binding.infoLayout.bg.text = lastBg?.valueToUnitsString(units)
?: rh.gs(R.string.notavailable)
?: rh.gs(R.string.value_unavailable_short)
binding.infoLayout.bg.setTextColor(lastBgColor)
binding.infoLayout.arrow.setImageResource(trendArrow.directionToIcon())
binding.infoLayout.arrow.setColorFilter(lastBgColor)
@ -813,7 +813,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
binding.infoLayout.longAvgDelta.text = Profile.toSignedUnitsString(glucoseStatus.longAvgDelta, glucoseStatus.longAvgDelta * Constants.MGDL_TO_MMOLL, units)
} else {
binding.infoLayout.deltaLarge.text = ""
binding.infoLayout.delta.text = "Δ " + rh.gs(R.string.notavailable)
binding.infoLayout.delta.text = "Δ " + rh.gs(R.string.value_unavailable_short)
binding.infoLayout.avgDelta.text = ""
binding.infoLayout.longAvgDelta.text = ""
}

View file

@ -23,8 +23,6 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNo
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewNotification
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
@ -81,8 +79,6 @@ class OverviewPlugin @Inject constructor(
rxBus.send(EventDismissNotification(id))
}
class DeviationDataPoint(x: Double, y: Double, var color: Int, scale: Scale) : ScaledDataPoint(x, y, scale)
override fun onStart() {
super.onStart()
overviewMenus.loadGraphConfig()

View file

@ -67,7 +67,7 @@ class StatusLightHandler @Inject constructor(
if (pump.model().supportBatteryLevel || erosBatteryLinkAvailable) {
handleLevel(careportal_battery_level, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
} else {
careportal_battery_level?.text = rh.gs(R.string.notavailable)
careportal_battery_level?.text = rh.gs(R.string.value_unavailable_short)
careportal_battery_level?.setTextColor(rh.gac(careportal_battery_level.context, R.attr.defaultTextColor))
}
}
@ -81,7 +81,7 @@ class StatusLightHandler @Inject constructor(
warnColors.setColorByAge(view, therapyEvent.value, warn, urgent)
view?.text = therapyEvent.value.age(rh.shortTextMode(), rh, dateUtil)
} else {
view?.text = if (rh.shortTextMode()) "-" else rh.gs(R.string.notavailable)
view?.text = if (rh.shortTextMode()) "-" else rh.gs(R.string.value_unavailable_short)
}
}

View file

@ -13,11 +13,22 @@ import info.nightscout.androidaps.database.entities.Bolus
import info.nightscout.androidaps.database.entities.ExtendedBolus
import info.nightscout.androidaps.database.entities.TemporaryBasal
import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.events.Event
import info.nightscout.androidaps.events.EventConfigBuilderChange
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toTemporaryBasal
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
@ -25,12 +36,10 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHi
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.MidnightTime
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.androidaps.events.Event
import info.nightscout.androidaps.utils.MidnightTime
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP

View file

@ -34,10 +34,10 @@ import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.widget.updateWidget
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.widget.Widget
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import kotlin.math.abs
@ -117,7 +117,7 @@ class KeepAliveWorker(
}
lastRun = dateUtil.now()
updateWidget(context)
Widget.updateWidget(context)
localAlertUtils.shortenSnoozeInterval()
localAlertUtils.checkStaleBGAlert()
checkPump()

View file

@ -15,12 +15,13 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DeviationDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.FixedLineGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
@ -29,10 +30,8 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCa
import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.util.ArrayList
import javax.inject.Inject
import kotlin.math.abs
import kotlin.math.max
@ -87,7 +86,7 @@ class PrepareIobAutosensGraphDataWorker(
val bgiArrayPrediction: MutableList<ScaledDataPoint> = ArrayList()
data.overviewData.maxBGIValue = Double.MIN_VALUE
val devArray: MutableList<OverviewPlugin.DeviationDataPoint> = ArrayList()
val devArray: MutableList<DeviationDataPoint> = ArrayList()
data.overviewData.maxDevValueFound = Double.MIN_VALUE
val ratioArray: MutableList<ScaledDataPoint> = ArrayList()
@ -168,7 +167,7 @@ class PrepareIobAutosensGraphDataWorker(
} else if (autosensData.type == "csf") {
color = rh.gac( ctx, R.attr.deviationGreyColor)
}
devArray.add(OverviewPlugin.DeviationDataPoint(time.toDouble(), autosensData.deviation, color, data.overviewData.devScale))
devArray.add(DeviationDataPoint(time.toDouble(), autosensData.deviation, color, data.overviewData.devScale))
data.overviewData.maxDevValueFound = maxOf(data.overviewData.maxDevValueFound, abs(autosensData.deviation), abs(bgi))
}
@ -260,7 +259,7 @@ class PrepareIobAutosensGraphDataWorker(
// DEVIATIONS
data.overviewData.deviationsSeries = BarGraphSeries(Array(devArray.size) { i -> devArray[i] }).also {
it.setValueDependentColor { data: OverviewPlugin.DeviationDataPoint -> data.color }
it.setValueDependentColor { data: DeviationDataPoint -> data.color }
}
// RATIO

View file

@ -9,6 +9,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
import info.nightscout.androidaps.plugins.general.overview.OverviewData
@ -19,8 +20,7 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Point
import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.interfaces.ResourceHelper
import java.util.*
import java.util.Calendar
import javax.inject.Inject
import kotlin.math.ceil
import kotlin.math.max

View file

@ -107,7 +107,7 @@
style="@style/GrayButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_startextbolus"
android:drawableTop="@drawable/ic_actions_start_extended_bolus"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/overview_extendedbolus_button"

View file

@ -23,7 +23,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
app:srcCompat="@drawable/ic_actions_startextbolus" />
app:srcCompat="@drawable/ic_actions_start_extended_bolus" />
<TextView
android:layout_width="match_parent"

View file

@ -57,7 +57,7 @@
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:hint="temp target"
android:text="@string/notavailable"
android:text="@string/value_unavailable_short"
android:textAppearance="?android:attr/textAppearanceSmall"
android:foreground="?attr/selectableItemBackgroundBorderless"
app:drawableStartCompat="@drawable/ic_crosstarget"

View file

@ -357,7 +357,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/ic_actions_startextbolus"
app:srcCompat="@drawable/ic_actions_start_extended_bolus"
android:contentDescription="@string/extended_bolus" />
<TextView
@ -391,7 +391,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/ic_swap_vert_black_48dp_green"
android:contentDescription="@string/a11y_autosenslabel" />
android:contentDescription="@string/a11y_autosens_label" />
<TextView
android:id="@+id/sensitivity"

View file

@ -26,7 +26,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/extended_bolus"
android:icon="@drawable/ic_actions_startextbolus" />
android:icon="@drawable/ic_actions_start_extended_bolus" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"

View file

@ -300,7 +300,6 @@
<string name="wear_detailedIOB_title">Show detailed IOB</string>
<string name="wear_detailedIOB_summary">Break down IOB into bolus and basal IOB on the watchface</string>
<string name="nosuccess">not successful - please check phone</string>
<string name="notavailable">n/a</string>
<string name="patientage">Patient type</string>
<string name="child">Child</string>
<string name="teenage">Teenage</string>
@ -415,7 +414,6 @@
<string name="absorptionsettings_title">Absorption settings</string>
<string name="absorption_maxtime_title">Meal max absorption time [h]</string>
<string name="absorption_maxtime_summary">Time in hours where is expected all carbs from meal will be absorbed</string>
<string name="key_rangetodisplay" translatable="false">rangetodisplay</string>
<string name="openaps_short">OAPS</string>
<string name="uploader_short">UPLD</string>
<string name="basal_short">BAS</string>
@ -550,7 +548,6 @@
<string name="ignore5m">Ignore 5m</string>
<string name="ignore15m">Ignore 15m</string>
<string name="ignore30m">Ignore 30m</string>
<string name="required">req</string>
<string name="nav_historybrowser">History browser</string>
<string name="wear_notifysmb_title">Notify on SMB</string>
<string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string>
@ -650,7 +647,6 @@
<string name="openapsama_bolussnooze_dia_divisor">Bolus snooze dia divisor</string>
<string name="openapsama_max_daily_safety_multiplier">Max daily safety multiplier</string>
<string name="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string>
<string name="value_unavailable_short">n/a</string>
<string name="key_virtualpump_uploadstatus" translatable="false">virtualpump_uploadstatus</string>
<string name="virtualpump_type">Virtual Pump Type</string>
<string name="virtualpump_definition">Pump Definition</string>
@ -908,7 +904,6 @@
<string name="graph_menu_divider_header">Graph</string>
<string name="chart_menu">Chart menu</string>
<string name="clear_filter">Clear filter</string>
<string name="trend_arrow">Trend arrow</string>
<string name="cannula">Cannula</string>
<string name="userentry">User entry</string>
<string name="common_values">Use values of your largest food you usually eat\n</string>
@ -978,18 +973,6 @@
<string name="a11_correction_percentage">correct outcome with %</string>
<string name="a11_correction_units">correct outcome with units</string>
<string name="not_available_full">Not available</string>
<string name="a11y_high">high</string>
<string name="a11y_inrange">in range</string>
<string name="a11y_low">low</string>
<string name="a11y_arrow_double_down">falling rapidly</string>
<string name="a11y_arrow_single_down">falling</string>
<string name="a11y_arrow_forty_five_down">falling slowly</string>
<string name="a11y_arrow_flat">stable</string>
<string name="a11y_arrow_forty_five_up">rising slowly</string>
<string name="a11y_arrow_single_up">rising</string>
<string name="a11y_arrow_double_up">rising rapidly</string>
<string name="a11y_arrow_none">none</string>
<string name="a11y_arrow_unknown">unknown</string>
<string name="a11y_graph">graph</string>
<string name="a11y_bg_quality">blood glucose quality</string>
<string name="a11y_bg_quality_recalculated">recalculated</string>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="info.nightscout.androidaps.widget.WidgetConfigureActivity"
android:configure="info.nightscout.ui.widget.WidgetConfigureActivity"
android:description="@string/widget_description"
android:initialKeyguardLayout="@layout/widget_layout"
android:initialLayout="@layout/widget_layout"

View file

@ -83,7 +83,6 @@
<string name="wifissidcompared">WiFi SSID %1$s %2$s</string>
<string name="autosenscompared">Autosens %1$s %2$s %%</string>
<string name="autosenslabel">Autosens %</string>
<string name="a11y_autosenslabel">Auto sens</string>
<string name="deltacompared">%3$s %1$s %2$s</string>
<string name="deltalabel">BG difference</string>
<string name="deltalabel_u">BG difference [%1$s]</string>

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.interfaces
interface ActivityNames {
val mainActivityClass: Class<*>
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.interfaces
interface VariableSensitivityResult {
var variableSens: Double?
}

View file

@ -1,11 +1,13 @@
package info.nightscout.androidaps.plugins.general.overview
import android.content.Context
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.androidaps.R
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper
@ -19,20 +21,21 @@ import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DeviationDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.FixedLineGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import java.util.*
import java.util.Calendar
import javax.inject.Inject
import javax.inject.Singleton
@ -45,8 +48,7 @@ class OverviewData @Inject constructor(
private val activePlugin: ActivePlugin,
private val defaultValueHelper: DefaultValueHelper,
private val profileFunction: ProfileFunction,
private val repository: AppRepository,
private val fabricPrivacy: FabricPrivacy
private val repository: AppRepository
) {
var rangeToDisplay = 6 // for graph
@ -163,7 +165,7 @@ class OverviewData @Inject constructor(
if (temporaryBasal?.isInProgress == false) temporaryBasal = null
temporaryBasal?.let { "T:" + it.toStringShort() }
?: rh.gs(R.string.pump_basebasalrate, profile.getBasal())
} ?: rh.gs(R.string.notavailable)
} ?: rh.gs(R.string.value_unavailable_short)
fun temporaryBasalDialogText(iobCobCalculator: IobCobCalculator): String =
profileFunction.getProfile()?.let { profile ->
@ -172,9 +174,9 @@ class OverviewData @Inject constructor(
"\n" + rh.gs(R.string.tempbasal_label) + ": " + temporaryBasal.toStringFull(profile, dateUtil)
}
?: "${rh.gs(R.string.basebasalrate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}"
} ?: rh.gs(R.string.notavailable)
} ?: rh.gs(R.string.value_unavailable_short)
fun temporaryBasalIcon(iobCobCalculator: IobCobCalculator): Int =
@DrawableRes fun temporaryBasalIcon(iobCobCalculator: IobCobCalculator): Int =
profileFunction.getProfile()?.let { profile ->
iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal ->
val percentRate = temporaryBasal.convertedToPercent(dateUtil.now(), profile)
@ -186,7 +188,8 @@ class OverviewData @Inject constructor(
}
} ?: R.drawable.ic_cp_basal_no_tbr
fun temporaryBasalColor(context: Context?, iobCobCalculator: IobCobCalculator): Int = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { rh.gac(context , R.attr.basal) }
@AttrRes fun temporaryBasalColor(context: Context?, iobCobCalculator: IobCobCalculator): Int = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { rh.gac(context, R
.attr.basal) }
?: rh.gac(context, R.attr.defaultTextColor)
/*
@ -239,7 +242,7 @@ class OverviewData @Inject constructor(
* SENSITIVITY
*/
fun lastAutosensData(iobCobCalculator: IobCobCalculator) = iobCobCalculator.ads.getLastAutosensData("Overview", aapsLogger, dateUtil)
fun lastAutosensData(iobCobCalculator: IobCobCalculator) : AutosensData? = iobCobCalculator.ads.getLastAutosensData("Overview", aapsLogger, dateUtil)
/*
* Graphs
@ -291,7 +294,7 @@ class OverviewData @Inject constructor(
var maxDevValueFound = Double.MIN_VALUE
val devScale = Scale()
var deviationsSeries: BarGraphSeries<OverviewPlugin.DeviationDataPoint> = BarGraphSeries()
var deviationsSeries: BarGraphSeries<DeviationDataPoint> = BarGraphSeries()
var maxRatioValueFound = 5.0 //even if sens data equals 0 for all the period, minimum scale is between 95% and 105%
var minRatioValueFound = -maxRatioValueFound

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
class DeviationDataPoint(x: Double, y: Double, var color: Int, scale: Scale) : ScaledDataPoint(x, y, scale)

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.utils
import info.nightscout.androidaps.R
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.GlucoseValue.TrendArrow.*

View file

@ -46,7 +46,7 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
Sources.WizardDialog -> R.drawable.ic_calculator
Sources.QuickWizard -> R.drawable.ic_quick_wizard
Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus
Sources.ExtendedBolusDialog -> R.drawable.ic_actions_start_extended_bolus
Sources.TTDialog -> R.drawable.ic_temptarget_high
Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch
Sources.LoopDialog -> R.drawable.ic_loop_closed

View file

@ -84,6 +84,7 @@
<string name="key_enable_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string>
<string name="key_enable_carbs_required_alert_local" translatable="false">enable_carbs_required_alert_local</string>
<string name="key_smscommunicator_report_pump_unreachable" translatable="false">smscommunicator_report_pump_unreachable</string>
<string name="key_rangetodisplay" translatable="false">rangetodisplay</string>
<!-- General-->
<string name="refresh">Refresh</string>
@ -208,6 +209,22 @@
<string name="pumpsuspended">Pump suspended</string>
<string name="notconfigured">Not configured</string>
<string name="loopsuspended">Loop suspended</string>
<string name="trend_arrow">Trend arrow</string>
<string name="a11y_autosens_label">Auto sens</string>
<string name="value_unavailable_short">n/a</string>
<string name="required">req</string>
<string name="a11y_arrow_double_down">falling rapidly</string>
<string name="a11y_arrow_single_down">falling</string>
<string name="a11y_arrow_forty_five_down">falling slowly</string>
<string name="a11y_arrow_flat">stable</string>
<string name="a11y_arrow_forty_five_up">rising slowly</string>
<string name="a11y_arrow_single_up">rising</string>
<string name="a11y_arrow_double_up">rising rapidly</string>
<string name="a11y_arrow_none">none</string>
<string name="a11y_arrow_unknown">unknown</string>
<string name="a11y_high">high</string>
<string name="a11y_inrange">in range</string>
<string name="a11y_low">low</string>
<!-- Constraints-->
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>

View file

@ -13,7 +13,8 @@ android {
}
dependencies {
implementation project(':core')
implementation project(':shared')
implementation project(':database')
implementation project(':core')
implementation project(':graphview')
}

View file

@ -1,4 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name=".widget.WidgetConfigureActivity"
android:exported="false"
android:theme="@android:style/Theme.Material.Dialog.NoActionBar">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver
android:name=".widget.Widget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
</application>
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.widget
package info.nightscout.ui.widget
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
@ -14,15 +14,21 @@ import android.view.View
import android.widget.RemoteViews
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.extensions.directionToIcon
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.interfaces.VariableSensitivityResult
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
@ -31,7 +37,8 @@ import info.nightscout.androidaps.utils.TrendCalculator
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import java.util.*
import info.nightscout.ui.R
import java.util.Locale
import javax.inject.Inject
import kotlin.math.abs
@ -43,6 +50,7 @@ class Widget : AppWidgetProvider() {
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var overviewData: OverviewData
@Inject lateinit var trendCalculator: TrendCalculator
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
@Inject lateinit var dateUtil: DateUtil
@ -58,6 +66,13 @@ class Widget : AppWidgetProvider() {
// This object doesn't behave like singleton,
// many threads were created. Making handler static resolve this issue
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
fun updateWidget(context: Context) {
context.sendBroadcast(Intent().also {
it.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, AppWidgetManager.getInstance(context)?.getAppWidgetIds(ComponentName(context, Widget::class.java)))
it.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
})
}
}
private val intentAction = "OpenApp"
@ -88,7 +103,7 @@ class Widget : AppWidgetProvider() {
val alpha = sp.getInt(WidgetConfigureActivity.PREF_PREFIX_KEY + appWidgetId, WidgetConfigureActivity.DEFAULT_OPACITY)
// Create an Intent to launch MainActivity when clicked
val intent = Intent(context, MainActivity::class.java).also { it.action = intentAction }
val intent = Intent(context, activityNames.mainActivityClass).also { it.action = intentAction }
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
// Widgets allow click handlers to only launch pending intents
views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent)
@ -109,7 +124,7 @@ class Widget : AppWidgetProvider() {
private fun updateBg(views: RemoteViews) {
val units = profileFunction.getUnits()
views.setTextViewText(R.id.bg, overviewData.lastBg?.valueToUnitsString(units) ?: rh.gs(R.string.notavailable))
views.setTextViewText(R.id.bg, overviewData.lastBg?.valueToUnitsString(units) ?: rh.gs(R.string.value_unavailable_short))
views.setTextColor(
R.id.bg, when {
overviewData.isLow -> rh.gc(R.color.widget_low)
@ -132,9 +147,9 @@ class Widget : AppWidgetProvider() {
views.setTextViewText(R.id.avg_delta, Profile.toSignedUnitsString(glucoseStatus.shortAvgDelta, glucoseStatus.shortAvgDelta * Constants.MGDL_TO_MMOLL, units))
views.setTextViewText(R.id.long_avg_delta, Profile.toSignedUnitsString(glucoseStatus.longAvgDelta, glucoseStatus.longAvgDelta * Constants.MGDL_TO_MMOLL, units))
} else {
views.setTextViewText(R.id.delta, rh.gs(R.string.notavailable))
views.setTextViewText(R.id.avg_delta, rh.gs(R.string.notavailable))
views.setTextViewText(R.id.long_avg_delta, rh.gs(R.string.notavailable))
views.setTextViewText(R.id.delta, rh.gs(R.string.value_unavailable_short))
views.setTextViewText(R.id.avg_delta, rh.gs(R.string.value_unavailable_short))
views.setTextViewText(R.id.long_avg_delta, rh.gs(R.string.value_unavailable_short))
}
// strike through if BG is old
@ -142,7 +157,7 @@ class Widget : AppWidgetProvider() {
else views.setInt(R.id.bg, "setPaintFlags", Paint.ANTI_ALIAS_FLAG)
views.setTextViewText(R.id.time_ago, dateUtil.minAgo(rh, overviewData.lastBg?.timestamp))
views.setTextViewText(R.id.time_ago_short, "(" + dateUtil.minAgoShort(overviewData.lastBg?.timestamp) + ")")
//views.setTextViewText(R.id.time_ago_short, "(" + dateUtil.minAgoShort(overviewData.lastBg?.timestamp) + ")")
}
private fun updateTemporaryBasal(views: RemoteViews) {
@ -240,7 +255,7 @@ class Widget : AppWidgetProvider() {
// Show variable sensitivity
val request = loop.lastRun?.request
if (request is DetermineBasalResultSMB) {
if (request is VariableSensitivityResult) {
val isfMgdl = profileFunction.getProfile()?.getIsfMgdl()
val variableSens = request.variableSens
if (variableSens != isfMgdl && variableSens != null && isfMgdl != null) {
@ -257,10 +272,3 @@ class Widget : AppWidgetProvider() {
} else views.setViewVisibility(R.id.variable_sensitivity, View.GONE)
}
}
internal fun updateWidget(context: Context) {
context.sendBroadcast(Intent().also {
it.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, AppWidgetManager.getInstance(context)?.getAppWidgetIds(ComponentName(context, Widget::class.java)))
it.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
})
}

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.widget
package info.nightscout.ui.widget
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.os.Bundle
import android.widget.SeekBar
import dagger.android.DaggerActivity
import info.nightscout.androidaps.databinding.WidgetConfigureBinding
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.databinding.WidgetConfigureBinding
import javax.inject.Inject
/**
@ -18,7 +18,6 @@ class WidgetConfigureActivity : DaggerActivity() {
companion object {
@Suppress("PrivatePropertyName")
const val PREF_PREFIX_KEY = "appwidget_"
const val DEFAULT_OPACITY = 25
}
@ -51,7 +50,7 @@ class WidgetConfigureActivity : DaggerActivity() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
value = progress
saveTitlePref(appWidgetId, value)
updateWidget(this@WidgetConfigureActivity)
Widget.updateWidget(this@WidgetConfigureActivity)
}
})

View file

@ -305,7 +305,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/extended_bolus"
android:src="@drawable/ic_actions_startextbolus" />
android:src="@drawable/ic_actions_start_extended_bolus" />
<TextView
android:id="@+id/extended_bolus"
@ -337,7 +337,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/a11y_autosenslabel"
android:contentDescription="@string/a11y_autosens_label"
android:src="@drawable/ic_swap_vert_black_48dp_green" />
<TextView