:app :wear cleanup
This commit is contained in:
parent
2e3159fd60
commit
7c417e3519
|
@ -99,7 +99,7 @@ def allCommitted = { ->
|
|||
|
||||
android {
|
||||
|
||||
namespace 'info.nightscout.androidaps'
|
||||
namespace 'app.aaps'
|
||||
ndkVersion "21.1.6352462"
|
||||
|
||||
defaultConfig {
|
||||
|
|
|
@ -59,22 +59,20 @@ import app.aaps.core.ui.toast.ToastUtils
|
|||
import app.aaps.core.utils.isRunningRealPumpTest
|
||||
import app.aaps.database.entities.UserEntry.Action
|
||||
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.SingleFragmentActivity
|
||||
import app.aaps.plugins.configuration.setupwizard.SetupWizardActivity
|
||||
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.tabs.TabLayoutMediator
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.joanzapata.iconify.Iconify
|
||||
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.kotlin.plusAssign
|
||||
import java.io.File
|
||||
|
|
|
@ -42,15 +42,13 @@ import app.aaps.receivers.BTReceiver
|
|||
import app.aaps.receivers.ChargingStateReceiver
|
||||
import app.aaps.receivers.KeepAliveWorker
|
||||
import app.aaps.receivers.TimeDateOrTZChangeReceiver
|
||||
import app.aaps.ui.activityMonitor.ActivityMonitor
|
||||
import app.aaps.ui.widget.Widget
|
||||
import dagger.android.AndroidInjector
|
||||
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.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||
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.exceptions.UndeliverableException
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
|
|
@ -30,11 +30,11 @@ import app.aaps.core.main.events.EventIobCalculationProgress
|
|||
import app.aaps.core.main.utils.fabric.FabricPrivacy
|
||||
import app.aaps.core.main.workflow.CalculationWorkflow
|
||||
import app.aaps.core.ui.activities.TranslatedDaggerAppCompatActivity
|
||||
import app.aaps.databinding.ActivityHistorybrowseBinding
|
||||
import app.aaps.plugins.main.general.overview.graphData.GraphData
|
||||
import com.google.android.material.datepicker.MaterialDatePicker
|
||||
import com.jjoe64.graphview.GraphView
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import java.util.Calendar
|
||||
|
|
|
@ -15,6 +15,7 @@ import androidx.preference.PreferenceGroup
|
|||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.PreferenceScreen
|
||||
import androidx.preference.size
|
||||
import app.aaps.R
|
||||
import app.aaps.core.interfaces.configuration.Config
|
||||
import app.aaps.core.interfaces.nsclient.NSSettingsStatus
|
||||
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.xdrip.XdripPlugin
|
||||
import dagger.android.support.AndroidSupportInjection
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
|
|
|
@ -8,9 +8,9 @@ import androidx.appcompat.widget.SearchView
|
|||
import androidx.core.view.MenuProvider
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceScreen
|
||||
import app.aaps.R
|
||||
import app.aaps.databinding.ActivityPreferencesBinding
|
||||
import app.aaps.plugins.configuration.activities.DaggerAppCompatActivityWithResult
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityPreferencesBinding
|
||||
|
||||
class PreferencesActivity : DaggerAppCompatActivityWithResult(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package app.aaps.implementations
|
||||
|
||||
import android.os.Build
|
||||
import app.aaps.BuildConfig
|
||||
import app.aaps.R
|
||||
import app.aaps.core.interfaces.configuration.Config
|
||||
import app.aaps.core.interfaces.maintenance.PrefFileListProvider
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import info.nightscout.androidaps.R
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.annotation.RawRes
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import app.aaps.MainActivity
|
||||
import app.aaps.R
|
||||
import app.aaps.activities.HistoryBrowseActivity
|
||||
import app.aaps.activities.MyPreferenceFragment
|
||||
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.plugins.configuration.activities.SingleFragmentActivity
|
||||
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.ErrorHelperActivity
|
||||
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.AlarmSoundServiceHelper
|
||||
import app.aaps.ui.widget.Widget
|
||||
import dagger.android.HasAndroidInjector
|
||||
import javax.inject.Inject
|
||||
|
||||
class UiInteractionImpl @Inject constructor(
|
||||
|
|
|
@ -9,6 +9,7 @@ import androidx.work.WorkManager
|
|||
import androidx.work.WorkQuery
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.work.workDataOf
|
||||
import app.aaps.R
|
||||
import app.aaps.core.interfaces.alerts.LocalAlertUtils
|
||||
import app.aaps.core.interfaces.aps.Loop
|
||||
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.plugins.configuration.maintenance.MaintenancePlugin
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
|
@ -13,7 +13,7 @@ fun isRunningTest(): Boolean {
|
|||
@Synchronized
|
||||
fun isRunningRealPumpTest(): Boolean {
|
||||
return try {
|
||||
Class.forName("info.nightscout.androidaps.RealPumpTest")
|
||||
Class.forName("app.aaps.RealPumpTest")
|
||||
true
|
||||
} catch (e: ClassNotFoundException) {
|
||||
false
|
||||
|
|
|
@ -80,7 +80,7 @@ android {
|
|||
versionName version + "-aapsclient"
|
||||
}
|
||||
}
|
||||
namespace 'info.nightscout.androidaps'
|
||||
namespace 'app.aaps.wear'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps
|
||||
package app.aaps.wear
|
||||
|
||||
import android.content.Intent
|
||||
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.LTag
|
||||
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.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
|
||||
|
||||
class WearApp : DaggerApplication(), OnSharedPreferenceChangeListener {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
|
||||
@Suppress("unused")
|
||||
@Inject lateinit var dataHandlerWear: DataHandlerWear // instantiate only
|
||||
@Inject lateinit var exceptionHandlerWear: ExceptionHandlerWear
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.comm
|
||||
package app.aaps.wear.comm
|
||||
|
||||
import android.annotation.TargetApi
|
||||
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.weardata.EventData
|
||||
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 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.kotlin.plusAssign
|
||||
import javax.inject.Inject
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.comm
|
||||
package app.aaps.wear.comm
|
||||
|
||||
import android.app.NotificationManager
|
||||
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.weardata.EventData
|
||||
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.wearable.CapabilityClient
|
||||
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.WearableListenerService
|
||||
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.kotlin.plusAssign
|
||||
import kotlinx.coroutines.CancellationException
|
|
@ -1,70 +1,70 @@
|
|||
package info.nightscout.androidaps.comm
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
import app.aaps.core.interfaces.rx.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.ObjectOutputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
class ExceptionHandlerWear @Inject constructor(
|
||||
private val rxBus: RxBus,
|
||||
) {
|
||||
|
||||
private var mDefaultUEH: Thread.UncaughtExceptionHandler? = null
|
||||
|
||||
private val mWearUEH = Thread.UncaughtExceptionHandler { thread, ex ->
|
||||
Log.d("WEAR", "uncaughtException :" + ex.message)
|
||||
|
||||
// Pass the exception to the bus which will send the data upstream to your Smartphone/Tablet
|
||||
val wearException = EventData.WearException(
|
||||
timeStamp = System.currentTimeMillis(),
|
||||
exception = exceptionToByteArray(ex),
|
||||
board = Build.BOARD,
|
||||
sdk = Build.VERSION.SDK_INT.toString(),
|
||||
fingerprint = Build.FINGERPRINT,
|
||||
model = Build.MODEL,
|
||||
manufacturer = Build.MANUFACTURER,
|
||||
product = Build.PRODUCT
|
||||
)
|
||||
rxBus.send(EventWearToMobile(wearException))
|
||||
|
||||
// Let the default UncaughtExceptionHandler take it from here
|
||||
mDefaultUEH?.uncaughtException(thread, ex)
|
||||
}
|
||||
|
||||
fun register() {
|
||||
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler()
|
||||
Thread.setDefaultUncaughtExceptionHandler(mWearUEH)
|
||||
}
|
||||
|
||||
private fun exceptionToByteArray(ex: Throwable): ByteArray {
|
||||
ex.stackTrace // Make sure the stacktrace gets built up
|
||||
val bos = ByteArrayOutputStream()
|
||||
var oos: ObjectOutputStream? = null
|
||||
try {
|
||||
oos = ObjectOutputStream(bos)
|
||||
oos.writeObject(ex)
|
||||
return bos.toByteArray()
|
||||
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
try {
|
||||
oos?.close()
|
||||
} catch (exx: IOException) {
|
||||
// Ignore close exception
|
||||
}
|
||||
try {
|
||||
bos.close()
|
||||
} catch (exx: IOException) {
|
||||
// Ignore close exception
|
||||
}
|
||||
}
|
||||
return byteArrayOf()
|
||||
}
|
||||
|
||||
}
|
||||
package app.aaps.wear.comm
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
import app.aaps.core.interfaces.rx.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.ObjectOutputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
class ExceptionHandlerWear @Inject constructor(
|
||||
private val rxBus: RxBus,
|
||||
) {
|
||||
|
||||
private var mDefaultUEH: Thread.UncaughtExceptionHandler? = null
|
||||
|
||||
private val mWearUEH = Thread.UncaughtExceptionHandler { thread, ex ->
|
||||
Log.d("WEAR", "uncaughtException :" + ex.message)
|
||||
|
||||
// Pass the exception to the bus which will send the data upstream to your Smartphone/Tablet
|
||||
val wearException = EventData.WearException(
|
||||
timeStamp = System.currentTimeMillis(),
|
||||
exception = exceptionToByteArray(ex),
|
||||
board = Build.BOARD,
|
||||
sdk = Build.VERSION.SDK_INT.toString(),
|
||||
fingerprint = Build.FINGERPRINT,
|
||||
model = Build.MODEL,
|
||||
manufacturer = Build.MANUFACTURER,
|
||||
product = Build.PRODUCT
|
||||
)
|
||||
rxBus.send(EventWearToMobile(wearException))
|
||||
|
||||
// Let the default UncaughtExceptionHandler take it from here
|
||||
mDefaultUEH?.uncaughtException(thread, ex)
|
||||
}
|
||||
|
||||
fun register() {
|
||||
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler()
|
||||
Thread.setDefaultUncaughtExceptionHandler(mWearUEH)
|
||||
}
|
||||
|
||||
private fun exceptionToByteArray(ex: Throwable): ByteArray {
|
||||
ex.stackTrace // Make sure the stacktrace gets built up
|
||||
val bos = ByteArrayOutputStream()
|
||||
var oos: ObjectOutputStream? = null
|
||||
try {
|
||||
oos = ObjectOutputStream(bos)
|
||||
oos.writeObject(ex)
|
||||
return bos.toByteArray()
|
||||
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
try {
|
||||
oos?.close()
|
||||
} catch (exx: IOException) {
|
||||
// Ignore close exception
|
||||
}
|
||||
try {
|
||||
bos.close()
|
||||
} catch (exx: IOException) {
|
||||
// Ignore close exception
|
||||
}
|
||||
}
|
||||
return byteArrayOf()
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.comm
|
||||
package app.aaps.wear.comm
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.comm
|
||||
package app.aaps.wear.comm
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
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.events.EventWearToMobile
|
||||
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 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
|
||||
|
||||
/**
|
|
@ -1,15 +1,15 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
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 info.nightscout.androidaps.data.RawDisplayData
|
||||
import info.nightscout.androidaps.interaction.utils.DisplayFormat
|
||||
import info.nightscout.androidaps.interaction.utils.SmallestDoubleString
|
||||
import kotlin.math.max
|
||||
|
||||
/*
|
|
@ -1,12 +1,12 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
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
|
|
@ -1,14 +1,14 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.graphics.drawable.Icon
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,14 +1,14 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
import info.nightscout.androidaps.interaction.utils.DisplayFormat
|
||||
import info.nightscout.androidaps.interaction.utils.SmallestDoubleString
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import app.aaps.wear.interaction.utils.DisplayFormat
|
||||
import app.aaps.wear.interaction.utils.SmallestDoubleString
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
enum class ComplicationAction {
|
||||
NONE, MENU, WIZARD, BOLUS, E_CARB, STATUS, WARNING_SYNC, WARNING_OLD
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
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.LTag
|
||||
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 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
|
||||
|
||||
/*
|
|
@ -1,12 +1,12 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
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
|
|
@ -1,16 +1,16 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.graphics.drawable.Icon
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
import info.nightscout.androidaps.interaction.utils.DisplayFormat
|
||||
import info.nightscout.androidaps.interaction.utils.SmallestDoubleString
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import app.aaps.wear.interaction.utils.DisplayFormat
|
||||
import app.aaps.wear.interaction.utils.SmallestDoubleString
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,13 +1,13 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,13 +1,13 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,13 +1,13 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.support.wearable.complications.ComplicationData
|
||||
import android.support.wearable.complications.ComplicationText
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.graphics.drawable.Icon
|
||||
|
@ -8,8 +8,8 @@ import android.support.wearable.complications.ComplicationData
|
|||
import android.support.wearable.complications.ComplicationText
|
||||
import androidx.annotation.DrawableRes
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.graphics.Bitmap
|
||||
|
@ -10,7 +10,7 @@ import android.support.wearable.complications.ComplicationData
|
|||
import android.util.DisplayMetrics
|
||||
import android.view.WindowManager
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import java.io.IOException
|
||||
|
||||
/*
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.complications
|
||||
package app.aaps.wear.complications
|
||||
|
||||
/*
|
||||
* Created by dlvoy on 2019-11-12
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.data
|
||||
package app.aaps.wear.data
|
||||
|
||||
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
|
|
@ -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.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
|
||||
@Suppress("unused")
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.di
|
||||
package app.aaps.wear.di
|
||||
|
||||
import app.aaps.wear.WearApp
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import dagger.android.AndroidInjectionModule
|
||||
import dagger.android.AndroidInjector
|
||||
import info.nightscout.androidaps.WearApp
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.androidaps.di
|
||||
package app.aaps.wear.di
|
||||
|
||||
import android.content.Context
|
||||
import app.aaps.shared.impl.di.SharedImplModule
|
||||
import app.aaps.wear.WearApp
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.WearApp
|
||||
import kotlinx.datetime.Clock
|
||||
|
||||
@Suppress("unused")
|
|
@ -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.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
|
||||
@Suppress("unused")
|
||||
|
@ -36,7 +60,6 @@ abstract class WearServicesModule {
|
|||
@ContributesAndroidInjector abstract fun contributesSteampunk(): SteampunkWatchface
|
||||
@ContributesAndroidInjector abstract fun contributesDigitalStyleWatchface(): DigitalStyleWatchface
|
||||
@ContributesAndroidInjector abstract fun contributesCockpitWatchface(): CockpitWatchface
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesBIGChart(): BigChartWatchface
|
||||
@ContributesAndroidInjector abstract fun contributesNOChart(): NoChartWatchface
|
||||
@ContributesAndroidInjector abstract fun contributesCircleWatchface(): CircleWatchface
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.events
|
||||
package app.aaps.wear.events
|
||||
|
||||
import android.content.Context
|
||||
import app.aaps.core.interfaces.rx.events.Event
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.heartrate
|
||||
package app.aaps.wear.heartrate
|
||||
|
||||
import android.content.Context
|
||||
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.rx.AapsSchedulers
|
||||
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 java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.locks.ReentrantLock
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction
|
||||
package app.aaps.wear.interaction
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
|
@ -6,8 +6,8 @@ import android.view.ViewGroup
|
|||
import androidx.core.content.ContextCompat
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.wear.R
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.R
|
||||
import preference.WearPreferenceActivity
|
||||
import javax.inject.Inject
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.androidaps.interaction
|
||||
package app.aaps.wear.interaction
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import androidx.wear.tiles.TileService
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.wear.tile.ActionsTileService
|
||||
import app.aaps.wear.tile.TempTargetTileService
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.tile.ActionsTileService
|
||||
import info.nightscout.androidaps.tile.TempTargetTileService
|
||||
import preference.WearPreferenceActivity
|
||||
import javax.inject.Inject
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction
|
||||
package app.aaps.wear.interaction
|
||||
|
||||
import android.Manifest
|
||||
import android.content.SharedPreferences
|
||||
|
@ -11,7 +11,7 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.preference.PreferenceManager
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.R
|
||||
import app.aaps.wear.R
|
||||
import preference.WearPreferenceActivity
|
||||
import javax.inject.Inject
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
@ -16,11 +16,11 @@ import android.widget.TextView
|
|||
import androidx.core.view.InputDeviceCompat
|
||||
import androidx.core.view.MotionEventCompat
|
||||
import androidx.core.view.ViewConfigurationCompat
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
|
||||
import info.nightscout.androidaps.comm.IntentCancelNotification
|
||||
import info.nightscout.androidaps.comm.IntentWearToMobile
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.comm.DataLayerListenerServiceWear
|
||||
import app.aaps.wear.comm.IntentCancelNotification
|
||||
import app.aaps.wear.comm.IntentWearToMobile
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class AcceptActivity : ViewSelectorActivity() {
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.wear.comm.DataLayerListenerServiceWear
|
||||
import dagger.android.DaggerActivity
|
||||
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
|
||||
import javax.inject.Inject
|
||||
|
||||
class BackgroundActionActivity : DaggerActivity() {
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.weardata.EventData.ActionBolusPreCheck
|
||||
import app.aaps.core.interfaces.utils.SafeParse
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
import kotlin.math.roundToInt
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.weardata.EventData.ActionECarbsPreCheck
|
||||
import app.aaps.core.interfaces.utils.SafeParse
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class CarbActivity : ViewSelectorActivity() {
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.utils.SafeParse.stringToDouble
|
||||
import app.aaps.core.interfaces.utils.SafeParse.stringToInt
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class ECarbActivity : ViewSelectorActivity() {
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.weardata.EventData.ActionFillPreCheck
|
||||
import app.aaps.core.interfaces.utils.SafeParse.stringToDouble
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class FillActivity : ViewSelectorActivity() {
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.weardata.EventData.ActionProfileSwitchPreCheck
|
||||
import app.aaps.core.interfaces.utils.SafeParse
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class ProfileSwitchActivity : ViewSelectorActivity() {
|
|
@ -1,54 +1,54 @@
|
|||
package info.nightscout.androidaps.interaction.actions
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
import app.aaps.core.interfaces.rx.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.shared.impl.extensions.safeGetPackageInfo
|
||||
import dagger.android.DaggerActivity
|
||||
import info.nightscout.androidaps.R
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Send a snooze request to silence any alarm. Designed to be bound to a button for fast access
|
||||
*/
|
||||
|
||||
class QuickSnoozeActivity : DaggerActivity() {
|
||||
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Toast.makeText(this, R.string.sending_snooze, Toast.LENGTH_LONG).show()
|
||||
rxBus.send(EventWearToMobile(EventData.SnoozeAlert(System.currentTimeMillis())))
|
||||
|
||||
val xDripPackageName = "com.eveningoutpost.dexdrip"
|
||||
if (isPackageExisted(xDripPackageName)) {
|
||||
try {
|
||||
val i = Intent()
|
||||
i.setClassName(xDripPackageName, "$xDripPackageName.QuickSnooze")
|
||||
startActivity(i)
|
||||
} catch (e: Exception) {
|
||||
Log.e("WEAR", "failed to snooze xDrip: ", e)
|
||||
}
|
||||
} else {
|
||||
Log.d("WEAR", "Package $xDripPackageName not available for snooze")
|
||||
}
|
||||
|
||||
finish()
|
||||
}
|
||||
|
||||
@Suppress("SameParameterValue")
|
||||
private fun isPackageExisted(targetPackage: String): Boolean {
|
||||
try {
|
||||
packageManager.safeGetPackageInfo(targetPackage, 0)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
import app.aaps.core.interfaces.rx.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.shared.impl.extensions.safeGetPackageInfo
|
||||
import app.aaps.wear.R
|
||||
import dagger.android.DaggerActivity
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Send a snooze request to silence any alarm. Designed to be bound to a button for fast access
|
||||
*/
|
||||
|
||||
class QuickSnoozeActivity : DaggerActivity() {
|
||||
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Toast.makeText(this, R.string.sending_snooze, Toast.LENGTH_LONG).show()
|
||||
rxBus.send(EventWearToMobile(EventData.SnoozeAlert(System.currentTimeMillis())))
|
||||
|
||||
val xDripPackageName = "com.eveningoutpost.dexdrip"
|
||||
if (isPackageExisted(xDripPackageName)) {
|
||||
try {
|
||||
val i = Intent()
|
||||
i.setClassName(xDripPackageName, "$xDripPackageName.QuickSnooze")
|
||||
startActivity(i)
|
||||
} catch (e: Exception) {
|
||||
Log.e("WEAR", "failed to snooze xDrip: ", e)
|
||||
}
|
||||
} else {
|
||||
Log.d("WEAR", "Package $xDripPackageName not available for snooze")
|
||||
}
|
||||
|
||||
finish()
|
||||
}
|
||||
|
||||
@Suppress("SameParameterValue")
|
||||
private fun isPackageExisted(targetPackage: String): Boolean {
|
||||
try {
|
||||
packageManager.safeGetPackageInfo(targetPackage, 0)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.weardata.EventData.ActionTempTargetPreCheck
|
||||
import app.aaps.core.interfaces.utils.SafeParse
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class TempTargetActivity : ViewSelectorActivity() {
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.utils.SafeParse.stringToDouble
|
||||
import app.aaps.core.interfaces.utils.SafeParse.stringToInt
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
import kotlin.math.roundToInt
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
@ -11,11 +11,11 @@ import android.widget.Toast
|
|||
import androidx.wear.widget.CurvedTextView
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
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 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
|
||||
|
||||
/**
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.interaction.actions
|
||||
package app.aaps.wear.interaction.actions
|
||||
|
||||
import android.os.Bundle
|
||||
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.weardata.EventData.ActionWizardPreCheck
|
||||
import app.aaps.core.interfaces.utils.SafeParse
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.EditPlusMinusViewAdapter
|
||||
import app.aaps.wear.interaction.utils.PlusMinusEditText
|
||||
import app.aaps.wear.nondeprecated.GridPagerAdapterNonDeprecated
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class WizardActivity : ViewSelectorActivity() {
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.androidaps.interaction.menus
|
||||
package app.aaps.wear.interaction.menus
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import app.aaps.core.interfaces.rx.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.FillActivity
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.actions.FillActivity
|
||||
import app.aaps.wear.interaction.utils.MenuListActivity
|
||||
|
||||
class FillMenuActivity : MenuListActivity() {
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
package info.nightscout.androidaps.interaction.menus
|
||||
package app.aaps.wear.interaction.menus
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import app.aaps.core.interfaces.rx.events.EventWearToMobile
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData.ActionResendData
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.ECarbActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TreatmentActivity
|
||||
import info.nightscout.androidaps.interaction.actions.WizardActivity
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.actions.ECarbActivity
|
||||
import app.aaps.wear.interaction.actions.TempTargetActivity
|
||||
import app.aaps.wear.interaction.actions.TreatmentActivity
|
||||
import app.aaps.wear.interaction.actions.WizardActivity
|
||||
import app.aaps.wear.interaction.utils.MenuListActivity
|
||||
|
||||
class MainMenuActivity : MenuListActivity() {
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.interaction.menus
|
||||
package app.aaps.wear.interaction.menus
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.WatchfaceConfigurationActivity
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.WatchfaceConfigurationActivity
|
||||
import app.aaps.wear.interaction.utils.MenuListActivity
|
||||
|
||||
class PreferenceMenuActivity : MenuListActivity() {
|
||||
|
||||
|
@ -24,23 +24,27 @@ class PreferenceMenuActivity : MenuListActivity() {
|
|||
|
||||
override fun doAction(position: String) {
|
||||
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)
|
||||
putExtra(getString(R.string.key_preference_id), R.xml.display_preferences)
|
||||
})
|
||||
|
||||
getString(R.string.pref_graph_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra(getString(R.string.key_preference_id), R.xml.graph_preferences)
|
||||
})
|
||||
|
||||
getString(R.string.pref_interface_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra(getString(R.string.key_preference_id), R.xml.interface_preferences)
|
||||
})
|
||||
|
||||
getString(R.string.pref_complication_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
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)
|
||||
putExtra(getString(R.string.key_preference_id), R.xml.others_preferences)
|
||||
})
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.androidaps.interaction.menus
|
||||
package app.aaps.wear.interaction.menus
|
||||
|
||||
import android.os.Bundle
|
||||
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.ActionPumpStatus
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData.ActionTddStatus
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.utils.MenuListActivity
|
||||
|
||||
class StatusMenuActivity : MenuListActivity() {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
@Suppress("unused")
|
||||
object Constants {
|
|
@ -1,142 +1,142 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.RawDisplayData
|
||||
import info.nightscout.androidaps.interaction.utils.Pair.Companion.create
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.max
|
||||
|
||||
@Singleton
|
||||
class DisplayFormat @Inject internal constructor() {
|
||||
|
||||
companion object {
|
||||
|
||||
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 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
|
||||
}
|
||||
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var wearUtil: WearUtil
|
||||
@Inject lateinit var context: Context
|
||||
|
||||
/**
|
||||
* 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 MIN values - this is minimal length that can hold legible data
|
||||
*/
|
||||
|
||||
private fun areComplicationsUnicode() = sp.getBoolean("complication_unicode", true)
|
||||
|
||||
private fun deltaSymbol() = if (areComplicationsUnicode()) "\u0394" else ""
|
||||
|
||||
private fun verticalSeparatorSymbol() = if (areComplicationsUnicode()) "\u205E" else "|"
|
||||
|
||||
fun basalRateSymbol() = if (areComplicationsUnicode()) "\u238D\u2006" else ""
|
||||
|
||||
fun shortTimeSince(refTime: Long): String {
|
||||
val deltaTimeMs = wearUtil.msSince(refTime)
|
||||
return if (deltaTimeMs < Constants.MINUTE_IN_MS) {
|
||||
"0'"
|
||||
} else if (deltaTimeMs < Constants.HOUR_IN_MS) {
|
||||
val minutes = (deltaTimeMs / Constants.MINUTE_IN_MS).toInt()
|
||||
"$minutes'"
|
||||
} else if (deltaTimeMs < Constants.DAY_IN_MS) {
|
||||
val hours = (deltaTimeMs / Constants.HOUR_IN_MS).toInt()
|
||||
hours.toString() + context.getString(R.string.hour_short)
|
||||
} else {
|
||||
val days = (deltaTimeMs / Constants.DAY_IN_MS).toInt()
|
||||
if (days < 7) {
|
||||
days.toString() + context.getString(R.string.day_short)
|
||||
} else {
|
||||
val weeks = days / 7
|
||||
weeks.toString() + context.getString(R.string.week_short)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun shortTrend(raw: RawDisplayData): String {
|
||||
var minutes = "--"
|
||||
val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta
|
||||
if (raw.singleBg.timeStamp > 0) {
|
||||
minutes = shortTimeSince(raw.singleBg.timeStamp)
|
||||
}
|
||||
if (minutes.length + rawDelta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
|
||||
return minutes + " " + deltaSymbol() + rawDelta
|
||||
}
|
||||
|
||||
// that only optimizes obvious things like 0 before . or at end, + at beginning
|
||||
val delta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - 1)
|
||||
if (minutes.length + delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
|
||||
return minutes + " " + deltaSymbol() + delta
|
||||
}
|
||||
val shortDelta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - (1 + minutes.length))
|
||||
return "$minutes $shortDelta"
|
||||
}
|
||||
|
||||
fun longGlucoseLine(raw: RawDisplayData): String {
|
||||
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) + ")"
|
||||
}
|
||||
|
||||
fun longDetailsLine(raw: RawDisplayData): String {
|
||||
val sepLong = " " + verticalSeparatorSymbol() + " "
|
||||
val sepShort = " " + verticalSeparatorSymbol() + " "
|
||||
val sepShortLen = sepShort.length
|
||||
val sepMin = " "
|
||||
var line = raw.status.cob + sepLong + raw.status.iobSum + sepLong + basalRateSymbol() + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
line = raw.status.cob + sepShort + raw.status.iobSum + sepShort + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
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))
|
||||
line = raw.status.cob + sepShort + smallestIoB + sepShort + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
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))
|
||||
line = simplifiedCob + sepShort + smallestIoB + sepShort + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
line = simplifiedCob + sepMin + smallestIoB + sepMin + raw.status.currentBasal
|
||||
return line
|
||||
}
|
||||
|
||||
fun detailedIob(raw: RawDisplayData): Pair<String, String> {
|
||||
val iob1 = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(MAX_FIELD_LEN_SHORT)
|
||||
var iob2 = ""
|
||||
if (raw.status.iobDetail.contains("|")) {
|
||||
val iobs = raw.status.iobDetail.replace("(", "").replace(")", "").split("|").toTypedArray()
|
||||
var iobBolus = SmallestDoubleString(iobs[0]).minimise(MIN_FIELD_LEN_IOB)
|
||||
if (iobBolus.trim().isEmpty()) {
|
||||
iobBolus = "--"
|
||||
}
|
||||
var iobBasal = SmallestDoubleString(iobs[1]).minimise(MAX_FIELD_LEN_SHORT - 1 - max(MIN_FIELD_LEN_IOB, iobBolus.length))
|
||||
if (iobBasal.trim().isEmpty()) {
|
||||
iobBasal = "--"
|
||||
}
|
||||
iob2 = "$iobBolus $iobBasal"
|
||||
}
|
||||
return create(iob1, iob2)
|
||||
}
|
||||
|
||||
fun detailedCob(raw: RawDisplayData): Pair<String, String> {
|
||||
val cobMini = SmallestDoubleString(raw.status.cob, SmallestDoubleString.Units.USE)
|
||||
var cob2 = ""
|
||||
if (cobMini.extra.isNotEmpty()) {
|
||||
cob2 = cobMini.extra + cobMini.units
|
||||
}
|
||||
val cob1 = cobMini.minimise(MAX_FIELD_LEN_SHORT)
|
||||
return create(cob1, cob2)
|
||||
}
|
||||
}
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.data.RawDisplayData
|
||||
import app.aaps.wear.interaction.utils.Pair.Companion.create
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.max
|
||||
|
||||
@Singleton
|
||||
class DisplayFormat @Inject internal constructor() {
|
||||
|
||||
companion object {
|
||||
|
||||
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 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
|
||||
}
|
||||
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var wearUtil: WearUtil
|
||||
@Inject lateinit var context: Context
|
||||
|
||||
/**
|
||||
* 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 MIN values - this is minimal length that can hold legible data
|
||||
*/
|
||||
|
||||
private fun areComplicationsUnicode() = sp.getBoolean("complication_unicode", true)
|
||||
|
||||
private fun deltaSymbol() = if (areComplicationsUnicode()) "\u0394" else ""
|
||||
|
||||
private fun verticalSeparatorSymbol() = if (areComplicationsUnicode()) "\u205E" else "|"
|
||||
|
||||
fun basalRateSymbol() = if (areComplicationsUnicode()) "\u238D\u2006" else ""
|
||||
|
||||
fun shortTimeSince(refTime: Long): String {
|
||||
val deltaTimeMs = wearUtil.msSince(refTime)
|
||||
return if (deltaTimeMs < Constants.MINUTE_IN_MS) {
|
||||
"0'"
|
||||
} else if (deltaTimeMs < Constants.HOUR_IN_MS) {
|
||||
val minutes = (deltaTimeMs / Constants.MINUTE_IN_MS).toInt()
|
||||
"$minutes'"
|
||||
} else if (deltaTimeMs < Constants.DAY_IN_MS) {
|
||||
val hours = (deltaTimeMs / Constants.HOUR_IN_MS).toInt()
|
||||
hours.toString() + context.getString(R.string.hour_short)
|
||||
} else {
|
||||
val days = (deltaTimeMs / Constants.DAY_IN_MS).toInt()
|
||||
if (days < 7) {
|
||||
days.toString() + context.getString(R.string.day_short)
|
||||
} else {
|
||||
val weeks = days / 7
|
||||
weeks.toString() + context.getString(R.string.week_short)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun shortTrend(raw: RawDisplayData): String {
|
||||
var minutes = "--"
|
||||
val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta
|
||||
if (raw.singleBg.timeStamp > 0) {
|
||||
minutes = shortTimeSince(raw.singleBg.timeStamp)
|
||||
}
|
||||
if (minutes.length + rawDelta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
|
||||
return minutes + " " + deltaSymbol() + rawDelta
|
||||
}
|
||||
|
||||
// that only optimizes obvious things like 0 before . or at end, + at beginning
|
||||
val delta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - 1)
|
||||
if (minutes.length + delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
|
||||
return minutes + " " + deltaSymbol() + delta
|
||||
}
|
||||
val shortDelta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - (1 + minutes.length))
|
||||
return "$minutes $shortDelta"
|
||||
}
|
||||
|
||||
fun longGlucoseLine(raw: RawDisplayData): String {
|
||||
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) + ")"
|
||||
}
|
||||
|
||||
fun longDetailsLine(raw: RawDisplayData): String {
|
||||
val sepLong = " " + verticalSeparatorSymbol() + " "
|
||||
val sepShort = " " + verticalSeparatorSymbol() + " "
|
||||
val sepShortLen = sepShort.length
|
||||
val sepMin = " "
|
||||
var line = raw.status.cob + sepLong + raw.status.iobSum + sepLong + basalRateSymbol() + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
line = raw.status.cob + sepShort + raw.status.iobSum + sepShort + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
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))
|
||||
line = raw.status.cob + sepShort + smallestIoB + sepShort + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
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))
|
||||
line = simplifiedCob + sepShort + smallestIoB + sepShort + raw.status.currentBasal
|
||||
if (line.length <= MAX_FIELD_LEN_LONG) {
|
||||
return line
|
||||
}
|
||||
line = simplifiedCob + sepMin + smallestIoB + sepMin + raw.status.currentBasal
|
||||
return line
|
||||
}
|
||||
|
||||
fun detailedIob(raw: RawDisplayData): Pair<String, String> {
|
||||
val iob1 = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(MAX_FIELD_LEN_SHORT)
|
||||
var iob2 = ""
|
||||
if (raw.status.iobDetail.contains("|")) {
|
||||
val iobs = raw.status.iobDetail.replace("(", "").replace(")", "").split("|").toTypedArray()
|
||||
var iobBolus = SmallestDoubleString(iobs[0]).minimise(MIN_FIELD_LEN_IOB)
|
||||
if (iobBolus.trim().isEmpty()) {
|
||||
iobBolus = "--"
|
||||
}
|
||||
var iobBasal = SmallestDoubleString(iobs[1]).minimise(MAX_FIELD_LEN_SHORT - 1 - max(MIN_FIELD_LEN_IOB, iobBolus.length))
|
||||
if (iobBasal.trim().isEmpty()) {
|
||||
iobBasal = "--"
|
||||
}
|
||||
iob2 = "$iobBolus $iobBasal"
|
||||
}
|
||||
return create(iob1, iob2)
|
||||
}
|
||||
|
||||
fun detailedCob(raw: RawDisplayData): Pair<String, String> {
|
||||
val cobMini = SmallestDoubleString(raw.status.cob, SmallestDoubleString.Units.USE)
|
||||
var cob2 = ""
|
||||
if (cobMini.extra.isNotEmpty()) {
|
||||
cob2 = cobMini.extra + cobMini.units
|
||||
}
|
||||
val cob1 = cobMini.minimise(MAX_FIELD_LEN_SHORT)
|
||||
return create(cob1, cob2)
|
||||
}
|
||||
}
|
|
@ -1,98 +1,98 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminMultiBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminQuickleftyBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminQuickleftyMultiBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminQuickrightyBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminQuickrightyMultiBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminViktoriaBinding
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class EditPlusMinusViewAdapter(
|
||||
eD: ActionEditplusminBinding?,
|
||||
eDP: ActionEditplusminMultiBinding?,
|
||||
eQL: ActionEditplusminQuickleftyBinding?,
|
||||
eQLP: ActionEditplusminQuickleftyMultiBinding?,
|
||||
eQR: ActionEditplusminQuickrightyBinding?,
|
||||
eQRP: ActionEditplusminQuickrightyMultiBinding?,
|
||||
eV: ActionEditplusminViktoriaBinding?
|
||||
) {
|
||||
|
||||
init {
|
||||
if (eD == null && eDP == null && eQL == null && eQLP == null && eQR == null && eQRP == null && eV == null) {
|
||||
throw IllegalArgumentException("Require at least on Binding parameter")
|
||||
}
|
||||
}
|
||||
|
||||
private val errorMessage = "Missing require View Binding parameter"
|
||||
val editText =
|
||||
eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val minButton =
|
||||
eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val plusButton1 =
|
||||
eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val label =
|
||||
eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2
|
||||
val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3
|
||||
val root =
|
||||
eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
|
||||
companion object {
|
||||
|
||||
fun getViewAdapter(sp: SP, context: Context, container: ViewGroup, multiple: Boolean = false): EditPlusMinusViewAdapter {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
|
||||
return when (sp.getInt(R.string.key_input_design, 1)) {
|
||||
2 -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminQuickrightyMultiBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, null, bindLayout, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminQuickrightyBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, bindLayout, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminQuickleftyMultiBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, bindLayout, null, null, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminQuickleftyBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, bindLayout, null, null, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
val bindLayout = ActionEditplusminViktoriaBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, null, null, bindLayout)
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminMultiBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, bindLayout, null, null, null, null, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(bindLayout, null, null, null, null, null, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.databinding.ActionEditplusminBinding
|
||||
import app.aaps.wear.databinding.ActionEditplusminMultiBinding
|
||||
import app.aaps.wear.databinding.ActionEditplusminQuickleftyBinding
|
||||
import app.aaps.wear.databinding.ActionEditplusminQuickleftyMultiBinding
|
||||
import app.aaps.wear.databinding.ActionEditplusminQuickrightyBinding
|
||||
import app.aaps.wear.databinding.ActionEditplusminQuickrightyMultiBinding
|
||||
import app.aaps.wear.databinding.ActionEditplusminViktoriaBinding
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class EditPlusMinusViewAdapter(
|
||||
eD: ActionEditplusminBinding?,
|
||||
eDP: ActionEditplusminMultiBinding?,
|
||||
eQL: ActionEditplusminQuickleftyBinding?,
|
||||
eQLP: ActionEditplusminQuickleftyMultiBinding?,
|
||||
eQR: ActionEditplusminQuickrightyBinding?,
|
||||
eQRP: ActionEditplusminQuickrightyMultiBinding?,
|
||||
eV: ActionEditplusminViktoriaBinding?
|
||||
) {
|
||||
|
||||
init {
|
||||
if (eD == null && eDP == null && eQL == null && eQLP == null && eQR == null && eQRP == null && eV == null) {
|
||||
throw IllegalArgumentException("Require at least on Binding parameter")
|
||||
}
|
||||
}
|
||||
|
||||
private val errorMessage = "Missing require View Binding parameter"
|
||||
val editText =
|
||||
eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val minButton =
|
||||
eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val plusButton1 =
|
||||
eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val label =
|
||||
eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2
|
||||
val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3
|
||||
val root =
|
||||
eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
|
||||
companion object {
|
||||
|
||||
fun getViewAdapter(sp: SP, context: Context, container: ViewGroup, multiple: Boolean = false): EditPlusMinusViewAdapter {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
|
||||
return when (sp.getInt(R.string.key_input_design, 1)) {
|
||||
2 -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminQuickrightyMultiBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, null, bindLayout, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminQuickrightyBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, bindLayout, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminQuickleftyMultiBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, bindLayout, null, null, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminQuickleftyBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, bindLayout, null, null, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
val bindLayout = ActionEditplusminViktoriaBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, null, null, bindLayout)
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminMultiBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, bindLayout, null, null, null, null, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(bindLayout, null, null, null, null, null, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.os.SystemClock
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import app.aaps.wear.BuildConfig
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -25,19 +25,19 @@ class Inevitable @Inject internal constructor() {
|
|||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
private val tasks = ConcurrentHashMap<String, Task>()
|
||||
fun task(id: String, idle_for: Long, runnable: Runnable?) {
|
||||
if (idle_for > MAX_QUEUE_TIME) {
|
||||
throw RuntimeException("$id Requested time: $idle_for beyond max queue time")
|
||||
fun task(id: String, idleFor: Long, runnable: Runnable?) {
|
||||
if (idleFor > MAX_QUEUE_TIME) {
|
||||
throw RuntimeException("$id Requested time: $idleFor beyond max queue time")
|
||||
}
|
||||
val task = tasks[id]
|
||||
if (task != null) {
|
||||
// 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`))
|
||||
} else {
|
||||
// otherwise create new task
|
||||
if (runnable == null) return // extension only if already exists
|
||||
tasks[id] = Task(id, idle_for, runnable)
|
||||
tasks[id] = Task(id, idleFor, runnable)
|
||||
if (debug) {
|
||||
aapsLogger.debug(
|
||||
LTag.WEAR,
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
|
@ -14,9 +14,9 @@ import androidx.wear.widget.WearableLinearLayoutManager.LayoutCallback
|
|||
import androidx.wear.widget.WearableRecyclerView
|
||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||
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 info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity.MenuAdapter.ItemViewHolder
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.min
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import app.aaps.annotations.OpenForTesting
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
|
@ -1,7 +1,14 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
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.MotionEvent
|
||||
import android.view.View
|
|
@ -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.text.DecimalFormat
|
||||
import java.util.regex.Pattern
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import preference.WearListPreference
|
||||
import android.widget.Toast
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import app.aaps.wear.BuildConfig
|
||||
import preference.WearListPreference
|
||||
|
||||
/**
|
||||
* Created by adrian on 07/08/17.
|
|
@ -1,9 +1,9 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.Toast
|
||||
import info.nightscout.androidaps.R
|
||||
import app.aaps.wear.R
|
||||
import preference.WearListPreference
|
||||
|
||||
@Suppress("unused")
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.interaction.utils
|
||||
package app.aaps.wear.interaction.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.PowerManager
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.nondeprecated
|
||||
package app.aaps.wear.nondeprecated
|
||||
|
||||
import android.content.Context
|
||||
import android.support.wearable.view.DotsPageIndicator
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.nondeprecated
|
||||
package app.aaps.wear.nondeprecated
|
||||
|
||||
import android.support.wearable.view.GridPagerAdapter
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.nondeprecated
|
||||
package app.aaps.wear.nondeprecated
|
||||
|
||||
import android.content.Context
|
||||
import android.support.wearable.view.GridViewPager
|
|
@ -1,19 +1,19 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.tile.source.ActionSource
|
||||
import javax.inject.Inject
|
||||
|
||||
class ActionsTileService : TileBase() {
|
||||
|
||||
@Inject lateinit var actionSource: ActionSource
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override val resourceVersion = "ActionsTileService"
|
||||
override val source get() = actionSource
|
||||
}
|
||||
package app.aaps.wear.tile
|
||||
|
||||
import app.aaps.wear.tile.source.ActionSource
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class ActionsTileService : TileBase() {
|
||||
|
||||
@Inject lateinit var actionSource: ActionSource
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override val resourceVersion = "ActionsTileService"
|
||||
override val source get() = actionSource
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.tile.source.QuickWizardSource
|
||||
import javax.inject.Inject
|
||||
|
||||
class QuickWizardTileService : TileBase() {
|
||||
|
||||
@Inject lateinit var quickWizardSource: QuickWizardSource
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override val resourceVersion = "QuickWizardTileService"
|
||||
override val source get() = quickWizardSource
|
||||
}
|
||||
package app.aaps.wear.tile
|
||||
|
||||
import app.aaps.wear.tile.source.QuickWizardSource
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class QuickWizardTileService : TileBase() {
|
||||
|
||||
@Inject lateinit var quickWizardSource: QuickWizardSource
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override val resourceVersion = "QuickWizardTileService"
|
||||
override val source get() = quickWizardSource
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.tile.source.TempTargetSource
|
||||
import javax.inject.Inject
|
||||
|
||||
class TempTargetTileService : TileBase() {
|
||||
|
||||
@Inject lateinit var tempTargetSource: TempTargetSource
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override val resourceVersion = "TempTargetTileService"
|
||||
override val source get() = tempTargetSource
|
||||
}
|
||||
package app.aaps.wear.tile
|
||||
|
||||
import app.aaps.wear.tile.source.TempTargetSource
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class TempTargetTileService : TileBase() {
|
||||
|
||||
@Inject lateinit var tempTargetSource: TempTargetSource
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override val resourceVersion = "TempTargetTileService"
|
||||
override val source get() = tempTargetSource
|
||||
}
|
|
@ -1,309 +1,309 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.tile
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.wear.tiles.ActionBuilders
|
||||
import androidx.wear.tiles.ColorBuilders.argb
|
||||
import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
|
||||
import androidx.wear.tiles.DeviceParametersBuilders.SCREEN_SHAPE_ROUND
|
||||
import androidx.wear.tiles.DimensionBuilders.SpProp
|
||||
import androidx.wear.tiles.DimensionBuilders.dp
|
||||
import androidx.wear.tiles.DimensionBuilders.sp
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Box
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Column
|
||||
import androidx.wear.tiles.LayoutElementBuilders.FONT_WEIGHT_BOLD
|
||||
import androidx.wear.tiles.LayoutElementBuilders.FontStyle
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Image
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Layout
|
||||
import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Row
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Spacer
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Text
|
||||
import androidx.wear.tiles.ModifiersBuilders.Background
|
||||
import androidx.wear.tiles.ModifiersBuilders.Clickable
|
||||
import androidx.wear.tiles.ModifiersBuilders.Corner
|
||||
import androidx.wear.tiles.ModifiersBuilders.Modifiers
|
||||
import androidx.wear.tiles.ModifiersBuilders.Semantics
|
||||
import androidx.wear.tiles.RequestBuilders
|
||||
import androidx.wear.tiles.RequestBuilders.ResourcesRequest
|
||||
import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
|
||||
import androidx.wear.tiles.ResourceBuilders.ImageResource
|
||||
import androidx.wear.tiles.ResourceBuilders.Resources
|
||||
import androidx.wear.tiles.TileBuilders.Tile
|
||||
import androidx.wear.tiles.TileService
|
||||
import androidx.wear.tiles.TimelineBuilders.Timeline
|
||||
import androidx.wear.tiles.TimelineBuilders.TimelineEntry
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.guava.future
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.sqrt
|
||||
|
||||
private const val SPACING_ACTIONS = 3f
|
||||
private const val ICON_SIZE_FRACTION = 0.4f // Percentage of button diameter
|
||||
private val BUTTON_COLOR = R.color.gray_850
|
||||
private const val LARGE_SCREEN_WIDTH_DP = 210
|
||||
|
||||
interface TileSource {
|
||||
|
||||
fun getResourceReferences(resources: android.content.res.Resources): List<Int>
|
||||
fun getSelectedActions(): List<Action>
|
||||
fun getValidFor(): Long?
|
||||
}
|
||||
|
||||
open class Action(
|
||||
val buttonText: String,
|
||||
val buttonTextSub: String? = null,
|
||||
val activityClass: String,
|
||||
@DrawableRes val iconRes: Int,
|
||||
val action: EventData? = null,
|
||||
val message: String? = null,
|
||||
)
|
||||
|
||||
enum class WearControl {
|
||||
NO_DATA, ENABLED, DISABLED
|
||||
}
|
||||
|
||||
abstract class TileBase : TileService() {
|
||||
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
abstract val resourceVersion: String
|
||||
abstract val source: TileSource
|
||||
|
||||
private val serviceJob = Job()
|
||||
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override fun onTileRequest(
|
||||
requestParams: RequestBuilders.TileRequest
|
||||
): ListenableFuture<Tile> = serviceScope.future {
|
||||
val actionsSelected = getSelectedActions()
|
||||
val wearControl = getWearControl()
|
||||
val tile = Tile.Builder()
|
||||
.setResourcesVersion(resourceVersion)
|
||||
.setTimeline(
|
||||
Timeline.Builder().addTimelineEntry(
|
||||
TimelineEntry.Builder().setLayout(
|
||||
Layout.Builder().setRoot(layout(wearControl, actionsSelected, requestParams.deviceParameters!!)).build()
|
||||
).build()
|
||||
).build()
|
||||
)
|
||||
|
||||
val validFor = validFor()
|
||||
if (validFor != null) {
|
||||
tile.setFreshnessIntervalMillis(validFor)
|
||||
}
|
||||
tile.build()
|
||||
}
|
||||
|
||||
private fun getSelectedActions(): List<Action> {
|
||||
// TODO check why thi scan not be don in scope of the coroutine
|
||||
return source.getSelectedActions()
|
||||
}
|
||||
|
||||
private fun validFor(): Long? {
|
||||
return source.getValidFor()
|
||||
}
|
||||
|
||||
override fun onResourcesRequest(
|
||||
requestParams: ResourcesRequest
|
||||
): ListenableFuture<Resources> = serviceScope.future {
|
||||
Resources.Builder()
|
||||
.setVersion(resourceVersion)
|
||||
.apply {
|
||||
source.getResourceReferences(resources).forEach { resourceId ->
|
||||
addIdToImageMapping(
|
||||
resourceId.toString(),
|
||||
ImageResource.Builder()
|
||||
.setAndroidResourceByResId(
|
||||
AndroidImageResourceByResId.Builder()
|
||||
.setResourceId(resourceId)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun layout(wearControl: WearControl, actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement {
|
||||
if (wearControl == WearControl.DISABLED) {
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.wear_control_not_enabled))
|
||||
.build()
|
||||
} else if (wearControl == WearControl.NO_DATA) {
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.wear_control_no_data))
|
||||
.build()
|
||||
}
|
||||
if (actions.isNotEmpty()) {
|
||||
with(Column.Builder()) {
|
||||
if (actions.size == 1 || actions.size == 3) {
|
||||
addContent(addRowSingle(actions[0], deviceParameters))
|
||||
}
|
||||
if (actions.size == 4 || actions.size == 2) {
|
||||
addContent(addRowDouble(actions[0], actions[1], deviceParameters))
|
||||
}
|
||||
if (actions.size == 3) {
|
||||
addContent(addRowDouble(actions[1], actions[2], deviceParameters))
|
||||
}
|
||||
if (actions.size == 4) {
|
||||
addContent(Spacer.Builder().setHeight(dp(SPACING_ACTIONS)).build())
|
||||
addContent(addRowDouble(actions[2], actions[3], deviceParameters))
|
||||
}
|
||||
return build()
|
||||
}
|
||||
}
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.tile_no_config))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun addRowSingle(action: Action, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Row.Builder()
|
||||
.addContent(action(action, deviceParameters))
|
||||
.build()
|
||||
|
||||
private fun addRowDouble(action1: Action, action2: Action, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Row.Builder()
|
||||
.addContent(action(action1, deviceParameters))
|
||||
.addContent(Spacer.Builder().setWidth(dp(SPACING_ACTIONS)).build())
|
||||
.addContent(action(action2, deviceParameters))
|
||||
.build()
|
||||
|
||||
private fun doAction(action: Action): ActionBuilders.Action {
|
||||
val builder = ActionBuilders.AndroidActivity.Builder()
|
||||
.setClassName(action.activityClass)
|
||||
.setPackageName(this.packageName)
|
||||
if (action.action != null) {
|
||||
val actionString = ActionBuilders.AndroidStringExtra.Builder().setValue(action.action.serialize()).build()
|
||||
builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_ACTION, actionString)
|
||||
}
|
||||
if (action.message != null) {
|
||||
val message = ActionBuilders.AndroidStringExtra.Builder().setValue(action.message).build()
|
||||
builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_MESSAGE, message)
|
||||
}
|
||||
|
||||
return ActionBuilders.LaunchAction.Builder()
|
||||
.setAndroidActivity(builder.build())
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun action(action: Action, deviceParameters: DeviceParameters): LayoutElement {
|
||||
val circleDiameter = circleDiameter(deviceParameters)
|
||||
val text = action.buttonText
|
||||
val textSub = action.buttonTextSub
|
||||
return Box.Builder()
|
||||
.setWidth(dp(circleDiameter))
|
||||
.setHeight(dp(circleDiameter))
|
||||
.setModifiers(
|
||||
Modifiers.Builder()
|
||||
.setBackground(
|
||||
Background.Builder()
|
||||
.setColor(argb(ContextCompat.getColor(baseContext, BUTTON_COLOR)))
|
||||
.setCorner(Corner.Builder().setRadius(dp(circleDiameter / 2)).build())
|
||||
.build()
|
||||
)
|
||||
.setSemantics(
|
||||
Semantics.Builder()
|
||||
.setContentDescription("$text $textSub")
|
||||
.build()
|
||||
)
|
||||
.setClickable(
|
||||
Clickable.Builder()
|
||||
.setOnClick(doAction(action))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.addContent(addTextContent(action, deviceParameters))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun addTextContent(action: Action, deviceParameters: DeviceParameters): LayoutElement {
|
||||
val circleDiameter = circleDiameter(deviceParameters)
|
||||
val iconSize = dp(circleDiameter * ICON_SIZE_FRACTION)
|
||||
val text = action.buttonText
|
||||
val textSub = action.buttonTextSub
|
||||
val col = Column.Builder()
|
||||
.addContent(
|
||||
Image.Builder()
|
||||
.setWidth(iconSize)
|
||||
.setHeight(iconSize)
|
||||
.setResourceId(action.iconRes.toString())
|
||||
.build()
|
||||
).addContent(
|
||||
Text.Builder()
|
||||
.setText(text)
|
||||
.setFontStyle(
|
||||
FontStyle.Builder()
|
||||
.setWeight(FONT_WEIGHT_BOLD)
|
||||
.setColor(argb(ContextCompat.getColor(baseContext, R.color.white)))
|
||||
.setSize(buttonTextSize(deviceParameters, text))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
if (textSub != null) {
|
||||
col.addContent(
|
||||
Text.Builder()
|
||||
.setText(textSub)
|
||||
.setFontStyle(
|
||||
FontStyle.Builder()
|
||||
.setColor(argb(ContextCompat.getColor(baseContext, R.color.white)))
|
||||
.setSize(buttonTextSize(deviceParameters, textSub))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
return col.build()
|
||||
}
|
||||
|
||||
private fun circleDiameter(deviceParameters: DeviceParameters) = when (deviceParameters.screenShape) {
|
||||
SCREEN_SHAPE_ROUND -> ((sqrt(2f) - 1) * deviceParameters.screenHeightDp) - (2 * SPACING_ACTIONS)
|
||||
else -> 0.5f * deviceParameters.screenHeightDp - SPACING_ACTIONS
|
||||
}
|
||||
|
||||
private fun buttonTextSize(deviceParameters: DeviceParameters, text: String): SpProp {
|
||||
if (text.length > 6) {
|
||||
return sp(if (isLargeScreen(deviceParameters)) 14f else 12f)
|
||||
}
|
||||
return sp(if (isLargeScreen(deviceParameters)) 16f else 14f)
|
||||
}
|
||||
|
||||
private fun isLargeScreen(deviceParameters: DeviceParameters): Boolean {
|
||||
return deviceParameters.screenWidthDp >= LARGE_SCREEN_WIDTH_DP
|
||||
}
|
||||
|
||||
private fun getWearControl(): WearControl {
|
||||
if (!sp.contains(R.string.key_wear_control)) {
|
||||
return WearControl.NO_DATA
|
||||
}
|
||||
val wearControlPref = sp.getBoolean(R.string.key_wear_control, false)
|
||||
if (wearControlPref) {
|
||||
return WearControl.ENABLED
|
||||
}
|
||||
return WearControl.DISABLED
|
||||
}
|
||||
|
||||
}
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package app.aaps.wear.tile
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.wear.tiles.ActionBuilders
|
||||
import androidx.wear.tiles.ColorBuilders.argb
|
||||
import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
|
||||
import androidx.wear.tiles.DeviceParametersBuilders.SCREEN_SHAPE_ROUND
|
||||
import androidx.wear.tiles.DimensionBuilders.SpProp
|
||||
import androidx.wear.tiles.DimensionBuilders.dp
|
||||
import androidx.wear.tiles.DimensionBuilders.sp
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Box
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Column
|
||||
import androidx.wear.tiles.LayoutElementBuilders.FONT_WEIGHT_BOLD
|
||||
import androidx.wear.tiles.LayoutElementBuilders.FontStyle
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Image
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Layout
|
||||
import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Row
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Spacer
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Text
|
||||
import androidx.wear.tiles.ModifiersBuilders.Background
|
||||
import androidx.wear.tiles.ModifiersBuilders.Clickable
|
||||
import androidx.wear.tiles.ModifiersBuilders.Corner
|
||||
import androidx.wear.tiles.ModifiersBuilders.Modifiers
|
||||
import androidx.wear.tiles.ModifiersBuilders.Semantics
|
||||
import androidx.wear.tiles.RequestBuilders
|
||||
import androidx.wear.tiles.RequestBuilders.ResourcesRequest
|
||||
import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
|
||||
import androidx.wear.tiles.ResourceBuilders.ImageResource
|
||||
import androidx.wear.tiles.ResourceBuilders.Resources
|
||||
import androidx.wear.tiles.TileBuilders.Tile
|
||||
import androidx.wear.tiles.TileService
|
||||
import androidx.wear.tiles.TimelineBuilders.Timeline
|
||||
import androidx.wear.tiles.TimelineBuilders.TimelineEntry
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.comm.DataLayerListenerServiceWear
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import dagger.android.AndroidInjection
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.guava.future
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.sqrt
|
||||
|
||||
private const val SPACING_ACTIONS = 3f
|
||||
private const val ICON_SIZE_FRACTION = 0.4f // Percentage of button diameter
|
||||
private val BUTTON_COLOR = R.color.gray_850
|
||||
private const val LARGE_SCREEN_WIDTH_DP = 210
|
||||
|
||||
interface TileSource {
|
||||
|
||||
fun getResourceReferences(resources: android.content.res.Resources): List<Int>
|
||||
fun getSelectedActions(): List<Action>
|
||||
fun getValidFor(): Long?
|
||||
}
|
||||
|
||||
open class Action(
|
||||
val buttonText: String,
|
||||
val buttonTextSub: String? = null,
|
||||
val activityClass: String,
|
||||
@DrawableRes val iconRes: Int,
|
||||
val action: EventData? = null,
|
||||
val message: String? = null,
|
||||
)
|
||||
|
||||
enum class WearControl {
|
||||
NO_DATA, ENABLED, DISABLED
|
||||
}
|
||||
|
||||
abstract class TileBase : TileService() {
|
||||
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
abstract val resourceVersion: String
|
||||
abstract val source: TileSource
|
||||
|
||||
private val serviceJob = Job()
|
||||
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
|
||||
|
||||
// Not derived from DaggerService, do injection here
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
override fun onTileRequest(
|
||||
requestParams: RequestBuilders.TileRequest
|
||||
): ListenableFuture<Tile> = serviceScope.future {
|
||||
val actionsSelected = getSelectedActions()
|
||||
val wearControl = getWearControl()
|
||||
val tile = Tile.Builder()
|
||||
.setResourcesVersion(resourceVersion)
|
||||
.setTimeline(
|
||||
Timeline.Builder().addTimelineEntry(
|
||||
TimelineEntry.Builder().setLayout(
|
||||
Layout.Builder().setRoot(layout(wearControl, actionsSelected, requestParams.deviceParameters!!)).build()
|
||||
).build()
|
||||
).build()
|
||||
)
|
||||
|
||||
val validFor = validFor()
|
||||
if (validFor != null) {
|
||||
tile.setFreshnessIntervalMillis(validFor)
|
||||
}
|
||||
tile.build()
|
||||
}
|
||||
|
||||
private fun getSelectedActions(): List<Action> {
|
||||
// TODO check why thi scan not be don in scope of the coroutine
|
||||
return source.getSelectedActions()
|
||||
}
|
||||
|
||||
private fun validFor(): Long? {
|
||||
return source.getValidFor()
|
||||
}
|
||||
|
||||
override fun onResourcesRequest(
|
||||
requestParams: ResourcesRequest
|
||||
): ListenableFuture<Resources> = serviceScope.future {
|
||||
Resources.Builder()
|
||||
.setVersion(resourceVersion)
|
||||
.apply {
|
||||
source.getResourceReferences(resources).forEach { resourceId ->
|
||||
addIdToImageMapping(
|
||||
resourceId.toString(),
|
||||
ImageResource.Builder()
|
||||
.setAndroidResourceByResId(
|
||||
AndroidImageResourceByResId.Builder()
|
||||
.setResourceId(resourceId)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun layout(wearControl: WearControl, actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement {
|
||||
if (wearControl == WearControl.DISABLED) {
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.wear_control_not_enabled))
|
||||
.build()
|
||||
} else if (wearControl == WearControl.NO_DATA) {
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.wear_control_no_data))
|
||||
.build()
|
||||
}
|
||||
if (actions.isNotEmpty()) {
|
||||
with(Column.Builder()) {
|
||||
if (actions.size == 1 || actions.size == 3) {
|
||||
addContent(addRowSingle(actions[0], deviceParameters))
|
||||
}
|
||||
if (actions.size == 4 || actions.size == 2) {
|
||||
addContent(addRowDouble(actions[0], actions[1], deviceParameters))
|
||||
}
|
||||
if (actions.size == 3) {
|
||||
addContent(addRowDouble(actions[1], actions[2], deviceParameters))
|
||||
}
|
||||
if (actions.size == 4) {
|
||||
addContent(Spacer.Builder().setHeight(dp(SPACING_ACTIONS)).build())
|
||||
addContent(addRowDouble(actions[2], actions[3], deviceParameters))
|
||||
}
|
||||
return build()
|
||||
}
|
||||
}
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.tile_no_config))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun addRowSingle(action: Action, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Row.Builder()
|
||||
.addContent(action(action, deviceParameters))
|
||||
.build()
|
||||
|
||||
private fun addRowDouble(action1: Action, action2: Action, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Row.Builder()
|
||||
.addContent(action(action1, deviceParameters))
|
||||
.addContent(Spacer.Builder().setWidth(dp(SPACING_ACTIONS)).build())
|
||||
.addContent(action(action2, deviceParameters))
|
||||
.build()
|
||||
|
||||
private fun doAction(action: Action): ActionBuilders.Action {
|
||||
val builder = ActionBuilders.AndroidActivity.Builder()
|
||||
.setClassName(action.activityClass)
|
||||
.setPackageName(this.packageName)
|
||||
if (action.action != null) {
|
||||
val actionString = ActionBuilders.AndroidStringExtra.Builder().setValue(action.action.serialize()).build()
|
||||
builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_ACTION, actionString)
|
||||
}
|
||||
if (action.message != null) {
|
||||
val message = ActionBuilders.AndroidStringExtra.Builder().setValue(action.message).build()
|
||||
builder.addKeyToExtraMapping(DataLayerListenerServiceWear.KEY_MESSAGE, message)
|
||||
}
|
||||
|
||||
return ActionBuilders.LaunchAction.Builder()
|
||||
.setAndroidActivity(builder.build())
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun action(action: Action, deviceParameters: DeviceParameters): LayoutElement {
|
||||
val circleDiameter = circleDiameter(deviceParameters)
|
||||
val text = action.buttonText
|
||||
val textSub = action.buttonTextSub
|
||||
return Box.Builder()
|
||||
.setWidth(dp(circleDiameter))
|
||||
.setHeight(dp(circleDiameter))
|
||||
.setModifiers(
|
||||
Modifiers.Builder()
|
||||
.setBackground(
|
||||
Background.Builder()
|
||||
.setColor(argb(ContextCompat.getColor(baseContext, BUTTON_COLOR)))
|
||||
.setCorner(Corner.Builder().setRadius(dp(circleDiameter / 2)).build())
|
||||
.build()
|
||||
)
|
||||
.setSemantics(
|
||||
Semantics.Builder()
|
||||
.setContentDescription("$text $textSub")
|
||||
.build()
|
||||
)
|
||||
.setClickable(
|
||||
Clickable.Builder()
|
||||
.setOnClick(doAction(action))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.addContent(addTextContent(action, deviceParameters))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun addTextContent(action: Action, deviceParameters: DeviceParameters): LayoutElement {
|
||||
val circleDiameter = circleDiameter(deviceParameters)
|
||||
val iconSize = dp(circleDiameter * ICON_SIZE_FRACTION)
|
||||
val text = action.buttonText
|
||||
val textSub = action.buttonTextSub
|
||||
val col = Column.Builder()
|
||||
.addContent(
|
||||
Image.Builder()
|
||||
.setWidth(iconSize)
|
||||
.setHeight(iconSize)
|
||||
.setResourceId(action.iconRes.toString())
|
||||
.build()
|
||||
).addContent(
|
||||
Text.Builder()
|
||||
.setText(text)
|
||||
.setFontStyle(
|
||||
FontStyle.Builder()
|
||||
.setWeight(FONT_WEIGHT_BOLD)
|
||||
.setColor(argb(ContextCompat.getColor(baseContext, R.color.white)))
|
||||
.setSize(buttonTextSize(deviceParameters, text))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
if (textSub != null) {
|
||||
col.addContent(
|
||||
Text.Builder()
|
||||
.setText(textSub)
|
||||
.setFontStyle(
|
||||
FontStyle.Builder()
|
||||
.setColor(argb(ContextCompat.getColor(baseContext, R.color.white)))
|
||||
.setSize(buttonTextSize(deviceParameters, textSub))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
return col.build()
|
||||
}
|
||||
|
||||
private fun circleDiameter(deviceParameters: DeviceParameters) = when (deviceParameters.screenShape) {
|
||||
SCREEN_SHAPE_ROUND -> ((sqrt(2f) - 1) * deviceParameters.screenHeightDp) - (2 * SPACING_ACTIONS)
|
||||
else -> 0.5f * deviceParameters.screenHeightDp - SPACING_ACTIONS
|
||||
}
|
||||
|
||||
private fun buttonTextSize(deviceParameters: DeviceParameters, text: String): SpProp {
|
||||
if (text.length > 6) {
|
||||
return sp(if (isLargeScreen(deviceParameters)) 14f else 12f)
|
||||
}
|
||||
return sp(if (isLargeScreen(deviceParameters)) 16f else 14f)
|
||||
}
|
||||
|
||||
private fun isLargeScreen(deviceParameters: DeviceParameters): Boolean {
|
||||
return deviceParameters.screenWidthDp >= LARGE_SCREEN_WIDTH_DP
|
||||
}
|
||||
|
||||
private fun getWearControl(): WearControl {
|
||||
if (!sp.contains(R.string.key_wear_control)) {
|
||||
return WearControl.NO_DATA
|
||||
}
|
||||
val wearControlPref = sp.getBoolean(R.string.key_wear_control, false)
|
||||
if (wearControlPref) {
|
||||
return WearControl.ENABLED
|
||||
}
|
||||
return WearControl.DISABLED
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +1,76 @@
|
|||
package info.nightscout.androidaps.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.BolusActivity
|
||||
import info.nightscout.androidaps.interaction.actions.CarbActivity
|
||||
import info.nightscout.androidaps.interaction.actions.ECarbActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TreatmentActivity
|
||||
import info.nightscout.androidaps.interaction.actions.WizardActivity
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class ActionSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
|
||||
|
||||
override val preferencePrefix = "tile_action_"
|
||||
|
||||
override fun getActions(resources: Resources): List<StaticAction> {
|
||||
return listOf(
|
||||
StaticAction(
|
||||
settingName = "wizard",
|
||||
buttonText = resources.getString(R.string.menu_wizard_short),
|
||||
iconRes = R.drawable.ic_calculator_green,
|
||||
activityClass = WizardActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "treatment",
|
||||
buttonText = resources.getString(R.string.menu_treatment_short),
|
||||
iconRes = R.drawable.ic_bolus_carbs,
|
||||
activityClass = TreatmentActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "bolus",
|
||||
buttonText = resources.getString(R.string.action_insulin),
|
||||
iconRes = R.drawable.ic_bolus,
|
||||
activityClass = BolusActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "carbs",
|
||||
buttonText = resources.getString(R.string.action_carbs),
|
||||
iconRes = R.drawable.ic_carbs_orange,
|
||||
activityClass = CarbActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "ecarbs",
|
||||
buttonText = resources.getString(R.string.action_ecarbs),
|
||||
iconRes = R.drawable.ic_carbs_orange,
|
||||
activityClass = ECarbActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "temp_target",
|
||||
buttonText = resources.getString(R.string.menu_tempt),
|
||||
iconRes = R.drawable.ic_temptarget_flat,
|
||||
activityClass = TempTargetActivity::class.java.name,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getResourceReferences(resources: Resources): List<Int> {
|
||||
return getActions(resources).map { it.iconRes }
|
||||
}
|
||||
|
||||
override fun getDefaultConfig(): Map<String, String> {
|
||||
return mapOf(
|
||||
"tile_action_1" to "wizard",
|
||||
"tile_action_2" to "treatment",
|
||||
"tile_action_3" to "ecarbs",
|
||||
"tile_action_4" to "temp_target"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
package app.aaps.wear.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.R
|
||||
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.TempTargetActivity
|
||||
import app.aaps.wear.interaction.actions.TreatmentActivity
|
||||
import app.aaps.wear.interaction.actions.WizardActivity
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class ActionSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
|
||||
|
||||
override val preferencePrefix = "tile_action_"
|
||||
|
||||
override fun getActions(resources: Resources): List<StaticAction> {
|
||||
return listOf(
|
||||
StaticAction(
|
||||
settingName = "wizard",
|
||||
buttonText = resources.getString(R.string.menu_wizard_short),
|
||||
iconRes = R.drawable.ic_calculator_green,
|
||||
activityClass = WizardActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "treatment",
|
||||
buttonText = resources.getString(R.string.menu_treatment_short),
|
||||
iconRes = R.drawable.ic_bolus_carbs,
|
||||
activityClass = TreatmentActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "bolus",
|
||||
buttonText = resources.getString(R.string.action_insulin),
|
||||
iconRes = R.drawable.ic_bolus,
|
||||
activityClass = BolusActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "carbs",
|
||||
buttonText = resources.getString(R.string.action_carbs),
|
||||
iconRes = R.drawable.ic_carbs_orange,
|
||||
activityClass = CarbActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "ecarbs",
|
||||
buttonText = resources.getString(R.string.action_ecarbs),
|
||||
iconRes = R.drawable.ic_carbs_orange,
|
||||
activityClass = ECarbActivity::class.java.name,
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "temp_target",
|
||||
buttonText = resources.getString(R.string.menu_tempt),
|
||||
iconRes = R.drawable.ic_temptarget_flat,
|
||||
activityClass = TempTargetActivity::class.java.name,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getResourceReferences(resources: Resources): List<Int> {
|
||||
return getActions(resources).map { it.iconRes }
|
||||
}
|
||||
|
||||
override fun getDefaultConfig(): Map<String, String> {
|
||||
return mapOf(
|
||||
"tile_action_1" to "wizard",
|
||||
"tile_action_2" to "treatment",
|
||||
"tile_action_3" to "ecarbs",
|
||||
"tile_action_4" to "temp_target"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,81 +1,81 @@
|
|||
package info.nightscout.androidaps.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.BackgroundActionActivity
|
||||
import info.nightscout.androidaps.tile.Action
|
||||
import info.nightscout.androidaps.tile.TileSource
|
||||
import java.util.Calendar
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class QuickWizardSource @Inject constructor(private val context: Context, private val sp: SP, private val aapsLogger: AAPSLogger) : TileSource {
|
||||
|
||||
override fun getSelectedActions(): List<Action> {
|
||||
val quickList = mutableListOf<Action>()
|
||||
val quickMap = getQuickWizardData(sp)
|
||||
val sfm = secondsFromMidnight()
|
||||
|
||||
for (quick in quickMap.entries) {
|
||||
val isActive = sfm in quick.validFrom..quick.validTo
|
||||
if (isActive && quick.guid.isNotEmpty()) {
|
||||
quickList.add(
|
||||
Action(
|
||||
buttonText = quick.buttonText,
|
||||
buttonTextSub = "${quick.carbs} g",
|
||||
iconRes = R.drawable.ic_quick_wizard,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
action = EventData.ActionQuickWizardPreCheck(quick.guid),
|
||||
message = context.resources.getString(R.string.action_quick_wizard_confirmation)
|
||||
)
|
||||
)
|
||||
aapsLogger.info(LTag.WEAR, """getSelectedActions: active ${quick.buttonText} guid=${quick.guid}""")
|
||||
} else {
|
||||
aapsLogger.info(LTag.WEAR, """getSelectedActions: not active ${quick.buttonText} guid=${quick.guid}""")
|
||||
}
|
||||
}
|
||||
return quickList
|
||||
}
|
||||
|
||||
override fun getValidFor(): Long? {
|
||||
val quickMap = getQuickWizardData(sp)
|
||||
if (quickMap.entries.size == 0) return null
|
||||
|
||||
val sfm = secondsFromMidnight()
|
||||
var validTill = 24 * 60 * 60
|
||||
|
||||
for (quick in quickMap.entries) {
|
||||
val isActive = sfm in quick.validFrom..quick.validTo
|
||||
if (quick.guid.isNotEmpty()) {
|
||||
if (isActive && validTill > quick.validTo) validTill = quick.validTo
|
||||
if (quick.validFrom in (sfm + 1) until validTill) validTill = quick.validFrom
|
||||
}
|
||||
}
|
||||
|
||||
val validWithin = 60
|
||||
//aapsLogger.info(LTag.WEAR, "getValidTill: sfm$sfm till$validTill d=$delta")
|
||||
return (validTill - sfm + validWithin) * 1000L
|
||||
}
|
||||
|
||||
private fun getQuickWizardData(sp: SP): EventData.QuickWizard =
|
||||
EventData.deserialize(sp.getString(R.string.key_quick_wizard_data, EventData.QuickWizard(arrayListOf()).serialize())) as EventData.QuickWizard
|
||||
|
||||
private fun secondsFromMidnight(): Int {
|
||||
val c = Calendar.getInstance()
|
||||
c.set(Calendar.HOUR_OF_DAY, 0)
|
||||
c.set(Calendar.MINUTE, 0)
|
||||
c.set(Calendar.SECOND, 0)
|
||||
c.set(Calendar.MILLISECOND, 0)
|
||||
val passed: Long = System.currentTimeMillis() - c.timeInMillis
|
||||
|
||||
return (passed / 1000).toInt()
|
||||
}
|
||||
|
||||
override fun getResourceReferences(resources: Resources): List<Int> = listOf(R.drawable.ic_quick_wizard)
|
||||
}
|
||||
package app.aaps.wear.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.actions.BackgroundActionActivity
|
||||
import app.aaps.wear.tile.Action
|
||||
import app.aaps.wear.tile.TileSource
|
||||
import java.util.Calendar
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class QuickWizardSource @Inject constructor(private val context: Context, private val sp: SP, private val aapsLogger: AAPSLogger) : TileSource {
|
||||
|
||||
override fun getSelectedActions(): List<Action> {
|
||||
val quickList = mutableListOf<Action>()
|
||||
val quickMap = getQuickWizardData(sp)
|
||||
val sfm = secondsFromMidnight()
|
||||
|
||||
for (quick in quickMap.entries) {
|
||||
val isActive = sfm in quick.validFrom..quick.validTo
|
||||
if (isActive && quick.guid.isNotEmpty()) {
|
||||
quickList.add(
|
||||
Action(
|
||||
buttonText = quick.buttonText,
|
||||
buttonTextSub = "${quick.carbs} g",
|
||||
iconRes = R.drawable.ic_quick_wizard,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
action = EventData.ActionQuickWizardPreCheck(quick.guid),
|
||||
message = context.resources.getString(R.string.action_quick_wizard_confirmation)
|
||||
)
|
||||
)
|
||||
aapsLogger.info(LTag.WEAR, """getSelectedActions: active ${quick.buttonText} guid=${quick.guid}""")
|
||||
} else {
|
||||
aapsLogger.info(LTag.WEAR, """getSelectedActions: not active ${quick.buttonText} guid=${quick.guid}""")
|
||||
}
|
||||
}
|
||||
return quickList
|
||||
}
|
||||
|
||||
override fun getValidFor(): Long? {
|
||||
val quickMap = getQuickWizardData(sp)
|
||||
if (quickMap.entries.size == 0) return null
|
||||
|
||||
val sfm = secondsFromMidnight()
|
||||
var validTill = 24 * 60 * 60
|
||||
|
||||
for (quick in quickMap.entries) {
|
||||
val isActive = sfm in quick.validFrom..quick.validTo
|
||||
if (quick.guid.isNotEmpty()) {
|
||||
if (isActive && validTill > quick.validTo) validTill = quick.validTo
|
||||
if (quick.validFrom in (sfm + 1) until validTill) validTill = quick.validFrom
|
||||
}
|
||||
}
|
||||
|
||||
val validWithin = 60
|
||||
//aapsLogger.info(LTag.WEAR, "getValidTill: sfm$sfm till$validTill d=$delta")
|
||||
return (validTill - sfm + validWithin) * 1000L
|
||||
}
|
||||
|
||||
private fun getQuickWizardData(sp: SP): EventData.QuickWizard =
|
||||
EventData.deserialize(sp.getString(R.string.key_quick_wizard_data, EventData.QuickWizard(arrayListOf()).serialize())) as EventData.QuickWizard
|
||||
|
||||
private fun secondsFromMidnight(): Int {
|
||||
val c = Calendar.getInstance()
|
||||
c.set(Calendar.HOUR_OF_DAY, 0)
|
||||
c.set(Calendar.MINUTE, 0)
|
||||
c.set(Calendar.SECOND, 0)
|
||||
c.set(Calendar.MILLISECOND, 0)
|
||||
val passed: Long = System.currentTimeMillis() - c.timeInMillis
|
||||
|
||||
return (passed / 1000).toInt()
|
||||
}
|
||||
|
||||
override fun getResourceReferences(resources: Resources): List<Int> = listOf(R.drawable.ic_quick_wizard)
|
||||
}
|
|
@ -1,61 +1,61 @@
|
|||
package info.nightscout.androidaps.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import androidx.annotation.DrawableRes
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.tile.Action
|
||||
import info.nightscout.androidaps.tile.TileSource
|
||||
|
||||
abstract class StaticTileSource(val context: Context, val sp: SP, val aapsLogger: AAPSLogger) : TileSource {
|
||||
|
||||
class StaticAction(
|
||||
val settingName: String,
|
||||
buttonText: String,
|
||||
buttonTextSub: String? = null,
|
||||
activityClass: String,
|
||||
@DrawableRes iconRes: Int,
|
||||
action: EventData? = null,
|
||||
message: String? = null,
|
||||
) : Action(buttonText, buttonTextSub, activityClass, iconRes, action, message)
|
||||
|
||||
abstract fun getActions(resources: Resources): List<StaticAction>
|
||||
|
||||
abstract val preferencePrefix: String
|
||||
abstract fun getDefaultConfig(): Map<String, String>
|
||||
|
||||
override fun getSelectedActions(): List<Action> {
|
||||
setDefaultSettings()
|
||||
|
||||
val actionList: MutableList<Action> = mutableListOf()
|
||||
for (i in 1..4) {
|
||||
val action = getActionFromPreference(i)
|
||||
if (action != null) {
|
||||
actionList.add(action)
|
||||
}
|
||||
}
|
||||
if (actionList.isEmpty()) {
|
||||
return getActions(context.resources).take(4)
|
||||
}
|
||||
return actionList
|
||||
}
|
||||
|
||||
override fun getValidFor(): Long? = null
|
||||
|
||||
private fun getActionFromPreference(index: Int): Action? {
|
||||
val actionPref = sp.getString(preferencePrefix + index, "none")
|
||||
return getActions(context.resources).find { action -> action.settingName == actionPref }
|
||||
}
|
||||
|
||||
private fun setDefaultSettings() {
|
||||
val defaults = getDefaultConfig()
|
||||
val firstKey = defaults.firstNotNullOf { settings -> settings.key }
|
||||
if (!sp.contains(firstKey)) {
|
||||
for ((key, value) in defaults) {
|
||||
sp.putString(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package app.aaps.wear.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import androidx.annotation.DrawableRes
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.tile.Action
|
||||
import app.aaps.wear.tile.TileSource
|
||||
|
||||
abstract class StaticTileSource(val context: Context, val sp: SP, val aapsLogger: AAPSLogger) : TileSource {
|
||||
|
||||
class StaticAction(
|
||||
val settingName: String,
|
||||
buttonText: String,
|
||||
buttonTextSub: String? = null,
|
||||
activityClass: String,
|
||||
@DrawableRes iconRes: Int,
|
||||
action: EventData? = null,
|
||||
message: String? = null,
|
||||
) : Action(buttonText, buttonTextSub, activityClass, iconRes, action, message)
|
||||
|
||||
abstract fun getActions(resources: Resources): List<StaticAction>
|
||||
|
||||
abstract val preferencePrefix: String
|
||||
abstract fun getDefaultConfig(): Map<String, String>
|
||||
|
||||
override fun getSelectedActions(): List<Action> {
|
||||
setDefaultSettings()
|
||||
|
||||
val actionList: MutableList<Action> = mutableListOf()
|
||||
for (i in 1..4) {
|
||||
val action = getActionFromPreference(i)
|
||||
if (action != null) {
|
||||
actionList.add(action)
|
||||
}
|
||||
}
|
||||
if (actionList.isEmpty()) {
|
||||
return getActions(context.resources).take(4)
|
||||
}
|
||||
return actionList
|
||||
}
|
||||
|
||||
override fun getValidFor(): Long? = null
|
||||
|
||||
private fun getActionFromPreference(index: Int): Action? {
|
||||
val actionPref = sp.getString(preferencePrefix + index, "none")
|
||||
return getActions(context.resources).find { action -> action.settingName == actionPref }
|
||||
}
|
||||
|
||||
private fun setDefaultSettings() {
|
||||
val defaults = getDefaultConfig()
|
||||
val firstKey = defaults.firstNotNullOf { settings -> settings.key }
|
||||
if (!sp.contains(firstKey)) {
|
||||
for ((key, value) in defaults) {
|
||||
sp.putString(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,83 +1,83 @@
|
|||
package info.nightscout.androidaps.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.BackgroundActionActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class TempTargetSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
|
||||
|
||||
override val preferencePrefix = "tile_tempt_"
|
||||
|
||||
override fun getActions(resources: Resources): List<StaticAction> {
|
||||
val message = resources.getString(R.string.action_tempt_confirmation)
|
||||
return listOf(
|
||||
StaticAction(
|
||||
settingName = "activity",
|
||||
buttonText = resources.getString(R.string.temp_target_activity),
|
||||
iconRes = R.drawable.ic_target_activity,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
// actionString = "temptarget false 90 8.0 8.0",
|
||||
// actionString = "temptarget preset activity",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_ACTIVITY)
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "eating_soon",
|
||||
buttonText = resources.getString(R.string.temp_target_eating_soon),
|
||||
iconRes = R.drawable.ic_target_eatingsoon,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
// actionString = "temptarget false 45 4.5 4.5",
|
||||
// actionString = "temptarget preset eating",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_EATING)
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "hypo",
|
||||
buttonText = resources.getString(R.string.temp_target_hypo),
|
||||
iconRes = R.drawable.ic_target_hypo,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
// actionString = "temptarget false 45 7.0 7.0",
|
||||
// actionString = "temptarget preset hypo",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_HYPO)
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "manual",
|
||||
buttonText = resources.getString(R.string.temp_target_manual),
|
||||
iconRes = R.drawable.ic_target_manual,
|
||||
activityClass = TempTargetActivity::class.java.name,
|
||||
action = null
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "cancel",
|
||||
buttonText = resources.getString(android.support.wearable.R.string.generic_cancel),
|
||||
iconRes = R.drawable.ic_target_cancel,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
//actionString = "temptarget cancel",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.CANCEL)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getResourceReferences(resources: Resources): List<Int> {
|
||||
return getActions(resources).map { it.iconRes }
|
||||
}
|
||||
|
||||
override fun getDefaultConfig(): Map<String, String> {
|
||||
return mapOf(
|
||||
"tile_tempt_1" to "activity",
|
||||
"tile_tempt_2" to "eating_soon",
|
||||
"tile_tempt_3" to "hypo",
|
||||
"tile_tempt_4" to "manual"
|
||||
)
|
||||
}
|
||||
}
|
||||
package app.aaps.wear.tile.source
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.interaction.actions.BackgroundActionActivity
|
||||
import app.aaps.wear.interaction.actions.TempTargetActivity
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class TempTargetSource @Inject constructor(context: Context, sp: SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
|
||||
|
||||
override val preferencePrefix = "tile_tempt_"
|
||||
|
||||
override fun getActions(resources: Resources): List<StaticAction> {
|
||||
val message = resources.getString(R.string.action_tempt_confirmation)
|
||||
return listOf(
|
||||
StaticAction(
|
||||
settingName = "activity",
|
||||
buttonText = resources.getString(R.string.temp_target_activity),
|
||||
iconRes = R.drawable.ic_target_activity,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
// actionString = "temptarget false 90 8.0 8.0",
|
||||
// actionString = "temptarget preset activity",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_ACTIVITY)
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "eating_soon",
|
||||
buttonText = resources.getString(R.string.temp_target_eating_soon),
|
||||
iconRes = R.drawable.ic_target_eatingsoon,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
// actionString = "temptarget false 45 4.5 4.5",
|
||||
// actionString = "temptarget preset eating",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_EATING)
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "hypo",
|
||||
buttonText = resources.getString(R.string.temp_target_hypo),
|
||||
iconRes = R.drawable.ic_target_hypo,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
// actionString = "temptarget false 45 7.0 7.0",
|
||||
// actionString = "temptarget preset hypo",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.PRESET_HYPO)
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "manual",
|
||||
buttonText = resources.getString(R.string.temp_target_manual),
|
||||
iconRes = R.drawable.ic_target_manual,
|
||||
activityClass = TempTargetActivity::class.java.name,
|
||||
action = null
|
||||
),
|
||||
StaticAction(
|
||||
settingName = "cancel",
|
||||
buttonText = resources.getString(android.support.wearable.R.string.generic_cancel),
|
||||
iconRes = R.drawable.ic_target_cancel,
|
||||
activityClass = BackgroundActionActivity::class.java.name,
|
||||
message = message,
|
||||
//actionString = "temptarget cancel",
|
||||
action = EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.CANCEL)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getResourceReferences(resources: Resources): List<Int> {
|
||||
return getActions(resources).map { it.iconRes }
|
||||
}
|
||||
|
||||
override fun getDefaultConfig(): Map<String, String> {
|
||||
return mapOf(
|
||||
"tile_tempt_1" to "activity",
|
||||
"tile_tempt_2" to "eating_soon",
|
||||
"tile_tempt_3" to "hypo",
|
||||
"tile_tempt_4" to "manual"
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.content.ContextCompat
|
||||
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 info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityHomeLargeBinding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
|
||||
class AapsLargeWatchface : BaseWatchFace() {
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
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 info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityHome2Binding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
|
||||
class AapsV2Watchface : BaseWatchFace() {
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.content.ContextCompat
|
||||
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 info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
import info.nightscout.androidaps.databinding.ActivityHomeBinding
|
||||
|
||||
class AapsWatchface : BaseWatchFace() {
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.content.ContextCompat
|
||||
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 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() {
|
||||
|
||||
|
@ -53,9 +53,9 @@ class BigChartWatchface : BaseWatchFace() {
|
|||
binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView))
|
||||
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
|
||||
val color = when (singleBg.sgvLevel) {
|
||||
1L -> R.color.dark_highColor
|
||||
0L -> R.color.dark_midColor
|
||||
-1L -> R.color.dark_lowColor
|
||||
1L -> R.color.dark_highColor
|
||||
0L -> R.color.dark_midColor
|
||||
-1L -> R.color.dark_lowColor
|
||||
else -> R.color.dark_midColor
|
||||
}
|
||||
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.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background))
|
||||
val color = when (singleBg.sgvLevel) {
|
||||
1L -> R.color.light_highColor
|
||||
0L -> R.color.light_midColor
|
||||
-1L -> R.color.light_lowColor
|
||||
1L -> R.color.light_highColor
|
||||
0L -> R.color.light_midColor
|
||||
-1L -> R.color.light_lowColor
|
||||
else -> R.color.light_midColor
|
||||
}
|
||||
binding.sgv?.setTextColor(ContextCompat.getColor(this, color))
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
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.SingleBg
|
||||
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.wearable.WatchFace
|
||||
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.kotlin.plusAssign
|
||||
import java.util.*
|
|
@ -1,11 +1,11 @@
|
|||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityCockpitBinding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.databinding.ActivityCockpitBinding
|
||||
import app.aaps.wear.watchfaces.utils.BaseWatchFace
|
||||
|
||||
/**
|
||||
* Created by andrew-warrington on 18/11/2017.
|
||||
|
@ -24,9 +24,9 @@ class CockpitWatchface : BaseWatchFace() {
|
|||
binding.mainLayout.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds)
|
||||
setTextSizes()
|
||||
val led = when (singleBg.sgvLevel) {
|
||||
1L -> R.drawable.airplane_led_yellow_lit
|
||||
0L -> R.drawable.airplane_led_grey_unlit
|
||||
-1L -> R.drawable.airplane_led_red_lit
|
||||
1L -> R.drawable.airplane_led_yellow_lit
|
||||
0L -> R.drawable.airplane_led_grey_unlit
|
||||
-1L -> R.drawable.airplane_led_red_lit
|
||||
else -> R.drawable.airplane_led_grey_unlit
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
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.ViewKeys
|
||||
import app.aaps.core.interfaces.rx.weardata.ZipWatchfaceFormat
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityCustomBinding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.databinding.ActivityCustomBinding
|
||||
import app.aaps.wear.watchfaces.utils.BaseWatchFace
|
||||
import org.joda.time.TimeOfDay
|
||||
import org.json.JSONObject
|
||||
import java.io.ByteArrayOutputStream
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.support.wearable.watchface.WatchFaceStyle
|
||||
|
@ -10,9 +10,9 @@ import android.widget.LinearLayout
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import app.aaps.core.interfaces.logging.LTag
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityDigitalstyleBinding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.databinding.ActivityDigitalstyleBinding
|
||||
import app.aaps.wear.watchfaces.utils.BaseWatchFace
|
||||
|
||||
class DigitalStyleWatchface : BaseWatchFace() {
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.content.ContextCompat
|
||||
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 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() {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.watchfaces
|
||||
package app.aaps.wear.watchfaces
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.animation.Animation
|
||||
|
@ -9,9 +9,9 @@ import android.view.animation.RotateAnimation
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import app.aaps.core.interfaces.utils.SafeParse.stringToFloat
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivitySteampunkBinding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
import app.aaps.wear.R
|
||||
import app.aaps.wear.databinding.ActivitySteampunkBinding
|
||||
import app.aaps.wear.watchfaces.utils.BaseWatchFace
|
||||
import org.joda.time.TimeOfDay
|
||||
|
||||
/**
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package info.nightscout.androidaps.watchfaces.utils
|
||||
package app.aaps.wear.watchfaces.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
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.sharedPreferences.SP
|
||||
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.WatchMode
|
||||
import com.ustwo.clockwise.common.WatchShape
|
||||
import com.ustwo.clockwise.wearable.WatchFace
|
||||
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.kotlin.plusAssign
|
||||
import javax.inject.Inject
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.watchfaces.utils
|
||||
package app.aaps.wear.watchfaces.utils
|
||||
|
||||
import android.graphics.DashPathEffect
|
||||
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.sharedPreferences.SP
|
||||
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.AxisValue
|
||||
import lecho.lib.hellocharts.model.Line
|
|
@ -1,154 +1,154 @@
|
|||
package info.nightscout.androidaps.watchfaces.utils
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Point
|
||||
import android.graphics.Typeface
|
||||
import android.os.BatteryManager
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import com.ustwo.clockwise.common.WatchMode
|
||||
import com.ustwo.clockwise.wearable.WatchFace
|
||||
import info.nightscout.androidaps.R
|
||||
import javax.inject.Inject
|
||||
|
||||
class SimpleUi @Inject constructor(
|
||||
private val context: Context,
|
||||
private val sp: SP,
|
||||
private val dateUtil: DateUtil
|
||||
) {
|
||||
|
||||
private var batteryReceiver: BroadcastReceiver? = null
|
||||
private var mBackgroundPaint = Paint()
|
||||
private lateinit var mTimePaint: Paint
|
||||
private lateinit var mSvgPaint: Paint
|
||||
private lateinit var mDirectionPaint: Paint
|
||||
private var mYOffset = 0f
|
||||
private val colorDarkHigh = ContextCompat.getColor(context, R.color.dark_highColor)
|
||||
private var colorDarkMid = ContextCompat.getColor(context, R.color.dark_midColor)
|
||||
private var colorDarkLow = ContextCompat.getColor(context, R.color.dark_lowColor)
|
||||
private val displaySize = Point()
|
||||
private lateinit var callback: () -> Unit
|
||||
|
||||
fun onCreate(callback: () -> Unit) {
|
||||
this.callback = callback
|
||||
@Suppress("DEPRECATION")
|
||||
(context.getSystemService(WatchFace.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(displaySize)
|
||||
setupBatteryReceiver()
|
||||
setupUi()
|
||||
}
|
||||
|
||||
fun updatePreferences() {
|
||||
setupBatteryReceiver()
|
||||
}
|
||||
|
||||
fun setAntiAlias(currentWatchMode: WatchMode) {
|
||||
val antiAlias = currentWatchMode == WatchMode.AMBIENT
|
||||
mSvgPaint.isAntiAlias = antiAlias
|
||||
mDirectionPaint.isAntiAlias = antiAlias
|
||||
mTimePaint.isAntiAlias = antiAlias
|
||||
}
|
||||
|
||||
fun isEnabled(currentWatchMode: WatchMode): Boolean {
|
||||
val simplify = sp.getString(R.string.key_simplify_ui, "off")
|
||||
return if (simplify == "off") false
|
||||
else if ((simplify == "ambient" || simplify == "ambient_charging") && currentWatchMode == WatchMode.AMBIENT) true
|
||||
else (simplify == "charging" || simplify == "ambient_charging") && isCharging
|
||||
}
|
||||
|
||||
fun onDraw(canvas: Canvas, singleBg: EventData.SingleBg) {
|
||||
canvas.drawRect(0f, 0f, displaySize.x.toFloat(), displaySize.y.toFloat(), mBackgroundPaint)
|
||||
val xHalf = displaySize.x / 2f
|
||||
val yThird = displaySize.y / 3f
|
||||
|
||||
mSvgPaint.isStrikeThruText = isOutdated(singleBg)
|
||||
mSvgPaint.color = getBgColour(singleBg.sgvLevel)
|
||||
mDirectionPaint.color = getBgColour(singleBg.sgvLevel)
|
||||
val sSvg = singleBg.sgvString
|
||||
val svgWidth = mSvgPaint.measureText(sSvg)
|
||||
val sDirection = " " + singleBg.slopeArrow + "\uFE0E"
|
||||
val directionWidth = mDirectionPaint.measureText(sDirection)
|
||||
val xSvg = xHalf - (svgWidth + directionWidth) / 2
|
||||
canvas.drawText(sSvg, xSvg, yThird + mYOffset, mSvgPaint)
|
||||
val xDirection = xSvg + svgWidth
|
||||
canvas.drawText(sDirection, xDirection, yThird + mYOffset, mDirectionPaint)
|
||||
val sTime = dateUtil.timeString()
|
||||
val xTime = xHalf - mTimePaint.measureText(sTime) / 2f
|
||||
canvas.drawText(sTime, xTime, yThird * 2f + mYOffset, mTimePaint)
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
if (batteryReceiver != null) {
|
||||
context.unregisterReceiver(batteryReceiver)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isOutdated(singleBg: EventData.SingleBg): Boolean =
|
||||
singleBg.timeStamp > 0 && (System.currentTimeMillis() - singleBg.timeStamp) > 1000 * 60 * 12
|
||||
|
||||
private fun getBgColour(level: Long): Int =
|
||||
when (level) {
|
||||
1L -> colorDarkHigh
|
||||
0L -> colorDarkMid
|
||||
else -> colorDarkLow
|
||||
}
|
||||
|
||||
private val isCharging: Boolean
|
||||
get() {
|
||||
val mBatteryStatus = context.registerReceiver(null, iFilter)
|
||||
val status = mBatteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
|
||||
return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL
|
||||
}
|
||||
|
||||
private fun setupUi() {
|
||||
val black = ContextCompat.getColor(context, R.color.black)
|
||||
mBackgroundPaint.color = black
|
||||
val white = ContextCompat.getColor(context, R.color.white)
|
||||
val resources = context.resources
|
||||
val textSizeSvg = resources.getDimension(R.dimen.simple_ui_svg_text_size)
|
||||
val textSizeDirection = resources.getDimension(R.dimen.simple_ui_direction_text_size)
|
||||
val textSizeTime = resources.getDimension(R.dimen.simple_ui_time_text_size)
|
||||
mYOffset = resources.getDimension(R.dimen.simple_ui_y_offset)
|
||||
mSvgPaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeSvg)
|
||||
mDirectionPaint = createTextPaint(BOLD_TYPEFACE, white, textSizeDirection)
|
||||
mTimePaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeTime)
|
||||
}
|
||||
|
||||
private fun setupBatteryReceiver() {
|
||||
val setting = sp.getString(R.string.key_simplify_ui, "off")
|
||||
if ((setting == "charging" || setting == "ambient_charging") && batteryReceiver == null) {
|
||||
val intentBatteryFilter = IntentFilter()
|
||||
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING)
|
||||
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING)
|
||||
batteryReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
context.registerReceiver(batteryReceiver, intentBatteryFilter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTextPaint(typeface: Typeface, colour: Int, textSize: Float): Paint {
|
||||
val paint = Paint()
|
||||
paint.color = colour
|
||||
paint.typeface = typeface
|
||||
paint.isAntiAlias = true
|
||||
paint.textSize = textSize
|
||||
return paint
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
var iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||
val NORMAL_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
|
||||
val BOLD_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)
|
||||
}
|
||||
}
|
||||
package app.aaps.wear.watchfaces.utils
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Point
|
||||
import android.graphics.Typeface
|
||||
import android.os.BatteryManager
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.wear.R
|
||||
import com.ustwo.clockwise.common.WatchMode
|
||||
import com.ustwo.clockwise.wearable.WatchFace
|
||||
import javax.inject.Inject
|
||||
|
||||
class SimpleUi @Inject constructor(
|
||||
private val context: Context,
|
||||
private val sp: SP,
|
||||
private val dateUtil: DateUtil
|
||||
) {
|
||||
|
||||
private var batteryReceiver: BroadcastReceiver? = null
|
||||
private var mBackgroundPaint = Paint()
|
||||
private lateinit var mTimePaint: Paint
|
||||
private lateinit var mSvgPaint: Paint
|
||||
private lateinit var mDirectionPaint: Paint
|
||||
private var mYOffset = 0f
|
||||
private val colorDarkHigh = ContextCompat.getColor(context, R.color.dark_highColor)
|
||||
private var colorDarkMid = ContextCompat.getColor(context, R.color.dark_midColor)
|
||||
private var colorDarkLow = ContextCompat.getColor(context, R.color.dark_lowColor)
|
||||
private val displaySize = Point()
|
||||
private lateinit var callback: () -> Unit
|
||||
|
||||
fun onCreate(callback: () -> Unit) {
|
||||
this.callback = callback
|
||||
@Suppress("DEPRECATION")
|
||||
(context.getSystemService(WatchFace.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(displaySize)
|
||||
setupBatteryReceiver()
|
||||
setupUi()
|
||||
}
|
||||
|
||||
fun updatePreferences() {
|
||||
setupBatteryReceiver()
|
||||
}
|
||||
|
||||
fun setAntiAlias(currentWatchMode: WatchMode) {
|
||||
val antiAlias = currentWatchMode == WatchMode.AMBIENT
|
||||
mSvgPaint.isAntiAlias = antiAlias
|
||||
mDirectionPaint.isAntiAlias = antiAlias
|
||||
mTimePaint.isAntiAlias = antiAlias
|
||||
}
|
||||
|
||||
fun isEnabled(currentWatchMode: WatchMode): Boolean {
|
||||
val simplify = sp.getString(R.string.key_simplify_ui, "off")
|
||||
return if (simplify == "off") false
|
||||
else if ((simplify == "ambient" || simplify == "ambient_charging") && currentWatchMode == WatchMode.AMBIENT) true
|
||||
else (simplify == "charging" || simplify == "ambient_charging") && isCharging
|
||||
}
|
||||
|
||||
fun onDraw(canvas: Canvas, singleBg: EventData.SingleBg) {
|
||||
canvas.drawRect(0f, 0f, displaySize.x.toFloat(), displaySize.y.toFloat(), mBackgroundPaint)
|
||||
val xHalf = displaySize.x / 2f
|
||||
val yThird = displaySize.y / 3f
|
||||
|
||||
mSvgPaint.isStrikeThruText = isOutdated(singleBg)
|
||||
mSvgPaint.color = getBgColour(singleBg.sgvLevel)
|
||||
mDirectionPaint.color = getBgColour(singleBg.sgvLevel)
|
||||
val sSvg = singleBg.sgvString
|
||||
val svgWidth = mSvgPaint.measureText(sSvg)
|
||||
val sDirection = " " + singleBg.slopeArrow + "\uFE0E"
|
||||
val directionWidth = mDirectionPaint.measureText(sDirection)
|
||||
val xSvg = xHalf - (svgWidth + directionWidth) / 2
|
||||
canvas.drawText(sSvg, xSvg, yThird + mYOffset, mSvgPaint)
|
||||
val xDirection = xSvg + svgWidth
|
||||
canvas.drawText(sDirection, xDirection, yThird + mYOffset, mDirectionPaint)
|
||||
val sTime = dateUtil.timeString()
|
||||
val xTime = xHalf - mTimePaint.measureText(sTime) / 2f
|
||||
canvas.drawText(sTime, xTime, yThird * 2f + mYOffset, mTimePaint)
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
if (batteryReceiver != null) {
|
||||
context.unregisterReceiver(batteryReceiver)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isOutdated(singleBg: EventData.SingleBg): Boolean =
|
||||
singleBg.timeStamp > 0 && (System.currentTimeMillis() - singleBg.timeStamp) > 1000 * 60 * 12
|
||||
|
||||
private fun getBgColour(level: Long): Int =
|
||||
when (level) {
|
||||
1L -> colorDarkHigh
|
||||
0L -> colorDarkMid
|
||||
else -> colorDarkLow
|
||||
}
|
||||
|
||||
private val isCharging: Boolean
|
||||
get() {
|
||||
val mBatteryStatus = context.registerReceiver(null, iFilter)
|
||||
val status = mBatteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
|
||||
return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL
|
||||
}
|
||||
|
||||
private fun setupUi() {
|
||||
val black = ContextCompat.getColor(context, R.color.black)
|
||||
mBackgroundPaint.color = black
|
||||
val white = ContextCompat.getColor(context, R.color.white)
|
||||
val resources = context.resources
|
||||
val textSizeSvg = resources.getDimension(R.dimen.simple_ui_svg_text_size)
|
||||
val textSizeDirection = resources.getDimension(R.dimen.simple_ui_direction_text_size)
|
||||
val textSizeTime = resources.getDimension(R.dimen.simple_ui_time_text_size)
|
||||
mYOffset = resources.getDimension(R.dimen.simple_ui_y_offset)
|
||||
mSvgPaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeSvg)
|
||||
mDirectionPaint = createTextPaint(BOLD_TYPEFACE, white, textSizeDirection)
|
||||
mTimePaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeTime)
|
||||
}
|
||||
|
||||
private fun setupBatteryReceiver() {
|
||||
val setting = sp.getString(R.string.key_simplify_ui, "off")
|
||||
if ((setting == "charging" || setting == "ambient_charging") && batteryReceiver == null) {
|
||||
val intentBatteryFilter = IntentFilter()
|
||||
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING)
|
||||
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING)
|
||||
batteryReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
context.registerReceiver(batteryReceiver, intentBatteryFilter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTextPaint(typeface: Typeface, colour: Int, textSize: Float): Paint {
|
||||
val paint = Paint()
|
||||
paint.color = colour
|
||||
paint.typeface = typeface
|
||||
paint.isAntiAlias = true
|
||||
paint.textSize = textSize
|
||||
return paint
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
var iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||
val NORMAL_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
|
||||
val BOLD_TYPEFACE: Typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)
|
||||
}
|
||||
}
|
|
@ -1,104 +1,105 @@
|
|||
package info.nightscout.androidaps.watchfaces.utils
|
||||
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityHomeLargeBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityHome2Binding
|
||||
import info.nightscout.androidaps.databinding.ActivityHomeBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityBigchartBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityCockpitBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityCustomBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityDigitalstyleBinding
|
||||
import info.nightscout.androidaps.databinding.ActivityNochartBinding
|
||||
import info.nightscout.androidaps.databinding.ActivitySteampunkBinding
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class WatchfaceViewAdapter(
|
||||
aL: ActivityHomeLargeBinding? = null,
|
||||
a2: ActivityHome2Binding? = null,
|
||||
aa: ActivityHomeBinding? = null,
|
||||
bC: ActivityBigchartBinding? = null,
|
||||
cp: ActivityCockpitBinding? = null,
|
||||
ds: ActivityDigitalstyleBinding? = null,
|
||||
nC: ActivityNochartBinding? = null,
|
||||
sP: ActivitySteampunkBinding? = null,
|
||||
cU: ActivityCustomBinding? = null
|
||||
) {
|
||||
|
||||
init {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
private val errorMessage = "Missing require View Binding parameter"
|
||||
// Required attributes
|
||||
val mainLayout =
|
||||
aL?.mainLayout ?: a2?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: cp?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: sP?.mainLayout ?: cU?.mainLayout
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val timestamp =
|
||||
aL?.timestamp ?: a2?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: cp?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: sP?.timestamp ?: cU?.timestamp
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val root =
|
||||
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
|
||||
val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction
|
||||
val loop = a2?.loop ?: cp?.loop ?: sP?.loop ?: cU?.loop
|
||||
val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
|
||||
val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
|
||||
val uploaderBattery = aL?.uploaderBattery ?: a2?.uploaderBattery ?: aa?.uploaderBattery ?: cp?.uploaderBattery ?: ds?.uploaderBattery ?: sP?.uploaderBattery ?: cU?.uploaderBattery
|
||||
val rigBattery = a2?.rigBattery ?: cp?.rigBattery ?: ds?.rigBattery ?: sP?.rigBattery ?: cU?.rigBattery
|
||||
val basalRate = a2?.basalRate ?: cp?.basalRate ?: ds?.basalRate ?: sP?.basalRate ?: cU?.basalRate
|
||||
val bgi = a2?.bgi ?: ds?.bgi ?: cU?.bgi
|
||||
val AAPSv2 = a2?.AAPSv2 ?: cp?.AAPSv2 ?: ds?.AAPSv2 ?: sP?.AAPSv2 ?: cU?.AAPSv2
|
||||
val cob1 = a2?.cob1 ?: ds?.cob1 ?: cU?.cob1
|
||||
val cob2 = a2?.cob2 ?: cp?.cob2 ?: ds?.cob2 ?: sP?.cob2 ?: cU?.cob2
|
||||
val time = aL?.time ?: a2?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: cp?.time ?: nC?.time ?: cU?.time
|
||||
val second = cU?.second
|
||||
val minute = ds?.minute ?: cU?.minute
|
||||
val hour = ds?.hour ?: cU?.hour
|
||||
val day = a2?.day ?: ds?.day ?: cU?.day
|
||||
val month = a2?.month ?: ds?.month ?: cU?.month
|
||||
val iob1 = a2?.iob1 ?: ds?.iob1 ?: cU?.iob1
|
||||
val iob2 = a2?.iob2 ?: cp?.iob2 ?: ds?.iob2 ?: sP?.iob2 ?: cU?.iob2
|
||||
val chart = a2?.chart ?: aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: sP?.chart ?: cU?.chart
|
||||
val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status
|
||||
val timePeriod = ds?.timePeriod ?: aL?.timePeriod ?: nC?.timePeriod ?: bC?.timePeriod ?: cU?.timePeriod
|
||||
val dayName = ds?.dayName ?: cU?.dayName
|
||||
val mainMenuTap = ds?.mainMenuTap ?: sP?.mainMenuTap
|
||||
val chartZoomTap = ds?.chartZoomTap ?: sP?.chartZoomTap
|
||||
val dateTime = ds?.dateTime ?: a2?.dateTime
|
||||
val weekNumber = ds?.weekNumber ?: cU?.weekNumber
|
||||
// val minuteHand = sP?.minuteHand
|
||||
// val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout ?: sP?.secondaryLayout
|
||||
// val tertiaryLayout = a2?.tertiaryLayout ?: sP?.tertiaryLayout
|
||||
// val highLight = cp?.highLight
|
||||
// val lowLight = cp?.lowLight
|
||||
// val deltaGauge = sP?.deltaPointer
|
||||
// val hourHand = sP?.hourHand
|
||||
// val glucoseDial = sP?.glucoseDial
|
||||
|
||||
companion object {
|
||||
|
||||
fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter {
|
||||
return when (bindLayout) {
|
||||
is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout)
|
||||
is ActivityHome2Binding -> WatchfaceViewAdapter(null, bindLayout)
|
||||
is ActivityHomeBinding -> WatchfaceViewAdapter(null, null, bindLayout)
|
||||
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
|
||||
is ActivityCockpitBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
|
||||
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout)
|
||||
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, bindLayout)
|
||||
is ActivitySteampunkBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, bindLayout)
|
||||
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, null, bindLayout)
|
||||
else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package app.aaps.wear.watchfaces.utils
|
||||
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import app.aaps.wear.databinding.ActivityBigchartBinding
|
||||
import app.aaps.wear.databinding.ActivityCockpitBinding
|
||||
import app.aaps.wear.databinding.ActivityCustomBinding
|
||||
import app.aaps.wear.databinding.ActivityDigitalstyleBinding
|
||||
import app.aaps.wear.databinding.ActivityHome2Binding
|
||||
import app.aaps.wear.databinding.ActivityHomeBinding
|
||||
import app.aaps.wear.databinding.ActivityHomeLargeBinding
|
||||
import app.aaps.wear.databinding.ActivityNochartBinding
|
||||
import app.aaps.wear.databinding.ActivitySteampunkBinding
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class WatchfaceViewAdapter(
|
||||
aL: ActivityHomeLargeBinding? = null,
|
||||
a2: ActivityHome2Binding? = null,
|
||||
aa: ActivityHomeBinding? = null,
|
||||
bC: ActivityBigchartBinding? = null,
|
||||
cp: ActivityCockpitBinding? = null,
|
||||
ds: ActivityDigitalstyleBinding? = null,
|
||||
nC: ActivityNochartBinding? = null,
|
||||
sP: ActivitySteampunkBinding? = null,
|
||||
cU: ActivityCustomBinding? = null
|
||||
) {
|
||||
|
||||
init {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
private val errorMessage = "Missing require View Binding parameter"
|
||||
|
||||
// Required attributes
|
||||
val mainLayout =
|
||||
aL?.mainLayout ?: a2?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: cp?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: sP?.mainLayout ?: cU?.mainLayout
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val timestamp =
|
||||
aL?.timestamp ?: a2?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: cp?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: sP?.timestamp ?: cU?.timestamp
|
||||
?: throw IllegalArgumentException(errorMessage)
|
||||
val root =
|
||||
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
|
||||
val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction
|
||||
val loop = a2?.loop ?: cp?.loop ?: sP?.loop ?: cU?.loop
|
||||
val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
|
||||
val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
|
||||
val uploaderBattery = aL?.uploaderBattery ?: a2?.uploaderBattery ?: aa?.uploaderBattery ?: cp?.uploaderBattery ?: ds?.uploaderBattery ?: sP?.uploaderBattery ?: cU?.uploaderBattery
|
||||
val rigBattery = a2?.rigBattery ?: cp?.rigBattery ?: ds?.rigBattery ?: sP?.rigBattery ?: cU?.rigBattery
|
||||
val basalRate = a2?.basalRate ?: cp?.basalRate ?: ds?.basalRate ?: sP?.basalRate ?: cU?.basalRate
|
||||
val bgi = a2?.bgi ?: ds?.bgi ?: cU?.bgi
|
||||
val AAPSv2 = a2?.AAPSv2 ?: cp?.AAPSv2 ?: ds?.AAPSv2 ?: sP?.AAPSv2 ?: cU?.AAPSv2
|
||||
val cob1 = a2?.cob1 ?: ds?.cob1 ?: cU?.cob1
|
||||
val cob2 = a2?.cob2 ?: cp?.cob2 ?: ds?.cob2 ?: sP?.cob2 ?: cU?.cob2
|
||||
val time = aL?.time ?: a2?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: cp?.time ?: nC?.time ?: cU?.time
|
||||
val second = cU?.second
|
||||
val minute = ds?.minute ?: cU?.minute
|
||||
val hour = ds?.hour ?: cU?.hour
|
||||
val day = a2?.day ?: ds?.day ?: cU?.day
|
||||
val month = a2?.month ?: ds?.month ?: cU?.month
|
||||
val iob1 = a2?.iob1 ?: ds?.iob1 ?: cU?.iob1
|
||||
val iob2 = a2?.iob2 ?: cp?.iob2 ?: ds?.iob2 ?: sP?.iob2 ?: cU?.iob2
|
||||
val chart = a2?.chart ?: aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: sP?.chart ?: cU?.chart
|
||||
val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status
|
||||
val timePeriod = ds?.timePeriod ?: aL?.timePeriod ?: nC?.timePeriod ?: bC?.timePeriod ?: cU?.timePeriod
|
||||
val dayName = ds?.dayName ?: cU?.dayName
|
||||
val mainMenuTap = ds?.mainMenuTap ?: sP?.mainMenuTap
|
||||
val chartZoomTap = ds?.chartZoomTap ?: sP?.chartZoomTap
|
||||
val dateTime = ds?.dateTime ?: a2?.dateTime
|
||||
val weekNumber = ds?.weekNumber ?: cU?.weekNumber
|
||||
// val minuteHand = sP?.minuteHand
|
||||
// val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout ?: sP?.secondaryLayout
|
||||
// val tertiaryLayout = a2?.tertiaryLayout ?: sP?.tertiaryLayout
|
||||
// val highLight = cp?.highLight
|
||||
// val lowLight = cp?.lowLight
|
||||
// val deltaGauge = sP?.deltaPointer
|
||||
// val hourHand = sP?.hourHand
|
||||
// val glucoseDial = sP?.glucoseDial
|
||||
|
||||
companion object {
|
||||
|
||||
fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter {
|
||||
return when (bindLayout) {
|
||||
is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout)
|
||||
is ActivityHome2Binding -> WatchfaceViewAdapter(null, bindLayout)
|
||||
is ActivityHomeBinding -> WatchfaceViewAdapter(null, null, bindLayout)
|
||||
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
|
||||
is ActivityCockpitBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
|
||||
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout)
|
||||
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, bindLayout)
|
||||
is ActivitySteampunkBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, bindLayout)
|
||||
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, null, bindLayout)
|
||||
else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:id="@+id/main_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -11,11 +10,11 @@
|
|||
android:id="@+id/background"
|
||||
android:layout_width="400px"
|
||||
android:layout_height="400px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:visibility="visible"
|
||||
android:layout_marginTop="0px"
|
||||
android:orientation="vertical"
|
||||
android:src="@drawable/background"
|
||||
android:orientation="vertical" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<lecho.lib.hellocharts.view.LineChartView
|
||||
android:id="@+id/chart"
|
||||
|
@ -29,84 +28,84 @@
|
|||
android:id="@+id/cover_chart"
|
||||
android:layout_width="400px"
|
||||
android:layout_height="400px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical" />
|
||||
android:layout_marginTop="0px"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/freetext1"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:textSize="21px"
|
||||
android:layout_marginTop="0px"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/light_grey" />
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/freetext2"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:textSize="21px"
|
||||
android:layout_marginTop="0px"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/light_grey" />
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/freetext3"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:textSize="21px"
|
||||
android:layout_marginTop="0px"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/light_grey" />
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/freetext4"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:textSize="21px"
|
||||
android:layout_marginTop="0px"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/light_grey" />
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/iob1"
|
||||
android:layout_width="130px"
|
||||
android:layout_height="33px"
|
||||
android:layout_marginTop="168px"
|
||||
android:layout_marginLeft="270px"
|
||||
android:textSize="21px"
|
||||
android:layout_marginTop="168px"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
tools:text="@string/activity_IOB" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/iob2"
|
||||
android:layout_width="130px"
|
||||
android:layout_height="33px"
|
||||
android:layout_marginTop="196px"
|
||||
android:layout_marginLeft="270px"
|
||||
android:textSize="21px"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="196px"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
android:textStyle="bold"
|
||||
tools:text="@string/no_iob_u" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cob1"
|
||||
android:layout_width="120px"
|
||||
android:layout_height="33px"
|
||||
android:layout_marginTop="168px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:layout_marginTop="168px"
|
||||
android:gravity="center"
|
||||
android:text="@string/activity_carb"
|
||||
android:textColor="@color/light_grey"
|
||||
|
@ -116,36 +115,36 @@
|
|||
android:id="@+id/cob2"
|
||||
android:layout_width="120px"
|
||||
android:layout_height="33px"
|
||||
android:layout_marginTop="196px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:layout_marginTop="196px"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_cob_g"
|
||||
android:textSize="21px"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="21px"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delta"
|
||||
android:layout_width="59px"
|
||||
android:layout_height="32px"
|
||||
android:layout_marginTop="133px"
|
||||
android:layout_marginLeft="15px"
|
||||
android:layout_marginTop="133px"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="23px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
tools:text="+/-" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/avg_delta"
|
||||
android:layout_width="59px"
|
||||
android:layout_height="32px"
|
||||
android:layout_marginTop="133px"
|
||||
android:layout_marginLeft="74px"
|
||||
android:layout_marginTop="133px"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="23px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
tools:text="@string/abbreviation_average" />
|
||||
|
||||
|
||||
|
@ -153,26 +152,26 @@
|
|||
android:id="@+id/uploader_battery"
|
||||
android:layout_width="60px"
|
||||
android:layout_height="32px"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="133px"
|
||||
android:layout_marginLeft="129px"
|
||||
android:textSize="23px"
|
||||
android:layout_marginTop="133px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="23px"
|
||||
android:textStyle="bold"
|
||||
tools:text="100%" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rig_battery"
|
||||
android:layout_width="60px"
|
||||
android:layout_height="32px"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="133px"
|
||||
android:layout_marginLeft="189px"
|
||||
android:textSize="23px"
|
||||
android:layout_marginTop="133px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="23px"
|
||||
android:textStyle="bold"
|
||||
android:visibility="visible"
|
||||
tools:text="100%" />
|
||||
|
||||
|
@ -180,25 +179,25 @@
|
|||
android:id="@+id/basalRate"
|
||||
android:layout_width="91px"
|
||||
android:layout_height="32px"
|
||||
android:layout_marginTop="133px"
|
||||
android:layout_marginLeft="249px"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="133px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="23px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
tools:text="@string/no_tmp_basal_u_h" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bgi"
|
||||
android:layout_width="60px"
|
||||
android:layout_height="32px"
|
||||
android:layout_marginTop="133px"
|
||||
android:layout_marginLeft="340px"
|
||||
android:layout_marginTop="133px"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="23px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:visibility="visible"
|
||||
tools:text="bgi" />
|
||||
|
||||
|
@ -208,11 +207,11 @@
|
|||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="151px"
|
||||
android:gravity="center"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="70px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:visibility="gone"
|
||||
tools:text="22:00" />
|
||||
|
||||
|
@ -221,13 +220,13 @@
|
|||
android:id="@+id/hour"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="151px"
|
||||
android:layout_marginLeft="119px"
|
||||
android:layout_marginTop="151px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="70px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:visibility="gone"
|
||||
tools:text="20" />
|
||||
<!-- minute -->
|
||||
|
@ -235,8 +234,8 @@
|
|||
android:id="@+id/minute"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="158px"
|
||||
android:layout_marginLeft="210px"
|
||||
android:layout_marginTop="158px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="46px"
|
||||
|
@ -247,8 +246,8 @@
|
|||
android:id="@+id/second"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="158px"
|
||||
android:layout_marginLeft="210px"
|
||||
android:layout_marginTop="158px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="46px"
|
||||
|
@ -265,9 +264,9 @@
|
|||
android:layout_marginLeft="210px"
|
||||
android:layout_marginTop="205px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="17px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
android:visibility="gone"
|
||||
tools:text="AM" />
|
||||
|
||||
|
@ -275,12 +274,12 @@
|
|||
android:id="@+id/day_name"
|
||||
android:layout_width="56px"
|
||||
android:layout_height="36px"
|
||||
android:layout_marginTop="172px"
|
||||
android:layout_marginLeft="120px"
|
||||
android:layout_marginTop="172px"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/white"
|
||||
android:visibility="visible"
|
||||
tools:text="day" />
|
||||
|
||||
|
@ -288,24 +287,24 @@
|
|||
android:id="@+id/day"
|
||||
android:layout_width="56px"
|
||||
android:layout_height="36px"
|
||||
android:layout_marginTop="198px"
|
||||
android:layout_marginLeft="120px"
|
||||
android:layout_marginTop="198px"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:textSize="24px"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24px"
|
||||
android:textStyle="bold"
|
||||
tools:text="01" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/week_number"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px"
|
||||
android:layout_marginTop="0px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:layout_marginTop="0px"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24px"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:text="ww" />
|
||||
|
||||
|
@ -313,60 +312,60 @@
|
|||
android:id="@+id/month"
|
||||
android:layout_width="50px"
|
||||
android:layout_height="36px"
|
||||
android:layout_marginTop="180px"
|
||||
android:layout_marginLeft="220px"
|
||||
android:layout_marginTop="180px"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:textSize="24px"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24px"
|
||||
android:textStyle="bold"
|
||||
tools:text="févr." />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loop"
|
||||
android:layout_width="50px"
|
||||
android:layout_height="50px"
|
||||
android:layout_marginTop="61px"
|
||||
android:layout_marginLeft="68px"
|
||||
android:layout_marginTop="61px"
|
||||
android:background="@drawable/loop_grey_25"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="24px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
tools:text="--'" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/direction2"
|
||||
android:layout_width="40px"
|
||||
android:layout_height="40px"
|
||||
android:layout_marginTop="36px"
|
||||
android:layout_marginLeft="291px"
|
||||
android:visibility="visible"
|
||||
android:layout_marginTop="36px"
|
||||
android:orientation="vertical"
|
||||
android:src="@drawable/ic_invalid"
|
||||
android:orientation="vertical" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
android:layout_width="52px"
|
||||
android:layout_height="34px"
|
||||
android:gravity="left"
|
||||
android:layout_marginTop="79px"
|
||||
android:layout_marginLeft="291px"
|
||||
android:layout_marginTop="79px"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/light_grey"
|
||||
android:textSize="25px"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/light_grey"
|
||||
tools:text="--'" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sgv"
|
||||
android:layout_width="400px"
|
||||
android:layout_height="100px"
|
||||
android:layout_marginLeft="0px"
|
||||
android:layout_marginTop="26px"
|
||||
android:fontFamily="@font/roboto_condensed_bold"
|
||||
android:gravity="center"
|
||||
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:textSize="74px"
|
||||
tools:text="200" />
|
||||
|
||||
<ImageView
|
||||
|
@ -374,8 +373,8 @@
|
|||
android:layout_width="400px"
|
||||
android:layout_height="400px"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
android:src="@drawable/simplified_dial" />
|
||||
android:src="@drawable/simplified_dial"
|
||||
android:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hour_hand"
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
android:textSize="18sp"
|
||||
tools:text="Title" />
|
||||
|
||||
<info.nightscout.androidaps.nondeprecated.GridViewPagerNonDeprecated
|
||||
<app.aaps.wear.nondeprecated.GridViewPagerNonDeprecated
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:keepScreenOn="true" />
|
||||
|
||||
<info.nightscout.androidaps.nondeprecated.DotsPageIndicatorNonDeprecated
|
||||
<app.aaps.wear.nondeprecated.DotsPageIndicatorNonDeprecated
|
||||
android:id="@+id/page_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package info.nightscout.androidaps
|
||||
package app.aaps.wear
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import app.aaps.core.interfaces.sharedPreferences.SP
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.shared.tests.TestBase
|
||||
import info.nightscout.androidaps.interaction.utils.Constants
|
||||
import info.nightscout.androidaps.interaction.utils.Persistence
|
||||
import info.nightscout.androidaps.interaction.utils.WearUtil
|
||||
import info.nightscout.androidaps.testing.mocks.SharedPreferencesMock
|
||||
import app.aaps.wear.interaction.utils.Constants
|
||||
import app.aaps.wear.interaction.utils.Persistence
|
||||
import app.aaps.wear.interaction.utils.WearUtil
|
||||
import app.aaps.wear.testing.mocks.SharedPreferencesMock
|
||||
import kotlinx.datetime.Clock
|
||||
import kotlinx.datetime.Instant
|
||||
import org.junit.jupiter.api.BeforeEach
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue