WearPlugin -> SYNC

This commit is contained in:
Milos Kozak 2023-10-15 19:26:06 +02:00
parent c050313ebb
commit d054ed3d1f
25 changed files with 167 additions and 159 deletions

View file

@ -44,7 +44,7 @@ import app.aaps.plugins.constraints.safety.SafetyPlugin
import app.aaps.plugins.insulin.InsulinOrefFreePeakPlugin import app.aaps.plugins.insulin.InsulinOrefFreePeakPlugin
import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin
import app.aaps.plugins.sync.garmin.GarminPlugin import app.aaps.plugins.sync.garmin.GarminPlugin
import app.aaps.plugins.main.general.wear.WearPlugin import app.aaps.plugins.sync.wear.WearPlugin
import app.aaps.plugins.sensitivity.SensitivityAAPSPlugin import app.aaps.plugins.sensitivity.SensitivityAAPSPlugin
import app.aaps.plugins.sensitivity.SensitivityOref1Plugin import app.aaps.plugins.sensitivity.SensitivityOref1Plugin
import app.aaps.plugins.sensitivity.SensitivityWeightedAveragePlugin import app.aaps.plugins.sensitivity.SensitivityWeightedAveragePlugin

View file

@ -27,7 +27,7 @@ import app.aaps.plugins.main.general.overview.OverviewPlugin
import app.aaps.plugins.main.general.persistentNotification.PersistentNotificationPlugin import app.aaps.plugins.main.general.persistentNotification.PersistentNotificationPlugin
import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin
import app.aaps.plugins.main.general.themes.ThemeSwitcherPlugin import app.aaps.plugins.main.general.themes.ThemeSwitcherPlugin
import app.aaps.plugins.main.general.wear.WearPlugin import app.aaps.plugins.sync.wear.WearPlugin
import app.aaps.plugins.main.iob.iobCobCalculator.IobCobCalculatorPlugin import app.aaps.plugins.main.iob.iobCobCalculator.IobCobCalculatorPlugin
import app.aaps.plugins.main.profile.ProfilePlugin import app.aaps.plugins.main.profile.ProfilePlugin
import app.aaps.plugins.sensitivity.SensitivityAAPSPlugin import app.aaps.plugins.sensitivity.SensitivityAAPSPlugin
@ -310,12 +310,6 @@ abstract class PluginsListModule {
@IntKey(320) @IntKey(320)
abstract fun bindFoodPlugin(plugin: FoodPlugin): PluginBase abstract fun bindFoodPlugin(plugin: FoodPlugin): PluginBase
@Binds
@AllConfigs
@IntoMap
@IntKey(330)
abstract fun bindWearPlugin(plugin: WearPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@ -341,16 +335,28 @@ abstract class PluginsListModule {
abstract fun bindXdripPlugin(plugin: XdripPlugin): PluginBase abstract fun bindXdripPlugin(plugin: XdripPlugin): PluginBase
@Binds @Binds
@AllConfigs @NotNSClient
@IntoMap @IntoMap
@IntKey(366) @IntKey(366)
abstract fun bindsOpenHumansPlugin(plugin: OpenHumansUploaderPlugin): PluginBase
@Binds
@AllConfigs
@IntoMap
@IntKey(367)
abstract fun bindWearPlugin(plugin: WearPlugin): PluginBase
@Binds
@AllConfigs
@IntoMap
@IntKey(368)
abstract fun bindDataBroadcastPlugin(plugin: DataBroadcastPlugin): PluginBase abstract fun bindDataBroadcastPlugin(plugin: DataBroadcastPlugin): PluginBase
@Binds @Binds
@NotNSClient @AllConfigs
@IntoMap @IntoMap
@IntKey(368) @IntKey(369)
abstract fun bindsOpenHumansPlugin(plugin: OpenHumansUploaderPlugin): PluginBase abstract fun bindGarminPlugin(plugin: GarminPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@ -466,12 +472,6 @@ abstract class PluginsListModule {
@IntKey(610) @IntKey(610)
abstract fun bindAvgSmoothingPlugin(plugin: AvgSmoothingPlugin): PluginBase abstract fun bindAvgSmoothingPlugin(plugin: AvgSmoothingPlugin): PluginBase
@Binds
@AllConfigs
@IntoMap
@IntKey(623)
abstract fun bindGarminPlugin(plugin: GarminPlugin): PluginBase
@Qualifier @Qualifier
annotation class AllConfigs annotation class AllConfigs

View file

@ -45,7 +45,4 @@ dependencies {
// Food // Food
api "androidx.work:work-runtime-ktx:$work_version" api "androidx.work:work-runtime-ktx:$work_version"
// DataLayerListenerService
api "com.google.android.gms:play-services-wearable:$play_services_wearable_version"
} }

View file

@ -24,7 +24,7 @@
</activity> </activity>
<activity <activity
android:name=".general.wear.activities.CwfInfosActivity" android:name="app.aaps.plugins.sync.wear.activities.CwfInfosActivity"
android:exported="false" android:exported="false"
android:theme="@style/AppTheme" /> android:theme="@style/AppTheme" />
@ -35,7 +35,7 @@
android:exported="false" /> android:exported="false" />
<service <service
android:name=".general.wear.wearintegration.DataLayerListenerServiceMobile" android:name="app.aaps.plugins.sync.wear.wearintegration.DataLayerListenerServiceMobile"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="com.google.android.gms.wearable.CHANNEL_EVENT" /> <action android:name="com.google.android.gms.wearable.CHANNEL_EVENT" />

View file

@ -4,7 +4,6 @@ import app.aaps.core.interfaces.iob.IobCobCalculator
import app.aaps.core.interfaces.smsCommunicator.SmsCommunicator import app.aaps.core.interfaces.smsCommunicator.SmsCommunicator
import app.aaps.plugins.main.general.persistentNotification.DummyService import app.aaps.plugins.main.general.persistentNotification.DummyService
import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin
import app.aaps.plugins.main.general.wear.WearFragment
import app.aaps.plugins.main.iob.iobCobCalculator.IobCobCalculatorPlugin import app.aaps.plugins.main.iob.iobCobCalculator.IobCobCalculatorPlugin
import app.aaps.plugins.main.iob.iobCobCalculator.data.AutosensDataObject import app.aaps.plugins.main.iob.iobCobCalculator.data.AutosensDataObject
import dagger.Binds import dagger.Binds
@ -21,7 +20,6 @@ import dagger.android.ContributesAndroidInjector
SkinsModule::class, SkinsModule::class,
SkinsUiModule::class, SkinsUiModule::class,
ActionsModule::class, ActionsModule::class,
WearModule::class,
OverviewModule::class, OverviewModule::class,
] ]
) )
@ -29,7 +27,6 @@ import dagger.android.ContributesAndroidInjector
@Suppress("unused") @Suppress("unused")
abstract class PluginsModule { abstract class PluginsModule {
@ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment
@ContributesAndroidInjector abstract fun contributesDummyService(): DummyService @ContributesAndroidInjector abstract fun contributesDummyService(): DummyService
@ContributesAndroidInjector abstract fun autosensDataObjectInjector(): AutosensDataObject @ContributesAndroidInjector abstract fun autosensDataObjectInjector(): AutosensDataObject

View file

@ -1,14 +0,0 @@
package app.aaps.plugins.main.di
import app.aaps.plugins.main.general.wear.activities.CwfInfosActivity
import app.aaps.plugins.main.general.wear.wearintegration.DataLayerListenerServiceMobile
import dagger.Module
import dagger.android.ContributesAndroidInjector
@Module
@Suppress("unused")
abstract class WearModule {
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): DataLayerListenerServiceMobile
@ContributesAndroidInjector abstract fun contributesCustomWatchfaceInfosActivity(): CwfInfosActivity
}

View file

@ -330,76 +330,9 @@
<string name="send_logfiles">Send today\'s log files to developers along with this time. Unexpected situation.</string> <string name="send_logfiles">Send today\'s log files to developers along with this time. Unexpected situation.</string>
<string name="iob_cob_calculator" translatable="false">IobCobCalculator</string> <string name="iob_cob_calculator" translatable="false">IobCobCalculator</string>
<!-- Wear-->
<string name="wear_shortname">WEAR</string>
<string name="description_wear">Monitor and control AAPS using your WearOS watch.</string>
<string name="no_watch_connected">(No Watch Connected)</string>
<string name="pump_status">Pump status</string>
<string name="loop_status">Loop status</string>
<string name="wizard_result">Calc. Wizard:\nInsulin: %1$.2fU\nCarbs: %2$dg</string>
<string name="quick_wizard_not_available">Selected quickwizard no longer available, please refresh your tile</string>
<string name="quick_wizard_message">QuickWizard: %1$s\nInsulin: %2$.2fU\nCarbs: %3$dg</string>
<string name="wear_action_tempt_preset_error">Temptarget unknown preset: %1$s</string>
<string name="wear_action_tempt_cancel_message">Cancelling running Temp-Targets?</string>
<string name="wear_action_tempt_unit_error">Different units used on watch and phone!</string>
<string name="wear_action_tempt_zero_message">Zero-Temp-Target - cancelling running Temp-Targets?</string>
<string name="wear_action_tempt_min_bg_error">Min-BG out of range!</string>
<string name="wear_action_tempt_max_bg_error">Max-BG out of range!</string>
<string name="wear_action_tempt_manual_range_message">Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s</string>
<string name="wear_action_tempt_manual_message">Temptarget:\nTarget: %1$s\nDuration: %2$s</string>
<string name="wear_action_tempt_preset_message">Temptarget:\nReason: %1$s\nTarget: %2$s\nDuration: %3$s</string>
<string name="no_success">not successful - please check phone</string>
<string name="wear_settings">Wear settings</string>
<string name="wearcontrol_title">Controls from Watch</string>
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
<string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string>
<string name="wear_general_settings">General Settings</string>
<string name="wear_notifysmb_title">Notify on SMB</string>
<string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string>
<string name="wear_custom_watchface_settings">Custom Watchface Settings</string>
<string name="wear_custom_watchface_authorization_title">Custom Watchface Authorization</string>
<string name="wear_custom_watchface_authorization_summary">Authorize loaded custom watchface to change and lock some watch display settings to suit watchface design</string>
<string name="wear_custom_watchface">Custom Watchface: %1$s</string>
<string name="wear_load_watchface">Load Watchface</string>
<string name="wear_infos_watchface">Infos Watchface</string>
<string name="wear_export_watchface">Export template</string>
<string name="wear_new_custom_watchface_exported">Custom watchface template exported</string>
<string name="resend_all_data">Resend All Data</string>
<string name="open_settings_on_wear">Open Settings on Wear</string>
<string name="cwf_infos_pref_locked">List of prefs locked by the Watchface</string>
<string name="cwf_infos_pref_required">List of prefs required for the Watchface</string>
<string name="cwf_infos_view_title">List of fields included into the Watchface</string>
<!-- PersistentNotification--> <!-- PersistentNotification-->
<string name="ongoingnotificaction" translatable="false">Ongoing Notification</string> <string name="ongoingnotificaction" translatable="false">Ongoing Notification</string>
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string> <string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
<string name="old_data">OLD DATA</string> <string name="old_data">OLD DATA</string>
<string name="pump_fetching_data">trying to fetch data from pump.</string>
<string name="pump_old_data">TDD: Still old data! Cannot load from pump.</string>
<string name="grams_short">g</string>
<string name="hour_short">h</string>
<string name="no_active_profile">No active profile switch!</string>
<string name="profile_message">Profile:\n\nTimeshift: %1$d\nPercentage: %2$d%%\"</string>
<string name="tdd_line">%1$.2fU %1$.0f%%</string>
<string name="no_profile">No profile loaded</string>
<string name="aps_only">Only apply in APS mode!</string>
<string name="last_aps_result_na">Last result not available!</string>
<string name="loop_status_closed">CLOSED LOOP</string>
<string name="loop_status_open">OPEN LOOP</string>
<string name="loop_status_disabled">LOOP DISABLED</string>
<string name="aps">APS</string>
<string name="last_run">Last run</string>
<string name="last_enact">Last Enact</string>
<string name="today">Today</string>
<string name="weighted">weighted</string>
<string name="target_only_aps_mode">Targets only apply in APS mode!</string>
<string name="no_history">No history data!</string>
<string name="units_short">U</string>
<string name="temp_target">Temp Target</string>
<string name="until">until</string>
<string name="default_range">DEFAULT RANGE</string>
<string name="target">target</string>
<string name="rate_duration">Rate: %1$.2fU/h (%2$.2f%%) \nDuration %3$d min</string>
</resources> </resources>

View file

@ -19,8 +19,9 @@ dependencies {
implementation project(':shared:impl') implementation project(':shared:impl')
implementation project(':database:entities') implementation project(':database:entities')
implementation project(':database:impl') implementation project(':database:impl')
implementation project(':core:main') implementation project(':core:graphview')
implementation project(':core:interfaces') implementation project(':core:interfaces')
implementation project(':core:main')
implementation project(':core:nssdk') implementation project(':core:nssdk')
implementation project(':core:ui') implementation project(':core:ui')
implementation project(':core:utils') implementation project(':core:utils')
@ -44,9 +45,11 @@ dependencies {
api("io.socket:socket.io-client:2.1.0") api("io.socket:socket.io-client:2.1.0")
api "com.squareup.okhttp3:okhttp:$okhttp3_version" api "com.squareup.okhttp3:okhttp:$okhttp3_version"
api "com.squareup.okhttp3:logging-interceptor:$okhttp3_version" api "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
//api "com.squareup.retrofit2:retrofit:$retrofit2_version"
api "com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version" api "com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version"
api "com.squareup.retrofit2:converter-gson:$retrofit2_version" api "com.squareup.retrofit2:converter-gson:$retrofit2_version"
api "com.google.code.gson:gson:$gson_version" api "com.google.code.gson:gson:$gson_version"
// DataLayerListenerService
api "com.google.android.gms:play-services-wearable:$play_services_wearable_version"
} }

View file

@ -63,7 +63,9 @@ class DataBroadcastPlugin @Inject constructor(
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.SYNC) .mainType(PluginType.SYNC)
.pluginIcon(app.aaps.core.main.R.drawable.ic_watch)
.pluginName(R.string.data_broadcaster) .pluginName(R.string.data_broadcaster)
.shortName(R.string.data_broadcaster_short)
.description(R.string.data_broadcaster_description), .description(R.string.data_broadcaster_description),
aapsLogger, rh, injector aapsLogger, rh, injector
) { ) {

View file

@ -27,6 +27,9 @@ import app.aaps.plugins.sync.nsclientV3.workers.LoadProfileStoreWorker
import app.aaps.plugins.sync.nsclientV3.workers.LoadStatusWorker import app.aaps.plugins.sync.nsclientV3.workers.LoadStatusWorker
import app.aaps.plugins.sync.nsclientV3.workers.LoadTreatmentsWorker import app.aaps.plugins.sync.nsclientV3.workers.LoadTreatmentsWorker
import app.aaps.plugins.sync.tidepool.TidepoolFragment import app.aaps.plugins.sync.tidepool.TidepoolFragment
import app.aaps.plugins.sync.wear.WearFragment
import app.aaps.plugins.sync.wear.activities.CwfInfosActivity
import app.aaps.plugins.sync.wear.wearintegration.DataLayerListenerServiceMobile
import app.aaps.plugins.sync.xdrip.DataSyncSelectorXdripImpl import app.aaps.plugins.sync.xdrip.DataSyncSelectorXdripImpl
import app.aaps.plugins.sync.xdrip.XdripFragment import app.aaps.plugins.sync.xdrip.XdripFragment
import app.aaps.plugins.sync.xdrip.XdripPlugin import app.aaps.plugins.sync.xdrip.XdripPlugin
@ -67,6 +70,9 @@ abstract class SyncModule {
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment @ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
@ContributesAndroidInjector abstract fun contributesXdripFragment(): XdripFragment @ContributesAndroidInjector abstract fun contributesXdripFragment(): XdripFragment
@ContributesAndroidInjector abstract fun contributesXdripDataSyncWorker(): XdripDataSyncWorker @ContributesAndroidInjector abstract fun contributesXdripDataSyncWorker(): XdripDataSyncWorker
@ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): DataLayerListenerServiceMobile
@ContributesAndroidInjector abstract fun contributesCustomWatchfaceInfosActivity(): CwfInfosActivity
@Module @Module
open class Provide { open class Provide {

View file

@ -4,9 +4,21 @@ import android.os.StrictMode
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import java.io.* import java.io.BufferedOutputStream
import java.io.ByteArrayOutputStream
import java.io.Closeable
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
import java.lang.Thread.UncaughtExceptionHandler import java.lang.Thread.UncaughtExceptionHandler
import java.net.* import java.net.HttpURLConnection
import java.net.Inet4Address
import java.net.InetSocketAddress
import java.net.ServerSocket
import java.net.Socket
import java.net.SocketAddress
import java.net.SocketTimeoutException
import java.net.URI
import java.nio.charset.Charset import java.nio.charset.Charset
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.time.Duration import java.time.Duration
@ -18,10 +30,11 @@ import java.util.regex.Pattern
import kotlin.concurrent.withLock import kotlin.concurrent.withLock
/** Basic HTTP server to communicate with Garmin device via localhost. */ /** Basic HTTP server to communicate with Garmin device via localhost. */
class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val port: Int): Closeable { class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val port: Int) : Closeable {
private val serverThread: Thread private val serverThread: Thread
private val workerExecutor: Executor = Executors.newCachedThreadPool() private val workerExecutor: Executor = Executors.newCachedThreadPool()
private val endpoints: MutableMap<String, (SocketAddress, URI, String?)->CharSequence> = private val endpoints: MutableMap<String, (SocketAddress, URI, String?) -> CharSequence> =
ConcurrentHashMap() ConcurrentHashMap()
private var serverSocket: ServerSocket? = null private var serverSocket: ServerSocket? = null
private val readyLock = ReentrantLock() private val readyLock = ReentrantLock()
@ -63,18 +76,18 @@ class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val po
} }
/** Register an endpoint (path) to handle requests. */ /** Register an endpoint (path) to handle requests. */
fun registerEndpoint(path: String, endpoint: (SocketAddress, URI, String?)->CharSequence) { fun registerEndpoint(path: String, endpoint: (SocketAddress, URI, String?) -> CharSequence) {
aapsLogger.info(LTag.GARMIN,"Register: '$path'") aapsLogger.info(LTag.GARMIN, "Register: '$path'")
endpoints[path] = endpoint endpoints[path] = endpoint
} }
// @Suppress("all") // @Suppress("all")
private fun respond( private fun respond(
@Suppress("SameParameterValue") code: Int, @Suppress("SameParameterValue") code: Int,
body: CharSequence, body: CharSequence,
@Suppress("SameParameterValue") contentType: String, @Suppress("SameParameterValue") contentType: String,
out: OutputStream) { out: OutputStream
) {
respond(code, body.toString().toByteArray(Charset.forName("UTF8")), contentType, out) respond(code, body.toString().toByteArray(Charset.forName("UTF8")), contentType, out)
} }
@ -143,12 +156,14 @@ class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val po
// Garmin will only connect to IP4 localhost. Therefore, we need to explicitly listen // Garmin will only connect to IP4 localhost. Therefore, we need to explicitly listen
// on that loopback interface and cannot use InetAddress.getLoopbackAddress(). That // on that loopback interface and cannot use InetAddress.getLoopbackAddress(). That
// gives ::1 (IP6 localhost). // gives ::1 (IP6 localhost).
InetSocketAddress(Inet4Address.getByAddress(byteArrayOf(127, 0, 0, 1)), port)) InetSocketAddress(Inet4Address.getByAddress(byteArrayOf(127, 0, 0, 1)), port)
readyCond.signalAll() } )
aapsLogger.info(LTag.GARMIN,"accept connections on " + serverSocket!!.localSocketAddress) readyCond.signalAll()
}
aapsLogger.info(LTag.GARMIN, "accept connections on " + serverSocket!!.localSocketAddress)
while (true) { while (true) {
val socket = serverSocket!!.accept() val socket = serverSocket!!.accept()
aapsLogger.info(LTag.GARMIN,"accept " + socket.remoteSocketAddress) aapsLogger.info(LTag.GARMIN, "accept " + socket.remoteSocketAddress)
workerExecutor.execute { workerExecutor.execute {
Thread.currentThread().name = "worker" + Thread.currentThread().id Thread.currentThread().name = "worker" + Thread.currentThread().id
try { try {
@ -173,14 +188,16 @@ class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val po
} }
companion object { companion object {
private val REQUEST_HEADER = Pattern.compile("(GET|POST) (\\S*) HTTP/1.1") private val REQUEST_HEADER = Pattern.compile("(GET|POST) (\\S*) HTTP/1.1")
private val HEADER_LINE = Pattern.compile("([A-Za-z-]+)\\s*:\\s*(.*)") private val HEADER_LINE = Pattern.compile("([A-Za-z-]+)\\s*:\\s*(.*)")
private fun readLine(input: InputStream, charset: Charset): String { private fun readLine(input: InputStream, charset: Charset): String {
val buffer = ByteArrayOutputStream(input.available()) val buffer = ByteArrayOutputStream(input.available())
loop@while (true) { loop@ while (true) {
when (val c = input.read()) { when (val c = input.read()) {
'\r'.code -> {} '\r'.code -> {}
-1 -> break@loop -1 -> break@loop
'\n'.code -> break@loop '\n'.code -> break@loop
else -> buffer.write(c) else -> buffer.write(c)
@ -224,10 +241,7 @@ class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val po
} }
var body: String? var body: String?
if (post) { if (post) {
var contentLength = Int.MAX_VALUE val contentLength = headers["Content-Length"]?.toInt() ?: Int.MAX_VALUE
if (headers.containsKey("Content-Length")) {
contentLength = headers["Content-Length"]!!.toInt()
}
val keepAlive = ("Keep-Alive" == headers["Connection"]) val keepAlive = ("Keep-Alive" == headers["Connection"])
val contentType = headers["Content-Type"] val contentType = headers["Content-Type"]
if (keepAlive && contentLength == Int.MAX_VALUE) { if (keepAlive && contentLength == Int.MAX_VALUE) {

View file

@ -1,4 +1,4 @@
package app.aaps.plugins.main.general.wear package app.aaps.plugins.sync.wear
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -21,9 +21,9 @@ import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.DateUtil
import app.aaps.core.interfaces.utils.fabric.FabricPrivacy import app.aaps.core.interfaces.utils.fabric.FabricPrivacy
import app.aaps.core.ui.toast.ToastUtils import app.aaps.core.ui.toast.ToastUtils
import app.aaps.plugins.main.R import app.aaps.plugins.sync.R
import app.aaps.plugins.main.databinding.WearFragmentBinding import app.aaps.plugins.sync.databinding.WearFragmentBinding
import app.aaps.plugins.main.general.wear.activities.CwfInfosActivity import app.aaps.plugins.sync.wear.activities.CwfInfosActivity
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign

View file

@ -1,4 +1,4 @@
package app.aaps.plugins.main.general.wear package app.aaps.plugins.sync.wear
import android.content.Context import android.content.Context
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
@ -20,9 +20,9 @@ import app.aaps.core.interfaces.rx.weardata.CwfMetadataKey
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.fabric.FabricPrivacy import app.aaps.core.interfaces.utils.fabric.FabricPrivacy
import app.aaps.plugins.main.R import app.aaps.plugins.sync.R
import app.aaps.plugins.main.general.wear.wearintegration.DataHandlerMobile import app.aaps.plugins.sync.wear.wearintegration.DataHandlerMobile
import app.aaps.plugins.main.general.wear.wearintegration.DataLayerListenerServiceMobileHelper import app.aaps.plugins.sync.wear.wearintegration.DataLayerListenerServiceMobileHelper
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -44,7 +44,7 @@ class WearPlugin @Inject constructor(
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.SYNC)
.fragmentClass(WearFragment::class.java.name) .fragmentClass(WearFragment::class.java.name)
.pluginIcon(app.aaps.core.main.R.drawable.ic_watch) .pluginIcon(app.aaps.core.main.R.drawable.ic_watch)
.pluginName(app.aaps.core.ui.R.string.wear) .pluginName(app.aaps.core.ui.R.string.wear)

View file

@ -1,4 +1,4 @@
package app.aaps.plugins.main.general.wear.activities package app.aaps.plugins.sync.wear.activities
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -24,11 +24,11 @@ import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.fabric.FabricPrivacy import app.aaps.core.interfaces.utils.fabric.FabricPrivacy
import app.aaps.core.interfaces.versionChecker.VersionCheckerUtils import app.aaps.core.interfaces.versionChecker.VersionCheckerUtils
import app.aaps.core.ui.activities.TranslatedDaggerAppCompatActivity import app.aaps.core.ui.activities.TranslatedDaggerAppCompatActivity
import app.aaps.plugins.main.R import app.aaps.plugins.sync.R
import app.aaps.plugins.main.databinding.CwfInfosActivityBinding import app.aaps.plugins.sync.databinding.CwfInfosActivityBinding
import app.aaps.plugins.main.databinding.CwfInfosActivityPrefItemBinding import app.aaps.plugins.sync.databinding.CwfInfosActivityPrefItemBinding
import app.aaps.plugins.main.databinding.CwfInfosActivityViewItemBinding import app.aaps.plugins.sync.databinding.CwfInfosActivityViewItemBinding
import app.aaps.plugins.main.general.wear.WearPlugin import app.aaps.plugins.sync.wear.WearPlugin
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import org.json.JSONObject import org.json.JSONObject
@ -192,7 +192,7 @@ class CwfInfosActivity : TranslatedDaggerAppCompatActivity() {
val visibleKeyPairs = mutableListOf<Pair<ViewKeys, Boolean>>() val visibleKeyPairs = mutableListOf<Pair<ViewKeys, Boolean>>()
for (viewKey in ViewKeys.values()) { for (viewKey in ViewKeys.entries) {
try { try {
val jsonValue = json.optJSONObject(viewKey.key) val jsonValue = json.optJSONObject(viewKey.key)
if (jsonValue != null) { if (jsonValue != null) {

View file

@ -1,4 +1,4 @@
package app.aaps.plugins.main.general.wear.wearintegration package app.aaps.plugins.sync.wear.wearintegration
import android.app.NotificationManager import android.app.NotificationManager
import android.content.Context import android.content.Context
@ -67,11 +67,10 @@ import app.aaps.database.impl.AppRepository
import app.aaps.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction import app.aaps.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import app.aaps.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction import app.aaps.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import app.aaps.database.impl.transactions.InsertOrUpdateHeartRateTransaction import app.aaps.database.impl.transactions.InsertOrUpdateHeartRateTransaction
import app.aaps.plugins.main.R import app.aaps.plugins.sync.R
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import org.json.JSONObject
import java.text.DateFormat import java.text.DateFormat
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date

View file

@ -1,4 +1,4 @@
package app.aaps.plugins.main.general.wear.wearintegration package app.aaps.plugins.sync.wear.wearintegration
import android.os.Binder import android.os.Binder
import android.os.Handler import android.os.Handler
@ -20,8 +20,8 @@ import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.fabric.FabricPrivacy import app.aaps.core.interfaces.utils.fabric.FabricPrivacy
import app.aaps.database.impl.AppRepository import app.aaps.database.impl.AppRepository
import app.aaps.plugins.main.R import app.aaps.plugins.sync.R
import app.aaps.plugins.main.general.wear.WearPlugin import app.aaps.plugins.sync.wear.WearPlugin
import com.google.android.gms.tasks.Tasks import com.google.android.gms.tasks.Tasks
import com.google.android.gms.wearable.CapabilityClient import com.google.android.gms.wearable.CapabilityClient
import com.google.android.gms.wearable.CapabilityInfo import com.google.android.gms.wearable.CapabilityInfo

View file

@ -1,4 +1,4 @@
package app.aaps.plugins.main.general.wear.wearintegration package app.aaps.plugins.sync.wear.wearintegration
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context

View file

@ -6,7 +6,7 @@
android:scrollbarStyle="outsideOverlay" android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" android:scrollbars="vertical"
android:paddingTop="2dp" android:paddingTop="2dp"
tools:context=".general.wear.activities.CwfInfosActivity"> tools:context="app.aaps.plugins.sync.wear.activities.CwfInfosActivity">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -58,7 +58,8 @@
android:text="Author: Name" android:text="Author: Name"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor" android:textColor="?attr/importListFileNameColor"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/created_at" android:id="@+id/created_at"
@ -71,7 +72,8 @@
android:text="created at: " android:text="created at: "
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor" android:textColor="?attr/importListFileNameColor"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/cwf_version" android:id="@+id/cwf_version"
@ -85,7 +87,8 @@
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor" android:textColor="?attr/importListFileNameColor"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/cwf_comment" android:id="@+id/cwf_comment"
@ -99,7 +102,8 @@
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor" android:textColor="?attr/importListFileNameColor"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="HardcodedText" />
<LinearLayout <LinearLayout
android:id="@+id/pref_layout" android:id="@+id/pref_layout"

View file

@ -26,7 +26,7 @@
<TextView <TextView
android:id="@+id/pref_label" android:id="@+id/pref_label"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="0dp" android:layout_marginTop="0dp"

View file

@ -3,7 +3,6 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/careportal_cardview"
style="@style/Widget.MaterialComponents.CardView" style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -43,7 +42,7 @@
<TextView <TextView
android:id="@+id/view_comment" android:id="@+id/view_comment"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="3dp" android:layout_marginStart="3dp"
android:layout_marginTop="0dp" android:layout_marginTop="0dp"

View file

@ -5,7 +5,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="2dp" android:paddingTop="2dp"
tools:context=".general.wear.WearFragment"> tools:context="app.aaps.plugins.sync.wear.WearFragment">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/log" android:id="@+id/log"

View file

@ -180,10 +180,78 @@
<!-- DataBroadcast--> <!-- DataBroadcast-->
<string name="data_broadcaster">Data Broadcaster</string> <string name="data_broadcaster">Data Broadcaster</string>
<string name="data_broadcaster_description" translatable="false">Broadcast data to other apps like Garmin watch</string> <string name="data_broadcaster_short">DBRO</string>
<string name="data_broadcaster_description">Broadcast data to Garmin\'s G-Watch Wear App</string>
<!-- GarminPlugin --> <!-- GarminPlugin -->
<string name="garmin">Garmin</string> <string name="garmin">Garmin</string>
<string name="garmin_description">Connection to Garmin device (Fenix, Edge, …)</string> <string name="garmin_description">Connection to Garmin device (Fenix, Edge, …)</string>
<string name="key_garmin_settings">Garmin settings</string> <string name="key_garmin_settings">Garmin settings</string>
<!-- Wear-->
<string name="wear_shortname">WEAR</string>
<string name="description_wear">Monitor and control AAPS using your WearOS watch.</string>
<string name="no_watch_connected">(No Watch Connected)</string>
<string name="pump_status">Pump status</string>
<string name="loop_status">Loop status</string>
<string name="wizard_result">Calc. Wizard:\nInsulin: %1$.2fU\nCarbs: %2$dg</string>
<string name="quick_wizard_not_available">Selected quickwizard no longer available, please refresh your tile</string>
<string name="quick_wizard_message">QuickWizard: %1$s\nInsulin: %2$.2fU\nCarbs: %3$dg</string>
<string name="wear_action_tempt_preset_error">Temptarget unknown preset: %1$s</string>
<string name="wear_action_tempt_cancel_message">Cancelling running Temp-Targets?</string>
<string name="wear_action_tempt_unit_error">Different units used on watch and phone!</string>
<string name="wear_action_tempt_zero_message">Zero-Temp-Target - cancelling running Temp-Targets?</string>
<string name="wear_action_tempt_min_bg_error">Min-BG out of range!</string>
<string name="wear_action_tempt_max_bg_error">Max-BG out of range!</string>
<string name="wear_action_tempt_manual_range_message">Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s</string>
<string name="wear_action_tempt_manual_message">Temptarget:\nTarget: %1$s\nDuration: %2$s</string>
<string name="wear_action_tempt_preset_message">Temptarget:\nReason: %1$s\nTarget: %2$s\nDuration: %3$s</string>
<string name="no_success">not successful - please check phone</string>
<string name="wear_settings">Wear settings</string>
<string name="wearcontrol_title">Controls from Watch</string>
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
<string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string>
<string name="wear_general_settings">General Settings</string>
<string name="wear_notifysmb_title">Notify on SMB</string>
<string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string>
<string name="wear_custom_watchface_settings">Custom Watchface Settings</string>
<string name="wear_custom_watchface_authorization_title">Custom Watchface Authorization</string>
<string name="wear_custom_watchface_authorization_summary">Authorize loaded custom watchface to change and lock some watch display settings to suit watchface design</string>
<string name="wear_custom_watchface">Custom Watchface: %1$s</string>
<string name="wear_load_watchface">Load Watchface</string>
<string name="wear_infos_watchface">Infos Watchface</string>
<string name="wear_export_watchface">Export template</string>
<string name="wear_new_custom_watchface_exported">Custom watchface template exported</string>
<string name="resend_all_data">Resend All Data</string>
<string name="open_settings_on_wear">Open Settings on Wear</string>
<string name="cwf_infos_pref_locked">List of prefs locked by the Watchface</string>
<string name="cwf_infos_pref_required">List of prefs required for the Watchface</string>
<string name="cwf_infos_view_title">List of fields included into the Watchface</string>
<string name="pump_fetching_data">trying to fetch data from pump.</string>
<string name="pump_old_data">TDD: Still old data! Cannot load from pump.</string>
<string name="units_short">U</string>
<string name="grams_short">g</string>
<string name="hour_short">h</string>
<string name="no_active_profile">No active profile switch!</string>
<string name="profile_message">Profile:\n\nTimeshift: %1$d\nPercentage: %2$d%%\"</string>
<string name="target_only_aps_mode">Targets only apply in APS mode!</string>
<string name="no_history">No history data!</string>
<string name="temp_target">Temp Target</string>
<string name="until">until</string>
<string name="default_range">DEFAULT RANGE</string>
<string name="target">target</string>
<string name="rate_duration">Rate: %1$.2fU/h (%2$.2f%%) \nDuration %3$d min</string>
<string name="no_profile">No profile loaded</string>
<string name="aps_only">Only apply in APS mode!</string>
<string name="last_aps_result_na">Last result not available!</string>
<string name="loop_status_closed">CLOSED LOOP</string>
<string name="loop_status_open">OPEN LOOP</string>
<string name="loop_status_disabled">LOOP DISABLED</string>
<string name="aps">APS</string>
<string name="last_run">Last run</string>
<string name="last_enact">Last Enact</string>
<string name="tdd_line">%1$.2fU %1$.0f%%</string>
<string name="today">Today</string>
<string name="weighted">weighted</string>
</resources> </resources>