1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-08 19:27:04 +01:00

Xiaomi Protobuf: Fix deleting first screen

This commit is contained in:
José Rebelo 2024-07-26 23:21:48 +01:00
parent 82d12e5fbe
commit da74ad036a

View File

@ -346,12 +346,19 @@ public class XiaomiWidgetManager implements WidgetManager {
final XiaomiProto.WidgetScreens.Builder builder = XiaomiProto.WidgetScreens.newBuilder(rawWidgetScreens) final XiaomiProto.WidgetScreens.Builder builder = XiaomiProto.WidgetScreens.newBuilder(rawWidgetScreens)
.clearWidgetScreen(); .clearWidgetScreen();
int i = 1;
for (final XiaomiProto.WidgetScreen screen : rawWidgetScreens.getWidgetScreenList()) { for (final XiaomiProto.WidgetScreen screen : rawWidgetScreens.getWidgetScreenList()) {
if (String.valueOf(screen.getId()).equals(widgetScreen.getId())) { if (String.valueOf(screen.getId()).equals(widgetScreen.getId())) {
continue; continue;
} }
builder.addWidgetScreen(screen); // Ensure the IDs stay sequential and start at 1
builder.addWidgetScreen(
XiaomiProto.WidgetScreen.newBuilder()
.mergeFrom(screen)
.setId(i++)
.build()
);
} }
getPrefs().getPreferences().edit() getPrefs().getPreferences().edit()