1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-08 14:18:08 +02:00

Fossil HR: centralized widget settings option for all widgets

This commit is contained in:
Daniel Dakhno 2020-04-08 03:00:45 +02:00
parent 4be50a332d
commit 791601f4bd
6 changed files with 55 additions and 32 deletions

View File

@ -246,6 +246,24 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
private void renderWidgets() {
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress()));
boolean forceWhiteBackground = prefs.getBoolean("force_white_color_scheme", false);
boolean drawCircles = prefs.getBoolean("widget_draw_circles", false);
Bitmap circleBitmap = null;
if(drawCircles) {
circleBitmap = Bitmap.createBitmap(76, 76, Bitmap.Config.ARGB_8888);
Canvas circleCanvas = new Canvas(circleBitmap);
Paint circlePaint = new Paint();
circlePaint.setColor(forceWhiteBackground ? Color.WHITE : Color.BLACK);
circlePaint.setStyle(Paint.Style.FILL);
circlePaint.setStrokeWidth(3);
circleCanvas.drawCircle(38, 38, 37, circlePaint);
circlePaint.setColor(forceWhiteBackground ? Color.BLACK : Color.WHITE);
circlePaint.setStyle(Paint.Style.STROKE);
circlePaint.setStrokeWidth(3);
circleCanvas.drawCircle(38, 38, 37, circlePaint);
}
try {
ArrayList<AssetImage> widgetImages = new ArrayList<>();
@ -253,29 +271,28 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
widgetImages.add(this.backGroundImage);
}
for (int i = 0; i < this.widgets.size(); i++) {
Widget w = widgets.get(i);
if(!(w instanceof CustomWidget)) continue;
if(!(w instanceof CustomWidget)){
if(drawCircles) {
widgetImages.add(AssetImageFactory.createAssetImage(
circleBitmap,
true,
w.getAngle(),
w.getDistance(),
1
));
}
continue;
};
CustomWidget widget = (CustomWidget) w;
Bitmap widgetBitmap = Bitmap.createBitmap(76, 76, Bitmap.Config.ARGB_8888);
Canvas widgetCanvas = new Canvas(widgetBitmap);
boolean backgroundDrawn = false;
if(!backgroundDrawn){
Paint circlePaint = new Paint();
circlePaint.setColor(forceWhiteBackground ? Color.WHITE : Color.BLACK);
circlePaint.setStyle(Paint.Style.FILL);
circlePaint.setStrokeWidth(3);
widgetCanvas.drawCircle(38, 38, 37, circlePaint);
circlePaint.setColor(forceWhiteBackground ? Color.BLACK : Color.WHITE);
circlePaint.setStyle(Paint.Style.STROKE);
circlePaint.setStrokeWidth(3);
widgetCanvas.drawCircle(38, 38, 37, circlePaint);
if(drawCircles){
widgetCanvas.drawBitmap(circleBitmap, 0, 0, null);
}
for (CustomWidgetElement element : widget.getElements()) {
@ -298,7 +315,6 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
0,
0,
null);
backgroundDrawn = true;
break;
}
}

View File

@ -17,26 +17,10 @@ public class CustomWidget extends Widget {
this.name = name;
}
public int getAngle() {
return angle;
}
public int getDistance() {
return distance;
}
public void setElements(ArrayList<CustomWidgetElement> elements) {
this.elements = elements;
}
public void setAngle(int angle) {
this.angle = angle;
}
public void setDistance(int distance) {
this.distance = distance;
}
public void setName(String name) {
this.name = name;
}

View File

@ -21,6 +21,22 @@ public class Widget implements Serializable {
this.fontColor = fontColor;
}
public int getAngle() {
return angle;
}
public int getDistance() {
return distance;
}
public void setAngle(int angle) {
this.angle = angle;
}
public void setDistance(int distance) {
this.distance = distance;
}
@NonNull
@Override
public String toString() {

View File

@ -860,4 +860,5 @@
<string name="devicetype_amazfit_bips">Amazfit Bip S</string>
<string name="pref_summary_relax_firmware_checks">Firmwareüberprüfung deaktivieren</string>
<string name="pref_title_relax_firmware_checks">Aktiviere das flashen von Firmware, die nicht für dieses Gerät bestimmt ist (auf eigenes Risiko)</string>
<string name="pref_qhybrid_title_widget_draw_circles">Widget-Kreise zeichnen</string>
</resources>

View File

@ -815,6 +815,7 @@
<string name="prefs_button_long_press_action_selection_title">Long press button action</string>
<string name="error_no_location_access">Location access must be granted and enabled for scanning to work properly</string>
<string name="pref_qhybrid_title_widget_draw_circles">Draw widget circles</string>
<plurals name="widget_alarm_target_hours">
<item quantity="one">%d hour</item>

View File

@ -27,6 +27,11 @@
android:key="force_white_color_scheme"
android:summary="@string/pref_summary_force_white_color_scheme"
android:title="@string/pref_title_force_white_color_scheme" />
<SwitchPreference
android:defaultValue="false"
android:key="widget_draw_circles"
android:title="@string/pref_qhybrid_title_widget_draw_circles" />
<SeekBarPreference
android:defaultValue="2"
android:key="@string/pref_title_vibration_strength"