Xiaomi Smart Band 7 Pro: Experimental support

This commit is contained in:
José Rebelo 2023-11-29 21:18:52 +00:00
parent 0c4e2df075
commit 5be3543fa3
5 changed files with 76 additions and 10 deletions

View File

@ -75,6 +75,7 @@ public class HuamiConst {
public static final String AMAZFIT_FALCON_NAME = "Amazfit Falcon";
public static final String XIAOMI_SMART_BAND7_NAME = "Xiaomi Smart Band 7";
public static final String XIAOMI_SMART_BAND7_PRO_NAME = "Xiaomi Smart Band 7 Pro";
public static final String PREF_DISPLAY_ITEMS = "display_items";
public static final String PREF_DISPLAY_ITEMS_SORTABLE = "display_items_sortable";

View File

@ -21,27 +21,20 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7Support;
public class MiBand7Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand7Coordinator.class);
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.XIAOMI_SMART_BAND7_NAME + ".*");
public boolean supports(final GBDeviceCandidate candidate) {
final String name = candidate.getName();
return name.startsWith(HuamiConst.XIAOMI_SMART_BAND7_NAME) && !name.contains("Pro");
}
@Override

View File

@ -0,0 +1,69 @@
/* Copyright (C) 2023 José Rebelo
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.xiaomi.miband7pro;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiEncryptedCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class MiBand7ProCoordinator extends XiaomiEncryptedCoordinator {
@Override
public boolean isExperimental() {
return true;
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.XIAOMI_SMART_BAND7_PRO_NAME + ".*");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_miband7pro;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_default;
}
@Override
public int getDisabledIconResource() {
return R.drawable.ic_device_default_disabled;
}
@Override
public boolean supportsMultipleWeatherLocations() {
return true;
}
}

View File

@ -140,6 +140,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.VivomoveHrCoordin
import nodomain.freeyourgadget.gadgetbridge.devices.waspos.WaspOSCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.watch9.Watch9DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.withingssteelhr.WithingsSteelHRDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband7pro.MiBand7ProCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband8.MiBand8Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.watchs1active.XiaomiWatchS1ActiveCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xwatch.XWatchCoordinator;
@ -196,6 +197,7 @@ public enum DeviceType {
AMAZFITPOP(AmazfitPopCoordinator.class),
AMAZFITPOPPRO(AmazfitPopProCoordinator.class),
MIBAND7(MiBand7Coordinator.class),
MIBAND7PRO(MiBand7ProCoordinator.class),
MIBAND8(MiBand8Coordinator.class),
MIWATCHLITE(MiWatchLiteCoordinator.class),
REDMIWATCH3ACTIVE(RedmiWatch3ActiveCoordinator.class),

View File

@ -1309,6 +1309,7 @@
<string name="devicetype_miband5">Mi Band 5</string>
<string name="devicetype_miband6">Mi Band 6</string>
<string name="devicetype_miband7">Xiaomi Smart Band 7</string>
<string name="devicetype_miband7pro">Xiaomi Smart Band 7 Pro</string>
<string name="devicetype_miband8">Xiaomi Smart Band 8</string>
<string name="devicetype_amazfit_balance">Amazfit Balance</string>
<string name="devicetype_amazfit_active">Amazfit Active</string>