CobIobComplication -> kt
This commit is contained in:
parent
759c81f10e
commit
9ee281876d
2 changed files with 34 additions and 41 deletions
|
@ -1,41 +0,0 @@
|
||||||
package info.nightscout.androidaps.complications;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.support.wearable.complications.ComplicationData;
|
|
||||||
import android.support.wearable.complications.ComplicationText;
|
|
||||||
|
|
||||||
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 CobIobComplication extends BaseComplicationProviderService {
|
|
||||||
|
|
||||||
public ComplicationData buildComplicationData(int dataType, RawDisplayData raw, PendingIntent complicationPendingIntent) {
|
|
||||||
|
|
||||||
ComplicationData complicationData = null;
|
|
||||||
|
|
||||||
if (dataType == ComplicationData.TYPE_SHORT_TEXT) {
|
|
||||||
final String cob = raw.getStatus().getCob();
|
|
||||||
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(cob))
|
|
||||||
.setShortTitle(ComplicationText.plainText(iob))
|
|
||||||
.setTapAction(complicationPendingIntent);
|
|
||||||
|
|
||||||
complicationData = builder.build();
|
|
||||||
} else {
|
|
||||||
aapsLogger.warn(LTag.WEAR, "Unexpected complication type " + dataType);
|
|
||||||
}
|
|
||||||
return complicationData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProviderCanonicalName() {
|
|
||||||
return CobIobComplication.class.getCanonicalName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
@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 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 CobIobComplication : BaseComplicationProviderService() {
|
||||||
|
|
||||||
|
override fun buildComplicationData(dataType: Int, raw: RawDisplayData, complicationPendingIntent: PendingIntent): ComplicationData? {
|
||||||
|
var complicationData: ComplicationData? = null
|
||||||
|
if (dataType == ComplicationData.TYPE_SHORT_TEXT) {
|
||||||
|
val cob = raw.status.cob
|
||||||
|
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(cob))
|
||||||
|
.setShortTitle(ComplicationText.plainText(iob))
|
||||||
|
.setTapAction(complicationPendingIntent)
|
||||||
|
complicationData = builder.build()
|
||||||
|
} else {
|
||||||
|
aapsLogger.warn(LTag.WEAR, "Unexpected complication type $dataType")
|
||||||
|
}
|
||||||
|
return complicationData
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getProviderCanonicalName(): String = CobIobComplication::class.java.canonicalName!!
|
||||||
|
}
|
Loading…
Reference in a new issue