diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java index d782cd135..ba104f634 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java @@ -188,6 +188,7 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick JSONObject widgetObject = new JSONObject(); widgetObject .put("name", widget.getName()) + .put("drawCircle", widget.getDrawCircle()) .put("elements", elementArray); widgetArray.put(widgetObject); @@ -208,7 +209,7 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick for (int i = 0; i < customWidgets.length(); i++) { JSONObject customWidgetObject = customWidgets.getJSONObject(i); CustomWidget widget = new CustomWidget( - customWidgetObject.getString("name"), 0, 0, "default" // FIXME: handle force white background + customWidgetObject.getString("name"), 0, 0, "default", false // FIXME: handle force white background ); JSONArray elements = customWidgetObject.getJSONArray("elements"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/WidgetSettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/WidgetSettingsActivity.java index 6662a1133..06dc97b4c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/WidgetSettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/WidgetSettingsActivity.java @@ -7,6 +7,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ListView; import android.widget.RadioButton; @@ -48,9 +50,10 @@ public class WidgetSettingsActivity extends AbstractGBActivity { if(getIntent().hasExtra("EXTRA_WIDGET")){ subject = (CustomWidget) getIntent().getExtras().get("EXTRA_WIDGET"); ((EditText) findViewById(R.id.qhybrid_widget_name)).setText(subject.getName()); + ((CheckBox)findViewById(R.id.qhybrid_widget_circle)).setChecked(subject.getDrawCircle()); resultCode = RESULT_CODE_WIDGET_UPDATED; }else{ - subject = new CustomWidget("", 0, 63, "default"); // FIXME: handle force white background + subject = new CustomWidget("", 0, 63, "default", false); // FIXME: handle force white background resultCode = RESULT_CODE_WIDGET_CREATED; findViewById(R.id.qhybrid_widget_delete).setEnabled(false); } @@ -93,6 +96,13 @@ public class WidgetSettingsActivity extends AbstractGBActivity { showElementDialog(null); } }); + + ((CheckBox)findViewById(R.id.qhybrid_widget_circle)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + subject.setDrawCircle(b); + } + }); } private void showElementDialog(@Nullable final CustomWidgetElement element){ diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index 0a9aafb5c..9d7721a20 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -193,11 +193,14 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { for(int i = 0; i < customWidgets.length(); i++){ JSONObject customWidget = customWidgets.getJSONObject(i); if(customWidget.getString("name").equals(identifier)){ + boolean drawCircle = false; + if(customWidget.has("drawCircle")) drawCircle = customWidget.getBoolean("drawCircle"); CustomWidget newWidget = new CustomWidget( customWidget.getString("name"), positionMap.get(position), 63, - fontColor + fontColor, + drawCircle ); JSONArray elements = customWidget.getJSONArray("elements"); @@ -263,8 +266,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { boolean backgroundDrawn = false; - Paint circlePaint = new Paint(); - if(!backgroundDrawn){ + if(widget.getDrawCircle() && !backgroundDrawn){ + Paint circlePaint = new Paint(); circlePaint.setColor(forceWhiteBackground ? Color.WHITE : Color.BLACK); circlePaint.setStyle(Paint.Style.FILL); circlePaint.setStrokeWidth(3); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/CustomWidget.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/CustomWidget.java index d6f1f0af3..1440d7aff 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/CustomWidget.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/CustomWidget.java @@ -9,12 +9,22 @@ public class CustomWidget extends Widget { private ArrayList elements = new ArrayList<>(); private int angle, distance; private String name; + private boolean drawCircle; - public CustomWidget(String name, int angle, int distance, String fontColor) { + public CustomWidget(String name, int angle, int distance, String fontColor, boolean drawCircle) { super(null, angle, distance, fontColor); this.angle = angle; this.distance = distance; this.name = name; + this.drawCircle = drawCircle; + } + + public boolean getDrawCircle(){ + return this.drawCircle; + } + + public void setDrawCircle(boolean drawCircle){ + this.drawCircle = drawCircle; } public int getAngle() { diff --git a/app/src/main/res/layout/qhybrid_activity_widget_settings.xml b/app/src/main/res/layout/qhybrid_activity_widget_settings.xml index a5c25077b..d84138554 100644 --- a/app/src/main/res/layout/qhybrid_activity_widget_settings.xml +++ b/app/src/main/res/layout/qhybrid_activity_widget_settings.xml @@ -43,6 +43,12 @@ android:layout_height="wrap_content" android:text="add element" /> + +