CobDetailedComplication -> kt
This commit is contained in:
parent
f350fa1ed5
commit
4e0a83ba85
2 changed files with 35 additions and 48 deletions
|
@ -1,48 +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.Pair;
|
|
||||||
import info.nightscout.shared.logging.LTag;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Created by dlvoy on 2019-11-12
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class CobDetailedComplication extends BaseComplicationProviderService {
|
|
||||||
|
|
||||||
public ComplicationData buildComplicationData(int dataType, RawDisplayData raw, PendingIntent complicationPendingIntent) {
|
|
||||||
|
|
||||||
ComplicationData complicationData = null;
|
|
||||||
|
|
||||||
if (dataType == ComplicationData.TYPE_SHORT_TEXT) {
|
|
||||||
|
|
||||||
Pair<String, String> cob = displayFormat.detailedCob(raw);
|
|
||||||
final ComplicationData.Builder builder = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)
|
|
||||||
.setShortText(ComplicationText.plainText(cob.first))
|
|
||||||
.setTapAction(complicationPendingIntent);
|
|
||||||
|
|
||||||
if (cob.second.length() > 0) {
|
|
||||||
builder.setShortTitle(ComplicationText.plainText(cob.second));
|
|
||||||
}
|
|
||||||
|
|
||||||
complicationData = builder.build();
|
|
||||||
} else {
|
|
||||||
aapsLogger.warn(LTag.WEAR, "Unexpected complication type " + dataType);
|
|
||||||
}
|
|
||||||
return complicationData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProviderCanonicalName() {
|
|
||||||
return CobDetailedComplication.class.getCanonicalName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ComplicationAction getComplicationAction() {
|
|
||||||
return ComplicationAction.WIZARD;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
@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.shared.logging.LTag
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Created by dlvoy on 2019-11-12
|
||||||
|
*/
|
||||||
|
class CobDetailedComplication : BaseComplicationProviderService() {
|
||||||
|
|
||||||
|
override fun buildComplicationData(dataType: Int, raw: RawDisplayData, complicationPendingIntent: PendingIntent): ComplicationData? {
|
||||||
|
var complicationData: ComplicationData? = null
|
||||||
|
if (dataType == ComplicationData.TYPE_SHORT_TEXT) {
|
||||||
|
val cob = displayFormat.detailedCob(raw)
|
||||||
|
val builder = ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)
|
||||||
|
.setShortText(ComplicationText.plainText(cob.first))
|
||||||
|
.setTapAction(complicationPendingIntent)
|
||||||
|
if (cob.second.isNotEmpty()) {
|
||||||
|
builder.setShortTitle(ComplicationText.plainText(cob.second))
|
||||||
|
}
|
||||||
|
complicationData = builder.build()
|
||||||
|
} else {
|
||||||
|
aapsLogger.warn(LTag.WEAR, "Unexpected complication type $dataType")
|
||||||
|
}
|
||||||
|
return complicationData
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getProviderCanonicalName(): String = CobDetailedComplication::class.java.canonicalName!!
|
||||||
|
override fun getComplicationAction(): ComplicationAction = ComplicationAction.WIZARD
|
||||||
|
}
|
Loading…
Reference in a new issue