diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/LongStatusFlippedComplication.java b/wear/src/main/java/info/nightscout/androidaps/complications/LongStatusFlippedComplication.java deleted file mode 100644 index e8f4f0a9c2..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/complications/LongStatusFlippedComplication.java +++ /dev/null @@ -1,61 +0,0 @@ -package info.nightscout.androidaps.complications; - -import android.app.PendingIntent; -import android.support.wearable.complications.ComplicationData; -import android.support.wearable.complications.ComplicationText; - -import javax.inject.Inject; - -import dagger.android.AndroidInjection; -import info.nightscout.androidaps.data.RawDisplayData; -import info.nightscout.androidaps.interaction.utils.DisplayFormat; -import info.nightscout.shared.logging.LTag; - -/* - * Created by dlvoy on 2019-11-12 - */ -@SuppressWarnings("deprecation") -public class LongStatusFlippedComplication extends BaseComplicationProviderService { - - @Inject DisplayFormat displayFormat; - - // Not derived from DaggerService, do injection here - @Override - public void onCreate() { - AndroidInjection.inject(this); - super.onCreate(); - } - - public ComplicationData buildComplicationData(int dataType, RawDisplayData raw, PendingIntent complicationPendingIntent) { - - ComplicationData complicationData = null; - - switch (dataType) { - case ComplicationData.TYPE_LONG_TEXT: - - final String glucoseLine = displayFormat.longGlucoseLine(raw); - final String detailsLine = displayFormat.longDetailsLine(raw); - - final ComplicationData.Builder builderLong = new ComplicationData.Builder(ComplicationData.TYPE_LONG_TEXT) - .setLongTitle(ComplicationText.plainText(detailsLine)) - .setLongText(ComplicationText.plainText(glucoseLine)) - .setTapAction(complicationPendingIntent); - complicationData = builderLong.build(); - - break; - default: - aapsLogger.warn(LTag.WEAR, "Unexpected complication type " + dataType); - } - return complicationData; - } - - @Override - public String getProviderCanonicalName() { - return LongStatusFlippedComplication.class.getCanonicalName(); - } - - @Override - protected boolean usesSinceField() { - return true; - } -} diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/LongStatusFlippedComplication.kt b/wear/src/main/java/info/nightscout/androidaps/complications/LongStatusFlippedComplication.kt new file mode 100644 index 0000000000..f6bf913871 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/complications/LongStatusFlippedComplication.kt @@ -0,0 +1,43 @@ +@file:Suppress("DEPRECATION") + +package info.nightscout.androidaps.complications + +import android.app.PendingIntent +import android.support.wearable.complications.ComplicationData +import android.support.wearable.complications.ComplicationText +import dagger.android.AndroidInjection +import info.nightscout.androidaps.data.RawDisplayData +import info.nightscout.shared.logging.LTag + +/* + * Created by dlvoy on 2019-11-12 + */ +class LongStatusFlippedComplication : BaseComplicationProviderService() { + + // Not derived from DaggerService, do injection here + override fun onCreate() { + AndroidInjection.inject(this) + super.onCreate() + } + + override fun buildComplicationData(dataType: Int, raw: RawDisplayData, complicationPendingIntent: PendingIntent): ComplicationData? { + var complicationData: ComplicationData? = null + when (dataType) { + ComplicationData.TYPE_LONG_TEXT -> { + val glucoseLine = displayFormat.longGlucoseLine(raw) + val detailsLine = displayFormat.longDetailsLine(raw) + val builderLong = ComplicationData.Builder(ComplicationData.TYPE_LONG_TEXT) + .setLongTitle(ComplicationText.plainText(detailsLine)) + .setLongText(ComplicationText.plainText(glucoseLine)) + .setTapAction(complicationPendingIntent) + complicationData = builderLong.build() + } + + else -> aapsLogger.warn(LTag.WEAR, "Unexpected complication type $dataType") + } + return complicationData + } + + override fun getProviderCanonicalName(): String = LongStatusFlippedComplication::class.java.canonicalName!! + override fun usesSinceField(): Boolean = true +} \ No newline at end of file