mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-11 17:41:57 +01:00
fixed unknown button setting exception
This commit is contained in:
parent
ca18e1fe34
commit
03e8925d9e
@ -353,10 +353,10 @@ public class ConfigActivity extends AbstractGBActivity {
|
|||||||
final int currentIndex = i;
|
final int currentIndex = i;
|
||||||
String configName = buttonConfig.getString(i);
|
String configName = buttonConfig.getString(i);
|
||||||
TextView buttonTextView = new TextView(ConfigActivity.this);
|
TextView buttonTextView = new TextView(ConfigActivity.this);
|
||||||
|
buttonTextView.setTextColor(Color.WHITE);
|
||||||
|
buttonTextView.setTextSize(20);
|
||||||
try {
|
try {
|
||||||
ConfigPayload payload = ConfigPayload.valueOf(configName);
|
ConfigPayload payload = ConfigPayload.valueOf(configName);
|
||||||
buttonTextView.setTextColor(Color.WHITE);
|
|
||||||
buttonTextView.setTextSize(20);
|
|
||||||
buttonTextView.setText("Button " + (i + 1) + ": " + payload.getDescription());
|
buttonTextView.setText("Button " + (i + 1) + ": " + payload.getDescription());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
buttonTextView.setText("Button " + (i + 1) + ": Unknown");
|
buttonTextView.setText("Button " + (i + 1) + ": Unknown");
|
||||||
|
@ -78,7 +78,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
super.onConfigurationsGet(configs);
|
super.onConfigurationsGet(configs);
|
||||||
|
|
||||||
JSONArray buttons = new JSONArray();
|
JSONArray buttons = new JSONArray();
|
||||||
for (ConfigPayload payload : configs) buttons.put(payload.toString());
|
for (ConfigPayload payload : configs) buttons.put(String.valueOf(payload));
|
||||||
String json = buttons.toString();
|
String json = buttons.toString();
|
||||||
getDeviceSupport().getDevice().addDeviceInfo(new GenericItem(ITEM_BUTTONS, json));
|
getDeviceSupport().getDevice().addDeviceInfo(new GenericItem(ITEM_BUTTONS, json));
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,14 @@ public class ButtonConfigurationGetRequest extends FileGetRequest {
|
|||||||
|
|
||||||
ConfigPayload[] configs = new ConfigPayload[count];
|
ConfigPayload[] configs = new ConfigPayload[count];
|
||||||
|
|
||||||
|
buffer.position(16);
|
||||||
for(int i = 0; i < count; i++){
|
for(int i = 0; i < count; i++){
|
||||||
byte buttonIndex = (byte) (buffer.get(16 + i * 7) >> 4);
|
int buttonIndex = buffer.get() >> 4;
|
||||||
short appId = buffer.getShort(19 + i * 7);
|
int entryCount = buffer.get();
|
||||||
|
buffer.get();
|
||||||
|
short appId = buffer.getShort();
|
||||||
|
|
||||||
|
buffer.position(buffer.position() + entryCount * 5 - 3);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
configs[buttonIndex - 1] = ConfigPayload.fromId(appId);
|
configs[buttonIndex - 1] = ConfigPayload.fromId(appId);
|
||||||
|
Loading…
Reference in New Issue
Block a user