1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 18:45:49 +01:00

Mi Band 2: enable per-device pairing keys

Now enabled for all Huami devices
This commit is contained in:
Andreas Shimokawa 2019-05-02 22:40:28 +02:00
parent bb161aff59
commit 6d28af1132
5 changed files with 18 additions and 42 deletions

View File

@ -40,6 +40,8 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity; import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.HuamiSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.DateTimeDisplay; import nodomain.freeyourgadget.gadgetbridge.devices.miband.DateTimeDisplay;
@ -119,6 +121,16 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return true; return true;
} }
@Override
public boolean supportsDeviceSpecificSettings(GBDevice device) {
return true;
}
@Override
public DeviceSpecificSettingsFragment getDeviceSpecificSettingsFragment(GBDevice device) {
return HuamiSettingsFragment.newInstance(device.getAddress());
}
@Override @Override
public SampleProvider<? extends AbstractActivitySample> getSampleProvider(GBDevice device, DaoSession session) { public SampleProvider<? extends AbstractActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
return new MiBand2SampleProvider(device, session); return new MiBand2SampleProvider(device, session);

View File

@ -21,13 +21,11 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.HuamiSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -77,15 +75,4 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
public boolean supportsWeather() { public boolean supportsWeather() {
return true; return true;
} }
@Override
public boolean supportsDeviceSpecificSettings(GBDevice device) {
return true;
}
@Override
public DeviceSpecificSettingsFragment getDeviceSpecificSettingsFragment(GBDevice device) {
return HuamiSettingsFragment.newInstance(device.getAddress());
}
} }

View File

@ -21,13 +21,11 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.HuamiSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -81,14 +79,4 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
@Override @Override
public boolean supportsUnicodeEmojis() { return true; } public boolean supportsUnicodeEmojis() { return true; }
@Override
public boolean supportsDeviceSpecificSettings(GBDevice device) {
return true;
}
@Override
public DeviceSpecificSettingsFragment getDeviceSpecificSettingsFragment(GBDevice device) {
return HuamiSettingsFragment.newInstance(device.getAddress());
}
} }

View File

@ -21,10 +21,11 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;

View File

@ -29,8 +29,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.HuamiSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -85,16 +83,6 @@ public class MiBand3Coordinator extends HuamiCoordinator {
return true; return true;
} }
@Override
public boolean supportsDeviceSpecificSettings(GBDevice device) {
return true;
}
@Override
public DeviceSpecificSettingsFragment getDeviceSpecificSettingsFragment(GBDevice device) {
return HuamiSettingsFragment.newInstance(device.getAddress());
}
public static boolean getBandScreenUnlock() { public static boolean getBandScreenUnlock() {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
return prefs.getBoolean(MiBandConst.PREF_MI3_BAND_SCREEN_UNLOCK, false); return prefs.getBoolean(MiBandConst.PREF_MI3_BAND_SCREEN_UNLOCK, false);