From d054ed3d1fcf99b9741ad3e28da21adad11f5d08 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 15 Oct 2023 19:26:06 +0200 Subject: [PATCH] WearPlugin -> SYNC --- .../aaps/activities/MyPreferenceFragment.kt | 2 +- .../kotlin/app/aaps/di/PluginsListModule.kt | 34 ++++----- plugins/main/build.gradle | 3 - plugins/main/src/main/AndroidManifest.xml | 4 +- .../app/aaps/plugins/main/di/PluginsModule.kt | 3 - .../app/aaps/plugins/main/di/WearModule.kt | 14 ---- plugins/main/src/main/res/values/strings.xml | 67 ------------------ plugins/sync/build.gradle | 7 +- .../dataBroadcaster/DataBroadcastPlugin.kt | 2 + .../app/aaps/plugins/sync/di/SyncModule.kt | 6 ++ .../aaps/plugins/sync/garmin/HttpServer.kt | 48 ++++++++----- .../aaps/plugins/sync}/wear/WearFragment.kt | 8 +-- .../app/aaps/plugins/sync}/wear/WearPlugin.kt | 10 +-- .../sync}/wear/activities/CwfInfosActivity.kt | 14 ++-- .../wear/wearintegration/DataHandlerMobile.kt | 5 +- .../DataLayerListenerServiceMobile.kt | 6 +- .../DataLayerListenerServiceMobileHelper.kt | 2 +- .../src/main/res/drawable/settings_off.xml | 0 .../src/main/res/drawable/settings_on.xml | 0 .../main/res/layout/cwf_infos_activity.xml | 14 ++-- .../layout/cwf_infos_activity_pref_item.xml | 2 +- .../layout/cwf_infos_activity_view_item.xml | 3 +- .../src/main/res/layout/wear_fragment.xml | 2 +- plugins/sync/src/main/res/values/strings.xml | 70 ++++++++++++++++++- .../src/main/res/xml/pref_wear.xml | 0 25 files changed, 167 insertions(+), 159 deletions(-) delete mode 100644 plugins/main/src/main/kotlin/app/aaps/plugins/main/di/WearModule.kt rename plugins/{main/src/main/kotlin/app/aaps/plugins/main/general => sync/src/main/kotlin/app/aaps/plugins/sync}/wear/WearFragment.kt (96%) rename plugins/{main/src/main/kotlin/app/aaps/plugins/main/general => sync/src/main/kotlin/app/aaps/plugins/sync}/wear/WearPlugin.kt (95%) rename plugins/{main/src/main/kotlin/app/aaps/plugins/main/general => sync/src/main/kotlin/app/aaps/plugins/sync}/wear/activities/CwfInfosActivity.kt (96%) rename plugins/{main/src/main/kotlin/app/aaps/plugins/main/general => sync/src/main/kotlin/app/aaps/plugins/sync}/wear/wearintegration/DataHandlerMobile.kt (99%) rename plugins/{main/src/main/kotlin/app/aaps/plugins/main/general => sync/src/main/kotlin/app/aaps/plugins/sync}/wear/wearintegration/DataLayerListenerServiceMobile.kt (98%) rename plugins/{main/src/main/kotlin/app/aaps/plugins/main/general => sync/src/main/kotlin/app/aaps/plugins/sync}/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt (97%) rename plugins/{main => sync}/src/main/res/drawable/settings_off.xml (100%) rename plugins/{main => sync}/src/main/res/drawable/settings_on.xml (100%) rename plugins/{main => sync}/src/main/res/layout/cwf_infos_activity.xml (94%) rename plugins/{main => sync}/src/main/res/layout/cwf_infos_activity_pref_item.xml (97%) rename plugins/{main => sync}/src/main/res/layout/cwf_infos_activity_view_item.xml (96%) rename plugins/{main => sync}/src/main/res/layout/wear_fragment.xml (99%) rename plugins/{main => sync}/src/main/res/xml/pref_wear.xml (100%) diff --git a/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt b/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt index 407c135495..28075f34f3 100644 --- a/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt @@ -44,7 +44,7 @@ import app.aaps.plugins.constraints.safety.SafetyPlugin import app.aaps.plugins.insulin.InsulinOrefFreePeakPlugin import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin 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.SensitivityOref1Plugin import app.aaps.plugins.sensitivity.SensitivityWeightedAveragePlugin diff --git a/app/src/main/kotlin/app/aaps/di/PluginsListModule.kt b/app/src/main/kotlin/app/aaps/di/PluginsListModule.kt index 02ab7bd4c6..6ea627c117 100644 --- a/app/src/main/kotlin/app/aaps/di/PluginsListModule.kt +++ b/app/src/main/kotlin/app/aaps/di/PluginsListModule.kt @@ -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.smsCommunicator.SmsCommunicatorPlugin 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.profile.ProfilePlugin import app.aaps.plugins.sensitivity.SensitivityAAPSPlugin @@ -310,12 +310,6 @@ abstract class PluginsListModule { @IntKey(320) abstract fun bindFoodPlugin(plugin: FoodPlugin): PluginBase - @Binds - @AllConfigs - @IntoMap - @IntKey(330) - abstract fun bindWearPlugin(plugin: WearPlugin): PluginBase - @Binds @AllConfigs @IntoMap @@ -341,16 +335,28 @@ abstract class PluginsListModule { abstract fun bindXdripPlugin(plugin: XdripPlugin): PluginBase @Binds - @AllConfigs + @NotNSClient @IntoMap @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 @Binds - @NotNSClient + @AllConfigs @IntoMap - @IntKey(368) - abstract fun bindsOpenHumansPlugin(plugin: OpenHumansUploaderPlugin): PluginBase + @IntKey(369) + abstract fun bindGarminPlugin(plugin: GarminPlugin): PluginBase @Binds @AllConfigs @@ -466,12 +472,6 @@ abstract class PluginsListModule { @IntKey(610) abstract fun bindAvgSmoothingPlugin(plugin: AvgSmoothingPlugin): PluginBase - @Binds - @AllConfigs - @IntoMap - @IntKey(623) - abstract fun bindGarminPlugin(plugin: GarminPlugin): PluginBase - @Qualifier annotation class AllConfigs diff --git a/plugins/main/build.gradle b/plugins/main/build.gradle index 42103017e3..fa34723f9c 100644 --- a/plugins/main/build.gradle +++ b/plugins/main/build.gradle @@ -45,7 +45,4 @@ dependencies { // Food api "androidx.work:work-runtime-ktx:$work_version" - - // DataLayerListenerService - api "com.google.android.gms:play-services-wearable:$play_services_wearable_version" } \ No newline at end of file diff --git a/plugins/main/src/main/AndroidManifest.xml b/plugins/main/src/main/AndroidManifest.xml index 26e8677ac8..a1e7d61553 100644 --- a/plugins/main/src/main/AndroidManifest.xml +++ b/plugins/main/src/main/AndroidManifest.xml @@ -24,7 +24,7 @@ @@ -35,7 +35,7 @@ android:exported="false" /> diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/PluginsModule.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/PluginsModule.kt index 0d9b1f930b..b6f2e74936 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/PluginsModule.kt +++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/PluginsModule.kt @@ -4,7 +4,6 @@ import app.aaps.core.interfaces.iob.IobCobCalculator import app.aaps.core.interfaces.smsCommunicator.SmsCommunicator import app.aaps.plugins.main.general.persistentNotification.DummyService 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.data.AutosensDataObject import dagger.Binds @@ -21,7 +20,6 @@ import dagger.android.ContributesAndroidInjector SkinsModule::class, SkinsUiModule::class, ActionsModule::class, - WearModule::class, OverviewModule::class, ] ) @@ -29,7 +27,6 @@ import dagger.android.ContributesAndroidInjector @Suppress("unused") abstract class PluginsModule { - @ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment @ContributesAndroidInjector abstract fun contributesDummyService(): DummyService @ContributesAndroidInjector abstract fun autosensDataObjectInjector(): AutosensDataObject diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/WearModule.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/WearModule.kt deleted file mode 100644 index 12b891b2a3..0000000000 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/di/WearModule.kt +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/plugins/main/src/main/res/values/strings.xml b/plugins/main/src/main/res/values/strings.xml index 9f1b4c6556..a46b55b81e 100644 --- a/plugins/main/src/main/res/values/strings.xml +++ b/plugins/main/src/main/res/values/strings.xml @@ -330,76 +330,9 @@ Send today\'s log files to developers along with this time. Unexpected situation. IobCobCalculator - - WEAR - Monitor and control AAPS using your WearOS watch. - (No Watch Connected) - Pump status - Loop status - Calc. Wizard:\nInsulin: %1$.2fU\nCarbs: %2$dg - Selected quickwizard no longer available, please refresh your tile - QuickWizard: %1$s\nInsulin: %2$.2fU\nCarbs: %3$dg - Temptarget unknown preset: %1$s - Cancelling running Temp-Targets? - Different units used on watch and phone! - Zero-Temp-Target - cancelling running Temp-Targets? - Min-BG out of range! - Max-BG out of range! - Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s - Temptarget:\nTarget: %1$s\nDuration: %2$s - Temptarget:\nReason: %1$s\nTarget: %2$s\nDuration: %3$s - not successful - please check phone - Wear settings - Controls from Watch - Set Temp-Targets and enter Treatments from the watch. - Calculations included in the Wizard result: - General Settings - Notify on SMB - Show SMB on the watch like a standard bolus. - Custom Watchface Settings - Custom Watchface Authorization - Authorize loaded custom watchface to change and lock some watch display settings to suit watchface design - Custom Watchface: %1$s - Load Watchface - Infos Watchface - Export template - Custom watchface template exported - Resend All Data - Open Settings on Wear - List of prefs locked by the Watchface - List of prefs required for the Watchface - List of fields included into the Watchface - - Ongoing Notification Shows an ongoing notification with a short overview of what your loop is doing OLD DATA - trying to fetch data from pump. - TDD: Still old data! Cannot load from pump. - g - h - No active profile switch! - Profile:\n\nTimeshift: %1$d\nPercentage: %2$d%%\" - %1$.2fU %1$.0f%% - No profile loaded - Only apply in APS mode! - Last result not available! - CLOSED LOOP - OPEN LOOP - LOOP DISABLED - APS - Last run - Last Enact - Today - weighted - Targets only apply in APS mode! - No history data! - U - Temp Target - until - DEFAULT RANGE - target - Rate: %1$.2fU/h (%2$.2f%%) \nDuration %3$d min diff --git a/plugins/sync/build.gradle b/plugins/sync/build.gradle index 7fdb1dbd8f..dc8826f9ba 100644 --- a/plugins/sync/build.gradle +++ b/plugins/sync/build.gradle @@ -19,8 +19,9 @@ dependencies { implementation project(':shared:impl') implementation project(':database:entities') implementation project(':database:impl') - implementation project(':core:main') + implementation project(':core:graphview') implementation project(':core:interfaces') + implementation project(':core:main') implementation project(':core:nssdk') implementation project(':core:ui') implementation project(':core:utils') @@ -44,9 +45,11 @@ dependencies { api("io.socket:socket.io-client:2.1.0") api "com.squareup.okhttp3:okhttp:$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:converter-gson:$retrofit2_version" api "com.google.code.gson:gson:$gson_version" + + // DataLayerListenerService + api "com.google.android.gms:play-services-wearable:$play_services_wearable_version" } \ No newline at end of file diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/dataBroadcaster/DataBroadcastPlugin.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/dataBroadcaster/DataBroadcastPlugin.kt index a4c8fb3c9e..6ee7128b16 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/dataBroadcaster/DataBroadcastPlugin.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/dataBroadcaster/DataBroadcastPlugin.kt @@ -63,7 +63,9 @@ class DataBroadcastPlugin @Inject constructor( ) : PluginBase( PluginDescription() .mainType(PluginType.SYNC) + .pluginIcon(app.aaps.core.main.R.drawable.ic_watch) .pluginName(R.string.data_broadcaster) + .shortName(R.string.data_broadcaster_short) .description(R.string.data_broadcaster_description), aapsLogger, rh, injector ) { diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/di/SyncModule.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/di/SyncModule.kt index 409af55495..fff36f508d 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/di/SyncModule.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/di/SyncModule.kt @@ -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.LoadTreatmentsWorker 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.XdripFragment import app.aaps.plugins.sync.xdrip.XdripPlugin @@ -67,6 +70,9 @@ abstract class SyncModule { @ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment @ContributesAndroidInjector abstract fun contributesXdripFragment(): XdripFragment @ContributesAndroidInjector abstract fun contributesXdripDataSyncWorker(): XdripDataSyncWorker + @ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment + @ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): DataLayerListenerServiceMobile + @ContributesAndroidInjector abstract fun contributesCustomWatchfaceInfosActivity(): CwfInfosActivity @Module open class Provide { diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/garmin/HttpServer.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/garmin/HttpServer.kt index de327c909c..c349e3cb3d 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/garmin/HttpServer.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/garmin/HttpServer.kt @@ -4,9 +4,21 @@ import android.os.StrictMode import androidx.annotation.VisibleForTesting import app.aaps.core.interfaces.logging.AAPSLogger 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.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.StandardCharsets import java.time.Duration @@ -18,10 +30,11 @@ import java.util.regex.Pattern import kotlin.concurrent.withLock /** 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 workerExecutor: Executor = Executors.newCachedThreadPool() - private val endpoints: MutableMapCharSequence> = + private val endpoints: MutableMap CharSequence> = ConcurrentHashMap() private var serverSocket: ServerSocket? = null 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. */ - fun registerEndpoint(path: String, endpoint: (SocketAddress, URI, String?)->CharSequence) { - aapsLogger.info(LTag.GARMIN,"Register: '$path'") + fun registerEndpoint(path: String, endpoint: (SocketAddress, URI, String?) -> CharSequence) { + aapsLogger.info(LTag.GARMIN, "Register: '$path'") endpoints[path] = endpoint } - // @Suppress("all") private fun respond( @Suppress("SameParameterValue") code: Int, body: CharSequence, @Suppress("SameParameterValue") contentType: String, - out: OutputStream) { + out: OutputStream + ) { 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 // on that loopback interface and cannot use InetAddress.getLoopbackAddress(). That // gives ::1 (IP6 localhost). - InetSocketAddress(Inet4Address.getByAddress(byteArrayOf(127, 0, 0, 1)), port)) - readyCond.signalAll() } - aapsLogger.info(LTag.GARMIN,"accept connections on " + serverSocket!!.localSocketAddress) + InetSocketAddress(Inet4Address.getByAddress(byteArrayOf(127, 0, 0, 1)), port) + ) + readyCond.signalAll() + } + aapsLogger.info(LTag.GARMIN, "accept connections on " + serverSocket!!.localSocketAddress) while (true) { val socket = serverSocket!!.accept() - aapsLogger.info(LTag.GARMIN,"accept " + socket.remoteSocketAddress) + aapsLogger.info(LTag.GARMIN, "accept " + socket.remoteSocketAddress) workerExecutor.execute { Thread.currentThread().name = "worker" + Thread.currentThread().id try { @@ -173,14 +188,16 @@ class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val po } companion object { + private val REQUEST_HEADER = Pattern.compile("(GET|POST) (\\S*) HTTP/1.1") private val HEADER_LINE = Pattern.compile("([A-Za-z-]+)\\s*:\\s*(.*)") private fun readLine(input: InputStream, charset: Charset): String { val buffer = ByteArrayOutputStream(input.available()) - loop@while (true) { + loop@ while (true) { when (val c = input.read()) { '\r'.code -> {} + -1 -> break@loop '\n'.code -> break@loop else -> buffer.write(c) @@ -224,10 +241,7 @@ class HttpServer internal constructor(private var aapsLogger: AAPSLogger, val po } var body: String? if (post) { - var contentLength = Int.MAX_VALUE - if (headers.containsKey("Content-Length")) { - contentLength = headers["Content-Length"]!!.toInt() - } + val contentLength = headers["Content-Length"]?.toInt() ?: Int.MAX_VALUE val keepAlive = ("Keep-Alive" == headers["Connection"]) val contentType = headers["Content-Type"] if (keepAlive && contentLength == Int.MAX_VALUE) { diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/WearFragment.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearFragment.kt similarity index 96% rename from plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/WearFragment.kt rename to plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearFragment.kt index acda63dfc0..9dc68e02ea 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/WearFragment.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearFragment.kt @@ -1,4 +1,4 @@ -package app.aaps.plugins.main.general.wear +package app.aaps.plugins.sync.wear import android.content.Intent 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.fabric.FabricPrivacy import app.aaps.core.ui.toast.ToastUtils -import app.aaps.plugins.main.R -import app.aaps.plugins.main.databinding.WearFragmentBinding -import app.aaps.plugins.main.general.wear.activities.CwfInfosActivity +import app.aaps.plugins.sync.R +import app.aaps.plugins.sync.databinding.WearFragmentBinding +import app.aaps.plugins.sync.wear.activities.CwfInfosActivity import dagger.android.support.DaggerFragment import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/WearPlugin.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt similarity index 95% rename from plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/WearPlugin.kt rename to plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt index 46cea0082b..58461db8c6 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/WearPlugin.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt @@ -1,4 +1,4 @@ -package app.aaps.plugins.main.general.wear +package app.aaps.plugins.sync.wear import android.content.Context 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.sharedPreferences.SP import app.aaps.core.interfaces.utils.fabric.FabricPrivacy -import app.aaps.plugins.main.R -import app.aaps.plugins.main.general.wear.wearintegration.DataHandlerMobile -import app.aaps.plugins.main.general.wear.wearintegration.DataLayerListenerServiceMobileHelper +import app.aaps.plugins.sync.R +import app.aaps.plugins.sync.wear.wearintegration.DataHandlerMobile +import app.aaps.plugins.sync.wear.wearintegration.DataLayerListenerServiceMobileHelper import dagger.android.HasAndroidInjector import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign @@ -44,7 +44,7 @@ class WearPlugin @Inject constructor( ) : PluginBase( PluginDescription() - .mainType(PluginType.GENERAL) + .mainType(PluginType.SYNC) .fragmentClass(WearFragment::class.java.name) .pluginIcon(app.aaps.core.main.R.drawable.ic_watch) .pluginName(app.aaps.core.ui.R.string.wear) diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/activities/CwfInfosActivity.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/activities/CwfInfosActivity.kt similarity index 96% rename from plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/activities/CwfInfosActivity.kt rename to plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/activities/CwfInfosActivity.kt index f12b2975bc..34c0776e31 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/activities/CwfInfosActivity.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/activities/CwfInfosActivity.kt @@ -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.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.versionChecker.VersionCheckerUtils import app.aaps.core.ui.activities.TranslatedDaggerAppCompatActivity -import app.aaps.plugins.main.R -import app.aaps.plugins.main.databinding.CwfInfosActivityBinding -import app.aaps.plugins.main.databinding.CwfInfosActivityPrefItemBinding -import app.aaps.plugins.main.databinding.CwfInfosActivityViewItemBinding -import app.aaps.plugins.main.general.wear.WearPlugin +import app.aaps.plugins.sync.R +import app.aaps.plugins.sync.databinding.CwfInfosActivityBinding +import app.aaps.plugins.sync.databinding.CwfInfosActivityPrefItemBinding +import app.aaps.plugins.sync.databinding.CwfInfosActivityViewItemBinding +import app.aaps.plugins.sync.wear.WearPlugin import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import org.json.JSONObject @@ -192,7 +192,7 @@ class CwfInfosActivity : TranslatedDaggerAppCompatActivity() { val visibleKeyPairs = mutableListOf>() - for (viewKey in ViewKeys.values()) { + for (viewKey in ViewKeys.entries) { try { val jsonValue = json.optJSONObject(viewKey.key) if (jsonValue != null) { diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt similarity index 99% rename from plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt rename to plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt index 7c69e06b5b..8724ca92af 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt @@ -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.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.InsertAndCancelCurrentTemporaryTargetTransaction import app.aaps.database.impl.transactions.InsertOrUpdateHeartRateTransaction -import app.aaps.plugins.main.R +import app.aaps.plugins.sync.R import dagger.android.HasAndroidInjector import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign -import org.json.JSONObject import java.text.DateFormat import java.text.SimpleDateFormat import java.util.Date diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataLayerListenerServiceMobile.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataLayerListenerServiceMobile.kt similarity index 98% rename from plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataLayerListenerServiceMobile.kt rename to plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataLayerListenerServiceMobile.kt index da33906a80..92fdea324e 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataLayerListenerServiceMobile.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataLayerListenerServiceMobile.kt @@ -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.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.utils.fabric.FabricPrivacy import app.aaps.database.impl.AppRepository -import app.aaps.plugins.main.R -import app.aaps.plugins.main.general.wear.WearPlugin +import app.aaps.plugins.sync.R +import app.aaps.plugins.sync.wear.WearPlugin import com.google.android.gms.tasks.Tasks import com.google.android.gms.wearable.CapabilityClient import com.google.android.gms.wearable.CapabilityInfo diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt similarity index 97% rename from plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt rename to plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt index 68cf866205..302e022962 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataLayerListenerServiceMobileHelper.kt @@ -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.Context diff --git a/plugins/main/src/main/res/drawable/settings_off.xml b/plugins/sync/src/main/res/drawable/settings_off.xml similarity index 100% rename from plugins/main/src/main/res/drawable/settings_off.xml rename to plugins/sync/src/main/res/drawable/settings_off.xml diff --git a/plugins/main/src/main/res/drawable/settings_on.xml b/plugins/sync/src/main/res/drawable/settings_on.xml similarity index 100% rename from plugins/main/src/main/res/drawable/settings_on.xml rename to plugins/sync/src/main/res/drawable/settings_on.xml diff --git a/plugins/main/src/main/res/layout/cwf_infos_activity.xml b/plugins/sync/src/main/res/layout/cwf_infos_activity.xml similarity index 94% rename from plugins/main/src/main/res/layout/cwf_infos_activity.xml rename to plugins/sync/src/main/res/layout/cwf_infos_activity.xml index 8648bea857..68bc98a6c1 100644 --- a/plugins/main/src/main/res/layout/cwf_infos_activity.xml +++ b/plugins/sync/src/main/res/layout/cwf_infos_activity.xml @@ -6,7 +6,7 @@ android:scrollbarStyle="outsideOverlay" android:scrollbars="vertical" android:paddingTop="2dp" - tools:context=".general.wear.activities.CwfInfosActivity"> + tools:context="app.aaps.plugins.sync.wear.activities.CwfInfosActivity"> + android:textSize="18sp" + tools:ignore="HardcodedText" /> + android:textSize="18sp" + tools:ignore="HardcodedText" /> + android:textSize="18sp" + tools:ignore="HardcodedText" /> + android:textSize="18sp" + tools:ignore="HardcodedText" /> + tools:context="app.aaps.plugins.sync.wear.WearFragment"> Data Broadcaster - Broadcast data to other apps like Garmin watch + DBRO + Broadcast data to Garmin\'s G-Watch Wear App Garmin Connection to Garmin device (Fenix, Edge, …) Garmin settings + + + WEAR + Monitor and control AAPS using your WearOS watch. + (No Watch Connected) + Pump status + Loop status + Calc. Wizard:\nInsulin: %1$.2fU\nCarbs: %2$dg + Selected quickwizard no longer available, please refresh your tile + QuickWizard: %1$s\nInsulin: %2$.2fU\nCarbs: %3$dg + Temptarget unknown preset: %1$s + Cancelling running Temp-Targets? + Different units used on watch and phone! + Zero-Temp-Target - cancelling running Temp-Targets? + Min-BG out of range! + Max-BG out of range! + Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s + Temptarget:\nTarget: %1$s\nDuration: %2$s + Temptarget:\nReason: %1$s\nTarget: %2$s\nDuration: %3$s + not successful - please check phone + Wear settings + Controls from Watch + Set Temp-Targets and enter Treatments from the watch. + Calculations included in the Wizard result: + General Settings + Notify on SMB + Show SMB on the watch like a standard bolus. + Custom Watchface Settings + Custom Watchface Authorization + Authorize loaded custom watchface to change and lock some watch display settings to suit watchface design + Custom Watchface: %1$s + Load Watchface + Infos Watchface + Export template + Custom watchface template exported + Resend All Data + Open Settings on Wear + List of prefs locked by the Watchface + List of prefs required for the Watchface + List of fields included into the Watchface + trying to fetch data from pump. + TDD: Still old data! Cannot load from pump. + U + g + h + No active profile switch! + Profile:\n\nTimeshift: %1$d\nPercentage: %2$d%%\" + Targets only apply in APS mode! + No history data! + Temp Target + until + DEFAULT RANGE + target + Rate: %1$.2fU/h (%2$.2f%%) \nDuration %3$d min + No profile loaded + Only apply in APS mode! + Last result not available! + CLOSED LOOP + OPEN LOOP + LOOP DISABLED + APS + Last run + Last Enact + %1$.2fU %1$.0f%% + Today + weighted + \ No newline at end of file diff --git a/plugins/main/src/main/res/xml/pref_wear.xml b/plugins/sync/src/main/res/xml/pref_wear.xml similarity index 100% rename from plugins/main/src/main/res/xml/pref_wear.xml rename to plugins/sync/src/main/res/xml/pref_wear.xml