migrate OH to sync module

This commit is contained in:
Milos Kozak 2023-02-16 16:20:02 +01:00
parent ac2d5192d7
commit c128e5c824
73 changed files with 71 additions and 153 deletions

View file

@ -200,7 +200,6 @@ dependencies {
implementation project(':plugins:constraints')
implementation project(':plugins:insulin')
implementation project(':plugins:main')
implementation project(':plugins:openhumans')
implementation project(':plugins:sensitivity')
implementation project(':plugins:smoothing')
implementation project(':plugins:source')

View file

@ -20,7 +20,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.plugins.sync.openhumans.OpenHumansUploaderPlugin
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin

View file

@ -8,7 +8,7 @@ import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.danar.di.DanaRModule
import info.nightscout.androidaps.insight.di.InsightDatabaseModule
import info.nightscout.androidaps.insight.di.InsightModule
import info.nightscout.androidaps.plugin.general.openhumans.di.OpenHumansModule
import info.nightscout.plugins.sync.di.OpenHumansModule
import info.nightscout.androidaps.plugins.pump.common.di.RileyLinkModule
import info.nightscout.androidaps.plugins.pump.eopatch.dagger.EopatchModule
import info.nightscout.androidaps.plugins.pump.medtronic.di.MedtronicModule

View file

@ -7,7 +7,7 @@ import dagger.multibindings.IntoMap
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.plugins.sync.openhumans.OpenHumansUploaderPlugin
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin

View file

@ -17,8 +17,6 @@ files:
translation: /plugins/constraints/src/main/res/values-%android_code%/%original_file_name%
- source: /plugins/automation/src/main/res/values/strings.xml
translation: /plugins/automation/src/main/res/values-%android_code%/strings.xml
- source: /plugins/openhumans/src/main/res/values/strings.xml
translation: /plugins/openhumans/src/main/res/values-%android_code%/strings.xml
- source: /plugins/sensitivity/src/main/res/values/strings.xml
translation: /plugins/sensitivity/src/main/res/values-%android_code%/strings.xml
- source: /plugins/source/src/main/res/values/strings.xml
@ -35,6 +33,8 @@ files:
translation: /plugins/sync/src/main/res/values-%android_code%/strings.xml
translate_attributes: 0
content_segmentation: 0
- source: /plugins/sync/src/main/res/values/oh_strings.xml
translation: /plugins/sync/src/main/res/values-%android_code%/oh_strings.xml
- source: /plugins/constraints/src/main/res/values/strings.xml
translation: /plugins/constraints/src/main/res/values-%android_code%/strings.xml
- source: /core/graph/src/main/res/values/strings.xml

View file

@ -1 +0,0 @@
/build

View file

@ -1,37 +0,0 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
}
apply from: "${project.rootDir}/core/main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/main/allopen_dependencies.gradle"
apply from: "${project.rootDir}/core/main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/main/jacoco_global.gradle"
android {
namespace 'info.nightscout.androidaps.plugin.general.openhumans'
}
dependencies {
implementation project(':database:entities')
implementation project(':database:impl')
implementation project(':core:interfaces')
implementation project(':app-wear-shared:shared')
api "com.squareup.okhttp3:okhttp:$okhttp3_version"
api "com.squareup.retrofit2:retrofit:$retrofit2_version"
api "androidx.browser:browser:1.5.0"
//WorkManager
api "androidx.work:work-runtime-ktx:$work_version"
//api "androidx.work:work-rxjava3:$work_version"
//api 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
api "com.google.android.material:material:$material_version"
}

View file

@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
<activity
android:name=".ui.OHLoginActivity"
android:launchMode="singleTop"
android:theme="@style/OpenHumans"
android:label="Setup Open Humans"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="setup-openhumans"
android:scheme="androidaps" />
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -31,6 +31,13 @@ dependencies {
testImplementation project(':implementation')
testImplementation project(':plugins:aps')
// OpenHuman
api "com.squareup.okhttp3:okhttp:$okhttp3_version"
api "com.squareup.retrofit2:retrofit:$retrofit2_version"
api "androidx.browser:browser:1.5.0"
api "androidx.work:work-runtime-ktx:$work_version"
api "com.google.android.material:material:$material_version"
// NSClient, Tidepool
api("io.socket:socket.io-client:2.1.0")
api "com.squareup.okhttp3:okhttp:$okhttp3_version"

View file

@ -1,11 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
<service
android:name=".nsclient.services.NSClientService"
android:enabled="true"
android:exported="true" />
<activity
android:name=".openhumans.ui.OHLoginActivity"
android:launchMode="singleTop"
android:theme="@style/OpenHumans"
android:label="Setup Open Humans"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="setup-openhumans"
android:scheme="androidaps" />
</intent-filter>
</activity>
</application>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans.di
package info.nightscout.plugins.sync.di
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans.di
package info.nightscout.plugins.sync.di
import androidx.lifecycle.ViewModel
import dagger.Binds
@ -6,11 +6,11 @@ import dagger.Module
import dagger.Provides
import dagger.android.ContributesAndroidInjector
import dagger.multibindings.IntoMap
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansWorker
import info.nightscout.androidaps.plugin.general.openhumans.delegates.OHStateDelegate
import info.nightscout.androidaps.plugin.general.openhumans.ui.OHFragment
import info.nightscout.androidaps.plugin.general.openhumans.ui.OHLoginActivity
import info.nightscout.androidaps.plugin.general.openhumans.ui.OHLoginViewModel
import info.nightscout.plugins.sync.openhumans.OpenHumansWorker
import info.nightscout.plugins.sync.openhumans.delegates.OHStateDelegate
import info.nightscout.plugins.sync.openhumans.ui.OHFragment
import info.nightscout.plugins.sync.openhumans.ui.OHLoginActivity
import info.nightscout.plugins.sync.openhumans.ui.OHLoginViewModel
@Module
abstract class OpenHumansModule {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans
package info.nightscout.plugins.sync.openhumans
import java.util.*

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugin.general.openhumans
package info.nightscout.plugins.sync.openhumans
import android.annotation.SuppressLint
import android.util.Base64
import info.nightscout.androidaps.plugin.general.openhumans.di.BaseUrl
import info.nightscout.androidaps.plugin.general.openhumans.di.ClientId
import info.nightscout.androidaps.plugin.general.openhumans.di.ClientSecret
import info.nightscout.androidaps.plugin.general.openhumans.di.RedirectUrl
import info.nightscout.plugins.sync.di.BaseUrl
import info.nightscout.plugins.sync.di.ClientId
import info.nightscout.plugins.sync.di.ClientSecret
import info.nightscout.plugins.sync.di.RedirectUrl
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.*

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans
package info.nightscout.plugins.sync.openhumans
internal data class OpenHumansState(
val accessToken: String,

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans
package info.nightscout.plugins.sync.openhumans
import android.app.NotificationChannel
import android.app.NotificationManager
@ -19,11 +19,11 @@ import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugin.general.openhumans.delegates.OHAppIDDelegate
import info.nightscout.androidaps.plugin.general.openhumans.delegates.OHCounterDelegate
import info.nightscout.androidaps.plugin.general.openhumans.delegates.OHStateDelegate
import info.nightscout.androidaps.plugin.general.openhumans.ui.OHFragment
import info.nightscout.androidaps.plugin.general.openhumans.ui.OHLoginActivity
import info.nightscout.plugins.sync.openhumans.delegates.OHAppIDDelegate
import info.nightscout.plugins.sync.openhumans.delegates.OHCounterDelegate
import info.nightscout.plugins.sync.openhumans.delegates.OHStateDelegate
import info.nightscout.plugins.sync.openhumans.ui.OHFragment
import info.nightscout.plugins.sync.openhumans.ui.OHLoginActivity
import info.nightscout.database.entities.data.Block
import info.nightscout.database.entities.interfaces.TraceableDBEntry
import info.nightscout.database.impl.AppRepository
@ -31,6 +31,7 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.sync.Sync
import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventPreferenceChange
import info.nightscout.rx.logging.AAPSLogger

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans
package info.nightscout.plugins.sync.openhumans
import android.content.Context
import androidx.work.CoroutineWorker

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans.delegates
package info.nightscout.plugins.sync.openhumans.delegates
import info.nightscout.shared.sharedPreferences.SP
import java.util.*

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans.delegates
package info.nightscout.plugins.sync.openhumans.delegates
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugin.general.openhumans.delegates
package info.nightscout.plugins.sync.openhumans.delegates
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansState
import info.nightscout.plugins.sync.openhumans.OpenHumansState
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans.ui
package info.nightscout.plugins.sync.openhumans.ui
import android.content.Intent
import android.os.Bundle
@ -10,15 +10,16 @@ import androidx.appcompat.view.ContextThemeWrapper
import androidx.lifecycle.LiveData
import com.google.android.material.button.MaterialButton
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansState
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.androidaps.plugin.general.openhumans.R
import info.nightscout.plugins.sync.openhumans.OpenHumansState
import info.nightscout.plugins.sync.openhumans.OpenHumansUploaderPlugin
import info.nightscout.plugins.sync.R
import javax.inject.Inject
class OHFragment : DaggerFragment() {
@Inject
internal lateinit var stateLiveData: LiveData<OpenHumansState?>
@Inject
internal lateinit var plugin: OpenHumansUploaderPlugin

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugin.general.openhumans.ui
package info.nightscout.plugins.sync.openhumans.ui
import android.content.Intent
import android.net.Uri
@ -16,9 +16,9 @@ import androidx.core.widget.NestedScrollView
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton
import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.plugin.general.openhumans.R
import info.nightscout.androidaps.plugin.general.openhumans.di.AuthUrl
import info.nightscout.androidaps.plugin.general.openhumans.di.ViewModelFactory
import info.nightscout.plugins.sync.di.AuthUrl
import info.nightscout.plugins.sync.di.ViewModelFactory
import info.nightscout.plugins.sync.R
import javax.inject.Inject
class OHLoginActivity : DaggerAppCompatActivity() {

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugin.general.openhumans.ui
package info.nightscout.plugins.sync.openhumans.ui
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.plugins.sync.openhumans.OpenHumansUploaderPlugin
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
@ -31,7 +31,7 @@ internal class OHLoginViewModel @Inject constructor(
_state.value = State.CONSENT
true
}
else -> false
else -> false
}
fun submitBearerToken(bearerToken: String) {

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
tools:context="info.nightscout.androidaps.plugin.general.openhumans.ui.OHLoginActivity">
tools:context=".openhumans.ui.OHLoginActivity">
<FrameLayout
android:layout_width="match_parent"

View file

@ -25,5 +25,4 @@
<string name="agree">Разбирам и съм съгласен.</string>
<string name="cancel">Откажи</string>
<string name="close">Затвори</string>
<string name="upload_now">Качи сега</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Jsme hotovi!</string>
<string name="silently_upload_date_note">Od této chvíle bude telefon čas od času tiše nahrávat data na pozadí.</string>
<string name="close">Zavřít</string>
<string name="upload_now">Nahrát nyní</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Vi er færdige!</string>
<string name="silently_upload_date_note">Fra nu af vil telefonen lydløst uploade data i baggrunden fra tid til anden.</string>
<string name="close">Luk</string>
<string name="upload_now">Upload nu</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Wir sind fertig!</string>
<string name="silently_upload_date_note">Von nun an wird Ihr Telefon von Zeit zu Zeit stillschweigend Daten im Hintergrund hochladen.</string>
<string name="close">Schließen</string>
<string name="upload_now">Jetzt hochladen</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">¡Terminamos!</string>
<string name="silently_upload_date_note">A partir de ahora, el teléfono cargará datos silenciosamente en segundo plano, de vez en cuando.</string>
<string name="close">Cerrar</string>
<string name="upload_now">Subir ahora</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Nous avons terminé !</string>
<string name="silently_upload_date_note">Désormais, votre téléphone téléversera les données en arrière-plan de temps en temps.</string>
<string name="close">Fermer</string>
<string name="upload_now">Télécharger maintenant</string>
</resources>

View file

@ -39,5 +39,4 @@
<string name="we_re_done">Gotovi smo!</string>
<string name="silently_upload_date_note">Od sada će vaš telefon s vremena na vrijeme tiho prenositi podatke u pozadini.</string>
<string name="close">Zatvori</string>
<string name="upload_now">Pošalji sada</string>
</resources>

View file

@ -18,5 +18,4 @@
<string name="settings">Beállítások</string>
<string name="nightscout_url">Nightscout URL</string>
<string name="cancel">Mégse</string>
<string name="upload_now">Feltöltés most</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Abbiamo fatto!</string>
<string name="silently_upload_date_note">D\'ora in poi, il tuo telefono caricherà i dati in background di tanto in tanto.</string>
<string name="close">Chiudi</string>
<string name="upload_now">Carica adesso</string>
</resources>

View file

@ -52,5 +52,4 @@
<string name="we_re_done">סיימנו!</string>
<string name="silently_upload_date_note">מעתה ואילך, הטלפון שלכם יעלה מדי פעם נתונים ברקע.</string>
<string name="close">סגור</string>
<string name="upload_now">העלה עכשיו</string>
</resources>

View file

@ -25,5 +25,4 @@
<string name="agree">이해하고 동의합니다.</string>
<string name="cancel">취소</string>
<string name="close">닫기</string>
<string name="upload_now">지금 업로드하기</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Užbaigta!</string>
<string name="silently_upload_date_note">Nuo šiol telefonas kartkartėmis tyliai fone įkels duomenis.</string>
<string name="close">Uždaryti</string>
<string name="upload_now">Įkelti dabar</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">We zijn klaar!</string>
<string name="silently_upload_date_note">Voortaan zal je telefoon zo nu en dan op de achtergrond gegevens uploaden.</string>
<string name="close">Sluiten</string>
<string name="upload_now">Nu Uploaden</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Vi er ferdig!</string>
<string name="silently_upload_date_note">Fra nå av vil telefonen din med jevne mellomrom i bakgrunnen overføre en kopi av dine nye brukerdata.</string>
<string name="close">Lukk</string>
<string name="upload_now">Last opp nå</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Gotowe!</string>
<string name="silently_upload_date_note">Od teraz Twój telefon będzie od czasu do czasu przesyłać dane w tle.</string>
<string name="close">Zamknij</string>
<string name="upload_now">Prześlij teraz</string>
</resources>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Estamos prontos!</string>
<string name="silently_upload_date_note">De agora em diante, o telefone fará o upload silencioso de dados em segundo plano de vez em quando.</string>
<string name="close">Fechar</string>
<string name="upload_now">Enviar agora</string>
</resources>

View file

@ -25,5 +25,4 @@
<string name="agree">Compreendo e concordo.</string>
<string name="cancel">Cancelar</string>
<string name="close">Fechar</string>
<string name="upload_now">Fazer o upload agora</string>
</resources>

View file

@ -25,5 +25,4 @@
<string name="agree">Înţeleg şi sunt de acord.</string>
<string name="cancel">Renunță</string>
<string name="close">Închide</string>
<string name="upload_now">Încarcă acum</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Готово!</string>
<string name="silently_upload_date_note">С этого момента ваш телефон будет иногда загружать данные в фоновом режиме.</string>
<string name="close">Закрыть</string>
<string name="upload_now">Начать передачу данных</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Skončili sme!</string>
<string name="silently_upload_date_note">Od tejto chvíle bude telefón čas od času potichu nahrávať dáta na pozadí.</string>
<string name="close">Zavrieť</string>
<string name="upload_now">Nahrať teraz</string>
</resources>

View file

@ -25,5 +25,4 @@
<string name="agree">Jag förstår och instämmer.</string>
<string name="cancel">Avbryt</string>
<string name="close">Stäng</string>
<string name="upload_now">Ladda upp nu</string>
</resources>

View file

@ -53,5 +53,4 @@
<string name="we_re_done">Bitirdik!</string>
<string name="silently_upload_date_note">Artık telefonunuz zaman zaman arka planda sessizce veri yükleyecektir.</string>
<string name="close">Kapat</string>
<string name="upload_now">Şimdi yükle</string>
</resources>

View file

@ -52,5 +52,4 @@
<string name="we_re_done">成功完成!</string>
<string name="silently_upload_date_note">从现在起,您的手机将不时在后台自动上传数据</string>
<string name="close">关闭</string>
<string name="upload_now">现在上传</string>
</resources>

View file

@ -54,6 +54,4 @@
<string name="we_re_done">We\'re done!</string>
<string name="silently_upload_date_note">From now on, your phone will silently upload data in the background from time to time.</string>
<string name="close">Close</string>
<string name="upload_now">Upload now</string>
</resources>

View file

@ -19,7 +19,6 @@ include ':plugins:configuration'
include ':plugins:constraints'
include ':plugins:insulin'
include ':plugins:main'
include ':plugins:openhumans'
include ':plugins:sensitivity'
include ':plugins:smoothing'
include ':plugins:source'