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 0e146a6ab..878fd8a32 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 @@ -91,6 +91,7 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick Intent startIntent = new Intent(HRConfigActivity.this, WidgetSettingsActivity.class); startIntent.putExtra("EXTRA_WIDGET", widget); startIntent.putExtra("EXTRA_WIDGET_IDNEX", position); + startIntent.putExtra("EXTRA_WIDGET_INITIAL_NAME", ((CustomWidget) widget).getName()); startActivityForResult(startIntent, REQUEST_CODE_WIDGET_EDIT); } @@ -187,8 +188,16 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick CustomWidget widget = (CustomWidget) data.getExtras().get("EXTRA_WIDGET"); int updateIndex = data.getIntExtra("EXTRA_WIDGET_IDNEX", -1); + String initialName = data.getStringExtra("EXTRA_WIDGET_INITIAL_NAME"); + String newName = widget.getName(); + + String widgetJSON = sharedPreferences.getString("FOSSIL_HR_WIDGETS", "{}"); + widgetJSON = widgetJSON.replace("custom_" + initialName, "custom_" + newName); + sharedPreferences.edit().putString("FOSSIL_HR_WIDGETS", widgetJSON).apply(); + this.customWidgets.set(updateIndex, widget); + loadWidgetConfigs(); refreshWidgetList(); saveCustomWidgetList(); 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 df9eb7ae1..2e18a850e 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 @@ -411,11 +411,13 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { AssetImage[] images = widgetImages.toArray(new AssetImage[0]); - queueWrite(new AssetFilePutRequest( - images, - (byte) 0x00, - this - )); + if(images.length > 0) { + queueWrite(new AssetFilePutRequest( + images, + (byte) 0x00, + this + )); + } // queueWrite(new FileDeleteRequest((short) 0x0503)); queueWrite(new ImagesSetRequest( images,