diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/IobIconComplication.java b/wear/src/main/java/info/nightscout/androidaps/complications/IobIconComplication.java deleted file mode 100644 index d9f66de4ac..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/complications/IobIconComplication.java +++ /dev/null @@ -1,51 +0,0 @@ -package info.nightscout.androidaps.complications; - -import android.app.PendingIntent; -import android.graphics.drawable.Icon; -import android.support.wearable.complications.ComplicationData; -import android.support.wearable.complications.ComplicationText; - -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.RawDisplayData; -import info.nightscout.androidaps.interaction.utils.SmallestDoubleString; -import info.nightscout.shared.logging.LTag; - -/* - * Created by dlvoy on 2019-11-12 - */ -@SuppressWarnings("deprecation") -public class IobIconComplication extends BaseComplicationProviderService { - - public ComplicationData buildComplicationData(int dataType, RawDisplayData raw, PendingIntent complicationPendingIntent) { - - ComplicationData complicationData = null; - - if (dataType == ComplicationData.TYPE_SHORT_TEXT) { - final String iob = new SmallestDoubleString(raw.getStatus().getIobSum(), SmallestDoubleString.Units.USE).minimise(displayFormat.MAX_FIELD_LEN_SHORT); - - final ComplicationData.Builder builder = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT) - .setShortText(ComplicationText.plainText(iob)) - .setIcon(Icon.createWithResource( - this, R.drawable.ic_ins)) - .setBurnInProtectionIcon( - Icon.createWithResource( - this, R.drawable.ic_ins_burnin)) - .setTapAction(complicationPendingIntent); - - complicationData = builder.build(); - } else { - aapsLogger.warn(LTag.WEAR, "Unexpected complication type " + dataType); - } - return complicationData; - } - - @Override - public String getProviderCanonicalName() { - return IobIconComplication.class.getCanonicalName(); - } - - @Override - public ComplicationAction getComplicationAction() { - return ComplicationAction.BOLUS; - } -} diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/IobIconComplication.kt b/wear/src/main/java/info/nightscout/androidaps/complications/IobIconComplication.kt new file mode 100644 index 0000000000..7befcd9858 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/complications/IobIconComplication.kt @@ -0,0 +1,37 @@ +@file:Suppress("DEPRECATION") + +package info.nightscout.androidaps.complications + +import android.app.PendingIntent +import android.graphics.drawable.Icon +import android.support.wearable.complications.ComplicationData +import android.support.wearable.complications.ComplicationText +import info.nightscout.androidaps.R +import info.nightscout.androidaps.data.RawDisplayData +import info.nightscout.androidaps.interaction.utils.SmallestDoubleString +import info.nightscout.shared.logging.LTag + +/* + * Created by dlvoy on 2019-11-12 + */ +class IobIconComplication : BaseComplicationProviderService() { + + override fun buildComplicationData(dataType: Int, raw: RawDisplayData, complicationPendingIntent: PendingIntent): ComplicationData? { + var complicationData: ComplicationData? = null + if (dataType == ComplicationData.TYPE_SHORT_TEXT) { + val iob = SmallestDoubleString(raw.status.iobSum, SmallestDoubleString.Units.USE).minimise(displayFormat.MAX_FIELD_LEN_SHORT) + val builder = ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT) + .setShortText(ComplicationText.plainText(iob)) + .setIcon(Icon.createWithResource(this, R.drawable.ic_ins)) + .setBurnInProtectionIcon(Icon.createWithResource(this, R.drawable.ic_ins_burnin)) + .setTapAction(complicationPendingIntent) + complicationData = builder.build() + } else { + aapsLogger.warn(LTag.WEAR, "Unexpected complication type $dataType") + } + return complicationData + } + + override fun getProviderCanonicalName(): String = IobIconComplication::class.java.canonicalName!! + override fun getComplicationAction(): ComplicationAction = ComplicationAction.BOLUS +} \ No newline at end of file