more kotlin conversion

This commit is contained in:
Milos Kozak 2021-03-07 15:31:05 +01:00
parent 563bee2faf
commit 20cabd00bb
7 changed files with 35 additions and 55 deletions

View file

@ -1,21 +0,0 @@
package info.nightscout.androidaps.logging;
import android.os.Bundle;
/**
* Created by mike on 14.08.2017.
*/
public class BundleLogger {
public static String log(Bundle bundle) {
if (bundle == null) {
return null;
}
String string = "Bundle{";
for (String key : bundle.keySet()) {
string += " " + key + " => " + bundle.get(key) + ";";
}
string += " }Bundle";
return string;
}
}

View file

@ -0,0 +1,18 @@
package info.nightscout.androidaps.logging
import android.os.Bundle
object BundleLogger {
fun log(bundle: Bundle?): String {
if (bundle == null) {
return "null"
}
var string = "Bundle{"
for (key in bundle.keySet()) {
string += " " + key + " => " + bundle[key] + ";"
}
string += " }Bundle"
return string
}
}

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.common;
public enum ManufacturerType {
AndroidAPS("AndroidAPS"),
Medtronic("Medtronic"),
Sooil("SOOIL"),
Tandem("Tandem"),
Insulet("Insulet"),
Animas("Animas"),
Cellnovo("Cellnovo"),
Roche("Roche"),
Ypsomed("Ypsomed");
private final String description;
ManufacturerType(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}

View file

@ -0,0 +1,13 @@
package info.nightscout.androidaps.plugins.common
enum class ManufacturerType(val description: String) {
AndroidAPS("AndroidAPS"),
Medtronic("Medtronic"),
Sooil("SOOIL"),
Tandem("Tandem"),
Insulet("Insulet"),
Animas("Animas"),
Cellnovo("Cellnovo"),
Roche("Roche"),
Ypsomed("Ypsomed");
}

View file

@ -88,7 +88,7 @@ class ProfileFunctionImplementation @Inject constructor(
} }
if (activeTreatments.profileSwitchesFromHistory.size() > 0) { if (activeTreatments.profileSwitchesFromHistory.size() > 0) {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "CatchedError") bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "CaughtError")
bundle.putString(FirebaseAnalytics.Param.START_DATE, time.toString()) bundle.putString(FirebaseAnalytics.Param.START_DATE, time.toString())
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, activeTreatments.profileSwitchesFromHistory.toString()) bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, activeTreatments.profileSwitchesFromHistory.toString())
fabricPrivacy.logCustom(bundle) fabricPrivacy.logCustom(bundle)

View file

@ -83,7 +83,7 @@ class RunningConfiguration @Inject constructor(
val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GenericAAPS.description) val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GenericAAPS.description)
sp.putString(R.string.key_virtualpump_type, pumpType) sp.putString(R.string.key_virtualpump_type, pumpType)
activePlugin.activePump.pumpDescription.setPumpDescription(PumpType.getByDescription(pumpType)) activePlugin.activePump.pumpDescription.setPumpDescription(PumpType.getByDescription(pumpType))
aapsLogger.debug(LTag.CORE, "Changing pump type to ${pumpType}") aapsLogger.debug(LTag.CORE, "Changing pump type to $pumpType")
} }
if (configuration.has("overviewConfiguration")) if (configuration.has("overviewConfiguration"))

View file

@ -140,7 +140,7 @@ fun String.numericVersionPart(): String =
"(((\\d+)\\.)+(\\d+))(\\D(.*))?".toRegex().matchEntire(this)?.groupValues?.getOrNull(1) "(((\\d+)\\.)+(\\d+))(\\D(.*))?".toRegex().matchEntire(this)?.groupValues?.getOrNull(1)
?: "" ?: ""
fun findVersion(file: String?): String? { @Suppress("unused") fun findVersion(file: String?): String? {
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex() val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
return file?.lines()?.filter { regex.matches(it) }?.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }?.firstOrNull() return file?.lines()?.filter { regex.matches(it) }?.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }?.firstOrNull()
} }