:app :wear cleanup

This commit is contained in:
Milos Kozak 2023-09-26 18:29:58 +02:00
parent 2e3159fd60
commit 7c417e3519
106 changed files with 1723 additions and 1684 deletions

View file

@ -99,7 +99,7 @@ def allCommitted = { ->
android { android {
namespace 'info.nightscout.androidaps' namespace 'app.aaps'
ndkVersion "21.1.6352462" ndkVersion "21.1.6352462"
defaultConfig { defaultConfig {

View file

@ -59,22 +59,20 @@ import app.aaps.core.ui.toast.ToastUtils
import app.aaps.core.utils.isRunningRealPumpTest import app.aaps.core.utils.isRunningRealPumpTest
import app.aaps.database.entities.UserEntry.Action import app.aaps.database.entities.UserEntry.Action
import app.aaps.database.entities.UserEntry.Sources import app.aaps.database.entities.UserEntry.Sources
import app.aaps.databinding.ActivityMainBinding
import app.aaps.plugins.configuration.activities.DaggerAppCompatActivityWithResult import app.aaps.plugins.configuration.activities.DaggerAppCompatActivityWithResult
import app.aaps.plugins.configuration.activities.SingleFragmentActivity import app.aaps.plugins.configuration.activities.SingleFragmentActivity
import app.aaps.plugins.configuration.setupwizard.SetupWizardActivity import app.aaps.plugins.configuration.setupwizard.SetupWizardActivity
import app.aaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin import app.aaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
import app.aaps.ui.activities.ProfileHelperActivity
import app.aaps.ui.activities.StatsActivity
import app.aaps.ui.activities.TreatmentsActivity
import app.aaps.ui.tabs.TabPageAdapter
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.joanzapata.iconify.Iconify import com.joanzapata.iconify.Iconify
import com.joanzapata.iconify.fonts.FontAwesomeModule import com.joanzapata.iconify.fonts.FontAwesomeModule
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityMainBinding
import app.aaps.ui.activities.ProfileHelperActivity
import app.aaps.ui.activities.StatsActivity
import app.aaps.ui.activities.TreatmentsActivity
import app.aaps.ui.tabs.TabPageAdapter
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 java.io.File import java.io.File

View file

@ -42,15 +42,13 @@ import app.aaps.receivers.BTReceiver
import app.aaps.receivers.ChargingStateReceiver import app.aaps.receivers.ChargingStateReceiver
import app.aaps.receivers.KeepAliveWorker import app.aaps.receivers.KeepAliveWorker
import app.aaps.receivers.TimeDateOrTZChangeReceiver import app.aaps.receivers.TimeDateOrTZChangeReceiver
import app.aaps.ui.activityMonitor.ActivityMonitor
import app.aaps.ui.widget.Widget
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.DaggerApplication import dagger.android.DaggerApplication
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.database.impl.transactions.VersionChangeTransaction import info.nightscout.database.impl.transactions.VersionChangeTransaction
import app.aaps.ui.activityMonitor.ActivityMonitor
import app.aaps.ui.widget.Widget
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.exceptions.UndeliverableException import io.reactivex.rxjava3.exceptions.UndeliverableException
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign

View file

@ -30,11 +30,11 @@ import app.aaps.core.main.events.EventIobCalculationProgress
import app.aaps.core.main.utils.fabric.FabricPrivacy import app.aaps.core.main.utils.fabric.FabricPrivacy
import app.aaps.core.main.workflow.CalculationWorkflow import app.aaps.core.main.workflow.CalculationWorkflow
import app.aaps.core.ui.activities.TranslatedDaggerAppCompatActivity import app.aaps.core.ui.activities.TranslatedDaggerAppCompatActivity
import app.aaps.databinding.ActivityHistorybrowseBinding
import app.aaps.plugins.main.general.overview.graphData.GraphData import app.aaps.plugins.main.general.overview.graphData.GraphData
import com.google.android.material.datepicker.MaterialDatePicker import com.google.android.material.datepicker.MaterialDatePicker
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding
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 java.util.Calendar import java.util.Calendar

View file

@ -15,6 +15,7 @@ import androidx.preference.PreferenceGroup
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import androidx.preference.size import androidx.preference.size
import app.aaps.R
import app.aaps.core.interfaces.configuration.Config import app.aaps.core.interfaces.configuration.Config
import app.aaps.core.interfaces.nsclient.NSSettingsStatus import app.aaps.core.interfaces.nsclient.NSSettingsStatus
import app.aaps.core.interfaces.plugin.PluginBase import app.aaps.core.interfaces.plugin.PluginBase
@ -60,7 +61,6 @@ import app.aaps.plugins.sync.openhumans.OpenHumansUploaderPlugin
import app.aaps.plugins.sync.tidepool.TidepoolPlugin import app.aaps.plugins.sync.tidepool.TidepoolPlugin
import app.aaps.plugins.sync.xdrip.XdripPlugin import app.aaps.plugins.sync.xdrip.XdripPlugin
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import info.nightscout.androidaps.R
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.danar.DanaRPlugin

View file

@ -8,9 +8,9 @@ import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import app.aaps.R
import app.aaps.databinding.ActivityPreferencesBinding
import app.aaps.plugins.configuration.activities.DaggerAppCompatActivityWithResult import app.aaps.plugins.configuration.activities.DaggerAppCompatActivityWithResult
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityPreferencesBinding
class PreferencesActivity : DaggerAppCompatActivityWithResult(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback { class PreferencesActivity : DaggerAppCompatActivityWithResult(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {

View file

@ -1,10 +1,10 @@
package app.aaps.implementations package app.aaps.implementations
import android.os.Build import android.os.Build
import app.aaps.BuildConfig
import app.aaps.R
import app.aaps.core.interfaces.configuration.Config import app.aaps.core.interfaces.configuration.Config
import app.aaps.core.interfaces.maintenance.PrefFileListProvider import app.aaps.core.interfaces.maintenance.PrefFileListProvider
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton

View file

@ -7,6 +7,7 @@ import androidx.annotation.RawRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import app.aaps.MainActivity import app.aaps.MainActivity
import app.aaps.R
import app.aaps.activities.HistoryBrowseActivity import app.aaps.activities.HistoryBrowseActivity
import app.aaps.activities.MyPreferenceFragment import app.aaps.activities.MyPreferenceFragment
import app.aaps.activities.PreferencesActivity import app.aaps.activities.PreferencesActivity
@ -18,8 +19,6 @@ import app.aaps.core.main.events.EventNewNotification
import app.aaps.core.ui.toast.ToastUtils import app.aaps.core.ui.toast.ToastUtils
import app.aaps.plugins.configuration.activities.SingleFragmentActivity import app.aaps.plugins.configuration.activities.SingleFragmentActivity
import app.aaps.plugins.main.general.overview.notifications.NotificationWithAction import app.aaps.plugins.main.general.overview.notifications.NotificationWithAction
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import app.aaps.ui.activities.BolusProgressHelperActivity import app.aaps.ui.activities.BolusProgressHelperActivity
import app.aaps.ui.activities.ErrorHelperActivity import app.aaps.ui.activities.ErrorHelperActivity
import app.aaps.ui.activities.QuickWizardListActivity import app.aaps.ui.activities.QuickWizardListActivity
@ -41,6 +40,7 @@ import app.aaps.ui.dialogs.WizardDialog
import app.aaps.ui.services.AlarmSoundService import app.aaps.ui.services.AlarmSoundService
import app.aaps.ui.services.AlarmSoundServiceHelper import app.aaps.ui.services.AlarmSoundServiceHelper
import app.aaps.ui.widget.Widget import app.aaps.ui.widget.Widget
import dagger.android.HasAndroidInjector
import javax.inject.Inject import javax.inject.Inject
class UiInteractionImpl @Inject constructor( class UiInteractionImpl @Inject constructor(

View file

@ -9,6 +9,7 @@ import androidx.work.WorkManager
import androidx.work.WorkQuery import androidx.work.WorkQuery
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import app.aaps.R
import app.aaps.core.interfaces.alerts.LocalAlertUtils import app.aaps.core.interfaces.alerts.LocalAlertUtils
import app.aaps.core.interfaces.aps.Loop import app.aaps.core.interfaces.aps.Loop
import app.aaps.core.interfaces.configuration.Config import app.aaps.core.interfaces.configuration.Config
@ -28,7 +29,6 @@ import app.aaps.core.main.profile.ProfileSealed
import app.aaps.core.main.utils.worker.LoggingWorker import app.aaps.core.main.utils.worker.LoggingWorker
import app.aaps.plugins.configuration.maintenance.MaintenancePlugin import app.aaps.plugins.configuration.maintenance.MaintenancePlugin
import com.google.common.util.concurrent.ListenableFuture import com.google.common.util.concurrent.ListenableFuture
import info.nightscout.androidaps.R
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit

View file

@ -13,7 +13,7 @@ fun isRunningTest(): Boolean {
@Synchronized @Synchronized
fun isRunningRealPumpTest(): Boolean { fun isRunningRealPumpTest(): Boolean {
return try { return try {
Class.forName("info.nightscout.androidaps.RealPumpTest") Class.forName("app.aaps.RealPumpTest")
true true
} catch (e: ClassNotFoundException) { } catch (e: ClassNotFoundException) {
false false

View file

@ -80,7 +80,7 @@ android {
versionName version + "-aapsclient" versionName version + "-aapsclient"
} }
} }
namespace 'info.nightscout.androidaps' namespace 'app.aaps.wear'
} }
allprojects { allprojects {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps package app.aaps.wear
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
@ -8,19 +8,20 @@ import androidx.preference.PreferenceManager
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.wear.comm.DataHandlerWear
import app.aaps.wear.comm.DataLayerListenerServiceWear
import app.aaps.wear.comm.ExceptionHandlerWear
import app.aaps.wear.di.DaggerWearComponent
import app.aaps.wear.events.EventWearPreferenceChange
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.DaggerApplication import dagger.android.DaggerApplication
import info.nightscout.androidaps.comm.DataHandlerWear
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
import info.nightscout.androidaps.comm.ExceptionHandlerWear
import info.nightscout.androidaps.di.DaggerWearComponent
import info.nightscout.androidaps.events.EventWearPreferenceChange
import javax.inject.Inject import javax.inject.Inject
class WearApp : DaggerApplication(), OnSharedPreferenceChangeListener { class WearApp : DaggerApplication(), OnSharedPreferenceChangeListener {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Suppress("unused") @Suppress("unused")
@Inject lateinit var dataHandlerWear: DataHandlerWear // instantiate only @Inject lateinit var dataHandlerWear: DataHandlerWear // instantiate only
@Inject lateinit var exceptionHandlerWear: ExceptionHandlerWear @Inject lateinit var exceptionHandlerWear: ExceptionHandlerWear

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.comm package app.aaps.wear.comm
import android.annotation.TargetApi import android.annotation.TargetApi
import android.app.Notification import android.app.Notification
@ -22,15 +22,15 @@ import app.aaps.core.interfaces.rx.events.EventWearDataToMobile
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.wear.R
import app.aaps.wear.interaction.WatchfaceConfigurationActivity
import app.aaps.wear.interaction.actions.AcceptActivity
import app.aaps.wear.interaction.actions.ProfileSwitchActivity
import app.aaps.wear.interaction.utils.Persistence
import app.aaps.wear.tile.ActionsTileService
import app.aaps.wear.tile.QuickWizardTileService
import app.aaps.wear.tile.TempTargetTileService
import com.google.android.gms.wearable.WearableListenerService import com.google.android.gms.wearable.WearableListenerService
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interaction.WatchfaceConfigurationActivity
import info.nightscout.androidaps.interaction.actions.AcceptActivity
import info.nightscout.androidaps.interaction.actions.ProfileSwitchActivity
import info.nightscout.androidaps.interaction.utils.Persistence
import info.nightscout.androidaps.tile.ActionsTileService
import info.nightscout.androidaps.tile.QuickWizardTileService
import info.nightscout.androidaps.tile.TempTargetTileService
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 javax.inject.Inject import javax.inject.Inject

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.comm package app.aaps.wear.comm
import android.app.NotificationManager import android.app.NotificationManager
import android.content.Intent import android.content.Intent
@ -13,6 +13,8 @@ import app.aaps.core.interfaces.rx.events.EventWearDataToMobile
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.wear.interaction.utils.Persistence
import app.aaps.wear.interaction.utils.WearUtil
import com.google.android.gms.tasks.Tasks import com.google.android.gms.tasks.Tasks
import com.google.android.gms.wearable.CapabilityClient import com.google.android.gms.wearable.CapabilityClient
import com.google.android.gms.wearable.CapabilityInfo import com.google.android.gms.wearable.CapabilityInfo
@ -25,8 +27,6 @@ import com.google.android.gms.wearable.PutDataMapRequest
import com.google.android.gms.wearable.Wearable import com.google.android.gms.wearable.Wearable
import com.google.android.gms.wearable.WearableListenerService import com.google.android.gms.wearable.WearableListenerService
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.interaction.utils.Persistence
import info.nightscout.androidaps.interaction.utils.WearUtil
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 kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException

View file

@ -1,70 +1,70 @@
package info.nightscout.androidaps.comm package app.aaps.wear.comm
import android.os.Build import android.os.Build
import android.util.Log import android.util.Log
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.IOException import java.io.IOException
import java.io.ObjectOutputStream import java.io.ObjectOutputStream
import javax.inject.Inject import javax.inject.Inject
class ExceptionHandlerWear @Inject constructor( class ExceptionHandlerWear @Inject constructor(
private val rxBus: RxBus, private val rxBus: RxBus,
) { ) {
private var mDefaultUEH: Thread.UncaughtExceptionHandler? = null private var mDefaultUEH: Thread.UncaughtExceptionHandler? = null
private val mWearUEH = Thread.UncaughtExceptionHandler { thread, ex -> private val mWearUEH = Thread.UncaughtExceptionHandler { thread, ex ->
Log.d("WEAR", "uncaughtException :" + ex.message) Log.d("WEAR", "uncaughtException :" + ex.message)
// Pass the exception to the bus which will send the data upstream to your Smartphone/Tablet // Pass the exception to the bus which will send the data upstream to your Smartphone/Tablet
val wearException = EventData.WearException( val wearException = EventData.WearException(
timeStamp = System.currentTimeMillis(), timeStamp = System.currentTimeMillis(),
exception = exceptionToByteArray(ex), exception = exceptionToByteArray(ex),
board = Build.BOARD, board = Build.BOARD,
sdk = Build.VERSION.SDK_INT.toString(), sdk = Build.VERSION.SDK_INT.toString(),
fingerprint = Build.FINGERPRINT, fingerprint = Build.FINGERPRINT,
model = Build.MODEL, model = Build.MODEL,
manufacturer = Build.MANUFACTURER, manufacturer = Build.MANUFACTURER,
product = Build.PRODUCT product = Build.PRODUCT
) )
rxBus.send(EventWearToMobile(wearException)) rxBus.send(EventWearToMobile(wearException))
// Let the default UncaughtExceptionHandler take it from here // Let the default UncaughtExceptionHandler take it from here
mDefaultUEH?.uncaughtException(thread, ex) mDefaultUEH?.uncaughtException(thread, ex)
} }
fun register() { fun register() {
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler() mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler(mWearUEH) Thread.setDefaultUncaughtExceptionHandler(mWearUEH)
} }
private fun exceptionToByteArray(ex: Throwable): ByteArray { private fun exceptionToByteArray(ex: Throwable): ByteArray {
ex.stackTrace // Make sure the stacktrace gets built up ex.stackTrace // Make sure the stacktrace gets built up
val bos = ByteArrayOutputStream() val bos = ByteArrayOutputStream()
var oos: ObjectOutputStream? = null var oos: ObjectOutputStream? = null
try { try {
oos = ObjectOutputStream(bos) oos = ObjectOutputStream(bos)
oos.writeObject(ex) oos.writeObject(ex)
return bos.toByteArray() return bos.toByteArray()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
} finally { } finally {
try { try {
oos?.close() oos?.close()
} catch (exx: IOException) { } catch (exx: IOException) {
// Ignore close exception // Ignore close exception
} }
try { try {
bos.close() bos.close()
} catch (exx: IOException) { } catch (exx: IOException) {
// Ignore close exception // Ignore close exception
} }
} }
return byteArrayOf() return byteArrayOf()
} }
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.comm package app.aaps.wear.comm
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.comm package app.aaps.wear.comm
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
@ -20,17 +20,17 @@ import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData
import app.aaps.wear.R
import app.aaps.wear.comm.DataLayerListenerServiceWear.Companion.INTENT_NEW_DATA
import app.aaps.wear.complications.ComplicationTapBroadcastReceiver.Companion.getTapActionIntent
import app.aaps.wear.complications.ComplicationTapBroadcastReceiver.Companion.getTapWarningSinceIntent
import app.aaps.wear.data.RawDisplayData
import app.aaps.wear.interaction.utils.Constants
import app.aaps.wear.interaction.utils.DisplayFormat
import app.aaps.wear.interaction.utils.Inevitable
import app.aaps.wear.interaction.utils.Persistence
import app.aaps.wear.interaction.utils.WearUtil
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.R
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear.Companion.INTENT_NEW_DATA
import info.nightscout.androidaps.complications.ComplicationTapBroadcastReceiver.Companion.getTapActionIntent
import info.nightscout.androidaps.complications.ComplicationTapBroadcastReceiver.Companion.getTapWarningSinceIntent
import info.nightscout.androidaps.data.RawDisplayData
import info.nightscout.androidaps.interaction.utils.Constants
import info.nightscout.androidaps.interaction.utils.DisplayFormat
import info.nightscout.androidaps.interaction.utils.Inevitable
import info.nightscout.androidaps.interaction.utils.Persistence
import info.nightscout.androidaps.interaction.utils.WearUtil
import javax.inject.Inject import javax.inject.Inject
/** /**

View file

@ -1,15 +1,15 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.wear.data.RawDisplayData
import app.aaps.wear.interaction.utils.DisplayFormat
import app.aaps.wear.interaction.utils.SmallestDoubleString
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.data.RawDisplayData
import info.nightscout.androidaps.interaction.utils.DisplayFormat
import info.nightscout.androidaps.interaction.utils.SmallestDoubleString
import kotlin.math.max import kotlin.math.max
/* /*

View file

@ -1,12 +1,12 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,14 +1,14 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,14 +1,14 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
import info.nightscout.androidaps.interaction.utils.DisplayFormat import app.aaps.wear.interaction.utils.DisplayFormat
import info.nightscout.androidaps.interaction.utils.SmallestDoubleString import app.aaps.wear.interaction.utils.SmallestDoubleString
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.complications package app.aaps.wear.complications
enum class ComplicationAction { enum class ComplicationAction {
NONE, MENU, WIZARD, BOLUS, E_CARB, STATUS, WARNING_SYNC, WARNING_OLD NONE, MENU, WIZARD, BOLUS, E_CARB, STATUS, WARNING_SYNC, WARNING_OLD

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.content.ComponentName import android.content.ComponentName
@ -12,16 +12,16 @@ import androidx.annotation.StringRes
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.wear.R
import app.aaps.wear.interaction.actions.ECarbActivity
import app.aaps.wear.interaction.actions.TreatmentActivity
import app.aaps.wear.interaction.actions.WizardActivity
import app.aaps.wear.interaction.menus.MainMenuActivity
import app.aaps.wear.interaction.menus.StatusMenuActivity
import app.aaps.wear.interaction.utils.Constants
import app.aaps.wear.interaction.utils.DisplayFormat
import app.aaps.wear.interaction.utils.WearUtil
import dagger.android.DaggerBroadcastReceiver import dagger.android.DaggerBroadcastReceiver
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interaction.actions.ECarbActivity
import info.nightscout.androidaps.interaction.actions.TreatmentActivity
import info.nightscout.androidaps.interaction.actions.WizardActivity
import info.nightscout.androidaps.interaction.menus.MainMenuActivity
import info.nightscout.androidaps.interaction.menus.StatusMenuActivity
import info.nightscout.androidaps.interaction.utils.Constants
import info.nightscout.androidaps.interaction.utils.DisplayFormat
import info.nightscout.androidaps.interaction.utils.WearUtil
import javax.inject.Inject import javax.inject.Inject
/* /*

View file

@ -1,12 +1,12 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,16 +1,16 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
import info.nightscout.androidaps.interaction.utils.DisplayFormat import app.aaps.wear.interaction.utils.DisplayFormat
import info.nightscout.androidaps.interaction.utils.SmallestDoubleString import app.aaps.wear.interaction.utils.SmallestDoubleString
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,13 +1,13 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.wear.data.RawDisplayData
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.data.RawDisplayData
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,13 +1,13 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.wear.data.RawDisplayData
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.data.RawDisplayData
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,13 +1,13 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.support.wearable.complications.ComplicationData import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.wear.data.RawDisplayData
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.data.RawDisplayData
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
@ -8,8 +8,8 @@ import android.support.wearable.complications.ComplicationData
import android.support.wearable.complications.ComplicationText import android.support.wearable.complications.ComplicationText
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
import kotlin.math.floor import kotlin.math.floor
import kotlin.math.max import kotlin.math.max
import kotlin.math.min import kotlin.math.min

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.complications package app.aaps.wear.complications
import android.app.PendingIntent import android.app.PendingIntent
import android.graphics.Bitmap import android.graphics.Bitmap
@ -10,7 +10,7 @@ import android.support.wearable.complications.ComplicationData
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.view.WindowManager import android.view.WindowManager
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
import java.io.IOException import java.io.IOException
/* /*

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.complications package app.aaps.wear.complications
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.complications package app.aaps.wear.complications
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.complications package app.aaps.wear.complications
/* /*
* Created by dlvoy on 2019-11-12 * Created by dlvoy on 2019-11-12

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.data package app.aaps.wear.data
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import info.nightscout.androidaps.interaction.utils.Persistence import app.aaps.wear.interaction.utils.Persistence
/** /**
* Holds bunch of data model variables and lists that arrive from phone app and are due to be * Holds bunch of data model variables and lists that arrive from phone app and are due to be

View file

@ -1,16 +1,26 @@
package info.nightscout.androidaps.di package app.aaps.wear.di
import app.aaps.wear.interaction.ConfigurationActivity
import app.aaps.wear.interaction.TileConfigurationActivity
import app.aaps.wear.interaction.actions.AcceptActivity
import app.aaps.wear.interaction.actions.BackgroundActionActivity
import app.aaps.wear.interaction.actions.BolusActivity
import app.aaps.wear.interaction.actions.CarbActivity
import app.aaps.wear.interaction.actions.ECarbActivity
import app.aaps.wear.interaction.actions.FillActivity
import app.aaps.wear.interaction.actions.ProfileSwitchActivity
import app.aaps.wear.interaction.actions.QuickSnoozeActivity
import app.aaps.wear.interaction.actions.TempTargetActivity
import app.aaps.wear.interaction.actions.TreatmentActivity
import app.aaps.wear.interaction.actions.ViewSelectorActivity
import app.aaps.wear.interaction.actions.WizardActivity
import app.aaps.wear.interaction.menus.FillMenuActivity
import app.aaps.wear.interaction.menus.MainMenuActivity
import app.aaps.wear.interaction.menus.PreferenceMenuActivity
import app.aaps.wear.interaction.menus.StatusMenuActivity
import app.aaps.wear.interaction.utils.MenuListActivity
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.interaction.actions.QuickSnoozeActivity
import info.nightscout.androidaps.interaction.ConfigurationActivity
import info.nightscout.androidaps.interaction.TileConfigurationActivity
import info.nightscout.androidaps.interaction.actions.*
import info.nightscout.androidaps.interaction.menus.FillMenuActivity
import info.nightscout.androidaps.interaction.menus.MainMenuActivity
import info.nightscout.androidaps.interaction.menus.PreferenceMenuActivity
import info.nightscout.androidaps.interaction.menus.StatusMenuActivity
import info.nightscout.androidaps.interaction.utils.MenuListActivity
@Module @Module
@Suppress("unused") @Suppress("unused")

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.di package app.aaps.wear.di
import app.aaps.wear.WearApp
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.androidaps.WearApp
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.di package app.aaps.wear.di
import android.content.Context import android.content.Context
import app.aaps.shared.impl.di.SharedImplModule import app.aaps.shared.impl.di.SharedImplModule
import app.aaps.wear.WearApp
import dagger.Binds import dagger.Binds
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.WearApp
import kotlinx.datetime.Clock import kotlinx.datetime.Clock
@Suppress("unused") @Suppress("unused")

View file

@ -1,13 +1,37 @@
package info.nightscout.androidaps.di package app.aaps.wear.di
import app.aaps.wear.comm.DataLayerListenerServiceWear
import app.aaps.wear.complications.BaseComplicationProviderService
import app.aaps.wear.complications.BrCobIobComplication
import app.aaps.wear.complications.CobDetailedComplication
import app.aaps.wear.complications.CobIconComplication
import app.aaps.wear.complications.CobIobComplication
import app.aaps.wear.complications.ComplicationTapBroadcastReceiver
import app.aaps.wear.complications.IobDetailedComplication
import app.aaps.wear.complications.IobIconComplication
import app.aaps.wear.complications.LongStatusComplication
import app.aaps.wear.complications.LongStatusFlippedComplication
import app.aaps.wear.complications.SgvComplication
import app.aaps.wear.complications.UploaderBatteryComplication
import app.aaps.wear.complications.WallpaperComplication
import app.aaps.wear.heartrate.HeartRateListener
import app.aaps.wear.tile.ActionsTileService
import app.aaps.wear.tile.QuickWizardTileService
import app.aaps.wear.tile.TempTargetTileService
import app.aaps.wear.tile.TileBase
import app.aaps.wear.watchfaces.AapsLargeWatchface
import app.aaps.wear.watchfaces.AapsV2Watchface
import app.aaps.wear.watchfaces.AapsWatchface
import app.aaps.wear.watchfaces.BigChartWatchface
import app.aaps.wear.watchfaces.CircleWatchface
import app.aaps.wear.watchfaces.CockpitWatchface
import app.aaps.wear.watchfaces.CustomWatchface
import app.aaps.wear.watchfaces.DigitalStyleWatchface
import app.aaps.wear.watchfaces.NoChartWatchface
import app.aaps.wear.watchfaces.SteampunkWatchface
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
import info.nightscout.androidaps.complications.*
import info.nightscout.androidaps.heartrate.HeartRateListener
import info.nightscout.androidaps.tile.*
import info.nightscout.androidaps.watchfaces.*
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
@Module @Module
@Suppress("unused") @Suppress("unused")
@ -36,7 +60,6 @@ abstract class WearServicesModule {
@ContributesAndroidInjector abstract fun contributesSteampunk(): SteampunkWatchface @ContributesAndroidInjector abstract fun contributesSteampunk(): SteampunkWatchface
@ContributesAndroidInjector abstract fun contributesDigitalStyleWatchface(): DigitalStyleWatchface @ContributesAndroidInjector abstract fun contributesDigitalStyleWatchface(): DigitalStyleWatchface
@ContributesAndroidInjector abstract fun contributesCockpitWatchface(): CockpitWatchface @ContributesAndroidInjector abstract fun contributesCockpitWatchface(): CockpitWatchface
@ContributesAndroidInjector abstract fun contributesBIGChart(): BigChartWatchface @ContributesAndroidInjector abstract fun contributesBIGChart(): BigChartWatchface
@ContributesAndroidInjector abstract fun contributesNOChart(): NoChartWatchface @ContributesAndroidInjector abstract fun contributesNOChart(): NoChartWatchface
@ContributesAndroidInjector abstract fun contributesCircleWatchface(): CircleWatchface @ContributesAndroidInjector abstract fun contributesCircleWatchface(): CircleWatchface

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.events package app.aaps.wear.events
import android.content.Context import android.content.Context
import app.aaps.core.interfaces.rx.events.Event import app.aaps.core.interfaces.rx.events.Event

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.heartrate package app.aaps.wear.heartrate
import android.content.Context import android.content.Context
import android.content.Context.SENSOR_SERVICE import android.content.Context.SENSOR_SERVICE
@ -12,7 +12,7 @@ import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.AapsSchedulers import app.aaps.core.interfaces.rx.AapsSchedulers
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import info.nightscout.androidaps.comm.IntentWearToMobile import app.aaps.wear.comm.IntentWearToMobile
import io.reactivex.rxjava3.disposables.Disposable import io.reactivex.rxjava3.disposables.Disposable
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.concurrent.locks.ReentrantLock import java.util.concurrent.locks.ReentrantLock

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction package app.aaps.wear.interaction
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@ -6,8 +6,8 @@ import android.view.ViewGroup
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.wear.R
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.R
import preference.WearPreferenceActivity import preference.WearPreferenceActivity
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.interaction package app.aaps.wear.interaction
import android.os.Bundle import android.os.Bundle
import android.view.ViewGroup import android.view.ViewGroup
import androidx.wear.tiles.TileService import androidx.wear.tiles.TileService
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.wear.tile.ActionsTileService
import app.aaps.wear.tile.TempTargetTileService
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.tile.ActionsTileService
import info.nightscout.androidaps.tile.TempTargetTileService
import preference.WearPreferenceActivity import preference.WearPreferenceActivity
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction package app.aaps.wear.interaction
import android.Manifest import android.Manifest
import android.content.SharedPreferences import android.content.SharedPreferences
@ -11,7 +11,7 @@ import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.R import app.aaps.wear.R
import preference.WearPreferenceActivity import preference.WearPreferenceActivity
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -16,11 +16,11 @@ import android.widget.TextView
import androidx.core.view.InputDeviceCompat import androidx.core.view.InputDeviceCompat
import androidx.core.view.MotionEventCompat import androidx.core.view.MotionEventCompat
import androidx.core.view.ViewConfigurationCompat import androidx.core.view.ViewConfigurationCompat
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear import app.aaps.wear.comm.DataLayerListenerServiceWear
import info.nightscout.androidaps.comm.IntentCancelNotification import app.aaps.wear.comm.IntentCancelNotification
import info.nightscout.androidaps.comm.IntentWearToMobile import app.aaps.wear.comm.IntentWearToMobile
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import kotlin.math.roundToInt import kotlin.math.roundToInt
class AcceptActivity : ViewSelectorActivity() { class AcceptActivity : ViewSelectorActivity() {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
@ -7,8 +7,8 @@ import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.wear.comm.DataLayerListenerServiceWear
import dagger.android.DaggerActivity import dagger.android.DaggerActivity
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
import javax.inject.Inject import javax.inject.Inject
class BackgroundActionActivity : DaggerActivity() { class BackgroundActionActivity : DaggerActivity() {

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -10,10 +10,10 @@ import android.widget.ImageView
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionBolusPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionBolusPreCheck
import app.aaps.core.interfaces.utils.SafeParse import app.aaps.core.interfaces.utils.SafeParse
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
import kotlin.math.roundToInt import kotlin.math.roundToInt

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -10,10 +10,10 @@ import android.widget.ImageView
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionECarbsPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionECarbsPreCheck
import app.aaps.core.interfaces.utils.SafeParse import app.aaps.core.interfaces.utils.SafeParse
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
class CarbActivity : ViewSelectorActivity() { class CarbActivity : ViewSelectorActivity() {

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -11,10 +11,10 @@ import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionECarbsPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionECarbsPreCheck
import app.aaps.core.interfaces.utils.SafeParse.stringToDouble import app.aaps.core.interfaces.utils.SafeParse.stringToDouble
import app.aaps.core.interfaces.utils.SafeParse.stringToInt import app.aaps.core.interfaces.utils.SafeParse.stringToInt
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
class ECarbActivity : ViewSelectorActivity() { class ECarbActivity : ViewSelectorActivity() {

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -10,10 +10,10 @@ import android.widget.ImageView
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionFillPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionFillPreCheck
import app.aaps.core.interfaces.utils.SafeParse.stringToDouble import app.aaps.core.interfaces.utils.SafeParse.stringToDouble
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
class FillActivity : ViewSelectorActivity() { class FillActivity : ViewSelectorActivity() {

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -10,10 +10,10 @@ import android.widget.ImageView
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionProfileSwitchPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionProfileSwitchPreCheck
import app.aaps.core.interfaces.utils.SafeParse import app.aaps.core.interfaces.utils.SafeParse
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
class ProfileSwitchActivity : ViewSelectorActivity() { class ProfileSwitchActivity : ViewSelectorActivity() {

View file

@ -1,54 +1,54 @@
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.shared.impl.extensions.safeGetPackageInfo import app.aaps.shared.impl.extensions.safeGetPackageInfo
import dagger.android.DaggerActivity import app.aaps.wear.R
import info.nightscout.androidaps.R import dagger.android.DaggerActivity
import javax.inject.Inject import javax.inject.Inject
/** /**
* Send a snooze request to silence any alarm. Designed to be bound to a button for fast access * Send a snooze request to silence any alarm. Designed to be bound to a button for fast access
*/ */
class QuickSnoozeActivity : DaggerActivity() { class QuickSnoozeActivity : DaggerActivity() {
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
Toast.makeText(this, R.string.sending_snooze, Toast.LENGTH_LONG).show() Toast.makeText(this, R.string.sending_snooze, Toast.LENGTH_LONG).show()
rxBus.send(EventWearToMobile(EventData.SnoozeAlert(System.currentTimeMillis()))) rxBus.send(EventWearToMobile(EventData.SnoozeAlert(System.currentTimeMillis())))
val xDripPackageName = "com.eveningoutpost.dexdrip" val xDripPackageName = "com.eveningoutpost.dexdrip"
if (isPackageExisted(xDripPackageName)) { if (isPackageExisted(xDripPackageName)) {
try { try {
val i = Intent() val i = Intent()
i.setClassName(xDripPackageName, "$xDripPackageName.QuickSnooze") i.setClassName(xDripPackageName, "$xDripPackageName.QuickSnooze")
startActivity(i) startActivity(i)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("WEAR", "failed to snooze xDrip: ", e) Log.e("WEAR", "failed to snooze xDrip: ", e)
} }
} else { } else {
Log.d("WEAR", "Package $xDripPackageName not available for snooze") Log.d("WEAR", "Package $xDripPackageName not available for snooze")
} }
finish() finish()
} }
@Suppress("SameParameterValue") @Suppress("SameParameterValue")
private fun isPackageExisted(targetPackage: String): Boolean { private fun isPackageExisted(targetPackage: String): Boolean {
try { try {
packageManager.safeGetPackageInfo(targetPackage, 0) packageManager.safeGetPackageInfo(targetPackage, 0)
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
return false return false
} }
return true return true
} }
} }

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -10,10 +10,10 @@ import android.widget.ImageView
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionTempTargetPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionTempTargetPreCheck
import app.aaps.core.interfaces.utils.SafeParse import app.aaps.core.interfaces.utils.SafeParse
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
class TempTargetActivity : ViewSelectorActivity() { class TempTargetActivity : ViewSelectorActivity() {

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -11,10 +11,10 @@ import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionBolusPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionBolusPreCheck
import app.aaps.core.interfaces.utils.SafeParse.stringToDouble import app.aaps.core.interfaces.utils.SafeParse.stringToDouble
import app.aaps.core.interfaces.utils.SafeParse.stringToInt import app.aaps.core.interfaces.utils.SafeParse.stringToInt
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
import kotlin.math.roundToInt import kotlin.math.roundToInt

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
@ -11,11 +11,11 @@ import android.widget.Toast
import androidx.wear.widget.CurvedTextView import androidx.wear.widget.CurvedTextView
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.wear.R
import app.aaps.wear.nondeprecated.DotsPageIndicatorNonDeprecated
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import app.aaps.wear.nondeprecated.GridViewPagerNonDeprecated
import dagger.android.DaggerActivity import dagger.android.DaggerActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.nondeprecated.DotsPageIndicatorNonDeprecated
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.androidaps.nondeprecated.GridViewPagerNonDeprecated
import javax.inject.Inject import javax.inject.Inject
/** /**

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.interaction.actions package app.aaps.wear.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -10,10 +10,10 @@ import android.widget.ImageView
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionWizardPreCheck import app.aaps.core.interfaces.rx.weardata.EventData.ActionWizardPreCheck
import app.aaps.core.interfaces.utils.SafeParse import app.aaps.core.interfaces.utils.SafeParse
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import app.aaps.wear.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
import java.text.DecimalFormat import java.text.DecimalFormat
class WizardActivity : ViewSelectorActivity() { class WizardActivity : ViewSelectorActivity() {

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.interaction.menus package app.aaps.wear.interaction.menus
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.actions.FillActivity import app.aaps.wear.interaction.actions.FillActivity
import info.nightscout.androidaps.interaction.utils.MenuListActivity import app.aaps.wear.interaction.utils.MenuListActivity
class FillMenuActivity : MenuListActivity() { class FillMenuActivity : MenuListActivity() {

View file

@ -1,16 +1,16 @@
package info.nightscout.androidaps.interaction.menus package app.aaps.wear.interaction.menus
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.actions.ECarbActivity import app.aaps.wear.interaction.actions.ECarbActivity
import info.nightscout.androidaps.interaction.actions.TempTargetActivity import app.aaps.wear.interaction.actions.TempTargetActivity
import info.nightscout.androidaps.interaction.actions.TreatmentActivity import app.aaps.wear.interaction.actions.TreatmentActivity
import info.nightscout.androidaps.interaction.actions.WizardActivity import app.aaps.wear.interaction.actions.WizardActivity
import info.nightscout.androidaps.interaction.utils.MenuListActivity import app.aaps.wear.interaction.utils.MenuListActivity
class MainMenuActivity : MenuListActivity() { class MainMenuActivity : MenuListActivity() {

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.interaction.menus package app.aaps.wear.interaction.menus
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.WatchfaceConfigurationActivity import app.aaps.wear.interaction.WatchfaceConfigurationActivity
import info.nightscout.androidaps.interaction.utils.MenuListActivity import app.aaps.wear.interaction.utils.MenuListActivity
class PreferenceMenuActivity : MenuListActivity() { class PreferenceMenuActivity : MenuListActivity() {
@ -24,23 +24,27 @@ class PreferenceMenuActivity : MenuListActivity() {
override fun doAction(position: String) { override fun doAction(position: String) {
when (position) { when (position) {
getString(R.string.pref_display_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply { getString(R.string.pref_display_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(getString(R.string.key_preference_id), R.xml.display_preferences) putExtra(getString(R.string.key_preference_id), R.xml.display_preferences)
}) })
getString(R.string.pref_graph_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply { getString(R.string.pref_graph_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(getString(R.string.key_preference_id), R.xml.graph_preferences) putExtra(getString(R.string.key_preference_id), R.xml.graph_preferences)
}) })
getString(R.string.pref_interface_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply { getString(R.string.pref_interface_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(getString(R.string.key_preference_id), R.xml.interface_preferences) putExtra(getString(R.string.key_preference_id), R.xml.interface_preferences)
}) })
getString(R.string.pref_complication_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply { getString(R.string.pref_complication_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(getString(R.string.key_preference_id), R.xml.complication_preferences) putExtra(getString(R.string.key_preference_id), R.xml.complication_preferences)
}) })
getString(R.string.pref_others_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
getString(R.string.pref_others_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(getString(R.string.key_preference_id), R.xml.others_preferences) putExtra(getString(R.string.key_preference_id), R.xml.others_preferences)
}) })

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.interaction.menus package app.aaps.wear.interaction.menus
import android.os.Bundle import android.os.Bundle
import app.aaps.core.interfaces.rx.events.EventWearToMobile import app.aaps.core.interfaces.rx.events.EventWearToMobile
import app.aaps.core.interfaces.rx.weardata.EventData.ActionLoopStatus import app.aaps.core.interfaces.rx.weardata.EventData.ActionLoopStatus
import app.aaps.core.interfaces.rx.weardata.EventData.ActionPumpStatus import app.aaps.core.interfaces.rx.weardata.EventData.ActionPumpStatus
import app.aaps.core.interfaces.rx.weardata.EventData.ActionTddStatus import app.aaps.core.interfaces.rx.weardata.EventData.ActionTddStatus
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.utils.MenuListActivity import app.aaps.wear.interaction.utils.MenuListActivity
class StatusMenuActivity : MenuListActivity() { class StatusMenuActivity : MenuListActivity() {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
@Suppress("unused") @Suppress("unused")
object Constants { object Constants {

View file

@ -1,142 +1,142 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.content.Context import android.content.Context
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.data.RawDisplayData import app.aaps.wear.data.RawDisplayData
import info.nightscout.androidaps.interaction.utils.Pair.Companion.create import app.aaps.wear.interaction.utils.Pair.Companion.create
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.max import kotlin.math.max
@Singleton @Singleton
class DisplayFormat @Inject internal constructor() { class DisplayFormat @Inject internal constructor() {
companion object { companion object {
const val MAX_FIELD_LEN_LONG = 22 // this is found out empirical, for TYPE_LONG_TEXT const val MAX_FIELD_LEN_LONG = 22 // this is found out empirical, for TYPE_LONG_TEXT
const val MAX_FIELD_LEN_SHORT = 7 // according to Wear OS docs for TYPE_SHORT_TEXT const val MAX_FIELD_LEN_SHORT = 7 // according to Wear OS docs for TYPE_SHORT_TEXT
const val MIN_FIELD_LEN_COB = 3 // since carbs are usually 0..99g const val MIN_FIELD_LEN_COB = 3 // since carbs are usually 0..99g
const val MIN_FIELD_LEN_IOB = 3 // IoB can range from like .1U to 99U const val MIN_FIELD_LEN_IOB = 3 // IoB can range from like .1U to 99U
} }
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var wearUtil: WearUtil @Inject lateinit var wearUtil: WearUtil
@Inject lateinit var context: Context @Inject lateinit var context: Context
/** /**
* Maximal and minimal lengths of fields/labels shown in complications, in characters * Maximal and minimal lengths of fields/labels shown in complications, in characters
* For MAX values - above that WearOS and watch faces may start ellipsize (...) contents * For MAX values - above that WearOS and watch faces may start ellipsize (...) contents
* For MIN values - this is minimal length that can hold legible data * For MIN values - this is minimal length that can hold legible data
*/ */
private fun areComplicationsUnicode() = sp.getBoolean("complication_unicode", true) private fun areComplicationsUnicode() = sp.getBoolean("complication_unicode", true)
private fun deltaSymbol() = if (areComplicationsUnicode()) "\u0394" else "" private fun deltaSymbol() = if (areComplicationsUnicode()) "\u0394" else ""
private fun verticalSeparatorSymbol() = if (areComplicationsUnicode()) "\u205E" else "|" private fun verticalSeparatorSymbol() = if (areComplicationsUnicode()) "\u205E" else "|"
fun basalRateSymbol() = if (areComplicationsUnicode()) "\u238D\u2006" else "" fun basalRateSymbol() = if (areComplicationsUnicode()) "\u238D\u2006" else ""
fun shortTimeSince(refTime: Long): String { fun shortTimeSince(refTime: Long): String {
val deltaTimeMs = wearUtil.msSince(refTime) val deltaTimeMs = wearUtil.msSince(refTime)
return if (deltaTimeMs < Constants.MINUTE_IN_MS) { return if (deltaTimeMs < Constants.MINUTE_IN_MS) {
"0'" "0'"
} else if (deltaTimeMs < Constants.HOUR_IN_MS) { } else if (deltaTimeMs < Constants.HOUR_IN_MS) {
val minutes = (deltaTimeMs / Constants.MINUTE_IN_MS).toInt() val minutes = (deltaTimeMs / Constants.MINUTE_IN_MS).toInt()
"$minutes'" "$minutes'"
} else if (deltaTimeMs < Constants.DAY_IN_MS) { } else if (deltaTimeMs < Constants.DAY_IN_MS) {
val hours = (deltaTimeMs / Constants.HOUR_IN_MS).toInt() val hours = (deltaTimeMs / Constants.HOUR_IN_MS).toInt()
hours.toString() + context.getString(R.string.hour_short) hours.toString() + context.getString(R.string.hour_short)
} else { } else {
val days = (deltaTimeMs / Constants.DAY_IN_MS).toInt() val days = (deltaTimeMs / Constants.DAY_IN_MS).toInt()
if (days < 7) { if (days < 7) {
days.toString() + context.getString(R.string.day_short) days.toString() + context.getString(R.string.day_short)
} else { } else {
val weeks = days / 7 val weeks = days / 7
weeks.toString() + context.getString(R.string.week_short) weeks.toString() + context.getString(R.string.week_short)
} }
} }
} }
fun shortTrend(raw: RawDisplayData): String { fun shortTrend(raw: RawDisplayData): String {
var minutes = "--" var minutes = "--"
val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta
if (raw.singleBg.timeStamp > 0) { if (raw.singleBg.timeStamp > 0) {
minutes = shortTimeSince(raw.singleBg.timeStamp) minutes = shortTimeSince(raw.singleBg.timeStamp)
} }
if (minutes.length + rawDelta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) { if (minutes.length + rawDelta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
return minutes + " " + deltaSymbol() + rawDelta return minutes + " " + deltaSymbol() + rawDelta
} }
// that only optimizes obvious things like 0 before . or at end, + at beginning // that only optimizes obvious things like 0 before . or at end, + at beginning
val delta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - 1) val delta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - 1)
if (minutes.length + delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) { if (minutes.length + delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
return minutes + " " + deltaSymbol() + delta return minutes + " " + deltaSymbol() + delta
} }
val shortDelta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - (1 + minutes.length)) val shortDelta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - (1 + minutes.length))
return "$minutes $shortDelta" return "$minutes $shortDelta"
} }
fun longGlucoseLine(raw: RawDisplayData): String { fun longGlucoseLine(raw: RawDisplayData): String {
val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta
return raw.singleBg.sgvString + raw.singleBg.slopeArrow + " " + deltaSymbol() + SmallestDoubleString(rawDelta).minimise(8) + " (" + shortTimeSince(raw.singleBg.timeStamp) + ")" return raw.singleBg.sgvString + raw.singleBg.slopeArrow + " " + deltaSymbol() + SmallestDoubleString(rawDelta).minimise(8) + " (" + shortTimeSince(raw.singleBg.timeStamp) + ")"
} }
fun longDetailsLine(raw: RawDisplayData): String { fun longDetailsLine(raw: RawDisplayData): String {
val sepLong = " " + verticalSeparatorSymbol() + " " val sepLong = " " + verticalSeparatorSymbol() + " "
val sepShort = " " + verticalSeparatorSymbol() + " " val sepShort = " " + verticalSeparatorSymbol() + " "
val sepShortLen = sepShort.length val sepShortLen = sepShort.length
val sepMin = " " val sepMin = " "
var line = raw.status.cob + sepLong + raw.status.iobSum + sepLong + basalRateSymbol() + raw.status.currentBasal var line = raw.status.cob + sepLong + raw.status.iobSum + sepLong + basalRateSymbol() + raw.status.currentBasal
if (line.length <= MAX_FIELD_LEN_LONG) { if (line.length <= MAX_FIELD_LEN_LONG) {
return line return line
} }
line = raw.status.cob + sepShort + raw.status.iobSum + sepShort + raw.status.currentBasal line = raw.status.cob + sepShort + raw.status.iobSum + sepShort + raw.status.currentBasal
if (line.length <= MAX_FIELD_LEN_LONG) { if (line.length <= MAX_FIELD_LEN_LONG) {
return line return line
} }
var remainingMax = MAX_FIELD_LEN_LONG - (raw.status.cob.length + raw.status.currentBasal.length + sepShortLen * 2) var remainingMax = MAX_FIELD_LEN_LONG - (raw.status.cob.length + raw.status.currentBasal.length + sepShortLen * 2)
val smallestIoB = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(max(MIN_FIELD_LEN_IOB, remainingMax)) val smallestIoB = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(max(MIN_FIELD_LEN_IOB, remainingMax))
line = raw.status.cob + sepShort + smallestIoB + sepShort + raw.status.currentBasal line = raw.status.cob + sepShort + smallestIoB + sepShort + raw.status.currentBasal
if (line.length <= MAX_FIELD_LEN_LONG) { if (line.length <= MAX_FIELD_LEN_LONG) {
return line return line
} }
remainingMax = MAX_FIELD_LEN_LONG - (smallestIoB.length + raw.status.currentBasal.length + sepShortLen * 2) remainingMax = MAX_FIELD_LEN_LONG - (smallestIoB.length + raw.status.currentBasal.length + sepShortLen * 2)
val simplifiedCob = SmallestDoubleString(raw.status.cob, SmallestDoubleString.Units.USE).minimise(max(MIN_FIELD_LEN_COB, remainingMax)) val simplifiedCob = SmallestDoubleString(raw.status.cob, SmallestDoubleString.Units.USE).minimise(max(MIN_FIELD_LEN_COB, remainingMax))
line = simplifiedCob + sepShort + smallestIoB + sepShort + raw.status.currentBasal line = simplifiedCob + sepShort + smallestIoB + sepShort + raw.status.currentBasal
if (line.length <= MAX_FIELD_LEN_LONG) { if (line.length <= MAX_FIELD_LEN_LONG) {
return line return line
} }
line = simplifiedCob + sepMin + smallestIoB + sepMin + raw.status.currentBasal line = simplifiedCob + sepMin + smallestIoB + sepMin + raw.status.currentBasal
return line return line
} }
fun detailedIob(raw: RawDisplayData): Pair<String, String> { fun detailedIob(raw: RawDisplayData): Pair<String, String> {
val iob1 = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(MAX_FIELD_LEN_SHORT) val iob1 = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(MAX_FIELD_LEN_SHORT)
var iob2 = "" var iob2 = ""
if (raw.status.iobDetail.contains("|")) { if (raw.status.iobDetail.contains("|")) {
val iobs = raw.status.iobDetail.replace("(", "").replace(")", "").split("|").toTypedArray() val iobs = raw.status.iobDetail.replace("(", "").replace(")", "").split("|").toTypedArray()
var iobBolus = SmallestDoubleString(iobs[0]).minimise(MIN_FIELD_LEN_IOB) var iobBolus = SmallestDoubleString(iobs[0]).minimise(MIN_FIELD_LEN_IOB)
if (iobBolus.trim().isEmpty()) { if (iobBolus.trim().isEmpty()) {
iobBolus = "--" iobBolus = "--"
} }
var iobBasal = SmallestDoubleString(iobs[1]).minimise(MAX_FIELD_LEN_SHORT - 1 - max(MIN_FIELD_LEN_IOB, iobBolus.length)) var iobBasal = SmallestDoubleString(iobs[1]).minimise(MAX_FIELD_LEN_SHORT - 1 - max(MIN_FIELD_LEN_IOB, iobBolus.length))
if (iobBasal.trim().isEmpty()) { if (iobBasal.trim().isEmpty()) {
iobBasal = "--" iobBasal = "--"
} }
iob2 = "$iobBolus $iobBasal" iob2 = "$iobBolus $iobBasal"
} }
return create(iob1, iob2) return create(iob1, iob2)
} }
fun detailedCob(raw: RawDisplayData): Pair<String, String> { fun detailedCob(raw: RawDisplayData): Pair<String, String> {
val cobMini = SmallestDoubleString(raw.status.cob, SmallestDoubleString.Units.USE) val cobMini = SmallestDoubleString(raw.status.cob, SmallestDoubleString.Units.USE)
var cob2 = "" var cob2 = ""
if (cobMini.extra.isNotEmpty()) { if (cobMini.extra.isNotEmpty()) {
cob2 = cobMini.extra + cobMini.units cob2 = cobMini.extra + cobMini.units
} }
val cob1 = cobMini.minimise(MAX_FIELD_LEN_SHORT) val cob1 = cobMini.minimise(MAX_FIELD_LEN_SHORT)
return create(cob1, cob2) return create(cob1, cob2)
} }
} }

View file

@ -1,98 +1,98 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.databinding.ActionEditplusminBinding import app.aaps.wear.databinding.ActionEditplusminBinding
import info.nightscout.androidaps.databinding.ActionEditplusminMultiBinding import app.aaps.wear.databinding.ActionEditplusminMultiBinding
import info.nightscout.androidaps.databinding.ActionEditplusminQuickleftyBinding import app.aaps.wear.databinding.ActionEditplusminQuickleftyBinding
import info.nightscout.androidaps.databinding.ActionEditplusminQuickleftyMultiBinding import app.aaps.wear.databinding.ActionEditplusminQuickleftyMultiBinding
import info.nightscout.androidaps.databinding.ActionEditplusminQuickrightyBinding import app.aaps.wear.databinding.ActionEditplusminQuickrightyBinding
import info.nightscout.androidaps.databinding.ActionEditplusminQuickrightyMultiBinding import app.aaps.wear.databinding.ActionEditplusminQuickrightyMultiBinding
import info.nightscout.androidaps.databinding.ActionEditplusminViktoriaBinding import app.aaps.wear.databinding.ActionEditplusminViktoriaBinding
/** /**
* EditPlusMinusViewAdapter binds both ActionEditplusminBinding variants shared attributes to one common view adapter. * EditPlusMinusViewAdapter binds both ActionEditplusminBinding variants shared attributes to one common view adapter.
* Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding. * Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding.
*/ */
class EditPlusMinusViewAdapter( class EditPlusMinusViewAdapter(
eD: ActionEditplusminBinding?, eD: ActionEditplusminBinding?,
eDP: ActionEditplusminMultiBinding?, eDP: ActionEditplusminMultiBinding?,
eQL: ActionEditplusminQuickleftyBinding?, eQL: ActionEditplusminQuickleftyBinding?,
eQLP: ActionEditplusminQuickleftyMultiBinding?, eQLP: ActionEditplusminQuickleftyMultiBinding?,
eQR: ActionEditplusminQuickrightyBinding?, eQR: ActionEditplusminQuickrightyBinding?,
eQRP: ActionEditplusminQuickrightyMultiBinding?, eQRP: ActionEditplusminQuickrightyMultiBinding?,
eV: ActionEditplusminViktoriaBinding? eV: ActionEditplusminViktoriaBinding?
) { ) {
init { init {
if (eD == null && eDP == null && eQL == null && eQLP == null && eQR == null && eQRP == null && eV == null) { if (eD == null && eDP == null && eQL == null && eQLP == null && eQR == null && eQRP == null && eV == null) {
throw IllegalArgumentException("Require at least on Binding parameter") throw IllegalArgumentException("Require at least on Binding parameter")
} }
} }
private val errorMessage = "Missing require View Binding parameter" private val errorMessage = "Missing require View Binding parameter"
val editText = val editText =
eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText
?: throw IllegalArgumentException(errorMessage) ?: throw IllegalArgumentException(errorMessage)
val minButton = val minButton =
eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton
?: throw IllegalArgumentException(errorMessage) ?: throw IllegalArgumentException(errorMessage)
val plusButton1 = val plusButton1 =
eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1 eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1
?: throw IllegalArgumentException(errorMessage) ?: throw IllegalArgumentException(errorMessage)
val label = val label =
eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label
?: throw IllegalArgumentException(errorMessage) ?: throw IllegalArgumentException(errorMessage)
val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2 val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2
val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3 val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3
val root = val root =
eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root
?: throw IllegalArgumentException(errorMessage) ?: throw IllegalArgumentException(errorMessage)
companion object { companion object {
fun getViewAdapter(sp: SP, context: Context, container: ViewGroup, multiple: Boolean = false): EditPlusMinusViewAdapter { fun getViewAdapter(sp: SP, context: Context, container: ViewGroup, multiple: Boolean = false): EditPlusMinusViewAdapter {
val inflater = LayoutInflater.from(context) val inflater = LayoutInflater.from(context)
return when (sp.getInt(R.string.key_input_design, 1)) { return when (sp.getInt(R.string.key_input_design, 1)) {
2 -> { 2 -> {
if (multiple) { if (multiple) {
val bindLayout = ActionEditplusminQuickrightyMultiBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminQuickrightyMultiBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(null, null, null, null, null, bindLayout, null) EditPlusMinusViewAdapter(null, null, null, null, null, bindLayout, null)
} else { } else {
val bindLayout = ActionEditplusminQuickrightyBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminQuickrightyBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(null, null, null, null, bindLayout, null, null) EditPlusMinusViewAdapter(null, null, null, null, bindLayout, null, null)
} }
} }
3 -> { 3 -> {
if (multiple) { if (multiple) {
val bindLayout = ActionEditplusminQuickleftyMultiBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminQuickleftyMultiBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(null, null, null, bindLayout, null, null, null) EditPlusMinusViewAdapter(null, null, null, bindLayout, null, null, null)
} else { } else {
val bindLayout = ActionEditplusminQuickleftyBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminQuickleftyBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(null, null, bindLayout, null, null, null, null) EditPlusMinusViewAdapter(null, null, bindLayout, null, null, null, null)
} }
} }
4 -> { 4 -> {
val bindLayout = ActionEditplusminViktoriaBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminViktoriaBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(null, null, null, null, null, null, bindLayout) EditPlusMinusViewAdapter(null, null, null, null, null, null, bindLayout)
} }
else -> { else -> {
if (multiple) { if (multiple) {
val bindLayout = ActionEditplusminMultiBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminMultiBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(null, bindLayout, null, null, null, null, null) EditPlusMinusViewAdapter(null, bindLayout, null, null, null, null, null)
} else { } else {
val bindLayout = ActionEditplusminBinding.inflate(inflater, container, false) val bindLayout = ActionEditplusminBinding.inflate(inflater, container, false)
EditPlusMinusViewAdapter(bindLayout, null, null, null, null, null, null) EditPlusMinusViewAdapter(bindLayout, null, null, null, null, null, null)
} }
} }
} }
} }
} }
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.os.SystemClock import android.os.SystemClock
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.DateUtil
import info.nightscout.androidaps.BuildConfig import app.aaps.wear.BuildConfig
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -25,19 +25,19 @@ class Inevitable @Inject internal constructor() {
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
private val tasks = ConcurrentHashMap<String, Task>() private val tasks = ConcurrentHashMap<String, Task>()
fun task(id: String, idle_for: Long, runnable: Runnable?) { fun task(id: String, idleFor: Long, runnable: Runnable?) {
if (idle_for > MAX_QUEUE_TIME) { if (idleFor > MAX_QUEUE_TIME) {
throw RuntimeException("$id Requested time: $idle_for beyond max queue time") throw RuntimeException("$id Requested time: $idleFor beyond max queue time")
} }
val task = tasks[id] val task = tasks[id]
if (task != null) { if (task != null) {
// if it already exists then extend the time // if it already exists then extend the time
task.extendTime(idle_for) task.extendTime(idleFor)
if (debug) aapsLogger.debug(LTag.WEAR, "Extending time for: " + id + " to " + dateUtil.dateAndTimeAndSecondsString(task.`when`)) if (debug) aapsLogger.debug(LTag.WEAR, "Extending time for: " + id + " to " + dateUtil.dateAndTimeAndSecondsString(task.`when`))
} else { } else {
// otherwise create new task // otherwise create new task
if (runnable == null) return // extension only if already exists if (runnable == null) return // extension only if already exists
tasks[id] = Task(id, idle_for, runnable) tasks[id] = Task(id, idleFor, runnable)
if (debug) { if (debug) {
aapsLogger.debug( aapsLogger.debug(
LTag.WEAR, LTag.WEAR,

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -14,9 +14,9 @@ import androidx.wear.widget.WearableLinearLayoutManager.LayoutCallback
import androidx.wear.widget.WearableRecyclerView import androidx.wear.widget.WearableRecyclerView
import app.aaps.core.interfaces.rx.bus.RxBus import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.wear.R
import app.aaps.wear.interaction.utils.MenuListActivity.MenuAdapter.ItemViewHolder
import dagger.android.DaggerActivity import dagger.android.DaggerActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interaction.utils.MenuListActivity.MenuAdapter.ItemViewHolder
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.min import kotlin.math.min

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import java.util.* import java.util.Objects
/** /**
* Same as android Pair, but clean room java class - does not require Android SDK for tests * Same as android Pair, but clean room java class - does not require Android SDK for tests

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import app.aaps.annotations.OpenForTesting import app.aaps.annotations.OpenForTesting
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger

View file

@ -1,7 +1,14 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.content.Context import android.content.Context
import android.os.* import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.os.VibrationEffect
import android.os.Vibrator
import android.os.VibratorManager
import android.view.KeyEvent import android.view.KeyEvent
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import kotlin.jvm.JvmOverloads
import java.math.RoundingMode import java.math.RoundingMode
import java.text.DecimalFormat import java.text.DecimalFormat
import java.util.regex.Pattern import java.util.regex.Pattern

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import preference.WearListPreference
import android.widget.Toast import android.widget.Toast
import info.nightscout.androidaps.BuildConfig import app.aaps.wear.BuildConfig
import preference.WearListPreference
/** /**
* Created by adrian on 07/08/17. * Created by adrian on 07/08/17.

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.Toast import android.widget.Toast
import info.nightscout.androidaps.R import app.aaps.wear.R
import preference.WearListPreference import preference.WearListPreference
@Suppress("unused") @Suppress("unused")

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.interaction.utils package app.aaps.wear.interaction.utils
import android.content.Context import android.content.Context
import android.os.PowerManager import android.os.PowerManager

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.nondeprecated package app.aaps.wear.nondeprecated
import android.content.Context import android.content.Context
import android.support.wearable.view.DotsPageIndicator import android.support.wearable.view.DotsPageIndicator

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.nondeprecated package app.aaps.wear.nondeprecated
import android.support.wearable.view.GridPagerAdapter import android.support.wearable.view.GridPagerAdapter

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.nondeprecated package app.aaps.wear.nondeprecated
import android.content.Context import android.content.Context
import android.support.wearable.view.GridViewPager import android.support.wearable.view.GridViewPager

View file

@ -1,19 +1,19 @@
package info.nightscout.androidaps.tile package app.aaps.wear.tile
import dagger.android.AndroidInjection import app.aaps.wear.tile.source.ActionSource
import info.nightscout.androidaps.tile.source.ActionSource import dagger.android.AndroidInjection
import javax.inject.Inject import javax.inject.Inject
class ActionsTileService : TileBase() { class ActionsTileService : TileBase() {
@Inject lateinit var actionSource: ActionSource @Inject lateinit var actionSource: ActionSource
// Not derived from DaggerService, do injection here // Not derived from DaggerService, do injection here
override fun onCreate() { override fun onCreate() {
AndroidInjection.inject(this) AndroidInjection.inject(this)
super.onCreate() super.onCreate()
} }
override val resourceVersion = "ActionsTileService" override val resourceVersion = "ActionsTileService"
override val source get() = actionSource override val source get() = actionSource
} }

View file

@ -1,19 +1,19 @@
package info.nightscout.androidaps.tile package app.aaps.wear.tile
import dagger.android.AndroidInjection import app.aaps.wear.tile.source.QuickWizardSource
import info.nightscout.androidaps.tile.source.QuickWizardSource import dagger.android.AndroidInjection
import javax.inject.Inject import javax.inject.Inject
class QuickWizardTileService : TileBase() { class QuickWizardTileService : TileBase() {
@Inject lateinit var quickWizardSource: QuickWizardSource @Inject lateinit var quickWizardSource: QuickWizardSource
// Not derived from DaggerService, do injection here // Not derived from DaggerService, do injection here
override fun onCreate() { override fun onCreate() {
AndroidInjection.inject(this) AndroidInjection.inject(this)
super.onCreate() super.onCreate()
} }
override val resourceVersion = "QuickWizardTileService" override val resourceVersion = "QuickWizardTileService"
override val source get() = quickWizardSource override val source get() = quickWizardSource
} }

View file

@ -1,19 +1,19 @@
package info.nightscout.androidaps.tile package app.aaps.wear.tile
import dagger.android.AndroidInjection import app.aaps.wear.tile.source.TempTargetSource
import info.nightscout.androidaps.tile.source.TempTargetSource import dagger.android.AndroidInjection
import javax.inject.Inject import javax.inject.Inject
class TempTargetTileService : TileBase() { class TempTargetTileService : TileBase() {
@Inject lateinit var tempTargetSource: TempTargetSource @Inject lateinit var tempTargetSource: TempTargetSource
// Not derived from DaggerService, do injection here // Not derived from DaggerService, do injection here
override fun onCreate() { override fun onCreate() {
AndroidInjection.inject(this) AndroidInjection.inject(this)
super.onCreate() super.onCreate()
} }
override val resourceVersion = "TempTargetTileService" override val resourceVersion = "TempTargetTileService"
override val source get() = tempTargetSource override val source get() = tempTargetSource
} }

View file

@ -1,309 +1,309 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.tile package app.aaps.wear.tile
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.wear.tiles.ActionBuilders import androidx.wear.tiles.ActionBuilders
import androidx.wear.tiles.ColorBuilders.argb import androidx.wear.tiles.ColorBuilders.argb
import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
import androidx.wear.tiles.DeviceParametersBuilders.SCREEN_SHAPE_ROUND import androidx.wear.tiles.DeviceParametersBuilders.SCREEN_SHAPE_ROUND
import androidx.wear.tiles.DimensionBuilders.SpProp import androidx.wear.tiles.DimensionBuilders.SpProp
import androidx.wear.tiles.DimensionBuilders.dp import androidx.wear.tiles.DimensionBuilders.dp
import androidx.wear.tiles.DimensionBuilders.sp import androidx.wear.tiles.DimensionBuilders.sp
import androidx.wear.tiles.LayoutElementBuilders.Box import androidx.wear.tiles.LayoutElementBuilders.Box
import androidx.wear.tiles.LayoutElementBuilders.Column import androidx.wear.tiles.LayoutElementBuilders.Column
import androidx.wear.tiles.LayoutElementBuilders.FONT_WEIGHT_BOLD import androidx.wear.tiles.LayoutElementBuilders.FONT_WEIGHT_BOLD
import androidx.wear.tiles.LayoutElementBuilders.FontStyle import androidx.wear.tiles.LayoutElementBuilders.FontStyle
import androidx.wear.tiles.LayoutElementBuilders.Image import androidx.wear.tiles.LayoutElementBuilders.Image
import androidx.wear.tiles.LayoutElementBuilders.Layout import androidx.wear.tiles.LayoutElementBuilders.Layout
import androidx.wear.tiles.LayoutElementBuilders.LayoutElement import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
import androidx.wear.tiles.LayoutElementBuilders.Row import androidx.wear.tiles.LayoutElementBuilders.Row
import androidx.wear.tiles.LayoutElementBuilders.Spacer import androidx.wear.tiles.LayoutElementBuilders.Spacer
import androidx.wear.tiles.LayoutElementBuilders.Text import androidx.wear.tiles.LayoutElementBuilders.Text
import androidx.wear.tiles.ModifiersBuilders.Background import androidx.wear.tiles.ModifiersBuilders.Background
import androidx.wear.tiles.ModifiersBuilders.Clickable import androidx.wear.tiles.ModifiersBuilders.Clickable
import androidx.wear.tiles.ModifiersBuilders.Corner import androidx.wear.tiles.ModifiersBuilders.Corner
import androidx.wear.tiles.ModifiersBuilders.Modifiers import androidx.wear.tiles.ModifiersBuilders.Modifiers
import androidx.wear.tiles.ModifiersBuilders.Semantics import androidx.wear.tiles.ModifiersBuilders.Semantics
import androidx.wear.tiles.RequestBuilders import androidx.wear.tiles.RequestBuilders
import androidx.wear.tiles.RequestBuilders.ResourcesRequest import androidx.wear.tiles.RequestBuilders.ResourcesRequest
import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
import androidx.wear.tiles.ResourceBuilders.ImageResource import androidx.wear.tiles.ResourceBuilders.ImageResource
import androidx.wear.tiles.ResourceBuilders.Resources import androidx.wear.tiles.ResourceBuilders.Resources
import androidx.wear.tiles.TileBuilders.Tile import androidx.wear.tiles.TileBuilders.Tile
import androidx.wear.tiles.TileService import androidx.wear.tiles.TileService
import androidx.wear.tiles.TimelineBuilders.Timeline import androidx.wear.tiles.TimelineBuilders.Timeline
import androidx.wear.tiles.TimelineBuilders.TimelineEntry import androidx.wear.tiles.TimelineBuilders.TimelineEntry
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import com.google.common.util.concurrent.ListenableFuture import app.aaps.wear.R
import dagger.android.AndroidInjection import app.aaps.wear.comm.DataLayerListenerServiceWear
import info.nightscout.androidaps.R import com.google.common.util.concurrent.ListenableFuture
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear import dagger.android.AndroidInjection
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.guava.future import kotlinx.coroutines.guava.future
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.sqrt import kotlin.math.sqrt
private const val SPACING_ACTIONS = 3f private const val SPACING_ACTIONS = 3f
private const val ICON_SIZE_FRACTION = 0.4f // Percentage of button diameter private const val ICON_SIZE_FRACTION = 0.4f // Percentage of button diameter
private val BUTTON_COLOR = R.color.gray_850 private val BUTTON_COLOR = R.color.gray_850
private const val LARGE_SCREEN_WIDTH_DP = 210 private const val LARGE_SCREEN_WIDTH_DP = 210
interface TileSource { interface TileSource {
fun getResourceReferences(resources: android.content.res.Resources): List<Int> fun getResourceReferences(resources: android.content.res.Resources): List<Int>
fun getSelectedActions(): List<Action> fun getSelectedActions(): List<Action>
fun getValidFor(): Long? fun getValidFor(): Long?
} }
open class Action( open class Action(
val buttonText: String, val buttonText: String,
val buttonTextSub: String? = null, val buttonTextSub: String? = null,
val activityClass: String, val activityClass: String,
@DrawableRes val iconRes: Int, @DrawableRes val iconRes: Int,
val action: EventData? = null, val action: EventData? = null,
val message: String? = null, val message: String? = null,
) )
enum class WearControl { enum class WearControl {
NO_DATA, ENABLED, DISABLED NO_DATA, ENABLED, DISABLED
} }
abstract class TileBase : TileService() { abstract class TileBase : TileService() {
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
abstract val resourceVersion: String abstract val resourceVersion: String
abstract val source: TileSource abstract val source: TileSource
private val serviceJob = Job() private val serviceJob = Job()
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob) private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
// Not derived from DaggerService, do injection here // Not derived from DaggerService, do injection here
override fun onCreate() { override fun onCreate() {
AndroidInjection.inject(this) AndroidInjection.inject(this)
super.onCreate() super.onCreate()
} }
override fun onTileRequest( override fun onTileRequest(
requestParams: RequestBuilders.TileRequest requestParams: RequestBuilders.TileRequest
): ListenableFuture<Tile> = serviceScope.future { ): ListenableFuture<Tile> = serviceScope.future {
val actionsSelected = getSelectedActions() val actionsSelected = getSelectedActions()
val wearControl = getWearControl() val wearControl = getWearControl()
val tile = Tile.Builder() val tile = Tile.Builder()
.setResourcesVersion(resourceVersion) .setResourcesVersion(resourceVersion)
.setTimeline( .setTimeline(
Timeline.Builder().addTimelineEntry( Timeline.Builder().addTimelineEntry(
TimelineEntry.Builder().setLayout( TimelineEntry.Builder().setLayout(
Layout.Builder().setRoot(layout(wearControl, actionsSelected, requestParams.deviceParameters!!)).build() Layout.Builder().setRoot(layout(wearControl, actionsSelected, requestParams.deviceParameters!!)).build()
).build() ).build()
).build() ).build()
) )
val validFor = validFor() val validFor = validFor()
if (validFor != null) { if (validFor != null) {
tile.setFreshnessIntervalMillis(validFor) tile.setFreshnessIntervalMillis(validFor)
} }
tile.build() tile.build()
} }
private fun getSelectedActions(): List<Action> { private fun getSelectedActions(): List<Action> {
// TODO check why thi scan not be don in scope of the coroutine // TODO check why thi scan not be don in scope of the coroutine
return source.getSelectedActions() return source.getSelectedActions()
} }
private fun validFor(): Long? { private fun validFor(): Long? {
return source.getValidFor() return source.getValidFor()
} }
override fun onResourcesRequest( override fun onResourcesRequest(
requestParams: ResourcesRequest requestParams: ResourcesRequest
): ListenableFuture<Resources> = serviceScope.future { ): ListenableFuture<Resources> = serviceScope.future {
Resources.Builder() Resources.Builder()
.setVersion(resourceVersion) .setVersion(resourceVersion)
.apply { .apply {
source.getResourceReferences(resources).forEach { resourceId -> source.getResourceReferences(resources).forEach { resourceId ->
addIdToImageMapping( addIdToImageMapping(
resourceId.toString(), resourceId.toString(),
ImageResource.Builder() ImageResource.Builder()
.setAndroidResourceByResId( .setAndroidResourceByResId(
AndroidImageResourceByResId.Builder() AndroidImageResourceByResId.Builder()
.setResourceId(resourceId) .setResourceId(resourceId)
.build() .build()
) )
.build() .build()
) )
} }
} }
.build() .build()
} }
private fun layout(wearControl: WearControl, actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement { private fun layout(wearControl: WearControl, actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement {
if (wearControl == WearControl.DISABLED) { if (wearControl == WearControl.DISABLED) {
return Text.Builder() return Text.Builder()
.setText(resources.getString(R.string.wear_control_not_enabled)) .setText(resources.getString(R.string.wear_control_not_enabled))
.build() .build()
} else if (wearControl == WearControl.NO_DATA) { } else if (wearControl == WearControl.NO_DATA) {
return Text.Builder() return Text.Builder()
.setText(resources.getString(R.string.wear_control_no_data)) .setText(resources.getString(R.string.wear_control_no_data))
.build() .build()
} }
if (actions.isNotEmpty()) { if (actions.isNotEmpty()) {
with(Column.Builder()) { with(Column.Builder()) {
if (actions.size == 1 || actions.size == 3) { if (actions.size == 1 || actions.size == 3) {
addContent(addRowSingle(actions[0], deviceParameters)) addContent(addRowSingle(actions[0], deviceParameters))
} }
if (actions.size == 4 || actions.size == 2) { if (actions.size == 4 || actions.size == 2) {
addContent(addRowDouble(actions[0], actions[1], deviceParameters)) addContent(addRowDouble(actions[0], actions[1], deviceParameters))
} }
if (actions.size == 3) { if (actions.size == 3) {
addContent(addRowDouble(actions[1], actions[2], deviceParameters)) addContent(addRowDouble(actions[1], actions[2], deviceParameters))
} }
if (actions.size == 4) { if (actions.size == 4) {
addContent(Spacer.Builder().setHeight(dp(SPACING_ACTIONS)).build()) addContent(Spacer.Builder().setHeight(dp(SPACING_ACTIONS)).build())
addContent(addRowDouble(actions[2], actions[3], deviceParameters)) addContent(addRowDouble(actions[2], actions[3], deviceParameters))
} }
return build() return build()
} }
} }
return Text.Builder() return Text.Builder()
.setText(resources.getString(R.string.tile_no_config)) .setText(resources.getString(R.string.tile_no_config))
.build() .build()
} }
private fun addRowSingle(action: Action, deviceParameters: DeviceParameters): LayoutElement = private fun addRowSingle(action: Action, deviceParameters: DeviceParameters): LayoutElement =
Row.Builder() Row.Builder()
.addContent(action(action, deviceParameters)) .addContent(action(action, deviceParameters))
.build() .build()
private fun addRowDouble(action1: Action, action2: Action, deviceParameters: DeviceParameters): LayoutElement = private fun addRowDouble(action1: Action, action2: Action, deviceParameters: DeviceParameters): LayoutElement =
Row.Builder() Row.Builder()
.addContent(action(action1, deviceParameters)) .addContent(action(action1, deviceParameters))
.addContent(Spacer.Builder().setWidth(dp(SPACING_ACTIONS)).build()) .addContent(Spacer.Builder().setWidth(dp(SPACING_ACTIONS)).build())
.addContent(action(action2, deviceParameters)) .addContent(action(action2, deviceParameters))
.build() .build()
private fun doAction(action: Action): ActionBuilders.Action { private fun doAction(action: Action): ActionBuilders.Action {
val builder = ActionBuilders.AndroidActivity.Builder() val builder = ActionBuilders.AndroidActivity.Builder()
.setClassName(action.activityClass) .setClassName(action.activityClass)
.setPackageName(this.packageName) .setPackageName(this.packageName)
if (action.action != null) { if (action.action != null) {
val actionString = ActionBuilders.AndroidStringExtra.Builder().setValue(action.action.serialize()).build() val actionString = ActionBuilders.AndroidStringExtra.Builder().setValue(action.action.serialize()).build()
builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_ACTION, actionString) builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_ACTION, actionString)
} }
if (action.message != null) { if (action.message != null) {
val message = ActionBuilders.AndroidStringExtra.Builder().setValue(action.message).build() val message = ActionBuilders.AndroidStringExtra.Builder().setValue(action.message).build()
builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_MESSAGE, message) builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_MESSAGE, message)
} }
return ActionBuilders.LaunchAction.Builder() return ActionBuilders.LaunchAction.Builder()
.setAndroidActivity(builder.build()) .setAndroidActivity(builder.build())
.build() .build()
} }
private fun action(action: Action, deviceParameters: DeviceParameters): LayoutElement { private fun action(action: Action, deviceParameters: DeviceParameters): LayoutElement {
val circleDiameter = circleDiameter(deviceParameters) val circleDiameter = circleDiameter(deviceParameters)
val text = action.buttonText val text = action.buttonText
val textSub = action.buttonTextSub val textSub = action.buttonTextSub
return Box.Builder() return Box.Builder()
.setWidth(dp(circleDiameter)) .setWidth(dp(circleDiameter))
.setHeight(dp(circleDiameter)) .setHeight(dp(circleDiameter))
.setModifiers( .setModifiers(
Modifiers.Builder() Modifiers.Builder()
.setBackground( .setBackground(
Background.Builder() Background.Builder()
.setColor(argb(ContextCompat.getColor(baseContext, BUTTON_COLOR))) .setColor(argb(ContextCompat.getColor(baseContext, BUTTON_COLOR)))
.setCorner(Corner.Builder().setRadius(dp(circleDiameter / 2)).build()) .setCorner(Corner.Builder().setRadius(dp(circleDiameter / 2)).build())
.build() .build()
) )
.setSemantics( .setSemantics(
Semantics.Builder() Semantics.Builder()
.setContentDescription("$text $textSub") .setContentDescription("$text $textSub")
.build() .build()
) )
.setClickable( .setClickable(
Clickable.Builder() Clickable.Builder()
.setOnClick(doAction(action)) .setOnClick(doAction(action))
.build() .build()
) )
.build() .build()
) )
.addContent(addTextContent(action, deviceParameters)) .addContent(addTextContent(action, deviceParameters))
.build() .build()
} }
private fun addTextContent(action: Action, deviceParameters: DeviceParameters): LayoutElement { private fun addTextContent(action: Action, deviceParameters: DeviceParameters): LayoutElement {
val circleDiameter = circleDiameter(deviceParameters) val circleDiameter = circleDiameter(deviceParameters)
val iconSize = dp(circleDiameter * ICON_SIZE_FRACTION) val iconSize = dp(circleDiameter * ICON_SIZE_FRACTION)
val text = action.buttonText val text = action.buttonText
val textSub = action.buttonTextSub val textSub = action.buttonTextSub
val col = Column.Builder() val col = Column.Builder()
.addContent( .addContent(
Image.Builder() Image.Builder()
.setWidth(iconSize) .setWidth(iconSize)
.setHeight(iconSize) .setHeight(iconSize)
.setResourceId(action.iconRes.toString()) .setResourceId(action.iconRes.toString())
.build() .build()
).addContent( ).addContent(
Text.Builder() Text.Builder()
.setText(text) .setText(text)
.setFontStyle( .setFontStyle(
FontStyle.Builder() FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD) .setWeight(FONT_WEIGHT_BOLD)
.setColor(argb(ContextCompat.getColor(baseContext, R.color.white))) .setColor(argb(ContextCompat.getColor(baseContext, R.color.white)))
.setSize(buttonTextSize(deviceParameters, text)) .setSize(buttonTextSize(deviceParameters, text))
.build() .build()
) )
.build() .build()
) )
if (textSub != null) { if (textSub != null) {
col.addContent( col.addContent(
Text.Builder() Text.Builder()
.setText(textSub) .setText(textSub)
.setFontStyle( .setFontStyle(
FontStyle.Builder() FontStyle.Builder()
.setColor(argb(ContextCompat.getColor(baseContext, R.color.white))) .setColor(argb(ContextCompat.getColor(baseContext, R.color.white)))
.setSize(buttonTextSize(deviceParameters, textSub)) .setSize(buttonTextSize(deviceParameters, textSub))
.build() .build()
) )
.build() .build()
) )
} }
return col.build() return col.build()
} }
private fun circleDiameter(deviceParameters: DeviceParameters) = when (deviceParameters.screenShape) { private fun circleDiameter(deviceParameters: DeviceParameters) = when (deviceParameters.screenShape) {
SCREEN_SHAPE_ROUND -> ((sqrt(2f) - 1) * deviceParameters.screenHeightDp) - (2 * SPACING_ACTIONS) SCREEN_SHAPE_ROUND -> ((sqrt(2f) - 1) * deviceParameters.screenHeightDp) - (2 * SPACING_ACTIONS)
else -> 0.5f * deviceParameters.screenHeightDp - SPACING_ACTIONS else -> 0.5f * deviceParameters.screenHeightDp - SPACING_ACTIONS
} }
private fun buttonTextSize(deviceParameters: DeviceParameters, text: String): SpProp { private fun buttonTextSize(deviceParameters: DeviceParameters, text: String): SpProp {
if (text.length > 6) { if (text.length > 6) {
return sp(if (isLargeScreen(deviceParameters)) 14f else 12f) return sp(if (isLargeScreen(deviceParameters)) 14f else 12f)
} }
return sp(if (isLargeScreen(deviceParameters)) 16f else 14f) return sp(if (isLargeScreen(deviceParameters)) 16f else 14f)
} }
private fun isLargeScreen(deviceParameters: DeviceParameters): Boolean { private fun isLargeScreen(deviceParameters: DeviceParameters): Boolean {
return deviceParameters.screenWidthDp >= LARGE_SCREEN_WIDTH_DP return deviceParameters.screenWidthDp >= LARGE_SCREEN_WIDTH_DP
} }
private fun getWearControl(): WearControl { private fun getWearControl(): WearControl {
if (!sp.contains(R.string.key_wear_control)) { if (!sp.contains(R.string.key_wear_control)) {
return WearControl.NO_DATA return WearControl.NO_DATA
} }
val wearControlPref = sp.getBoolean(R.string.key_wear_control, false) val wearControlPref = sp.getBoolean(R.string.key_wear_control, false)
if (wearControlPref) { if (wearControlPref) {
return WearControl.ENABLED return WearControl.ENABLED
} }
return WearControl.DISABLED return WearControl.DISABLED
} }
} }

View file

@ -1,76 +1,76 @@
package info.nightscout.androidaps.tile.source package app.aaps.wear.tile.source
import android.content.Context import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.actions.BolusActivity import app.aaps.wear.interaction.actions.BolusActivity
import info.nightscout.androidaps.interaction.actions.CarbActivity import app.aaps.wear.interaction.actions.CarbActivity
import info.nightscout.androidaps.interaction.actions.ECarbActivity import app.aaps.wear.interaction.actions.ECarbActivity
import info.nightscout.androidaps.interaction.actions.TempTargetActivity import app.aaps.wear.interaction.actions.TempTargetActivity
import info.nightscout.androidaps.interaction.actions.TreatmentActivity import app.aaps.wear.interaction.actions.TreatmentActivity
import info.nightscout.androidaps.interaction.actions.WizardActivity import app.aaps.wear.interaction.actions.WizardActivity
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class ActionSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) { class ActionSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
override val preferencePrefix = "tile_action_" override val preferencePrefix = "tile_action_"
override fun getActions(resources: Resources): List<StaticAction> { override fun getActions(resources: Resources): List<StaticAction> {
return listOf( return listOf(
StaticAction( StaticAction(
settingName = "wizard", settingName = "wizard",
buttonText = resources.getString(R.string.menu_wizard_short), buttonText = resources.getString(R.string.menu_wizard_short),
iconRes = R.drawable.ic_calculator_green, iconRes = R.drawable.ic_calculator_green,
activityClass = WizardActivity::class.java.name, activityClass = WizardActivity::class.java.name,
), ),
StaticAction( StaticAction(
settingName = "treatment", settingName = "treatment",
buttonText = resources.getString(R.string.menu_treatment_short), buttonText = resources.getString(R.string.menu_treatment_short),
iconRes = R.drawable.ic_bolus_carbs, iconRes = R.drawable.ic_bolus_carbs,
activityClass = TreatmentActivity::class.java.name, activityClass = TreatmentActivity::class.java.name,
), ),
StaticAction( StaticAction(
settingName = "bolus", settingName = "bolus",
buttonText = resources.getString(R.string.action_insulin), buttonText = resources.getString(R.string.action_insulin),
iconRes = R.drawable.ic_bolus, iconRes = R.drawable.ic_bolus,
activityClass = BolusActivity::class.java.name, activityClass = BolusActivity::class.java.name,
), ),
StaticAction( StaticAction(
settingName = "carbs", settingName = "carbs",
buttonText = resources.getString(R.string.action_carbs), buttonText = resources.getString(R.string.action_carbs),
iconRes = R.drawable.ic_carbs_orange, iconRes = R.drawable.ic_carbs_orange,
activityClass = CarbActivity::class.java.name, activityClass = CarbActivity::class.java.name,
), ),
StaticAction( StaticAction(
settingName = "ecarbs", settingName = "ecarbs",
buttonText = resources.getString(R.string.action_ecarbs), buttonText = resources.getString(R.string.action_ecarbs),
iconRes = R.drawable.ic_carbs_orange, iconRes = R.drawable.ic_carbs_orange,
activityClass = ECarbActivity::class.java.name, activityClass = ECarbActivity::class.java.name,
), ),
StaticAction( StaticAction(
settingName = "temp_target", settingName = "temp_target",
buttonText = resources.getString(R.string.menu_tempt), buttonText = resources.getString(R.string.menu_tempt),
iconRes = R.drawable.ic_temptarget_flat, iconRes = R.drawable.ic_temptarget_flat,
activityClass = TempTargetActivity::class.java.name, activityClass = TempTargetActivity::class.java.name,
) )
) )
} }
override fun getResourceReferences(resources: Resources): List<Int> { override fun getResourceReferences(resources: Resources): List<Int> {
return getActions(resources).map { it.iconRes } return getActions(resources).map { it.iconRes }
} }
override fun getDefaultConfig(): Map<String, String> { override fun getDefaultConfig(): Map<String, String> {
return mapOf( return mapOf(
"tile_action_1" to "wizard", "tile_action_1" to "wizard",
"tile_action_2" to "treatment", "tile_action_2" to "treatment",
"tile_action_3" to "ecarbs", "tile_action_3" to "ecarbs",
"tile_action_4" to "temp_target" "tile_action_4" to "temp_target"
) )
} }
} }

View file

@ -1,81 +1,81 @@
package info.nightscout.androidaps.tile.source package app.aaps.wear.tile.source
import android.content.Context import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.actions.BackgroundActionActivity import app.aaps.wear.interaction.actions.BackgroundActionActivity
import info.nightscout.androidaps.tile.Action import app.aaps.wear.tile.Action
import info.nightscout.androidaps.tile.TileSource import app.aaps.wear.tile.TileSource
import java.util.Calendar import java.util.Calendar
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class QuickWizardSource @Inject constructor(private val context: Context, private val sp: SP, private val aapsLogger: AAPSLogger) : TileSource { class QuickWizardSource @Inject constructor(private val context: Context, private val sp: SP, private val aapsLogger: AAPSLogger) : TileSource {
override fun getSelectedActions(): List<Action> { override fun getSelectedActions(): List<Action> {
val quickList = mutableListOf<Action>() val quickList = mutableListOf<Action>()
val quickMap = getQuickWizardData(sp) val quickMap = getQuickWizardData(sp)
val sfm = secondsFromMidnight() val sfm = secondsFromMidnight()
for (quick in quickMap.entries) { for (quick in quickMap.entries) {
val isActive = sfm in quick.validFrom..quick.validTo val isActive = sfm in quick.validFrom..quick.validTo
if (isActive && quick.guid.isNotEmpty()) { if (isActive && quick.guid.isNotEmpty()) {
quickList.add( quickList.add(
Action( Action(
buttonText = quick.buttonText, buttonText = quick.buttonText,
buttonTextSub = "${quick.carbs} g", buttonTextSub = "${quick.carbs} g",
iconRes = R.drawable.ic_quick_wizard, iconRes = R.drawable.ic_quick_wizard,
activityClass = BackgroundActionActivity::class.java.name, activityClass = BackgroundActionActivity::class.java.name,
action = EventData.ActionQuickWizardPreCheck(quick.guid), action = EventData.ActionQuickWizardPreCheck(quick.guid),
message = context.resources.getString(R.string.action_quick_wizard_confirmation) message = context.resources.getString(R.string.action_quick_wizard_confirmation)
) )
) )
aapsLogger.info(LTag.WEAR, """getSelectedActions: active ${quick.buttonText} guid=${quick.guid}""") aapsLogger.info(LTag.WEAR, """getSelectedActions: active ${quick.buttonText} guid=${quick.guid}""")
} else { } else {
aapsLogger.info(LTag.WEAR, """getSelectedActions: not active ${quick.buttonText} guid=${quick.guid}""") aapsLogger.info(LTag.WEAR, """getSelectedActions: not active ${quick.buttonText} guid=${quick.guid}""")
} }
} }
return quickList return quickList
} }
override fun getValidFor(): Long? { override fun getValidFor(): Long? {
val quickMap = getQuickWizardData(sp) val quickMap = getQuickWizardData(sp)
if (quickMap.entries.size == 0) return null if (quickMap.entries.size == 0) return null
val sfm = secondsFromMidnight() val sfm = secondsFromMidnight()
var validTill = 24 * 60 * 60 var validTill = 24 * 60 * 60
for (quick in quickMap.entries) { for (quick in quickMap.entries) {
val isActive = sfm in quick.validFrom..quick.validTo val isActive = sfm in quick.validFrom..quick.validTo
if (quick.guid.isNotEmpty()) { if (quick.guid.isNotEmpty()) {
if (isActive && validTill > quick.validTo) validTill = quick.validTo if (isActive && validTill > quick.validTo) validTill = quick.validTo
if (quick.validFrom in (sfm + 1) until validTill) validTill = quick.validFrom if (quick.validFrom in (sfm + 1) until validTill) validTill = quick.validFrom
} }
} }
val validWithin = 60 val validWithin = 60
//aapsLogger.info(LTag.WEAR, "getValidTill: sfm$sfm till$validTill d=$delta") //aapsLogger.info(LTag.WEAR, "getValidTill: sfm$sfm till$validTill d=$delta")
return (validTill - sfm + validWithin) * 1000L return (validTill - sfm + validWithin) * 1000L
} }
private fun getQuickWizardData(sp: SP): EventData.QuickWizard = private fun getQuickWizardData(sp: SP): EventData.QuickWizard =
EventData.deserialize(sp.getString(R.string.key_quick_wizard_data, EventData.QuickWizard(arrayListOf()).serialize())) as EventData.QuickWizard EventData.deserialize(sp.getString(R.string.key_quick_wizard_data, EventData.QuickWizard(arrayListOf()).serialize())) as EventData.QuickWizard
private fun secondsFromMidnight(): Int { private fun secondsFromMidnight(): Int {
val c = Calendar.getInstance() val c = Calendar.getInstance()
c.set(Calendar.HOUR_OF_DAY, 0) c.set(Calendar.HOUR_OF_DAY, 0)
c.set(Calendar.MINUTE, 0) c.set(Calendar.MINUTE, 0)
c.set(Calendar.SECOND, 0) c.set(Calendar.SECOND, 0)
c.set(Calendar.MILLISECOND, 0) c.set(Calendar.MILLISECOND, 0)
val passed: Long = System.currentTimeMillis() - c.timeInMillis val passed: Long = System.currentTimeMillis() - c.timeInMillis
return (passed / 1000).toInt() return (passed / 1000).toInt()
} }
override fun getResourceReferences(resources: Resources): List<Int> = listOf(R.drawable.ic_quick_wizard) override fun getResourceReferences(resources: Resources): List<Int> = listOf(R.drawable.ic_quick_wizard)
} }

View file

@ -1,61 +1,61 @@
package info.nightscout.androidaps.tile.source package app.aaps.wear.tile.source
import android.content.Context import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import info.nightscout.androidaps.tile.Action import app.aaps.wear.tile.Action
import info.nightscout.androidaps.tile.TileSource import app.aaps.wear.tile.TileSource
abstract class StaticTileSource(val context: Context, val sp: SP, val aapsLogger: AAPSLogger) : TileSource { abstract class StaticTileSource(val context: Context, val sp: SP, val aapsLogger: AAPSLogger) : TileSource {
class StaticAction( class StaticAction(
val settingName: String, val settingName: String,
buttonText: String, buttonText: String,
buttonTextSub: String? = null, buttonTextSub: String? = null,
activityClass: String, activityClass: String,
@DrawableRes iconRes: Int, @DrawableRes iconRes: Int,
action: EventData? = null, action: EventData? = null,
message: String? = null, message: String? = null,
) : Action(buttonText, buttonTextSub, activityClass, iconRes, action, message) ) : Action(buttonText, buttonTextSub, activityClass, iconRes, action, message)
abstract fun getActions(resources: Resources): List<StaticAction> abstract fun getActions(resources: Resources): List<StaticAction>
abstract val preferencePrefix: String abstract val preferencePrefix: String
abstract fun getDefaultConfig(): Map<String, String> abstract fun getDefaultConfig(): Map<String, String>
override fun getSelectedActions(): List<Action> { override fun getSelectedActions(): List<Action> {
setDefaultSettings() setDefaultSettings()
val actionList: MutableList<Action> = mutableListOf() val actionList: MutableList<Action> = mutableListOf()
for (i in 1..4) { for (i in 1..4) {
val action = getActionFromPreference(i) val action = getActionFromPreference(i)
if (action != null) { if (action != null) {
actionList.add(action) actionList.add(action)
} }
} }
if (actionList.isEmpty()) { if (actionList.isEmpty()) {
return getActions(context.resources).take(4) return getActions(context.resources).take(4)
} }
return actionList return actionList
} }
override fun getValidFor(): Long? = null override fun getValidFor(): Long? = null
private fun getActionFromPreference(index: Int): Action? { private fun getActionFromPreference(index: Int): Action? {
val actionPref = sp.getString(preferencePrefix + index, "none") val actionPref = sp.getString(preferencePrefix + index, "none")
return getActions(context.resources).find { action -> action.settingName == actionPref } return getActions(context.resources).find { action -> action.settingName == actionPref }
} }
private fun setDefaultSettings() { private fun setDefaultSettings() {
val defaults = getDefaultConfig() val defaults = getDefaultConfig()
val firstKey = defaults.firstNotNullOf { settings -> settings.key } val firstKey = defaults.firstNotNullOf { settings -> settings.key }
if (!sp.contains(firstKey)) { if (!sp.contains(firstKey)) {
for ((key, value) in defaults) { for ((key, value) in defaults) {
sp.putString(key, value) sp.putString(key, value)
} }
} }
} }
} }

View file

@ -1,83 +1,83 @@
package info.nightscout.androidaps.tile.source package app.aaps.wear.tile.source
import android.content.Context import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.interaction.actions.BackgroundActionActivity import app.aaps.wear.interaction.actions.BackgroundActionActivity
import info.nightscout.androidaps.interaction.actions.TempTargetActivity import app.aaps.wear.interaction.actions.TempTargetActivity
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class TempTargetSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) { class TempTargetSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
override val preferencePrefix = "tile_tempt_" override val preferencePrefix = "tile_tempt_"
override fun getActions(resources: Resources): List<StaticAction> { override fun getActions(resources: Resources): List<StaticAction> {
val message = resources.getString(R.string.action_tempt_confirmation) val message = resources.getString(R.string.action_tempt_confirmation)
return listOf( return listOf(
StaticAction( StaticAction(
settingName = "activity", settingName = "activity",
buttonText = resources.getString(R.string.temp_target_activity), buttonText = resources.getString(R.string.temp_target_activity),
iconRes = R.drawable.ic_target_activity, iconRes = R.drawable.ic_target_activity,
activityClass = BackgroundActionActivity::class.java.name, activityClass = BackgroundActionActivity::class.java.name,
message = message, message = message,
// actionString = "temptarget false 90 8.0 8.0", // actionString = "temptarget false 90 8.0 8.0",
// actionString = "temptarget preset activity", // actionString = "temptarget preset activity",
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_ACTIVITY) action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_ACTIVITY)
), ),
StaticAction( StaticAction(
settingName = "eating_soon", settingName = "eating_soon",
buttonText = resources.getString(R.string.temp_target_eating_soon), buttonText = resources.getString(R.string.temp_target_eating_soon),
iconRes = R.drawable.ic_target_eatingsoon, iconRes = R.drawable.ic_target_eatingsoon,
activityClass = BackgroundActionActivity::class.java.name, activityClass = BackgroundActionActivity::class.java.name,
message = message, message = message,
// actionString = "temptarget false 45 4.5 4.5", // actionString = "temptarget false 45 4.5 4.5",
// actionString = "temptarget preset eating", // actionString = "temptarget preset eating",
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_EATING) action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_EATING)
), ),
StaticAction( StaticAction(
settingName = "hypo", settingName = "hypo",
buttonText = resources.getString(R.string.temp_target_hypo), buttonText = resources.getString(R.string.temp_target_hypo),
iconRes = R.drawable.ic_target_hypo, iconRes = R.drawable.ic_target_hypo,
activityClass = BackgroundActionActivity::class.java.name, activityClass = BackgroundActionActivity::class.java.name,
message = message, message = message,
// actionString = "temptarget false 45 7.0 7.0", // actionString = "temptarget false 45 7.0 7.0",
// actionString = "temptarget preset hypo", // actionString = "temptarget preset hypo",
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_HYPO) action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_HYPO)
), ),
StaticAction( StaticAction(
settingName = "manual", settingName = "manual",
buttonText = resources.getString(R.string.temp_target_manual), buttonText = resources.getString(R.string.temp_target_manual),
iconRes = R.drawable.ic_target_manual, iconRes = R.drawable.ic_target_manual,
activityClass = TempTargetActivity::class.java.name, activityClass = TempTargetActivity::class.java.name,
action = null action = null
), ),
StaticAction( StaticAction(
settingName = "cancel", settingName = "cancel",
buttonText = resources.getString(android.support.wearable.R.string.generic_cancel), buttonText = resources.getString(android.support.wearable.R.string.generic_cancel),
iconRes = R.drawable.ic_target_cancel, iconRes = R.drawable.ic_target_cancel,
activityClass = BackgroundActionActivity::class.java.name, activityClass = BackgroundActionActivity::class.java.name,
message = message, message = message,
//actionString = "temptarget cancel", //actionString = "temptarget cancel",
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.CANCEL) action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.CANCEL)
) )
) )
} }
override fun getResourceReferences(resources: Resources): List<Int> { override fun getResourceReferences(resources: Resources): List<Int> {
return getActions(resources).map { it.iconRes } return getActions(resources).map { it.iconRes }
} }
override fun getDefaultConfig(): Map<String, String> { override fun getDefaultConfig(): Map<String, String> {
return mapOf( return mapOf(
"tile_tempt_1" to "activity", "tile_tempt_1" to "activity",
"tile_tempt_2" to "eating_soon", "tile_tempt_2" to "eating_soon",
"tile_tempt_3" to "hypo", "tile_tempt_3" to "hypo",
"tile_tempt_4" to "manual" "tile_tempt_4" to "manual"
) )
} }
} }

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.graphics.Color import android.graphics.Color
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityHomeLargeBinding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchMode
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityHomeLargeBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
class AapsLargeWatchface : BaseWatchFace() { class AapsLargeWatchface : BaseWatchFace() {

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.graphics.Color import android.graphics.Color
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityHome2Binding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchMode
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityHome2Binding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
class AapsV2Watchface : BaseWatchFace() { class AapsV2Watchface : BaseWatchFace() {

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.graphics.Color import android.graphics.Color
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityHomeBinding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchMode
import info.nightscout.androidaps.R
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
import info.nightscout.androidaps.databinding.ActivityHomeBinding
class AapsWatchface : BaseWatchFace() { class AapsWatchface : BaseWatchFace() {

View file

@ -1,16 +1,16 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityBigchartBinding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import app.aaps.wear.watchfaces.utils.WatchfaceViewAdapter
import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchMode
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityBigchartBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
import info.nightscout.androidaps.watchfaces.utils.WatchfaceViewAdapter
class BigChartWatchface : BaseWatchFace() { class BigChartWatchface : BaseWatchFace() {
@ -53,9 +53,9 @@ class BigChartWatchface : BaseWatchFace() {
binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
val color = when (singleBg.sgvLevel) { val color = when (singleBg.sgvLevel) {
1L -> R.color.dark_highColor 1L -> R.color.dark_highColor
0L -> R.color.dark_midColor 0L -> R.color.dark_midColor
-1L -> R.color.dark_lowColor -1L -> R.color.dark_lowColor
else -> R.color.dark_midColor else -> R.color.dark_midColor
} }
binding.sgv?.setTextColor(ContextCompat.getColor(this, color)) binding.sgv?.setTextColor(ContextCompat.getColor(this, color))
@ -82,9 +82,9 @@ class BigChartWatchface : BaseWatchFace() {
binding.status?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_status)) binding.status?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_status))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background))
val color = when (singleBg.sgvLevel) { val color = when (singleBg.sgvLevel) {
1L -> R.color.light_highColor 1L -> R.color.light_highColor
0L -> R.color.light_midColor 0L -> R.color.light_midColor
-1L -> R.color.light_lowColor -1L -> R.color.light_lowColor
else -> R.color.light_midColor else -> R.color.light_midColor
} }
binding.sgv?.setTextColor(ContextCompat.getColor(this, color)) binding.sgv?.setTextColor(ContextCompat.getColor(this, color))

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
@ -25,13 +25,13 @@ import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData
import app.aaps.core.interfaces.rx.weardata.EventData.SingleBg import app.aaps.core.interfaces.rx.weardata.EventData.SingleBg
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.wear.R
import app.aaps.wear.data.RawDisplayData
import app.aaps.wear.interaction.menus.MainMenuActivity
import app.aaps.wear.interaction.utils.Persistence
import com.ustwo.clockwise.common.WatchFaceTime import com.ustwo.clockwise.common.WatchFaceTime
import com.ustwo.clockwise.wearable.WatchFace import com.ustwo.clockwise.wearable.WatchFace
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.RawDisplayData
import info.nightscout.androidaps.interaction.menus.MainMenuActivity
import info.nightscout.androidaps.interaction.utils.Persistence
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 java.util.* import java.util.*

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.databinding.ActivityCockpitBinding import app.aaps.wear.databinding.ActivityCockpitBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace import app.aaps.wear.watchfaces.utils.BaseWatchFace
/** /**
* Created by andrew-warrington on 18/11/2017. * Created by andrew-warrington on 18/11/2017.
@ -24,9 +24,9 @@ class CockpitWatchface : BaseWatchFace() {
binding.mainLayout.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds) binding.mainLayout.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds)
setTextSizes() setTextSizes()
val led = when (singleBg.sgvLevel) { val led = when (singleBg.sgvLevel) {
1L -> R.drawable.airplane_led_yellow_lit 1L -> R.drawable.airplane_led_yellow_lit
0L -> R.drawable.airplane_led_grey_unlit 0L -> R.drawable.airplane_led_grey_unlit
-1L -> R.drawable.airplane_led_red_lit -1L -> R.drawable.airplane_led_red_lit
else -> R.drawable.airplane_led_grey_unlit else -> R.drawable.airplane_led_grey_unlit
} }

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
@ -44,9 +44,9 @@ import app.aaps.core.interfaces.rx.weardata.ResFileMap
import app.aaps.core.interfaces.rx.weardata.ResFormat import app.aaps.core.interfaces.rx.weardata.ResFormat
import app.aaps.core.interfaces.rx.weardata.ViewKeys import app.aaps.core.interfaces.rx.weardata.ViewKeys
import app.aaps.core.interfaces.rx.weardata.ZipWatchfaceFormat import app.aaps.core.interfaces.rx.weardata.ZipWatchfaceFormat
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.databinding.ActivityCustomBinding import app.aaps.wear.databinding.ActivityCustomBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace import app.aaps.wear.watchfaces.utils.BaseWatchFace
import org.joda.time.TimeOfDay import org.joda.time.TimeOfDay
import org.json.JSONObject import org.json.JSONObject
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.support.wearable.watchface.WatchFaceStyle import android.support.wearable.watchface.WatchFaceStyle
@ -10,9 +10,9 @@ import android.widget.LinearLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.databinding.ActivityDigitalstyleBinding import app.aaps.wear.databinding.ActivityDigitalstyleBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace import app.aaps.wear.watchfaces.utils.BaseWatchFace
class DigitalStyleWatchface : BaseWatchFace() { class DigitalStyleWatchface : BaseWatchFace() {

View file

@ -1,14 +1,13 @@
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityNochartBinding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import app.aaps.wear.watchfaces.utils.WatchfaceViewAdapter
import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchMode
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActivityBigchartBinding
import info.nightscout.androidaps.databinding.ActivityNochartBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
import info.nightscout.androidaps.watchfaces.utils.WatchfaceViewAdapter
class NoChartWatchface : BaseWatchFace() { class NoChartWatchface : BaseWatchFace() {

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.watchfaces package app.aaps.wear.watchfaces
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.animation.Animation import android.view.animation.Animation
@ -9,9 +9,9 @@ import android.view.animation.RotateAnimation
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import app.aaps.core.interfaces.utils.SafeParse.stringToFloat import app.aaps.core.interfaces.utils.SafeParse.stringToFloat
import info.nightscout.androidaps.R import app.aaps.wear.R
import info.nightscout.androidaps.databinding.ActivitySteampunkBinding import app.aaps.wear.databinding.ActivitySteampunkBinding
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace import app.aaps.wear.watchfaces.utils.BaseWatchFace
import org.joda.time.TimeOfDay import org.joda.time.TimeOfDay
/** /**

View file

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package info.nightscout.androidaps.watchfaces.utils package app.aaps.wear.watchfaces.utils
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
@ -23,18 +23,18 @@ import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.DateUtil
import app.aaps.wear.R
import app.aaps.wear.data.RawDisplayData
import app.aaps.wear.events.EventWearPreferenceChange
import app.aaps.wear.heartrate.HeartRateListener
import app.aaps.wear.interaction.menus.MainMenuActivity
import app.aaps.wear.interaction.utils.Persistence
import app.aaps.wear.interaction.utils.WearUtil
import com.ustwo.clockwise.common.WatchFaceTime import com.ustwo.clockwise.common.WatchFaceTime
import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchMode
import com.ustwo.clockwise.common.WatchShape import com.ustwo.clockwise.common.WatchShape
import com.ustwo.clockwise.wearable.WatchFace import com.ustwo.clockwise.wearable.WatchFace
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.RawDisplayData
import info.nightscout.androidaps.events.EventWearPreferenceChange
import info.nightscout.androidaps.heartrate.HeartRateListener
import info.nightscout.androidaps.interaction.menus.MainMenuActivity
import info.nightscout.androidaps.interaction.utils.Persistence
import info.nightscout.androidaps.interaction.utils.WearUtil
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 javax.inject.Inject import javax.inject.Inject

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.watchfaces.utils package app.aaps.wear.watchfaces.utils
import android.graphics.DashPathEffect import android.graphics.DashPathEffect
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
@ -6,7 +6,7 @@ import app.aaps.core.interfaces.rx.weardata.EventData.SingleBg
import app.aaps.core.interfaces.rx.weardata.EventData.TreatmentData.Basal import app.aaps.core.interfaces.rx.weardata.EventData.TreatmentData.Basal
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.DateUtil
import info.nightscout.androidaps.R import app.aaps.wear.R
import lecho.lib.hellocharts.model.Axis import lecho.lib.hellocharts.model.Axis
import lecho.lib.hellocharts.model.AxisValue import lecho.lib.hellocharts.model.AxisValue
import lecho.lib.hellocharts.model.Line import lecho.lib.hellocharts.model.Line

View file

@ -1,154 +1,154 @@
package info.nightscout.androidaps.watchfaces.utils package app.aaps.wear.watchfaces.utils
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Paint import android.graphics.Paint
import android.graphics.Point import android.graphics.Point
import android.graphics.Typeface import android.graphics.Typeface
import android.os.BatteryManager import android.os.BatteryManager
import android.view.WindowManager import android.view.WindowManager
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.DateUtil
import com.ustwo.clockwise.common.WatchMode import app.aaps.wear.R
import com.ustwo.clockwise.wearable.WatchFace import com.ustwo.clockwise.common.WatchMode
import info.nightscout.androidaps.R import com.ustwo.clockwise.wearable.WatchFace
import javax.inject.Inject import javax.inject.Inject
class SimpleUi @Inject constructor( class SimpleUi @Inject constructor(
private val context: Context, private val context: Context,
private val sp: SP, private val sp: SP,
private val dateUtil: DateUtil private val dateUtil: DateUtil
) { ) {
private var batteryReceiver: BroadcastReceiver? = null private var batteryReceiver: BroadcastReceiver? = null
private var mBackgroundPaint = Paint() private var mBackgroundPaint = Paint()
private lateinit var mTimePaint: Paint private lateinit var mTimePaint: Paint
private lateinit var mSvgPaint: Paint private lateinit var mSvgPaint: Paint
private lateinit var mDirectionPaint: Paint private lateinit var mDirectionPaint: Paint
private var mYOffset = 0f private var mYOffset = 0f
private val colorDarkHigh = ContextCompat.getColor(context, R.color.dark_highColor) private val colorDarkHigh = ContextCompat.getColor(context, R.color.dark_highColor)
private var colorDarkMid = ContextCompat.getColor(context, R.color.dark_midColor) private var colorDarkMid = ContextCompat.getColor(context, R.color.dark_midColor)
private var colorDarkLow = ContextCompat.getColor(context, R.color.dark_lowColor) private var colorDarkLow = ContextCompat.getColor(context, R.color.dark_lowColor)
private val displaySize = Point() private val displaySize = Point()
private lateinit var callback: () -> Unit private lateinit var callback: () -> Unit
fun onCreate(callback: () -> Unit) { fun onCreate(callback: () -> Unit) {
this.callback = callback this.callback = callback
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
(context.getSystemService(WatchFace.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(displaySize) (context.getSystemService(WatchFace.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(displaySize)
setupBatteryReceiver() setupBatteryReceiver()
setupUi() setupUi()
} }
fun updatePreferences() { fun updatePreferences() {
setupBatteryReceiver() setupBatteryReceiver()
} }
fun setAntiAlias(currentWatchMode: WatchMode) { fun setAntiAlias(currentWatchMode: WatchMode) {
val antiAlias = currentWatchMode == WatchMode.AMBIENT val antiAlias = currentWatchMode == WatchMode.AMBIENT
mSvgPaint.isAntiAlias = antiAlias mSvgPaint.isAntiAlias = antiAlias
mDirectionPaint.isAntiAlias = antiAlias mDirectionPaint.isAntiAlias = antiAlias
mTimePaint.isAntiAlias = antiAlias mTimePaint.isAntiAlias = antiAlias
} }
fun isEnabled(currentWatchMode: WatchMode): Boolean { fun isEnabled(currentWatchMode: WatchMode): Boolean {
val simplify = sp.getString(R.string.key_simplify_ui, "off") val simplify = sp.getString(R.string.key_simplify_ui, "off")
return if (simplify == "off") false return if (simplify == "off") false
else if ((simplify == "ambient" || simplify == "ambient_charging") && currentWatchMode == WatchMode.AMBIENT) true else if ((simplify == "ambient" || simplify == "ambient_charging") && currentWatchMode == WatchMode.AMBIENT) true
else (simplify == "charging" || simplify == "ambient_charging") && isCharging else (simplify == "charging" || simplify == "ambient_charging") && isCharging
} }
fun onDraw(canvas: Canvas, singleBg: EventData.SingleBg) { fun onDraw(canvas: Canvas, singleBg: EventData.SingleBg) {
canvas.drawRect(0f, 0f, displaySize.x.toFloat(), displaySize.y.toFloat(), mBackgroundPaint) canvas.drawRect(0f, 0f, displaySize.x.toFloat(), displaySize.y.toFloat(), mBackgroundPaint)
val xHalf = displaySize.x / 2f val xHalf = displaySize.x / 2f
val yThird = displaySize.y / 3f val yThird = displaySize.y / 3f
mSvgPaint.isStrikeThruText = isOutdated(singleBg) mSvgPaint.isStrikeThruText = isOutdated(singleBg)
mSvgPaint.color = getBgColour(singleBg.sgvLevel) mSvgPaint.color = getBgColour(singleBg.sgvLevel)
mDirectionPaint.color = getBgColour(singleBg.sgvLevel) mDirectionPaint.color = getBgColour(singleBg.sgvLevel)
val sSvg = singleBg.sgvString val sSvg = singleBg.sgvString
val svgWidth = mSvgPaint.measureText(sSvg) val svgWidth = mSvgPaint.measureText(sSvg)
val sDirection = " " + singleBg.slopeArrow + "\uFE0E" val sDirection = " " + singleBg.slopeArrow + "\uFE0E"
val directionWidth = mDirectionPaint.measureText(sDirection) val directionWidth = mDirectionPaint.measureText(sDirection)
val xSvg = xHalf - (svgWidth + directionWidth) / 2 val xSvg = xHalf - (svgWidth + directionWidth) / 2
canvas.drawText(sSvg, xSvg, yThird + mYOffset, mSvgPaint) canvas.drawText(sSvg, xSvg, yThird + mYOffset, mSvgPaint)
val xDirection = xSvg + svgWidth val xDirection = xSvg + svgWidth
canvas.drawText(sDirection, xDirection, yThird + mYOffset, mDirectionPaint) canvas.drawText(sDirection, xDirection, yThird + mYOffset, mDirectionPaint)
val sTime = dateUtil.timeString() val sTime = dateUtil.timeString()
val xTime = xHalf - mTimePaint.measureText(sTime) / 2f val xTime = xHalf - mTimePaint.measureText(sTime) / 2f
canvas.drawText(sTime, xTime, yThird * 2f + mYOffset, mTimePaint) canvas.drawText(sTime, xTime, yThird * 2f + mYOffset, mTimePaint)
} }
fun onDestroy() { fun onDestroy() {
if (batteryReceiver != null) { if (batteryReceiver != null) {
context.unregisterReceiver(batteryReceiver) context.unregisterReceiver(batteryReceiver)
} }
} }
private fun isOutdated(singleBg: EventData.SingleBg): Boolean = private fun isOutdated(singleBg: EventData.SingleBg): Boolean =
singleBg.timeStamp > 0 && (System.currentTimeMillis() - singleBg.timeStamp) > 1000 * 60 * 12 singleBg.timeStamp > 0 && (System.currentTimeMillis() - singleBg.timeStamp) > 1000 * 60 * 12
private fun getBgColour(level: Long): Int = private fun getBgColour(level: Long): Int =
when (level) { when (level) {
1L -> colorDarkHigh 1L -> colorDarkHigh
0L -> colorDarkMid 0L -> colorDarkMid
else -> colorDarkLow else -> colorDarkLow
} }
private val isCharging: Boolean private val isCharging: Boolean
get() { get() {
val mBatteryStatus = context.registerReceiver(null, iFilter) val mBatteryStatus = context.registerReceiver(null, iFilter)
val status = mBatteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1) val status = mBatteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL
} }
private fun setupUi() { private fun setupUi() {
val black = ContextCompat.getColor(context, R.color.black) val black = ContextCompat.getColor(context, R.color.black)
mBackgroundPaint.color = black mBackgroundPaint.color = black
val white = ContextCompat.getColor(context, R.color.white) val white = ContextCompat.getColor(context, R.color.white)
val resources = context.resources val resources = context.resources
val textSizeSvg = resources.getDimension(R.dimen.simple_ui_svg_text_size) val textSizeSvg = resources.getDimension(R.dimen.simple_ui_svg_text_size)
val textSizeDirection = resources.getDimension(R.dimen.simple_ui_direction_text_size) val textSizeDirection = resources.getDimension(R.dimen.simple_ui_direction_text_size)
val textSizeTime = resources.getDimension(R.dimen.simple_ui_time_text_size) val textSizeTime = resources.getDimension(R.dimen.simple_ui_time_text_size)
mYOffset = resources.getDimension(R.dimen.simple_ui_y_offset) mYOffset = resources.getDimension(R.dimen.simple_ui_y_offset)
mSvgPaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeSvg) mSvgPaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeSvg)
mDirectionPaint = createTextPaint(BOLD_TYPEFACE, white, textSizeDirection) mDirectionPaint = createTextPaint(BOLD_TYPEFACE, white, textSizeDirection)
mTimePaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeTime) mTimePaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeTime)
} }
private fun setupBatteryReceiver() { private fun setupBatteryReceiver() {
val setting = sp.getString(R.string.key_simplify_ui, "off") val setting = sp.getString(R.string.key_simplify_ui, "off")
if ((setting == "charging" || setting == "ambient_charging") && batteryReceiver == null) { if ((setting == "charging" || setting == "ambient_charging") && batteryReceiver == null) {
val intentBatteryFilter = IntentFilter() val intentBatteryFilter = IntentFilter()
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING) intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING)
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING) intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING)
batteryReceiver = object : BroadcastReceiver() { batteryReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
callback() callback()
} }
} }
context.registerReceiver(batteryReceiver, intentBatteryFilter) context.registerReceiver(batteryReceiver, intentBatteryFilter)
} }
} }
private fun createTextPaint(typeface: Typeface, colour: Int, textSize: Float): Paint { private fun createTextPaint(typeface: Typeface, colour: Int, textSize: Float): Paint {
val paint = Paint() val paint = Paint()
paint.color = colour paint.color = colour
paint.typeface = typeface paint.typeface = typeface
paint.isAntiAlias = true paint.isAntiAlias = true
paint.textSize = textSize paint.textSize = textSize
return paint return paint
} }
companion object { companion object {
var iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED) var iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
val NORMAL_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL) val NORMAL_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
val BOLD_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD) val BOLD_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)
} }
} }

View file

@ -1,104 +1,105 @@
package info.nightscout.androidaps.watchfaces.utils package app.aaps.wear.watchfaces.utils
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import info.nightscout.androidaps.databinding.ActivityHomeLargeBinding import app.aaps.wear.databinding.ActivityBigchartBinding
import info.nightscout.androidaps.databinding.ActivityHome2Binding import app.aaps.wear.databinding.ActivityCockpitBinding
import info.nightscout.androidaps.databinding.ActivityHomeBinding import app.aaps.wear.databinding.ActivityCustomBinding
import info.nightscout.androidaps.databinding.ActivityBigchartBinding import app.aaps.wear.databinding.ActivityDigitalstyleBinding
import info.nightscout.androidaps.databinding.ActivityCockpitBinding import app.aaps.wear.databinding.ActivityHome2Binding
import info.nightscout.androidaps.databinding.ActivityCustomBinding import app.aaps.wear.databinding.ActivityHomeBinding
import info.nightscout.androidaps.databinding.ActivityDigitalstyleBinding import app.aaps.wear.databinding.ActivityHomeLargeBinding
import info.nightscout.androidaps.databinding.ActivityNochartBinding import app.aaps.wear.databinding.ActivityNochartBinding
import info.nightscout.androidaps.databinding.ActivitySteampunkBinding import app.aaps.wear.databinding.ActivitySteampunkBinding
/** /**
* WatchfaceViewAdapter binds all WatchFace variants shared attributes to one common view adapter. * WatchfaceViewAdapter binds all WatchFace variants shared attributes to one common view adapter.
* Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding. * Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding.
*/ */
class WatchfaceViewAdapter( class WatchfaceViewAdapter(
aL: ActivityHomeLargeBinding? = null, aL: ActivityHomeLargeBinding? = null,
a2: ActivityHome2Binding? = null, a2: ActivityHome2Binding? = null,
aa: ActivityHomeBinding? = null, aa: ActivityHomeBinding? = null,
bC: ActivityBigchartBinding? = null, bC: ActivityBigchartBinding? = null,
cp: ActivityCockpitBinding? = null, cp: ActivityCockpitBinding? = null,
ds: ActivityDigitalstyleBinding? = null, ds: ActivityDigitalstyleBinding? = null,
nC: ActivityNochartBinding? = null, nC: ActivityNochartBinding? = null,
sP: ActivitySteampunkBinding? = null, sP: ActivitySteampunkBinding? = null,
cU: ActivityCustomBinding? = null cU: ActivityCustomBinding? = null
) { ) {
init { init {
if (aL == null && a2 == null && aa == null && bC == null && cp == null && ds == null && nC == null && sP == null && cU == null) { if (aL == null && a2 == null && aa == null && bC == null && cp == null && ds == null && nC == null && sP == null && cU == null) {
throw IllegalArgumentException("Require at least on Binding parameter") throw IllegalArgumentException("Require at least on Binding parameter")
} }
} }
private val errorMessage = "Missing require View Binding parameter" private val errorMessage = "Missing require View Binding parameter"
// Required attributes
val mainLayout = // Required attributes
aL?.mainLayout ?: a2?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: cp?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: sP?.mainLayout ?: cU?.mainLayout val mainLayout =
?: throw IllegalArgumentException(errorMessage) aL?.mainLayout ?: a2?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: cp?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: sP?.mainLayout ?: cU?.mainLayout
val timestamp = ?: throw IllegalArgumentException(errorMessage)
aL?.timestamp ?: a2?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: cp?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: sP?.timestamp ?: cU?.timestamp val timestamp =
?: throw IllegalArgumentException(errorMessage) aL?.timestamp ?: a2?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: cp?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: sP?.timestamp ?: cU?.timestamp
val root = ?: throw IllegalArgumentException(errorMessage)
aL?.root ?: a2?.root ?: aa?.root ?: bC?.root ?: bC?.root ?: cp?.root ?: ds?.root ?: nC?.root ?: sP?.root ?: cU?.root val root =
?: throw IllegalArgumentException(errorMessage) aL?.root ?: a2?.root ?: aa?.root ?: bC?.root ?: bC?.root ?: cp?.root ?: ds?.root ?: nC?.root ?: sP?.root ?: cU?.root
?: throw IllegalArgumentException(errorMessage)
// Optional attributes
val sgv = aL?.sgv ?: a2?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: cp?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv // Optional attributes
val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction val sgv = aL?.sgv ?: a2?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: cp?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
val loop = a2?.loop ?: cp?.loop ?: sP?.loop ?: cU?.loop val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction
val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta val loop = a2?.loop ?: cp?.loop ?: sP?.loop ?: cU?.loop
val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
val uploaderBattery = aL?.uploaderBattery ?: a2?.uploaderBattery ?: aa?.uploaderBattery ?: cp?.uploaderBattery ?: ds?.uploaderBattery ?: sP?.uploaderBattery ?: cU?.uploaderBattery val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
val rigBattery = a2?.rigBattery ?: cp?.rigBattery ?: ds?.rigBattery ?: sP?.rigBattery ?: cU?.rigBattery val uploaderBattery = aL?.uploaderBattery ?: a2?.uploaderBattery ?: aa?.uploaderBattery ?: cp?.uploaderBattery ?: ds?.uploaderBattery ?: sP?.uploaderBattery ?: cU?.uploaderBattery
val basalRate = a2?.basalRate ?: cp?.basalRate ?: ds?.basalRate ?: sP?.basalRate ?: cU?.basalRate val rigBattery = a2?.rigBattery ?: cp?.rigBattery ?: ds?.rigBattery ?: sP?.rigBattery ?: cU?.rigBattery
val bgi = a2?.bgi ?: ds?.bgi ?: cU?.bgi val basalRate = a2?.basalRate ?: cp?.basalRate ?: ds?.basalRate ?: sP?.basalRate ?: cU?.basalRate
val AAPSv2 = a2?.AAPSv2 ?: cp?.AAPSv2 ?: ds?.AAPSv2 ?: sP?.AAPSv2 ?: cU?.AAPSv2 val bgi = a2?.bgi ?: ds?.bgi ?: cU?.bgi
val cob1 = a2?.cob1 ?: ds?.cob1 ?: cU?.cob1 val AAPSv2 = a2?.AAPSv2 ?: cp?.AAPSv2 ?: ds?.AAPSv2 ?: sP?.AAPSv2 ?: cU?.AAPSv2
val cob2 = a2?.cob2 ?: cp?.cob2 ?: ds?.cob2 ?: sP?.cob2 ?: cU?.cob2 val cob1 = a2?.cob1 ?: ds?.cob1 ?: cU?.cob1
val time = aL?.time ?: a2?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: cp?.time ?: nC?.time ?: cU?.time val cob2 = a2?.cob2 ?: cp?.cob2 ?: ds?.cob2 ?: sP?.cob2 ?: cU?.cob2
val second = cU?.second val time = aL?.time ?: a2?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: cp?.time ?: nC?.time ?: cU?.time
val minute = ds?.minute ?: cU?.minute val second = cU?.second
val hour = ds?.hour ?: cU?.hour val minute = ds?.minute ?: cU?.minute
val day = a2?.day ?: ds?.day ?: cU?.day val hour = ds?.hour ?: cU?.hour
val month = a2?.month ?: ds?.month ?: cU?.month val day = a2?.day ?: ds?.day ?: cU?.day
val iob1 = a2?.iob1 ?: ds?.iob1 ?: cU?.iob1 val month = a2?.month ?: ds?.month ?: cU?.month
val iob2 = a2?.iob2 ?: cp?.iob2 ?: ds?.iob2 ?: sP?.iob2 ?: cU?.iob2 val iob1 = a2?.iob1 ?: ds?.iob1 ?: cU?.iob1
val chart = a2?.chart ?: aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: sP?.chart ?: cU?.chart val iob2 = a2?.iob2 ?: cp?.iob2 ?: ds?.iob2 ?: sP?.iob2 ?: cU?.iob2
val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status val chart = a2?.chart ?: aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: sP?.chart ?: cU?.chart
val timePeriod = ds?.timePeriod ?: aL?.timePeriod ?: nC?.timePeriod ?: bC?.timePeriod ?: cU?.timePeriod val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status
val dayName = ds?.dayName ?: cU?.dayName val timePeriod = ds?.timePeriod ?: aL?.timePeriod ?: nC?.timePeriod ?: bC?.timePeriod ?: cU?.timePeriod
val mainMenuTap = ds?.mainMenuTap ?: sP?.mainMenuTap val dayName = ds?.dayName ?: cU?.dayName
val chartZoomTap = ds?.chartZoomTap ?: sP?.chartZoomTap val mainMenuTap = ds?.mainMenuTap ?: sP?.mainMenuTap
val dateTime = ds?.dateTime ?: a2?.dateTime val chartZoomTap = ds?.chartZoomTap ?: sP?.chartZoomTap
val weekNumber = ds?.weekNumber ?: cU?.weekNumber val dateTime = ds?.dateTime ?: a2?.dateTime
// val minuteHand = sP?.minuteHand val weekNumber = ds?.weekNumber ?: cU?.weekNumber
// val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout ?: sP?.secondaryLayout // val minuteHand = sP?.minuteHand
// val tertiaryLayout = a2?.tertiaryLayout ?: sP?.tertiaryLayout // val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout ?: sP?.secondaryLayout
// val highLight = cp?.highLight // val tertiaryLayout = a2?.tertiaryLayout ?: sP?.tertiaryLayout
// val lowLight = cp?.lowLight // val highLight = cp?.highLight
// val deltaGauge = sP?.deltaPointer // val lowLight = cp?.lowLight
// val hourHand = sP?.hourHand // val deltaGauge = sP?.deltaPointer
// val glucoseDial = sP?.glucoseDial // val hourHand = sP?.hourHand
// val glucoseDial = sP?.glucoseDial
companion object {
companion object {
fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter {
return when (bindLayout) { fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter {
is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout) return when (bindLayout) {
is ActivityHome2Binding -> WatchfaceViewAdapter(null, bindLayout) is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout)
is ActivityHomeBinding -> WatchfaceViewAdapter(null, null, bindLayout) is ActivityHome2Binding -> WatchfaceViewAdapter(null, bindLayout)
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout) is ActivityHomeBinding -> WatchfaceViewAdapter(null, null, bindLayout)
is ActivityCockpitBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout) is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout) is ActivityCockpitBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, bindLayout) is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout)
is ActivitySteampunkBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, bindLayout) is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, bindLayout)
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, null, bindLayout) is ActivitySteampunkBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, bindLayout)
else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter") is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, null, bindLayout)
} else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter")
} }
} }
}
}
}

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout" android:id="@+id/main_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -11,11 +10,11 @@
android:id="@+id/background" android:id="@+id/background"
android:layout_width="400px" android:layout_width="400px"
android:layout_height="400px" android:layout_height="400px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:visibility="visible" android:layout_marginTop="0px"
android:orientation="vertical"
android:src="@drawable/background" android:src="@drawable/background"
android:orientation="vertical" /> android:visibility="visible" />
<lecho.lib.hellocharts.view.LineChartView <lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart" android:id="@+id/chart"
@ -29,84 +28,84 @@
android:id="@+id/cover_chart" android:id="@+id/cover_chart"
android:layout_width="400px" android:layout_width="400px"
android:layout_height="400px" android:layout_height="400px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:visibility="gone" android:layout_marginTop="0px"
android:orientation="vertical" /> android:orientation="vertical"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/freetext1" android:id="@+id/freetext1"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:textSize="21px" android:layout_marginTop="0px"
android:gravity="center" android:gravity="center"
android:visibility="gone" android:textColor="@color/light_grey"
android:textColor="@color/light_grey" /> android:textSize="21px"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/freetext2" android:id="@+id/freetext2"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:textSize="21px" android:layout_marginTop="0px"
android:gravity="center" android:gravity="center"
android:visibility="gone" android:textColor="@color/light_grey"
android:textColor="@color/light_grey" /> android:textSize="21px"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/freetext3" android:id="@+id/freetext3"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:textSize="21px" android:layout_marginTop="0px"
android:gravity="center" android:gravity="center"
android:visibility="gone" android:textColor="@color/light_grey"
android:textColor="@color/light_grey" /> android:textSize="21px"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/freetext4" android:id="@+id/freetext4"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:textSize="21px" android:layout_marginTop="0px"
android:gravity="center" android:gravity="center"
android:visibility="gone" android:textColor="@color/light_grey"
android:textColor="@color/light_grey" /> android:textSize="21px"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/iob1" android:id="@+id/iob1"
android:layout_width="130px" android:layout_width="130px"
android:layout_height="33px" android:layout_height="33px"
android:layout_marginTop="168px"
android:layout_marginLeft="270px" android:layout_marginLeft="270px"
android:textSize="21px" android:layout_marginTop="168px"
android:gravity="center" android:gravity="center"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="21px"
tools:text="@string/activity_IOB" /> tools:text="@string/activity_IOB" />
<TextView <TextView
android:id="@+id/iob2" android:id="@+id/iob2"
android:layout_width="130px" android:layout_width="130px"
android:layout_height="33px" android:layout_height="33px"
android:layout_marginTop="196px"
android:layout_marginLeft="270px" android:layout_marginLeft="270px"
android:textSize="21px" android:layout_marginTop="196px"
android:textStyle="bold"
android:gravity="center" android:gravity="center"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="21px"
android:textStyle="bold"
tools:text="@string/no_iob_u" /> tools:text="@string/no_iob_u" />
<TextView <TextView
android:id="@+id/cob1" android:id="@+id/cob1"
android:layout_width="120px" android:layout_width="120px"
android:layout_height="33px" android:layout_height="33px"
android:layout_marginTop="168px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:layout_marginTop="168px"
android:gravity="center" android:gravity="center"
android:text="@string/activity_carb" android:text="@string/activity_carb"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
@ -116,36 +115,36 @@
android:id="@+id/cob2" android:id="@+id/cob2"
android:layout_width="120px" android:layout_width="120px"
android:layout_height="33px" android:layout_height="33px"
android:layout_marginTop="196px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:layout_marginTop="196px"
android:gravity="center" android:gravity="center"
android:text="@string/no_cob_g" android:text="@string/no_cob_g"
android:textSize="21px"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="21px"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/delta" android:id="@+id/delta"
android:layout_width="59px" android:layout_width="59px"
android:layout_height="32px" android:layout_height="32px"
android:layout_marginTop="133px"
android:layout_marginLeft="15px" android:layout_marginLeft="15px"
android:layout_marginTop="133px"
android:gravity="center" android:gravity="center"
android:textColor="@color/light_grey"
android:textSize="23px" android:textSize="23px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
tools:text="+/-" /> tools:text="+/-" />
<TextView <TextView
android:id="@+id/avg_delta" android:id="@+id/avg_delta"
android:layout_width="59px" android:layout_width="59px"
android:layout_height="32px" android:layout_height="32px"
android:layout_marginTop="133px"
android:layout_marginLeft="74px" android:layout_marginLeft="74px"
android:layout_marginTop="133px"
android:gravity="center" android:gravity="center"
android:textColor="@color/light_grey"
android:textSize="23px" android:textSize="23px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
tools:text="@string/abbreviation_average" /> tools:text="@string/abbreviation_average" />
@ -153,26 +152,26 @@
android:id="@+id/uploader_battery" android:id="@+id/uploader_battery"
android:layout_width="60px" android:layout_width="60px"
android:layout_height="32px" android:layout_height="32px"
android:gravity="center"
android:layout_marginTop="133px"
android:layout_marginLeft="129px" android:layout_marginLeft="129px"
android:textSize="23px" android:layout_marginTop="133px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:textStyle="bold" android:gravity="center"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="23px"
android:textStyle="bold"
tools:text="100%" /> tools:text="100%" />
<TextView <TextView
android:id="@+id/rig_battery" android:id="@+id/rig_battery"
android:layout_width="60px" android:layout_width="60px"
android:layout_height="32px" android:layout_height="32px"
android:gravity="center"
android:layout_marginTop="133px"
android:layout_marginLeft="189px" android:layout_marginLeft="189px"
android:textSize="23px" android:layout_marginTop="133px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:textStyle="bold" android:gravity="center"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="23px"
android:textStyle="bold"
android:visibility="visible" android:visibility="visible"
tools:text="100%" /> tools:text="100%" />
@ -180,25 +179,25 @@
android:id="@+id/basalRate" android:id="@+id/basalRate"
android:layout_width="91px" android:layout_width="91px"
android:layout_height="32px" android:layout_height="32px"
android:layout_marginTop="133px"
android:layout_marginLeft="249px" android:layout_marginLeft="249px"
android:gravity="center" android:layout_marginTop="133px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:gravity="center"
android:textColor="@color/light_grey"
android:textSize="23px" android:textSize="23px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
tools:text="@string/no_tmp_basal_u_h" /> tools:text="@string/no_tmp_basal_u_h" />
<TextView <TextView
android:id="@+id/bgi" android:id="@+id/bgi"
android:layout_width="60px" android:layout_width="60px"
android:layout_height="32px" android:layout_height="32px"
android:layout_marginTop="133px"
android:layout_marginLeft="340px" android:layout_marginLeft="340px"
android:layout_marginTop="133px"
android:gravity="center" android:gravity="center"
android:textColor="@color/light_grey"
android:textSize="23px" android:textSize="23px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
android:visibility="visible" android:visibility="visible"
tools:text="bgi" /> tools:text="bgi" />
@ -208,11 +207,11 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="151px" android:layout_marginTop="151px"
android:gravity="center"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:gravity="center"
android:textColor="@color/light_grey"
android:textSize="70px" android:textSize="70px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
android:visibility="gone" android:visibility="gone"
tools:text="22:00" /> tools:text="22:00" />
@ -221,13 +220,13 @@
android:id="@+id/hour" android:id="@+id/hour"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="151px"
android:layout_marginLeft="119px" android:layout_marginLeft="119px"
android:layout_marginTop="151px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="@color/light_grey"
android:textSize="70px" android:textSize="70px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
android:visibility="gone" android:visibility="gone"
tools:text="20" /> tools:text="20" />
<!-- minute --> <!-- minute -->
@ -235,8 +234,8 @@
android:id="@+id/minute" android:id="@+id/minute"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="158px"
android:layout_marginLeft="210px" android:layout_marginLeft="210px"
android:layout_marginTop="158px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="46px" android:textSize="46px"
@ -247,8 +246,8 @@
android:id="@+id/second" android:id="@+id/second"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="158px"
android:layout_marginLeft="210px" android:layout_marginLeft="210px"
android:layout_marginTop="158px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="46px" android:textSize="46px"
@ -265,9 +264,9 @@
android:layout_marginLeft="210px" android:layout_marginLeft="210px"
android:layout_marginTop="205px" android:layout_marginTop="205px"
android:fontFamily="@font/roboto_condensed_bold" android:fontFamily="@font/roboto_condensed_bold"
android:textColor="@color/light_grey"
android:textSize="17px" android:textSize="17px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
android:visibility="gone" android:visibility="gone"
tools:text="AM" /> tools:text="AM" />
@ -275,12 +274,12 @@
android:id="@+id/day_name" android:id="@+id/day_name"
android:layout_width="56px" android:layout_width="56px"
android:layout_height="36px" android:layout_height="36px"
android:layout_marginTop="172px"
android:layout_marginLeft="120px" android:layout_marginLeft="120px"
android:layout_marginTop="172px"
android:gravity="center" android:gravity="center"
android:textColor="@color/white"
android:textSize="24px" android:textSize="24px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/white"
android:visibility="visible" android:visibility="visible"
tools:text="day" /> tools:text="day" />
@ -288,24 +287,24 @@
android:id="@+id/day" android:id="@+id/day"
android:layout_width="56px" android:layout_width="56px"
android:layout_height="36px" android:layout_height="36px"
android:layout_marginTop="198px"
android:layout_marginLeft="120px" android:layout_marginLeft="120px"
android:layout_marginTop="198px"
android:gravity="center" android:gravity="center"
android:textStyle="bold"
android:textSize="24px"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24px"
android:textStyle="bold"
tools:text="01" /> tools:text="01" />
<TextView <TextView
android:id="@+id/week_number" android:id="@+id/week_number"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="0px" android:layout_height="0px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" android:layout_marginLeft="0px"
android:layout_marginTop="0px"
android:gravity="center" android:gravity="center"
android:textStyle="bold"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24px" android:textSize="24px"
android:textStyle="bold"
android:visibility="gone" android:visibility="gone"
tools:text="ww" /> tools:text="ww" />
@ -313,60 +312,60 @@
android:id="@+id/month" android:id="@+id/month"
android:layout_width="50px" android:layout_width="50px"
android:layout_height="36px" android:layout_height="36px"
android:layout_marginTop="180px"
android:layout_marginLeft="220px" android:layout_marginLeft="220px"
android:layout_marginTop="180px"
android:gravity="center" android:gravity="center"
android:textStyle="bold"
android:textSize="24px"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24px"
android:textStyle="bold"
tools:text="févr." /> tools:text="févr." />
<TextView <TextView
android:id="@+id/loop" android:id="@+id/loop"
android:layout_width="50px" android:layout_width="50px"
android:layout_height="50px" android:layout_height="50px"
android:layout_marginTop="61px"
android:layout_marginLeft="68px" android:layout_marginLeft="68px"
android:layout_marginTop="61px"
android:background="@drawable/loop_grey_25" android:background="@drawable/loop_grey_25"
android:gravity="center" android:gravity="center"
android:textColor="@color/light_grey"
android:textSize="24px" android:textSize="24px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
tools:text="--'" /> tools:text="--'" />
<ImageView <ImageView
android:id="@+id/direction2" android:id="@+id/direction2"
android:layout_width="40px" android:layout_width="40px"
android:layout_height="40px" android:layout_height="40px"
android:layout_marginTop="36px"
android:layout_marginLeft="291px" android:layout_marginLeft="291px"
android:visibility="visible" android:layout_marginTop="36px"
android:orientation="vertical"
android:src="@drawable/ic_invalid" android:src="@drawable/ic_invalid"
android:orientation="vertical" /> android:visibility="visible" />
<TextView <TextView
android:id="@+id/timestamp" android:id="@+id/timestamp"
android:layout_width="52px" android:layout_width="52px"
android:layout_height="34px" android:layout_height="34px"
android:gravity="left"
android:layout_marginTop="79px"
android:layout_marginLeft="291px" android:layout_marginLeft="291px"
android:layout_marginTop="79px"
android:gravity="left"
android:textColor="@color/light_grey"
android:textSize="25px" android:textSize="25px"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/light_grey"
tools:text="--'" /> tools:text="--'" />
<TextView <TextView
android:id="@+id/sgv" android:id="@+id/sgv"
android:layout_width="400px" android:layout_width="400px"
android:layout_height="100px" android:layout_height="100px"
android:layout_marginLeft="0px"
android:layout_marginTop="26px"
android:fontFamily="@font/roboto_condensed_bold"
android:gravity="center" android:gravity="center"
android:lines="1" android:lines="1"
android:layout_marginTop="26px"
android:layout_marginLeft="0px"
android:fontFamily="@font/roboto_condensed_bold"
android:textSize="74px"
android:textColor="@color/light_grey" android:textColor="@color/light_grey"
android:textSize="74px"
tools:text="200" /> tools:text="200" />
<ImageView <ImageView
@ -374,8 +373,8 @@
android:layout_width="400px" android:layout_width="400px"
android:layout_height="400px" android:layout_height="400px"
android:orientation="vertical" android:orientation="vertical"
android:visibility="visible" android:src="@drawable/simplified_dial"
android:src="@drawable/simplified_dial" /> android:visibility="visible" />
<ImageView <ImageView
android:id="@+id/hour_hand" android:id="@+id/hour_hand"

View file

@ -24,13 +24,13 @@
android:textSize="18sp" android:textSize="18sp"
tools:text="Title" /> tools:text="Title" />
<info.nightscout.androidaps.nondeprecated.GridViewPagerNonDeprecated <app.aaps.wear.nondeprecated.GridViewPagerNonDeprecated
android:id="@+id/pager" android:id="@+id/pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:keepScreenOn="true" /> android:keepScreenOn="true" />
<info.nightscout.androidaps.nondeprecated.DotsPageIndicatorNonDeprecated <app.aaps.wear.nondeprecated.DotsPageIndicatorNonDeprecated
android:id="@+id/page_indicator" android:id="@+id/page_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps package app.aaps.wear
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.DateUtil
import app.aaps.shared.tests.TestBase import app.aaps.shared.tests.TestBase
import info.nightscout.androidaps.interaction.utils.Constants import app.aaps.wear.interaction.utils.Constants
import info.nightscout.androidaps.interaction.utils.Persistence import app.aaps.wear.interaction.utils.Persistence
import info.nightscout.androidaps.interaction.utils.WearUtil import app.aaps.wear.interaction.utils.WearUtil
import info.nightscout.androidaps.testing.mocks.SharedPreferencesMock import app.aaps.wear.testing.mocks.SharedPreferencesMock
import kotlinx.datetime.Clock import kotlinx.datetime.Clock
import kotlinx.datetime.Instant import kotlinx.datetime.Instant
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach

Some files were not shown because too many files have changed in this diff Show more