fixed unknown button setting exception

This commit is contained in:
Daniel Dakhno 2019-11-17 15:56:44 +01:00
parent ca18e1fe34
commit 03e8925d9e
3 changed files with 10 additions and 5 deletions

View File

@ -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");

View File

@ -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));
} }

View File

@ -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);