lints
This commit is contained in:
parent
2251a20094
commit
b548325059
|
@ -363,7 +363,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
if (!fabricPrivacy.fabricEnabled()) return
|
||||
val closedLoopEnabled = if (constraintChecker.isClosedLoopAllowed().value()) "CLOSED_LOOP_ENABLED" else "CLOSED_LOOP_DISABLED"
|
||||
// Size is limited to 36 chars
|
||||
val remote = BuildConfig.REMOTE.toLowerCase(Locale.getDefault())
|
||||
val remote = BuildConfig.REMOTE.lowercase(Locale.getDefault())
|
||||
.replace("https://", "")
|
||||
.replace("http://", "")
|
||||
.replace(".git", "")
|
||||
|
|
|
@ -7,7 +7,7 @@ import javax.inject.Inject
|
|||
class RequestDexcomPermissionActivity : DialogAppCompatActivity() {
|
||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||
|
||||
private val requestCode = "AndroidAPS <3".map { it.toInt() }.sum()
|
||||
private val requestCode = "AndroidAPS <3".map { it.code }.sum()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
@ -122,7 +122,7 @@ class ObjectivesPlugin @Inject constructor(
|
|||
|
||||
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, "").toLowerCase(Locale.getDefault())
|
||||
var url = sp.getString(R.string.key_nsclientinternal_url, "").lowercase(Locale.getDefault())
|
||||
if (!url.endsWith("/")) url = "$url/"
|
||||
@Suppress("DEPRECATION") val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString()
|
||||
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
|
||||
|
|
|
@ -157,7 +157,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
|||
val sb = StringBuilder()
|
||||
for (i in array.indices) {
|
||||
if (i != 0) sb.append(":")
|
||||
sb.append(String.format("%02X", 0xFF and map[map.indexOf(shortHash[i])].toInt()))
|
||||
sb.append(String.format("%02X", 0xFF and map[map.indexOf(shortHash[i])].code))
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ class FoodFragment : DaggerFragment() {
|
|||
if (f.category == null || f.subCategory == null) continue
|
||||
if (subcategoryFilter != resourceHelper.gs(R.string.none) && f.subCategory != subcategoryFilter) continue
|
||||
if (categoryFilter != resourceHelper.gs(R.string.none) && f.category != categoryFilter) continue
|
||||
if (textFilter != "" && !f.name.toLowerCase(Locale.getDefault()).contains(textFilter.toLowerCase(Locale.getDefault()))) continue
|
||||
if (textFilter != "" && !f.name.lowercase(Locale.getDefault()).contains(textFilter.lowercase(Locale.getDefault()))) continue
|
||||
newFiltered.add(f)
|
||||
}
|
||||
filtered = newFiltered
|
||||
|
|
|
@ -251,7 +251,7 @@ class NSClientService : DaggerService() {
|
|||
} else if (!nsEnabled) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "disabled"))
|
||||
rxBus.send(EventNSClientStatus("Disabled"))
|
||||
} else if (nsURL != "" && (buildHelper.isEngineeringMode() || nsURL.toLowerCase(Locale.getDefault()).startsWith("https://"))) {
|
||||
} else if (nsURL != "" && (buildHelper.isEngineeringMode() || nsURL.lowercase(Locale.getDefault()).startsWith("https://"))) {
|
||||
try {
|
||||
rxBus.send(EventNSClientStatus("Connecting ..."))
|
||||
val opt = IO.Options()
|
||||
|
@ -279,7 +279,7 @@ class NSClientService : DaggerService() {
|
|||
rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax"))
|
||||
rxBus.send(EventNSClientStatus("Wrong URL syntax"))
|
||||
}
|
||||
} else if (nsURL.toLowerCase(Locale.getDefault()).startsWith("http://")) {
|
||||
} else if (nsURL.lowercase(Locale.getDefault()).startsWith("http://")) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "NS URL not encrypted"))
|
||||
rxBus.send(EventNSClientStatus("Not encrypted"))
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.openhumans
|
|||
|
||||
import java.util.*
|
||||
|
||||
fun String.isAllowedKey() = if (startsWith("ConfigBuilder_")) true else allowedKeys.contains(this.toUpperCase(Locale.ROOT))
|
||||
fun String.isAllowedKey() = if (startsWith("ConfigBuilder_")) true else allowedKeys.contains(this.uppercase(Locale.ROOT))
|
||||
|
||||
private val allowedKeys = """
|
||||
absorption
|
||||
|
@ -206,4 +206,4 @@ private val allowedKeys = """
|
|||
xdripstatus
|
||||
xdripstatus_detailediob
|
||||
xdripstatus_showbgi
|
||||
""".trimIndent().split("\n").filterNot { it.isBlank() }.map { it.toUpperCase() }
|
||||
""".trimIndent().split("\n").filterNot { it.isBlank() }.map { it.uppercase(Locale.getDefault()) }
|
|
@ -246,8 +246,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
T.mins(sp.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).msecs()
|
||||
else Constants.remoteBolusMinDistance
|
||||
|
||||
if (divided.isNotEmpty() && isCommand(divided[0].toUpperCase(Locale.getDefault()), receivedSms.phoneNumber)) {
|
||||
when (divided[0].toUpperCase(Locale.getDefault())) {
|
||||
if (divided.isNotEmpty() && isCommand(divided[0].uppercase(Locale.getDefault()), receivedSms.phoneNumber)) {
|
||||
when (divided[0].uppercase(Locale.getDefault())) {
|
||||
"BG" ->
|
||||
if (divided.size == 1) processBG(receivedSms)
|
||||
else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
|
@ -335,7 +335,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
private fun processLOOP(divided: Array<String>, receivedSms: Sms) {
|
||||
when (divided[1].toUpperCase(Locale.getDefault())) {
|
||||
when (divided[1].uppercase(Locale.getDefault())) {
|
||||
"DISABLE", "STOP" -> {
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
val passCode = generatePassCode()
|
||||
|
@ -454,7 +454,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
private fun processNSCLIENT(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].toUpperCase(Locale.getDefault()) == "RESTART") {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "RESTART") {
|
||||
rxBus.send(EventNSClientRestart())
|
||||
sendSMS(Sms(receivedSms.phoneNumber, "NSCLIENT RESTART SENT"))
|
||||
receivedSms.processed = true
|
||||
|
@ -469,8 +469,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
}
|
||||
|
||||
isCommand(divided[1].toUpperCase(Locale.getDefault()), receivedSms.phoneNumber) -> {
|
||||
commands[divided[1].toUpperCase(Locale.getDefault())]?.let {
|
||||
isCommand(divided[1].uppercase(Locale.getDefault()), receivedSms.phoneNumber) -> {
|
||||
commands[divided[1].uppercase(Locale.getDefault())]?.let {
|
||||
sendSMS(Sms(receivedSms.phoneNumber, it))
|
||||
receivedSms.processed = true
|
||||
}
|
||||
|
@ -554,9 +554,9 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
val profileName = profileFunction.getProfileName()
|
||||
val list = store.getProfileList()
|
||||
if (divided[1].toUpperCase(Locale.getDefault()) == "STATUS") {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "STATUS") {
|
||||
sendSMS(Sms(receivedSms.phoneNumber, profileName))
|
||||
} else if (divided[1].toUpperCase(Locale.getDefault()) == "LIST") {
|
||||
} else if (divided[1].uppercase(Locale.getDefault()) == "LIST") {
|
||||
if (list.isEmpty()) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.invalidprofile)))
|
||||
else {
|
||||
var reply = ""
|
||||
|
@ -598,7 +598,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
private fun processBASAL(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].toUpperCase(Locale.getDefault()) == "CANCEL" || divided[1].toUpperCase(Locale.getDefault()) == "STOP") {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "CANCEL" || divided[1].uppercase(Locale.getDefault()) == "STOP") {
|
||||
val passCode = generatePassCode()
|
||||
val reply = String.format(resourceHelper.gs(R.string.smscommunicator_basalstopreplywithcode), passCode)
|
||||
receivedSms.processed = true
|
||||
|
@ -714,7 +714,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
private fun processEXTENDED(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].toUpperCase(Locale.getDefault()) == "CANCEL" || divided[1].toUpperCase(Locale.getDefault()) == "STOP") {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "CANCEL" || divided[1].uppercase(Locale.getDefault()) == "STOP") {
|
||||
val passCode = generatePassCode()
|
||||
val reply = String.format(resourceHelper.gs(R.string.smscommunicator_extendedstopreplywithcode), passCode)
|
||||
receivedSms.processed = true
|
||||
|
@ -883,7 +883,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
var grams = SafeParse.stringToInt(divided[1])
|
||||
var time = dateUtil.now()
|
||||
if (divided.size > 2) {
|
||||
time = toTodayTime(divided[2].toUpperCase(Locale.getDefault()))
|
||||
time = toTodayTime(divided[2].uppercase(Locale.getDefault()))
|
||||
if (time == 0L) {
|
||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
return
|
||||
|
@ -929,7 +929,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
val isStop = divided[1].equals("STOP", ignoreCase = true) || divided[1].equals("CANCEL", ignoreCase = true)
|
||||
if (isMeal || isActivity || isHypo) {
|
||||
val passCode = generatePassCode()
|
||||
val reply = String.format(resourceHelper.gs(R.string.smscommunicator_temptargetwithcode), divided[1].toUpperCase(Locale.getDefault()), passCode)
|
||||
val reply = String.format(resourceHelper.gs(R.string.smscommunicator_temptargetwithcode), divided[1].uppercase(Locale.getDefault()), passCode)
|
||||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
|
|
|
@ -22,9 +22,9 @@ class JSONFormatter @Inject constructor(
|
|||
val visitor = JsonVisitor(1, '\t')
|
||||
return try {
|
||||
when {
|
||||
jsonString == "undefined" -> fromHtml("undefined")
|
||||
jsonString.toByteArray()[0] == '['.toByte() -> fromHtml(visitor.visit(JSONArray(jsonString), 0))
|
||||
else -> fromHtml(visitor.visit(JSONObject(jsonString), 0))
|
||||
jsonString == "undefined" -> fromHtml("undefined")
|
||||
jsonString.toByteArray()[0] == '['.code.toByte() -> fromHtml(visitor.visit(JSONArray(jsonString), 0))
|
||||
else -> fromHtml(visitor.visit(JSONObject(jsonString), 0))
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
|
|
|
@ -18,11 +18,11 @@ fun ByteArray.toHex() : String{
|
|||
return result.toString()
|
||||
}
|
||||
|
||||
fun String.hexStringToByteArray() : ByteArray {
|
||||
fun String.hexStringToByteArray(): ByteArray {
|
||||
|
||||
val result = ByteArray(length / 2)
|
||||
|
||||
val lowerCased = this.toLowerCase(Locale.getDefault())
|
||||
val lowerCased = this.lowercase(Locale.getDefault())
|
||||
for (i in 0 until length step 2) {
|
||||
val firstIndex = HEX_CHARS.indexOf(lowerCased[i])
|
||||
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1])
|
||||
|
|
|
@ -22,11 +22,11 @@ class PinStrengthValidator(val _customErrorMessage: String?) : Validator(_custom
|
|||
same = false
|
||||
}
|
||||
|
||||
if (last.toInt() + 1 != c.toInt()) {
|
||||
if (last.code + 1 != c.code) {
|
||||
falling = false
|
||||
}
|
||||
|
||||
if (last.toInt() != c.toInt() + 1) {
|
||||
if (last.code != c.code + 1) {
|
||||
rising = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,14 +199,14 @@ abstract class DanaRS_Packet_History_(
|
|||
danaRHistoryRecord.timestamp = datetimewihtsec.millis
|
||||
var strAlarm = "None"
|
||||
when (paramByte8) {
|
||||
'P'.toByte() -> strAlarm = "Basal Compare"
|
||||
'R'.toByte() -> strAlarm = "Empty Reservoir"
|
||||
'C'.toByte() -> strAlarm = "Check"
|
||||
'O'.toByte() -> strAlarm = "Occlusion"
|
||||
'M'.toByte() -> strAlarm = "Basal max"
|
||||
'D'.toByte() -> strAlarm = "Daily max"
|
||||
'B'.toByte() -> strAlarm = "Low Battery"
|
||||
'S'.toByte() -> strAlarm = "Shutdown"
|
||||
'P'.code.toByte() -> strAlarm = "Basal Compare"
|
||||
'R'.code.toByte() -> strAlarm = "Empty Reservoir"
|
||||
'C'.code.toByte() -> strAlarm = "Check"
|
||||
'O'.code.toByte() -> strAlarm = "Occlusion"
|
||||
'M'.code.toByte() -> strAlarm = "Basal max"
|
||||
'D'.code.toByte() -> strAlarm = "Daily max"
|
||||
'B'.code.toByte() -> strAlarm = "Low Battery"
|
||||
'S'.code.toByte() -> strAlarm = "Shutdown"
|
||||
}
|
||||
danaRHistoryRecord.alarm = strAlarm
|
||||
danaRHistoryRecord.value = value * 0.01
|
||||
|
|
|
@ -452,7 +452,7 @@ class BLEComm @Inject internal constructor(
|
|||
// 1st packet response
|
||||
private fun processConnectResponse(decryptedBuffer: ByteArray) {
|
||||
// response OK v1
|
||||
if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) {
|
||||
if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.code.toByte() && decryptedBuffer[3] == 'K'.code.toByte()) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||
v3Encryption = false
|
||||
danaPump.v3RSPump = false
|
||||
|
@ -466,7 +466,7 @@ class BLEComm @Inject internal constructor(
|
|||
sendPairingRequest()
|
||||
}
|
||||
// response OK v3
|
||||
} else if (decryptedBuffer.size == 9 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) {
|
||||
} else if (decryptedBuffer.size == 9 && decryptedBuffer[2] == 'O'.code.toByte() && decryptedBuffer[3] == 'K'.code.toByte()) {
|
||||
// v3 2nd layer encryption
|
||||
v3Encryption = true
|
||||
danaPump.v3RSPump = true
|
||||
|
@ -485,7 +485,7 @@ class BLEComm @Inject internal constructor(
|
|||
sendEasyMenuCheck()
|
||||
}
|
||||
// response PUMP : error status
|
||||
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) {
|
||||
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.code.toByte() && decryptedBuffer[3] == 'U'.code.toByte() && decryptedBuffer[4] == 'M'.code.toByte() && decryptedBuffer[5] == 'P'.code.toByte()) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||
mSendQueue.clear()
|
||||
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror)))
|
||||
|
@ -493,7 +493,7 @@ class BLEComm @Inject internal constructor(
|
|||
val n = Notification(Notification.PUMP_ERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(n))
|
||||
// response BUSY: error status
|
||||
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) {
|
||||
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.code.toByte() && decryptedBuffer[3] == 'U'.code.toByte() && decryptedBuffer[4] == 'S'.code.toByte() && decryptedBuffer[5] == 'Y'.code.toByte()) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||
mSendQueue.clear()
|
||||
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy)))
|
||||
|
|
Loading…
Reference in a new issue