Rx module
This commit is contained in:
parent
b4edb71e27
commit
4643b12414
35
app-wear-shared/rx/build.gradle
Normal file
35
app-wear-shared/rx/build.gradle
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'kotlin-allopen'
|
||||||
|
apply plugin: 'com.hiya.jacoco-android'
|
||||||
|
apply plugin: 'kotlinx-serialization'
|
||||||
|
|
||||||
|
apply from: "${project.rootDir}/core/android_dependencies.gradle"
|
||||||
|
apply from: "${project.rootDir}/core/android_module_dependencies.gradle"
|
||||||
|
apply from: "${project.rootDir}/core/test_dependencies.gradle"
|
||||||
|
apply from: "${project.rootDir}/core/jacoco_global.gradle"
|
||||||
|
|
||||||
|
android {
|
||||||
|
|
||||||
|
namespace 'info.nightscout.rx'
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 23 // for wear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
api "com.google.dagger:dagger:$dagger_version"
|
||||||
|
api "com.google.dagger:dagger-android:$dagger_version"
|
||||||
|
|
||||||
|
//Logger
|
||||||
|
api 'org.slf4j:slf4j-api:1.7.36' // 2.0.x breaks logging. Code change needed
|
||||||
|
api 'com.github.tony19:logback-android:2.0.0'
|
||||||
|
|
||||||
|
//RxBus
|
||||||
|
api "io.reactivex.rxjava3:rxjava:$rxjava_version"
|
||||||
|
api "io.reactivex.rxjava3:rxkotlin:$rxkotlin_version"
|
||||||
|
api "io.reactivex.rxjava3:rxandroid:$rxandroid_version"
|
||||||
|
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
|
||||||
|
api "org.apache.commons:commons-lang3:$commonslang3_version"
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package info.nightscout.rx.annotations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the actual annotation that makes the class open. Don't use it directly, only through [RxOpenForTesting]
|
||||||
|
* which has a NOOP replacement in production.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.ANNOTATION_CLASS)
|
||||||
|
annotation class RxOpenClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotate a class with [RxOpenForTesting] if it should be extendable for testing.
|
||||||
|
*/
|
||||||
|
@RxOpenClass
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
annotation class RxOpenForTesting
|
4
app-wear-shared/rx/src/main/AndroidManifest.xml
Normal file
4
app-wear-shared/rx/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.utils.rx
|
package info.nightscout.rx
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.rxjava3.core.Scheduler
|
import io.reactivex.rxjava3.core.Scheduler
|
|
@ -1,16 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.bus
|
package info.nightscout.rx.bus
|
||||||
|
|
||||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.events.Event
|
import info.nightscout.rx.annotations.RxOpenForTesting
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.rx.events.Event
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.rx.logging.LTag
|
||||||
import io.reactivex.rxjava3.core.Observable
|
import io.reactivex.rxjava3.core.Observable
|
||||||
import io.reactivex.rxjava3.subjects.PublishSubject
|
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@OpenForTesting
|
@RxOpenForTesting
|
||||||
@Singleton
|
@Singleton
|
||||||
class RxBus @Inject constructor(
|
class RxBus @Inject constructor(
|
||||||
val aapsSchedulers: AapsSchedulers,
|
val aapsSchedulers: AapsSchedulers,
|
||||||
|
@ -26,7 +26,7 @@ class RxBus @Inject constructor(
|
||||||
|
|
||||||
// Listen should return an Observable and not the publisher
|
// Listen should return an Observable and not the publisher
|
||||||
// Using ofType we filter only events that match that class type
|
// Using ofType we filter only events that match that class type
|
||||||
fun <T: Any> toObservable(eventType: Class<T>): Observable<T> =
|
fun <T : Any> toObservable(eventType: Class<T>): Observable<T> =
|
||||||
publisher
|
publisher
|
||||||
.subscribeOn(aapsSchedulers.io)
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.ofType(eventType)
|
.ofType(eventType)
|
|
@ -0,0 +1,25 @@
|
||||||
|
package info.nightscout.rx.di
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import info.nightscout.rx.AapsSchedulers
|
||||||
|
import info.nightscout.rx.DefaultAapsSchedulers
|
||||||
|
import info.nightscout.rx.interfaces.L
|
||||||
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
|
import info.nightscout.rx.logging.AAPSLoggerProduction
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module(
|
||||||
|
includes = [
|
||||||
|
]
|
||||||
|
)
|
||||||
|
open class RxModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
internal fun provideSchedulers(): AapsSchedulers = DefaultAapsSchedulers()
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideAAPSLogger(l: L): AAPSLogger = AAPSLoggerProduction(l)
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder
|
import org.apache.commons.lang3.builder.ReflectionToStringBuilder
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle
|
import org.apache.commons.lang3.builder.ToStringStyle
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventAcceptOpenLoopChange : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventAppExit : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventAppInitialized : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventAutosensCalculationFinished(val cause: Event?) : EventLoop()
|
class EventAutosensCalculationFinished(val cause: Event?) : EventLoop()
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventBTChange(val state: Change, val deviceName: String?, val deviceAddress: String? = null) : Event() {
|
class EventBTChange(val state: Change, val deviceName: String?, val deviceAddress: String? = null) : Event() {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventChargingState(val isCharging: Boolean, val batterLevel: Int) : Event()
|
class EventChargingState(val isCharging: Boolean, val batterLevel: Int) : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventConfigBuilderChange : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventCustomActionsChanged : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventCustomCalculationFinished : Event()
|
class EventCustomCalculationFinished : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventDanaRSyncStatus(var message: String) : Event()
|
class EventDanaRSyncStatus(var message: String) : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventExtendedBolusChange : EventLoop()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventFoodDatabaseChanged : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventInitializationChanged : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventLocalProfileChanged : Event()
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */
|
/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */
|
||||||
abstract class EventLoop : Event()
|
abstract class EventLoop : Event()
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
import info.nightscout.rx.weardata.EventData
|
||||||
|
|
||||||
|
class EventMobileToWear(val payload: EventData) : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventNSClientRestart : Event()
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventNetworkChange(
|
class EventNetworkChange(
|
||||||
var mobileConnected: Boolean = false,
|
var mobileConnected: Boolean = false,
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventNtpStatus(val status: String, val percent: Int) : Event()
|
class EventNtpStatus(val status: String, val percent: Int) : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventOfflineChange : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventProfileStoreChanged : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventProfileSwitchChanged : Event()
|
class EventProfileSwitchChanged : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventRebuildTabs constructor(var recreate: Boolean = false) : Event()
|
class EventRebuildTabs constructor(var recreate: Boolean = false) : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventRefreshOverview(var from: String, val now : Boolean = false) : Event()
|
class EventRefreshOverview(var from: String, val now : Boolean = false) : Event()
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
class EventScale(val hours: Int) : Event()
|
class EventScale(val hours: Int) : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventTempBasalChange : EventLoop()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventTempTargetChange : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventThemeSwitch : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventTherapyEventChange : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
class EventTreatmentChange : EventLoop()
|
|
@ -0,0 +1,4 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
/** Base class for events to update the UI, mostly a specific tab. */
|
||||||
|
abstract class EventUpdateGui : Event()
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
import info.nightscout.rx.weardata.EventData
|
||||||
|
|
||||||
|
class EventWearToMobile(val payload: EventData) : Event()
|
|
@ -0,0 +1,7 @@
|
||||||
|
package info.nightscout.rx.interfaces
|
||||||
|
|
||||||
|
interface L {
|
||||||
|
fun resetToDefaults()
|
||||||
|
fun findByName(name: String): LogElement
|
||||||
|
fun getLogElements(): List<LogElement>
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package info.nightscout.rx.interfaces
|
||||||
|
|
||||||
|
interface LogElement {
|
||||||
|
|
||||||
|
var name: String
|
||||||
|
var defaultValue: Boolean
|
||||||
|
var enabled: Boolean
|
||||||
|
|
||||||
|
fun enable(enabled: Boolean)
|
||||||
|
fun resetToDefault()
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.shared.logging
|
package info.nightscout.rx.logging
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by adrian on 2019-12-27.
|
* Created by adrian on 2019-12-27.
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.shared.logging
|
package info.nightscout.rx.logging
|
||||||
|
|
||||||
|
import info.nightscout.rx.interfaces.L
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.shared.logging
|
package info.nightscout.rx.logging
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by adrian on 2019-12-27.
|
* Created by adrian on 2019-12-27.
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.shared.logging
|
package info.nightscout.rx.logging
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.shared.logging
|
package info.nightscout.rx.logging
|
||||||
|
|
||||||
enum class LTag(val tag: String, val defaultValue : Boolean = true, val requiresRestart: Boolean = false) {
|
enum class LTag(val tag: String, val defaultValue : Boolean = true, val requiresRestart: Boolean = false) {
|
||||||
CORE("CORE"),
|
CORE("CORE"),
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.shared.weardata
|
package info.nightscout.rx.weardata
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event
|
import info.nightscout.rx.events.Event
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.util.*
|
import java.util.Objects
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed class EventData : Event() {
|
sealed class EventData : Event() {
|
|
@ -0,0 +1,8 @@
|
||||||
|
package info.nightscout.rx.annotations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotate a class with [DbOpenForTesting] if it should be extendable for testing.
|
||||||
|
* In production the class remains final.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
annotation class RxOpenForTesting
|
1
app-wear-shared/shared-impl/.gitignore
vendored
Normal file
1
app-wear-shared/shared-impl/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
24
app-wear-shared/shared-impl/build.gradle
Normal file
24
app-wear-shared/shared-impl/build.gradle
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'kotlin-allopen'
|
||||||
|
apply plugin: 'com.hiya.jacoco-android'
|
||||||
|
apply plugin: 'kotlinx-serialization'
|
||||||
|
|
||||||
|
apply from: "${project.rootDir}/core/android_dependencies.gradle"
|
||||||
|
apply from: "${project.rootDir}/core/android_module_dependencies.gradle"
|
||||||
|
//apply from: "${project.rootDir}/core/test_dependencies.gradle"
|
||||||
|
//apply from: "${project.rootDir}/core/jacoco_global.gradle"
|
||||||
|
|
||||||
|
android {
|
||||||
|
|
||||||
|
namespace 'info.nightscout.shared.impl'
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 23 // for wear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(':app-wear-shared:rx')
|
||||||
|
implementation project(':app-wear-shared:shared')
|
||||||
|
}
|
0
app-wear-shared/shared-impl/consumer-rules.pro
Normal file
0
app-wear-shared/shared-impl/consumer-rules.pro
Normal file
21
app-wear-shared/shared-impl/proguard-rules.pro
vendored
Normal file
21
app-wear-shared/shared-impl/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# 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
|
4
app-wear-shared/shared-impl/src/main/AndroidManifest.xml
Normal file
4
app-wear-shared/shared-impl/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -0,0 +1,19 @@
|
||||||
|
package info.nightscout.rx.di
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import info.nightcout.shared.impl.logging.LImpl
|
||||||
|
import info.nightscout.rx.interfaces.L
|
||||||
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module(
|
||||||
|
includes = [
|
||||||
|
]
|
||||||
|
)
|
||||||
|
open class SharedImplModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideL(sp: SP): L = LImpl(sp)
|
||||||
|
}
|
|
@ -1,43 +1,46 @@
|
||||||
package info.nightscout.shared.logging
|
package info.nightcout.shared.impl.logging
|
||||||
|
|
||||||
|
import info.nightscout.rx.interfaces.L
|
||||||
|
import info.nightscout.rx.interfaces.LogElement
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import java.util.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class L @Inject constructor(
|
class LImpl @Inject constructor(
|
||||||
private val sp: SP
|
private val sp: SP
|
||||||
) {
|
) : L {
|
||||||
|
|
||||||
private var logElements: MutableList<LogElement> = ArrayList()
|
private var logElements: MutableList<LogElement> = ArrayList()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
LTag.values().forEach { logElements.add(LogElement(it, sp)) }
|
LTag.values().forEach { logElements.add(LogElementImpl(it, sp)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findByName(name: String): LogElement {
|
override fun findByName(name: String): LogElement {
|
||||||
for (element in logElements) {
|
for (element in logElements) {
|
||||||
if (element.name == name) return element
|
if (element.name == name) return element
|
||||||
}
|
}
|
||||||
return LogElement(false, sp)
|
return LogElementImpl(false, sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLogElements(): List<LogElement> {
|
override fun getLogElements(): List<LogElement> {
|
||||||
return logElements
|
return logElements
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToDefaults() {
|
override fun resetToDefaults() {
|
||||||
for (element in logElements) {
|
for (element in logElements) {
|
||||||
element.resetToDefault()
|
element.resetToDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LogElement {
|
class LogElementImpl : LogElement {
|
||||||
|
|
||||||
var sp: SP
|
var sp: SP
|
||||||
var name: String
|
override var name: String
|
||||||
var defaultValue: Boolean
|
override var defaultValue: Boolean
|
||||||
var enabled: Boolean
|
override var enabled: Boolean
|
||||||
private var requiresRestart = false
|
private var requiresRestart = false
|
||||||
|
|
||||||
internal constructor(tag: LTag, sp: SP) {
|
internal constructor(tag: LTag, sp: SP) {
|
||||||
|
@ -57,12 +60,12 @@ class L @Inject constructor(
|
||||||
|
|
||||||
private fun getSPName(): String = "log_$name"
|
private fun getSPName(): String = "log_$name"
|
||||||
|
|
||||||
fun enable(enabled: Boolean) {
|
override fun enable(enabled: Boolean) {
|
||||||
this.enabled = enabled
|
this.enabled = enabled
|
||||||
sp.putBoolean(getSPName(), enabled)
|
sp.putBoolean(getSPName(), enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToDefault() {
|
override fun resetToDefault() {
|
||||||
enable(defaultValue)
|
enable(defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
1
app-wear-shared/shared/.gitignore
vendored
Normal file
1
app-wear-shared/shared/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
0
app-wear-shared/shared/consumer-rules.pro
Normal file
0
app-wear-shared/shared/consumer-rules.pro
Normal file
21
app-wear-shared/shared/proguard-rules.pro
vendored
Normal file
21
app-wear-shared/shared/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# 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
|
4
app-wear-shared/shared/src/main/AndroidManifest.xml
Normal file
4
app-wear-shared/shared/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -5,7 +5,15 @@ import android.content.res.AssetFileDescriptor
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import androidx.annotation.*
|
import androidx.annotation.ArrayRes
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.BoolRes
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.annotation.ColorRes
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.PluralsRes
|
||||||
|
import androidx.annotation.RawRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
|
||||||
interface ResourceHelper {
|
interface ResourceHelper {
|
||||||
fun updateContext(ctx: Context?)
|
fun updateContext(ctx: Context?)
|
|
@ -20,7 +20,12 @@ import java.text.SimpleDateFormat
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.EnumSet
|
||||||
|
import java.util.GregorianCalendar
|
||||||
|
import java.util.Locale
|
||||||
|
import java.util.TimeZone
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
|
@ -4,22 +4,17 @@ import android.content.Context
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
|
||||||
import info.nightscout.shared.logging.AAPSLoggerProduction
|
|
||||||
import info.nightscout.shared.logging.L
|
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.sharedPreferences.SPImplementation
|
import info.nightscout.shared.sharedPreferences.SPImplementation
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module(includes = [
|
@Module(
|
||||||
])
|
includes = [
|
||||||
|
]
|
||||||
|
)
|
||||||
open class SharedModule {
|
open class SharedModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideSharedPreferences(context: Context): SP = SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), context)
|
fun provideSharedPreferences(context: Context): SP = SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), context)
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideAAPSLogger(l: L): AAPSLogger = AAPSLoggerProduction(l)
|
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue