LongStatusFlippedComplication -> kt
This commit is contained in:
parent
a427c290f4
commit
e2436fedcf
2 changed files with 43 additions and 61 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue