mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 02:45:49 +01:00
Humai: Implement menu sorting for remaining devices (except Mi Band 2)
This commit is contained in:
parent
8cb2fb980a
commit
d20e6516c8
@ -37,6 +37,4 @@ public class AmazfitBipService {
|
|||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPORTS_DETAILS = 0x06;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPORTS_DETAILS = 0x06;
|
||||||
|
|
||||||
public static final byte[] COMMAND_ACK_FIND_PHONE_IN_PROGRESS = new byte[]{ENDPOINT_DISPLAY, 0x14, 0x00, 0x00};
|
public static final byte[] COMMAND_ACK_FIND_PHONE_IN_PROGRESS = new byte[]{ENDPOINT_DISPLAY, 0x14, 0x00, 0x00};
|
||||||
|
|
||||||
public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x10, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
/* Copyright (C) 2015-2020 Andreas Shimokawa, Carsten Pfeiffer
|
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
|
||||||
|
|
||||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Gadgetbridge is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor;
|
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.DISPLAY_ITEM_BIT_CLOCK;
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY_ITEMS;
|
|
||||||
|
|
||||||
public class AmazfitCorService {
|
|
||||||
public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x20, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
|
||||||
}
|
|
@ -17,12 +17,9 @@
|
|||||||
|
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3;
|
package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.DISPLAY_ITEM_BIT_CLOCK;
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY_ITEMS;
|
|
||||||
|
|
||||||
public class MiBand3Service {
|
public class MiBand3Service {
|
||||||
public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
||||||
public static final byte[] COMMAND_ENABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x01};
|
public static final byte[] COMMAND_ENABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x01};
|
||||||
public static final byte[] COMMAND_DISABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x00};
|
public static final byte[] COMMAND_DISABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x00};
|
||||||
public static final byte[] COMMAND_NIGHT_MODE_OFF = new byte[]{0x1a, 0x00};
|
public static final byte[] COMMAND_NIGHT_MODE_OFF = new byte[]{0x1a, 0x00};
|
||||||
|
@ -156,6 +156,8 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF
|
|||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_START_NON_WEAR_SELECTION;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_START_NON_WEAR_SELECTION;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_WOKE_UP_BROADCAST;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_WOKE_UP_BROADCAST;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_WOKE_UP_SELECTION;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_WOKE_UP_SELECTION;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.DISPLAY_ITEM_BIT_CLOCK;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY_ITEMS;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PROFILE;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PROFILE;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VIBRATION_COUNT;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VIBRATION_COUNT;
|
||||||
@ -2315,6 +2317,54 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HuamiSupport setDisplayItemsOld(TransactionBuilder builder, boolean isShortcuts, int defaultSettings, Map<String, Integer> keyPosMap) {
|
||||||
|
|
||||||
|
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
||||||
|
String pages;
|
||||||
|
List<String> enabledList;
|
||||||
|
if (isShortcuts) {
|
||||||
|
pages = prefs.getString(HuamiConst.PREF_SHORTCUTS_SORTABLE, null);
|
||||||
|
LOG.info("Setting shortcuts");
|
||||||
|
} else {
|
||||||
|
pages = prefs.getString(HuamiConst.PREF_DISPLAY_ITEMS_SORTABLE, null);
|
||||||
|
LOG.info("Setting menu items");
|
||||||
|
}
|
||||||
|
if (pages == null) {
|
||||||
|
enabledList = Arrays.asList(getContext().getResources().getStringArray(defaultSettings));
|
||||||
|
} else {
|
||||||
|
enabledList = Arrays.asList(pages.split(","));
|
||||||
|
}
|
||||||
|
LOG.info("enabled items" + enabledList);
|
||||||
|
|
||||||
|
byte[] command = new byte[keyPosMap.size() + 4];
|
||||||
|
command[0] = ENDPOINT_DISPLAY_ITEMS;
|
||||||
|
byte index = 1;
|
||||||
|
int enabled_mask = DISPLAY_ITEM_BIT_CLOCK;
|
||||||
|
// it seem that we first have to put all ENABLED items into the array, oder does matter
|
||||||
|
for (String key : enabledList) {
|
||||||
|
Integer id = keyPosMap.get(key);
|
||||||
|
if (id != null) {
|
||||||
|
enabled_mask |= (1 << id.byteValue());
|
||||||
|
command[3 + id] = index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// And then all DISABLED ones, order does not matter
|
||||||
|
for (Map.Entry<String, Integer> entry : keyPosMap.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
int id = entry.getValue();
|
||||||
|
|
||||||
|
if (!enabledList.contains(key)) {
|
||||||
|
command[3 + id] = index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
command[1] = (byte) (enabled_mask & 0xff);
|
||||||
|
command[2] = (byte) ((enabled_mask >> 8 & 0xff));
|
||||||
|
|
||||||
|
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
protected HuamiSupport setDisplayItemsNew(TransactionBuilder builder, boolean isShortcuts, int defaultSettings, Map<String, Integer> keyIdMap) {
|
protected HuamiSupport setDisplayItemsNew(TransactionBuilder builder, boolean isShortcuts, int defaultSettings, Map<String, Integer> keyIdMap) {
|
||||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
||||||
String pages;
|
String pages;
|
||||||
@ -2358,7 +2408,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
if (!enabledList.contains(key)) {
|
if (!enabledList.contains(key)) {
|
||||||
command[pos++] = (byte) index++;
|
command[pos++] = (byte) index++;
|
||||||
command[pos++] = 0x01;
|
command[pos++] = 0x01;
|
||||||
command[pos++] = (byte) menuType;
|
command[pos++] = menuType;
|
||||||
command[pos++] = (byte) id;
|
command[pos++] = (byte) id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,24 +18,19 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.HashSet;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipService;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||||
@ -74,55 +69,18 @@ public class AmazfitBipSupport extends HuamiSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AmazfitBipSupport setDisplayItems(TransactionBuilder builder) {
|
protected AmazfitBipSupport setDisplayItems(TransactionBuilder builder) {
|
||||||
if (gbDevice.getFirmwareVersion() == null) {
|
Map<String, Integer> keyPosMap = new LinkedHashMap<>();
|
||||||
LOG.warn("Device not initialized yet, won't set menu items");
|
keyPosMap.put("status", 1);
|
||||||
return this;
|
keyPosMap.put("activity", 2);
|
||||||
}
|
keyPosMap.put("weather", 3);
|
||||||
|
keyPosMap.put("alarm", 4);
|
||||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
keyPosMap.put("timer", 5);
|
||||||
Set<String> pages = prefs.getStringSet(HuamiConst.PREF_DISPLAY_ITEMS, new HashSet<>(Arrays.asList(getContext().getResources().getStringArray(R.array.pref_bip_display_items_default))));
|
keyPosMap.put("compass", 6);
|
||||||
|
keyPosMap.put("settings", 7);
|
||||||
LOG.info("Setting display items to " + (pages == null ? "none" : pages));
|
keyPosMap.put("alipay", 8);
|
||||||
byte[] command = AmazfitBipService.COMMAND_CHANGE_SCREENS.clone();
|
|
||||||
|
|
||||||
boolean shortcut_weather = false;
|
|
||||||
boolean shortcut_alipay = false;
|
|
||||||
|
|
||||||
if (pages != null) {
|
|
||||||
if (pages.contains("status")) {
|
|
||||||
command[1] |= 0x02;
|
|
||||||
}
|
|
||||||
if (pages.contains("activity")) {
|
|
||||||
command[1] |= 0x04;
|
|
||||||
}
|
|
||||||
if (pages.contains("weather")) {
|
|
||||||
command[1] |= 0x08;
|
|
||||||
}
|
|
||||||
if (pages.contains("alarm")) {
|
|
||||||
command[1] |= 0x10;
|
|
||||||
}
|
|
||||||
if (pages.contains("timer")) {
|
|
||||||
command[1] |= 0x20;
|
|
||||||
}
|
|
||||||
if (pages.contains("compass")) {
|
|
||||||
command[1] |= 0x40;
|
|
||||||
}
|
|
||||||
if (pages.contains("settings")) {
|
|
||||||
command[1] |= 0x80;
|
|
||||||
}
|
|
||||||
if (pages.contains("alipay")) {
|
|
||||||
command[2] |= 0x01;
|
|
||||||
}
|
|
||||||
if (pages.contains("shortcut_weather")) {
|
|
||||||
shortcut_weather = true;
|
|
||||||
}
|
|
||||||
if (pages.contains("shortcut_alipay")) {
|
|
||||||
shortcut_alipay = true;
|
|
||||||
}
|
|
||||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
|
|
||||||
setShortcuts(builder, shortcut_weather, shortcut_alipay);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
setDisplayItemsOld(builder, false, R.array.pref_bip_display_items_default, keyPosMap);
|
||||||
|
//setShortcuts(builder, shortcut_weather, shortcut_alipay);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,72 +17,35 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.HashSet;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor.AmazfitCorFWHelper;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor.AmazfitCorFWHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor.AmazfitCorService;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
|
||||||
|
|
||||||
public class AmazfitCorSupport extends AmazfitBipSupport {
|
public class AmazfitCorSupport extends AmazfitBipSupport {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCorSupport.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AmazfitCorSupport setDisplayItems(TransactionBuilder builder) {
|
protected AmazfitCorSupport setDisplayItems(TransactionBuilder builder) {
|
||||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
Map<String, Integer> keyPosMap = new LinkedHashMap<>();
|
||||||
Set<String> pages = prefs.getStringSet(HuamiConst.PREF_DISPLAY_ITEMS, new HashSet<>(Arrays.asList(getContext().getResources().getStringArray(R.array.pref_cor_display_items_default))));
|
keyPosMap.put("status", 1);
|
||||||
LOG.info("Setting display items to " + (pages == null ? "none" : pages));
|
keyPosMap.put("notifications", 2);
|
||||||
|
keyPosMap.put("activity", 3);
|
||||||
byte[] command = AmazfitCorService.COMMAND_CHANGE_SCREENS.clone();
|
keyPosMap.put("weather", 4);
|
||||||
|
keyPosMap.put("alarm", 5);
|
||||||
if (pages != null) {
|
keyPosMap.put("timer", 6);
|
||||||
if (pages.contains("status")) {
|
keyPosMap.put("settings", 7);
|
||||||
command[1] |= 0x02;
|
keyPosMap.put("alipay", 8);
|
||||||
}
|
keyPosMap.put("music", 9);
|
||||||
if (pages.contains("notifications")) {
|
|
||||||
command[1] |= 0x04;
|
|
||||||
}
|
|
||||||
if (pages.contains("activity")) {
|
|
||||||
command[1] |= 0x08;
|
|
||||||
}
|
|
||||||
if (pages.contains("weather")) {
|
|
||||||
command[1] |= 0x10;
|
|
||||||
}
|
|
||||||
if (pages.contains("alarm")) {
|
|
||||||
command[1] |= 0x20;
|
|
||||||
}
|
|
||||||
if (pages.contains("timer")) {
|
|
||||||
command[1] |= 0x40;
|
|
||||||
}
|
|
||||||
if (pages.contains("settings")) {
|
|
||||||
command[1] |= 0x80;
|
|
||||||
}
|
|
||||||
if (pages.contains("alipay")) {
|
|
||||||
command[2] |= 0x01;
|
|
||||||
}
|
|
||||||
if (pages.contains("music")) {
|
|
||||||
command[2] |= 0x02;
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
setDisplayItemsOld(builder, false, R.array.pref_cor_display_items_default, keyPosMap);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -25,16 +24,13 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.HashSet;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Set;
|
import java.util.Map;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3Coordinator;
|
||||||
@ -56,55 +52,17 @@ public class MiBand3Support extends AmazfitBipSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MiBand3Support setDisplayItems(TransactionBuilder builder) {
|
protected MiBand3Support setDisplayItems(TransactionBuilder builder) {
|
||||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
Map<String, Integer> keyPosMap = new LinkedHashMap<>();
|
||||||
Set<String> pages = prefs.getStringSet(HuamiConst.PREF_DISPLAY_ITEMS, new HashSet<>(Arrays.asList(getContext().getResources().getStringArray(R.array.pref_miband3_display_items_default))));
|
keyPosMap.put("notifications", 1);
|
||||||
|
keyPosMap.put("weather", 2);
|
||||||
LOG.info("Setting display items to " + (pages == null ? "none" : pages));
|
keyPosMap.put("activity", 3);
|
||||||
byte[] command = MiBand3Service.COMMAND_CHANGE_SCREENS.clone();
|
keyPosMap.put("more", 4);
|
||||||
|
keyPosMap.put("status", 5);
|
||||||
byte pos = 1;
|
keyPosMap.put("heart_rate", 6);
|
||||||
if (pages != null) {
|
keyPosMap.put("timer", 7);
|
||||||
if (pages.contains("notifications")) {
|
keyPosMap.put("nfc", 8);
|
||||||
command[1] |= 0x02;
|
|
||||||
command[4] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("weather")) {
|
|
||||||
command[1] |= 0x04;
|
|
||||||
command[5] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("activity")) {
|
|
||||||
command[1] |= 0x08;
|
|
||||||
command[6] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("more")) {
|
|
||||||
command[1] |= 0x10;
|
|
||||||
command[7] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("status")) {
|
|
||||||
command[1] |= 0x20;
|
|
||||||
command[8] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("heart_rate")) {
|
|
||||||
command[1] |= 0x40;
|
|
||||||
command[9] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("timer")) {
|
|
||||||
command[1] |= 0x80;
|
|
||||||
command[10] = pos++;
|
|
||||||
}
|
|
||||||
if (pages.contains("nfc")) {
|
|
||||||
command[2] |= 0x01;
|
|
||||||
command[11] = pos++;
|
|
||||||
}
|
|
||||||
for (int i = 4; i <= 11; i++) {
|
|
||||||
if (command[i] == 0) {
|
|
||||||
command[i] = pos++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
setDisplayItemsOld(builder, false, R.array.pref_miband3_display_items_default, keyPosMap);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +401,6 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="pref_bip_display_items">
|
<string-array name="pref_bip_display_items">
|
||||||
<item>@string/menuitem_shortcut_alipay</item>
|
|
||||||
<item>@string/menuitem_shortcut_weather</item>
|
|
||||||
<item>@string/menuitem_status</item>
|
<item>@string/menuitem_status</item>
|
||||||
<item>@string/menuitem_activity</item>
|
<item>@string/menuitem_activity</item>
|
||||||
<item>@string/menuitem_weather</item>
|
<item>@string/menuitem_weather</item>
|
||||||
@ -414,8 +412,6 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="pref_bip_display_items_values">
|
<string-array name="pref_bip_display_items_values">
|
||||||
<item>@string/p_menuitem_shortcut_alipay</item>
|
|
||||||
<item>@string/p_menuitem_shortcut_weather</item>
|
|
||||||
<item>@string/p_menuitem_status</item>
|
<item>@string/p_menuitem_status</item>
|
||||||
<item>@string/p_menuitem_activity</item>
|
<item>@string/p_menuitem_activity</item>
|
||||||
<item>@string/p_menuitem_weather</item>
|
<item>@string/p_menuitem_weather</item>
|
||||||
@ -436,6 +432,20 @@
|
|||||||
<item>@string/p_menuitem_settings</item>
|
<item>@string/p_menuitem_settings</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="pref_bip_shortcuts">
|
||||||
|
<item>@string/menuitem_alipay</item>
|
||||||
|
<item>@string/menuitem_weather</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="pref_bip_shortcuts_values">
|
||||||
|
<item>@string/p_menuitem_alipay</item>
|
||||||
|
<item>@string/p_menuitem_weather</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="pref_bip_shortcuts_default">
|
||||||
|
<item>@string/p_menuitem_weather</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="pref_cor_display_items">
|
<string-array name="pref_cor_display_items">
|
||||||
<item>@string/menuitem_status</item>
|
<item>@string/menuitem_status</item>
|
||||||
<item>@string/menuitem_notifications</item>
|
<item>@string/menuitem_notifications</item>
|
||||||
|
@ -812,8 +812,6 @@
|
|||||||
<string name="devicetype_sg2">Lemfo SG2</string>
|
<string name="devicetype_sg2">Lemfo SG2</string>
|
||||||
<string name="devicetype_lefun">Lefun</string>
|
<string name="devicetype_lefun">Lefun</string>
|
||||||
<!-- Menus on the smart device -->
|
<!-- Menus on the smart device -->
|
||||||
<string name="menuitem_shortcut_alipay">Alipay (Shortcut)</string>
|
|
||||||
<string name="menuitem_shortcut_weather">Weather (Shortcut)</string>
|
|
||||||
<string name="menuitem_status">Status</string>
|
<string name="menuitem_status">Status</string>
|
||||||
<string name="menuitem_notifications">Notifications</string>
|
<string name="menuitem_notifications">Notifications</string>
|
||||||
<string name="menuitem_activity">Activity</string>
|
<string name="menuitem_activity">Activity</string>
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
<item name="p_heart_rate" type="string">heart_rate</item>
|
<item name="p_heart_rate" type="string">heart_rate</item>
|
||||||
<item name="p_battery" type="string">battery</item>
|
<item name="p_battery" type="string">battery</item>
|
||||||
|
|
||||||
<item name="p_menuitem_shortcut_alipay" type="string">shortcut_alipay</item>
|
|
||||||
<item name="p_menuitem_shortcut_weather" type="string">shortcut_weather</item>
|
|
||||||
<item name="p_menuitem_status" type="string">status</item>
|
<item name="p_menuitem_status" type="string">status</item>
|
||||||
<item name="p_menuitem_activity" type="string">activity</item>
|
<item name="p_menuitem_activity" type="string">activity</item>
|
||||||
<item name="p_menuitem_weather" type="string">weather</item>
|
<item name="p_menuitem_weather" type="string">weather</item>
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<MultiSelectListPreference
|
<com.mobeta.android.dslv.DragSortListPreference
|
||||||
android:icon="@drawable/ic_widgets"
|
android:icon="@drawable/ic_widgets"
|
||||||
android:defaultValue="@array/pref_bip_display_items_default"
|
android:defaultValue="@array/pref_bip_display_items_default"
|
||||||
android:dialogTitle="@string/mi2_prefs_display_items"
|
android:dialogTitle="@string/mi2_prefs_display_items"
|
||||||
android:entries="@array/pref_bip_display_items"
|
android:entries="@array/pref_bip_display_items"
|
||||||
android:entryValues="@array/pref_bip_display_items_values"
|
android:entryValues="@array/pref_bip_display_items_values"
|
||||||
android:key="display_items"
|
android:key="display_items_sortable"
|
||||||
|
android:persistent="true"
|
||||||
android:summary="@string/mi2_prefs_display_items_summary"
|
android:summary="@string/mi2_prefs_display_items_summary"
|
||||||
android:title="@string/mi2_prefs_display_items" />
|
android:title="@string/mi2_prefs_display_items" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<MultiSelectListPreference
|
<com.mobeta.android.dslv.DragSortListPreference
|
||||||
android:icon="@drawable/ic_widgets"
|
android:icon="@drawable/ic_widgets"
|
||||||
android:defaultValue="@array/pref_cor_display_items_default"
|
android:defaultValue="@array/pref_cor_display_items_default"
|
||||||
android:dialogTitle="@string/mi2_prefs_display_items"
|
android:dialogTitle="@string/mi2_prefs_display_items"
|
||||||
android:entries="@array/pref_cor_display_items"
|
android:entries="@array/pref_cor_display_items"
|
||||||
android:entryValues="@array/pref_cor_display_items_values"
|
android:entryValues="@array/pref_cor_display_items_values"
|
||||||
android:key="display_items"
|
android:key="display_items_sortable"
|
||||||
|
android:persistent="true"
|
||||||
android:summary="@string/mi2_prefs_display_items_summary"
|
android:summary="@string/mi2_prefs_display_items_summary"
|
||||||
android:title="@string/mi2_prefs_display_items" />
|
android:title="@string/mi2_prefs_display_items" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<MultiSelectListPreference
|
<com.mobeta.android.dslv.DragSortListPreference
|
||||||
android:icon="@drawable/ic_widgets"
|
android:icon="@drawable/ic_widgets"
|
||||||
android:defaultValue="@array/pref_miband3_display_items_default"
|
android:defaultValue="@array/pref_miband3_display_items_default"
|
||||||
android:dialogTitle="@string/mi2_prefs_display_items"
|
android:dialogTitle="@string/mi2_prefs_display_items"
|
||||||
android:entries="@array/pref_miband3_display_items"
|
android:entries="@array/pref_miband3_display_items"
|
||||||
android:entryValues="@array/pref_miband3_display_items_values"
|
android:entryValues="@array/pref_miband3_display_items_values"
|
||||||
android:key="display_items"
|
android:key="display_items_sortable"
|
||||||
|
android:persistent="true"
|
||||||
android:summary="@string/mi2_prefs_display_items_summary"
|
android:summary="@string/mi2_prefs_display_items_summary"
|
||||||
android:title="@string/mi2_prefs_display_items" />
|
android:title="@string/mi2_prefs_display_items" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
Loading…
Reference in New Issue
Block a user