From 759c81f10ec079bf4962b2edaca9ec9c4e27ed9f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 2 May 2022 22:24:06 +0200 Subject: [PATCH] CobIconComplication -> kt --- .../complications/CobIconComplication.java | 48 ------------------- .../complications/CobIconComplication.kt | 35 ++++++++++++++ 2 files changed, 35 insertions(+), 48 deletions(-) delete mode 100644 wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.kt diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.java b/wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.java deleted file mode 100644 index a0dcde11b7..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.java +++ /dev/null @@ -1,48 +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.shared.logging.LTag; - -/* - * Created by dlvoy on 2019-11-12 - */ -@SuppressWarnings("deprecation") -public class CobIconComplication extends BaseComplicationProviderService { - - public ComplicationData buildComplicationData(int dataType, RawDisplayData raw, PendingIntent complicationPendingIntent) { - - ComplicationData complicationData = null; - - if (dataType == ComplicationData.TYPE_SHORT_TEXT) { - final ComplicationData.Builder builder = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT) - .setShortText(ComplicationText.plainText(raw.getStatus().getCob())) - .setIcon( - Icon.createWithResource( - this, R.drawable.ic_carbs)) - .setBurnInProtectionIcon( - Icon.createWithResource( - this, R.drawable.ic_carbs)) - .setTapAction(complicationPendingIntent); - - complicationData = builder.build(); - } else { - aapsLogger.warn(LTag.WEAR, "Unexpected complication type " + dataType); - } - return complicationData; - } - - @Override - public String getProviderCanonicalName() { - return CobIconComplication.class.getCanonicalName(); - } - - public ComplicationAction getComplicationAction() { - return ComplicationAction.WIZARD; - } -} diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.kt b/wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.kt new file mode 100644 index 0000000000..9c38290f75 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/complications/CobIconComplication.kt @@ -0,0 +1,35 @@ +@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.shared.logging.LTag + +/* + * Created by dlvoy on 2019-11-12 + */ +class CobIconComplication : BaseComplicationProviderService() { + + override fun buildComplicationData(dataType: Int, raw: RawDisplayData, complicationPendingIntent: PendingIntent): ComplicationData? { + var complicationData: ComplicationData? = null + if (dataType == ComplicationData.TYPE_SHORT_TEXT) { + val builder = ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT) + .setShortText(ComplicationText.plainText(raw.status.cob)) + .setIcon(Icon.createWithResource(this, R.drawable.ic_carbs)) + .setBurnInProtectionIcon(Icon.createWithResource(this, R.drawable.ic_carbs)) + .setTapAction(complicationPendingIntent) + complicationData = builder.build() + } else { + aapsLogger.warn(LTag.WEAR, "Unexpected complication type $dataType") + } + return complicationData + } + + override fun getProviderCanonicalName(): String = CobIconComplication::class.java.canonicalName!! + override fun getComplicationAction(): ComplicationAction = ComplicationAction.WIZARD +} \ No newline at end of file