mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 06:22:55 +01:00
Amazfit Neo: Fix setting menu items
- Fixes a bug with cycling through entries - adds steps, distance, calories, battery - removes world clock (does not seem to work)
This commit is contained in:
parent
e9766da89c
commit
a234c1d527
@ -20,12 +20,13 @@ public enum HuamiFirmwareType {
|
||||
FIRMWARE((byte) 0),
|
||||
FONT((byte) 1),
|
||||
RES((byte) 2),
|
||||
RES_COMPRESSED((byte)130),
|
||||
RES_COMPRESSED((byte) 130),
|
||||
GPS((byte) 3),
|
||||
GPS_CEP((byte) 4),
|
||||
GPS_ALMANAC((byte)5),
|
||||
WATCHFACE((byte)8),
|
||||
FONT_LATIN((byte)11),
|
||||
GPS_CEP_NEW((byte) -4),
|
||||
GPS_ALMANAC((byte) 5),
|
||||
WATCHFACE((byte) 8),
|
||||
FONT_LATIN((byte) 11),
|
||||
INVALID(Byte.MIN_VALUE);
|
||||
|
||||
private final byte value;
|
||||
|
@ -37,6 +37,7 @@ class HuamiMenuType {
|
||||
put("mutephone", 0x0f);
|
||||
put("nfc", 0x10);
|
||||
put("alipay", 0x11);
|
||||
put("watchface", 0x12);
|
||||
put("settings", 0x13);
|
||||
put("activity", 0x14);
|
||||
put("eventreminder", 0x15);
|
||||
@ -50,7 +51,11 @@ class HuamiMenuType {
|
||||
put("sleep", 0x23);
|
||||
put("spo2", 0x24);
|
||||
put("breathing",0x33);
|
||||
put("steps",0x34);
|
||||
put("distance",0x35);
|
||||
put("calories",0x36);
|
||||
put("pomodoro", 0x38);
|
||||
put("alexa", 0x39);
|
||||
put("battery", 0x3a);
|
||||
}};
|
||||
}
|
||||
|
@ -2442,7 +2442,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected HuamiSupport setDisplayItemsNew(TransactionBuilder builder, boolean isShortcuts, int defaultSettings) {
|
||||
protected HuamiSupport setDisplayItemsNew(TransactionBuilder builder, boolean isShortcuts, boolean forceWatchface, int defaultSettings) {
|
||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
||||
String pages;
|
||||
List<String> enabledList;
|
||||
@ -2461,19 +2461,16 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
} else {
|
||||
enabledList = Arrays.asList(pages.split(","));
|
||||
}
|
||||
if (forceWatchface) {
|
||||
enabledList.add(0, "watchface");
|
||||
}
|
||||
LOG.info("enabled items" + enabledList);
|
||||
|
||||
byte[] command = new byte[(enabledList.size() + 1) * 4 + 1];
|
||||
byte[] command = new byte[enabledList.size() * 4 + 1];
|
||||
command[0] = 0x1e;
|
||||
|
||||
int pos = 1;
|
||||
int index = 0;
|
||||
|
||||
command[pos++] = (byte) index++;
|
||||
command[pos++] = 0x00;
|
||||
command[pos++] = menuType;
|
||||
command[pos++] = 0x12;
|
||||
|
||||
for (String key : enabledList) {
|
||||
Integer id = HuamiMenuType.idLookup.get(key);
|
||||
if (id != null) {
|
||||
|
@ -35,13 +35,13 @@ public class AmazfitBand5Support extends MiBand5Support {
|
||||
|
||||
@Override
|
||||
protected AmazfitBand5Support setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_amazfitband5_display_items_default);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_amazfitband5_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AmazfitBand5Support setShortcuts(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, true, R.array.pref_amazfitband5_shortcuts_default);
|
||||
setDisplayItemsNew(builder, true, true, R.array.pref_amazfitband5_shortcuts_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,13 @@ public class AmazfitBipSSupport extends AmazfitBipSupport {
|
||||
|
||||
@Override
|
||||
protected AmazfitBipSSupport setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_bips_display_items_default);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_bips_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AmazfitBipSSupport setShortcuts(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, true, R.array.pref_bips_display_items_default);
|
||||
setDisplayItemsNew(builder, true, true, R.array.pref_bips_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class AmazfitGTSSupport extends AmazfitBipSupport {
|
||||
|
||||
@Override
|
||||
protected AmazfitGTSSupport setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_gts_display_items_default);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_gts_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -16,16 +16,10 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitneo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||
//import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitneo.AmazfitBand5FWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband5.MiBand5Support;
|
||||
@ -35,16 +29,10 @@ public class AmazfitNeoSupport extends MiBand5Support {
|
||||
|
||||
@Override
|
||||
protected AmazfitNeoSupport setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_neo_display_items_default);
|
||||
setDisplayItemsNew(builder, false, false, R.array.pref_neo_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
//@Override
|
||||
//protected AmazfitNeoSupport setShortcuts(TransactionBuilder builder) {
|
||||
// setDisplayItemsNew(builder, true, R.array.pref_amazfitband5_shortcuts_default);
|
||||
// return this;
|
||||
//}
|
||||
|
||||
//@Override
|
||||
//public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
|
||||
// return new AmazfitBand5FWHelper(uri, context);
|
||||
|
@ -25,7 +25,6 @@ import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex.AmazfitTRexFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport;
|
||||
|
||||
public class AmazfitTRexSupport extends AmazfitGTSSupport {
|
||||
@ -37,7 +36,7 @@ public class AmazfitTRexSupport extends AmazfitGTSSupport {
|
||||
|
||||
@Override
|
||||
protected AmazfitTRexSupport setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_trex_display_items_default);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_trex_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.Ama
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitvergel.AmazfitVergeLFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperationNew;
|
||||
|
||||
public class AmazfitVergeLSupport extends AmazfitBipSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AmazfitVergeLSupport.class);
|
||||
@ -49,7 +48,7 @@ public class AmazfitVergeLSupport extends AmazfitBipSupport {
|
||||
|
||||
@Override
|
||||
protected AmazfitVergeLSupport setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_gts_display_items_values);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_gts_display_items_values);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -35,13 +35,13 @@ public class AmazfitXSupport extends MiBand5Support {
|
||||
|
||||
@Override
|
||||
protected AmazfitXSupport setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_amazfitband5_display_items_default);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_amazfitband5_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AmazfitXSupport setShortcuts(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, true, R.array.pref_amazfitband5_shortcuts_default);
|
||||
setDisplayItemsNew(builder, true, true, R.array.pref_amazfitband5_shortcuts_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -35,13 +35,13 @@ public class MiBand5Support extends MiBand4Support {
|
||||
|
||||
@Override
|
||||
protected MiBand5Support setDisplayItems(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, false, R.array.pref_miband5_display_items_default);
|
||||
setDisplayItemsNew(builder, false, true, R.array.pref_miband5_display_items_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MiBand5Support setShortcuts(TransactionBuilder builder) {
|
||||
setDisplayItemsNew(builder, true, R.array.pref_miband5_shortcuts_default);
|
||||
setDisplayItemsNew(builder, true, true, R.array.pref_miband5_shortcuts_default);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -415,9 +415,10 @@
|
||||
<item>@string/menuitem_weather</item>
|
||||
<item>@string/menuitem_stopwatch</item>
|
||||
<item>@string/menuitem_alarm</item>
|
||||
<item>@string/menuitem_worldclock</item>
|
||||
<item>@string/menuitem_activity</item>
|
||||
<item>@string/menuitem_goal</item>
|
||||
<item>@string/chart_steps</item>
|
||||
<item>@string/distance</item>
|
||||
<item>@string/calories</item>
|
||||
<item>@string/battery</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_neo_display_items_values">
|
||||
@ -427,9 +428,10 @@
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_stopwatch</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_worldclock</item>
|
||||
<item>@string/p_menuitem_activity</item>
|
||||
<item>@string/p_menuitem_goal</item>
|
||||
<item>@string/p_steps</item>
|
||||
<item>@string/p_distance</item>
|
||||
<item>@string/p_calories</item>
|
||||
<item>@string/p_battery</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_neo_display_items_default">
|
||||
|
@ -10,15 +10,7 @@
|
||||
android:persistent="true"
|
||||
android:summary="@string/mi2_prefs_display_items_summary"
|
||||
android:title="@string/mi2_prefs_display_items" />
|
||||
<!--com.mobeta.android.dslv.DragSortListPreference
|
||||
android:defaultValue="@array/pref_amazfitband5_shortcuts_default"
|
||||
android:dialogTitle="@string/bip_prefs_shortcuts"
|
||||
android:entries="@array/pref_amazfitband5_shortcuts"
|
||||
android:entryValues="@array/pref_amazfitband5_shortcuts_values"
|
||||
android:key="shortcuts_sortable"
|
||||
android:persistent="true"
|
||||
android:summary="@string/bip_prefs_shotcuts_summary"
|
||||
android:title="@string/bip_prefs_shortcuts" /-->
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_language"
|
||||
android:defaultValue="auto"
|
||||
@ -28,11 +20,3 @@
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_language" />
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
|
||||
android:entryValues="@array/pref_amazfitband5_display_items_values"
|
||||
|
||||
-->
|
Loading…
Reference in New Issue
Block a user