make it compile with kotlin 1.4
This commit is contained in:
parent
59afd03f95
commit
11f00d1776
26 changed files with 50 additions and 3 deletions
|
@ -99,6 +99,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Iconify.with(FontAwesomeModule())
|
||||
|
@ -359,6 +360,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
// Correct place for calling setUserStats() would be probably MainApp
|
||||
// but we need to have it called at least once a day. Thus this location
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun setUserStats() {
|
||||
if (!fabricPrivacy.fabricEnabled()) return
|
||||
val closedLoopEnabled = if (constraintChecker.isClosedLoopAllowed().value()) "CLOSED_LOOP_ENABLED" else "CLOSED_LOOP_DISABLED"
|
||||
|
|
|
@ -7,8 +7,10 @@ import javax.inject.Inject
|
|||
class RequestDexcomPermissionActivity : DialogAppCompatActivity() {
|
||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private val requestCode = "AndroidAPS <3".map { it.code }.sum()
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestPermissions(arrayOf(DexcomPlugin.PERMISSION), requestCode)
|
||||
|
|
|
@ -58,6 +58,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
@ -90,6 +91,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun updateGUI() {
|
||||
if (_binding == null) return
|
||||
openAPSAMAPlugin.lastAPSResult?.let { lastAPSResult ->
|
||||
|
|
|
@ -59,6 +59,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += rxBus
|
||||
|
@ -90,6 +91,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun updateGUI() {
|
||||
if (_binding == null) return
|
||||
openAPSSMBPlugin.lastAPSResult?.let { lastAPSResult ->
|
||||
|
|
|
@ -120,6 +120,7 @@ class ObjectivesPlugin @Inject constructor(
|
|||
sp.putBoolean(R.string.key_objectiveusescale, false)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun completeObjectives(activity: FragmentActivity, request: String) {
|
||||
val requestCode = sp.getString(R.string.key_objectives_request_code, "")
|
||||
var url = sp.getString(R.string.key_nsclientinternal_url, "").lowercase(Locale.getDefault())
|
||||
|
|
|
@ -5,7 +5,6 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -30,6 +29,7 @@ class Objective3 @Inject constructor(injector: HasAndroidInjector) : Objective(i
|
|||
override fun specialActionEnabled(): Boolean =
|
||||
nsClientPlugin.nsClientService?.isConnected == true && nsClientPlugin.nsClientService?.hasWriteAuth == true
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun specialAction(activity: FragmentActivity, input: String) {
|
||||
objectivesPlugin.completeObjectives(activity, input)
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
|||
return sb.toString()
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun singleCharUnMap(shortHash: String): String {
|
||||
val array = ByteArray(shortHash.length)
|
||||
val sb = StringBuilder()
|
||||
|
|
|
@ -67,6 +67,7 @@ class FoodFragment : DaggerFragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
@ -128,6 +129,7 @@ class FoodFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(rxBus
|
||||
|
@ -139,6 +141,7 @@ class FoodFragment : DaggerFragment() {
|
|||
swapAdapter()
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun swapAdapter() {
|
||||
disposable += repository
|
||||
.getFoodData()
|
||||
|
@ -199,6 +202,7 @@ class FoodFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun filterData() {
|
||||
val textFilter = binding.filter.text.toString()
|
||||
val categoryFilter = binding.category.selectedItem?.toString()
|
||||
|
|
|
@ -113,6 +113,7 @@ class NSClientService : DaggerService() {
|
|||
var latestDateInReceivedData: Long = 0
|
||||
|
||||
@SuppressLint("WakelockTimeout")
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
wakeLock = (getSystemService(Context.POWER_SERVICE) as PowerManager).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NSClientService")
|
||||
|
@ -236,6 +237,7 @@ class NSClientService : DaggerService() {
|
|||
return START_STICKY
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun initialize() {
|
||||
dataCounter = 0
|
||||
readPreferences()
|
||||
|
@ -650,6 +652,7 @@ class NSClientService : DaggerService() {
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun restart() {
|
||||
destroy()
|
||||
initialize()
|
||||
|
|
|
@ -2,8 +2,10 @@ package info.nightscout.androidaps.plugins.general.openhumans
|
|||
|
||||
import java.util.*
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun String.isAllowedKey() = if (startsWith("ConfigBuilder_")) true else allowedKeys.contains(this.uppercase(Locale.ROOT))
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private val allowedKeys = """
|
||||
absorption
|
||||
absorption_maxtime
|
||||
|
|
|
@ -28,6 +28,7 @@ class OHUploadWorker(context: Context, workerParameters: WorkerParameters)
|
|||
@Inject
|
||||
lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun createWork(): Single<Result> = Single.defer {
|
||||
|
||||
// Here we inject every time we create work
|
||||
|
|
|
@ -439,6 +439,7 @@ class OpenHumansUploader @Inject constructor(
|
|||
notificationManager.notify(FAILURE_NOTIFICATION_ID, notification)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun uploadDataSegmentally(): Completable =
|
||||
uploadData(UPLOAD_SEGMENT_SIZE)
|
||||
.repeatUntil { databaseHelper.getOHQueueSize() == 0L }
|
||||
|
@ -452,6 +453,7 @@ class OpenHumansUploader @Inject constructor(
|
|||
aapsLogger.error(LTag.OHUPLOADER, "Segmental upload exceptional", it)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
@Suppress("SameParameterValue")
|
||||
private fun uploadData(maxEntries: Long): Completable = gatherData(maxEntries)
|
||||
.flatMap { data -> refreshAccessTokensIfNeeded().map { accessToken -> accessToken to data } }
|
||||
|
@ -494,6 +496,7 @@ class OpenHumansUploader @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun gatherData(maxEntries: Long) = Single.defer {
|
||||
val items = databaseHelper.getAllOHQueueItems(maxEntries)
|
||||
val baos = ByteArrayOutputStream()
|
||||
|
|
|
@ -181,6 +181,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun doWork(): Result {
|
||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
|
@ -223,6 +224,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
return false
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun processSms(receivedSms: Sms) {
|
||||
if (!isEnabled(PluginType.GENERAL)) {
|
||||
aapsLogger.debug(LTag.SMS, "Ignoring SMS. Plugin disabled.")
|
||||
|
@ -334,6 +336,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processLOOP(divided: Array<String>, receivedSms: Sms) {
|
||||
when (divided[1].uppercase(Locale.getDefault())) {
|
||||
"DISABLE", "STOP" -> {
|
||||
|
@ -453,6 +456,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processNSCLIENT(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "RESTART") {
|
||||
rxBus.send(EventNSClientRestart())
|
||||
|
@ -462,6 +466,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processHELP(divided: Array<String>, receivedSms: Sms) {
|
||||
when {
|
||||
divided.size == 1 -> {
|
||||
|
@ -544,6 +549,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processPROFILE(divided: Array<String>, receivedSms: Sms) { // load profiles
|
||||
val anInterface = activePlugin.activeProfileSource
|
||||
val store = anInterface.profile
|
||||
|
@ -597,6 +603,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processBASAL(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "CANCEL" || divided[1].uppercase(Locale.getDefault()) == "STOP") {
|
||||
val passCode = generatePassCode()
|
||||
|
@ -713,6 +720,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processEXTENDED(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "CANCEL" || divided[1].uppercase(Locale.getDefault()) == "STOP") {
|
||||
val passCode = generatePassCode()
|
||||
|
@ -879,6 +887,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
return retVal
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processCARBS(divided: Array<String>, receivedSms: Sms) {
|
||||
var grams = SafeParse.stringToInt(divided[1])
|
||||
var time = dateUtil.now()
|
||||
|
@ -922,6 +931,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processTARGET(divided: Array<String>, receivedSms: Sms) {
|
||||
val isMeal = divided[1].equals("MEAL", ignoreCase = true)
|
||||
val isActivity = divided[1].equals("ACTIVITY", ignoreCase = true)
|
||||
|
|
|
@ -17,6 +17,7 @@ class JSONFormatter @Inject constructor(
|
|||
private val aapsLogger: AAPSLogger
|
||||
) {
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun format(jsonString: String?): Spanned {
|
||||
jsonString ?: return fromHtml("")
|
||||
val visitor = JsonVisitor(1, '\t')
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.junit.Assert
|
|||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
class SignatureVerifierPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -57,6 +57,7 @@ import java.util.*
|
|||
SmsManager::class, CommandQueue::class, LocalProfilePlugin::class, DateUtil::class,
|
||||
OneTimePassword::class, UserEntryLogger::class, LoopPlugin::class,
|
||||
AppRepository::class, DateUtil::class, AutosensDataStore::class)
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
||||
|
||||
@Mock lateinit var sp: SP
|
||||
|
@ -66,7 +67,6 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
|||
@Mock lateinit var loopPlugin: LoopPlugin
|
||||
@Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin
|
||||
@Mock lateinit var localProfilePlugin: LocalProfilePlugin
|
||||
@Mock lateinit var treatmentService: TreatmentService
|
||||
@Mock lateinit var otp: OneTimePassword
|
||||
@Mock lateinit var xdripCalibrations: XdripCalibrations
|
||||
@Mock lateinit var uel: UserEntryLogger
|
||||
|
|
|
@ -18,6 +18,7 @@ fun ByteArray.toHex() : String{
|
|||
return result.toString()
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun String.hexStringToByteArray(): ByteArray {
|
||||
|
||||
val result = ByteArray(length / 2)
|
||||
|
|
|
@ -105,6 +105,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun loadPreferences(file: File, masterPassword: String?): Prefs {
|
||||
|
||||
val entries: MutableMap<String, String> = mutableMapOf()
|
||||
|
|
|
@ -6,6 +6,7 @@ class PinStrengthValidator(val _customErrorMessage: String?) : Validator(_custom
|
|||
|
||||
val regex = "[0-9]{3,6}".toRegex()
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun isValid(editText: EditText): Boolean {
|
||||
return try {
|
||||
val value = editText.text.toString()
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.File
|
|||
@PowerMockIgnore("javax.crypto.*")
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(File::class)
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
class EncryptedPrefsFormatTest : TestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -141,6 +141,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
commandQueue.readStatus("DeviceChanged", null)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun connect(reason: String) {
|
||||
aapsLogger.debug(LTag.PUMP, "RS connect from: $reason")
|
||||
if (danaRSService != null && mDeviceAddress != "" && mDeviceName != "") {
|
||||
|
|
|
@ -33,6 +33,7 @@ class EnterPinActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
private lateinit var binding: DanarsEnterPinActivityBinding
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DanarsEnterPinActivityBinding.inflate(layoutInflater)
|
||||
|
|
|
@ -60,6 +60,7 @@ abstract class DanaRS_Packet_History_(
|
|||
return request
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun handleMessage(data: ByteArray) {
|
||||
val error: Int
|
||||
totalCount = 0
|
||||
|
|
|
@ -86,6 +86,7 @@ class BLEComm @Inject internal constructor(
|
|||
private var uartWrite: BluetoothGattCharacteristic? = null
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun connect(from: String, address: String?): Boolean {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing BLEComm.")
|
||||
if (bluetoothManager == null) {
|
||||
|
@ -176,6 +177,7 @@ class BLEComm @Inject internal constructor(
|
|||
bluetoothGatt = null
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private val mGattCallback: BluetoothGattCallback = object : BluetoothGattCallback() {
|
||||
override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
|
||||
onConnectionStateChangeSynchronized(gatt, newState) // call it synchronized
|
||||
|
@ -323,6 +325,7 @@ class BLEComm @Inject internal constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun readDataParsing(receivedData: ByteArray) {
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM, "readDataParsing")
|
||||
var startSignatureFound = false
|
||||
|
@ -449,6 +452,7 @@ class BLEComm @Inject internal constructor(
|
|||
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
// 1st packet response
|
||||
private fun processConnectResponse(decryptedBuffer: ByteArray) {
|
||||
// response OK v1
|
||||
|
|
|
@ -97,6 +97,7 @@ class DanaRSService : DaggerService() {
|
|||
val isConnecting: Boolean
|
||||
get() = bleComm.isConnecting
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun connect(from: String, address: String): Boolean {
|
||||
return bleComm.connect(from, address)
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class DanaRSPacketHistoryAlarmTest : DanaRSTestBase() {
|
|||
}
|
||||
|
||||
@Test
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun runTest() {
|
||||
val packet = DanaRS_Packet_History_Alarm(packetInjector, 0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue