mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 11:26:47 +01:00
added some widget example code (WIP)
This commit is contained in:
parent
d2ede421c1
commit
961c0aa97c
@ -88,6 +88,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
public static final String QHYBRID_COMMAND_OVERWRITE_BUTTONS = "nodomain.freeyourgadget.gadgetbridge.Q_OVERWRITE_BUTTONS";
|
||||
public static final String QHYBRID_COMMAND_SET_MENU_MESSAGE = "nodomain.freeyourgadget.gadgetbridge.Q_SET_MENU_MESSAGE";
|
||||
public static final String QHYBRID_COMMAND_SEND_MENU_ITEMS = "nodomain.freeyourgadget.gadgetbridge.Q_SEND_MENU_ITEMS";
|
||||
public static final String QHYBRID_COMMAND_SET_WIDGET_CONTENT = "nodomain.freeyourgadget.gadgetbridge.Q_SET_WIDGET_CONTENT";
|
||||
|
||||
private static final String QHYBRID_ACTION_SET_ACTIVITY_HAND = "nodomain.freeyourgadget.gadgetbridge.Q_SET_ACTIVITY_HAND";
|
||||
|
||||
@ -231,6 +232,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
IntentFilter globalFilter = new IntentFilter();
|
||||
globalFilter.addAction(QHYBRID_ACTION_SET_ACTIVITY_HAND);
|
||||
globalFilter.addAction(QHYBRID_COMMAND_SET_MENU_MESSAGE);
|
||||
globalFilter.addAction(QHYBRID_COMMAND_SET_WIDGET_CONTENT);
|
||||
BroadcastReceiver globalCommandReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@ -262,6 +264,12 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
|
||||
break;
|
||||
}
|
||||
case QHYBRID_COMMAND_SET_WIDGET_CONTENT: {
|
||||
String id = String.valueOf(intent.getExtras().get("EXTRA_WIDGET_ID"));
|
||||
String content = String.valueOf(intent.getExtras().get("EXTRA_CONTENT"));
|
||||
watchAdapter.setWidgetContent(id, content);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -105,4 +105,7 @@ public abstract class WatchAdapter {
|
||||
|
||||
public void setMusicState(MusicStateSpec stateSpec) {
|
||||
}
|
||||
|
||||
public void setWidgetContent(String widgetID, String content) {
|
||||
}
|
||||
}
|
||||
|
@ -86,11 +86,16 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
|
||||
overwriteButtons(null);
|
||||
|
||||
drawWidgetText("19.00");
|
||||
drawWidgetText("-");
|
||||
|
||||
queueWrite(new SetDeviceStateRequest(GBDevice.State.INITIALIZED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidgetContent(String widgetID, String content) {
|
||||
drawWidgetText(content);
|
||||
}
|
||||
|
||||
private void drawWidgetText(String text){
|
||||
|
||||
try {
|
||||
@ -108,8 +113,15 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
circlePaint.setStrokeWidth(4);
|
||||
circlePaint.setTextSize(17f);
|
||||
circlePaint.setStyle(Paint.Style.FILL);
|
||||
circlePaint.setTextAlign(Paint.Align.CENTER);
|
||||
|
||||
testCanvas.drawText(text, 16, 60, circlePaint);
|
||||
testCanvas.drawText("ETH", 38, 76f / 3f * 1f - (circlePaint.descent() + circlePaint.ascent()) / 2f, circlePaint);
|
||||
testCanvas.drawText(text, 38, 76f / 3f * 2f - (circlePaint.descent() + circlePaint.ascent()) / 2f, circlePaint);
|
||||
|
||||
circlePaint.setStrokeWidth(1);
|
||||
circlePaint.setStyle(Paint.Style.STROKE);
|
||||
|
||||
// for(int i = 0; i <= 3; i++) testCanvas.drawLine(0, 76f / 3f * i - (i / 3), 76, 76f / 3f * i - (i / 3), circlePaint);
|
||||
|
||||
AssetImage image = AssetImageFactory.createAssetImage(
|
||||
StringUtils.bytesToHex(
|
||||
|
Loading…
Reference in New Issue
Block a user