mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 18:45:49 +01:00
Merge branch 'master' of https://codeberg.org/Freeyourgadget/Gadgetbridge into fossil-q-hr-background-image
This commit is contained in:
commit
b34e74494d
@ -1,5 +1,6 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -240,7 +241,6 @@ 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);
|
||||
@ -261,7 +261,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", false // FIXME: handle force white background
|
||||
customWidgetObject.getString("name"), 0, 0, "default" // FIXME: handle force white background
|
||||
);
|
||||
JSONArray elements = customWidgetObject.getJSONArray("elements");
|
||||
|
||||
@ -527,6 +527,7 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
|
||||
super(HRConfigActivity.this, 0, objects);
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
|
@ -50,10 +50,9 @@ 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", false); // FIXME: handle force white background
|
||||
subject = new CustomWidget("", 0, 63, "default"); // FIXME: handle force white background
|
||||
resultCode = RESULT_CODE_WIDGET_CREATED;
|
||||
findViewById(R.id.qhybrid_widget_delete).setEnabled(false);
|
||||
}
|
||||
@ -96,13 +95,6 @@ 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){
|
||||
|
@ -242,8 +242,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
customWidget.getString("name"),
|
||||
positionMap.get(position),
|
||||
63,
|
||||
fontColor,
|
||||
drawCircle
|
||||
fontColor
|
||||
);
|
||||
JSONArray elements = customWidget.getJSONArray("elements");
|
||||
|
||||
@ -290,32 +289,50 @@ 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<>();
|
||||
|
||||
|
||||
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(widget.getDrawCircle() && !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()) {
|
||||
@ -338,7 +355,6 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
0,
|
||||
0,
|
||||
null);
|
||||
backgroundDrawn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -9,44 +9,18 @@ public class CustomWidget extends Widget {
|
||||
private ArrayList<CustomWidgetElement> elements = new ArrayList<>();
|
||||
private int angle, distance;
|
||||
private String name;
|
||||
private boolean drawCircle;
|
||||
|
||||
public CustomWidget(String name, int angle, int distance, String fontColor, boolean drawCircle) {
|
||||
public CustomWidget(String name, int angle, int distance, String fontColor) {
|
||||
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() {
|
||||
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;
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -43,12 +43,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="add element" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="draw circle"
|
||||
android:id="@+id/qhybrid_widget_circle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -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>
|
@ -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>
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user