mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-12 13:09:24 +01:00
DevicePrefs gets the GBDevice since it it device specific
This commit is contained in:
parent
80fea5b916
commit
8a4aca06e6
@ -1737,8 +1737,8 @@ public class GBApplication extends Application {
|
||||
return context.getSharedPreferences("devicesettings_" + deviceIdentifier, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static DevicePrefs getDevicePrefs(final String deviceIdentifier) {
|
||||
return new DevicePrefs(getDeviceSpecificSharedPrefs(deviceIdentifier));
|
||||
public static DevicePrefs getDevicePrefs(GBDevice gbDevice) {
|
||||
return new DevicePrefs(getDeviceSpecificSharedPrefs(gbDevice.getAddress()), gbDevice);
|
||||
}
|
||||
|
||||
public static void deleteDeviceSpecificSharedPrefs(String deviceIdentifier) {
|
||||
|
@ -102,7 +102,7 @@ public class ConfigureReminders extends AbstractGBActivity {
|
||||
public void onClick(View v) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
int deviceSlots = coordinator.getReminderSlotCount(gbDevice) - GBApplication.getDevicePrefs(gbDevice.getAddress()).getReservedReminderCalendarSlots(gbDevice);
|
||||
int deviceSlots = coordinator.getReminderSlotCount(gbDevice) - GBApplication.getDevicePrefs(gbDevice).getReservedReminderCalendarSlots();
|
||||
|
||||
if (mGBReminderListAdapter.getItemCount() >= deviceSlots) {
|
||||
// No more free slots
|
||||
|
@ -260,7 +260,7 @@ public class DevicesFragment extends Fragment {
|
||||
|
||||
private void updateDevice(final DBHandler db, final GBDevice gbDevice) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
final boolean showActivityCard = GBApplication.getDevicePrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREFS_ACTIVITY_IN_DEVICE_CARD, true);
|
||||
final boolean showActivityCard = GBApplication.getDevicePrefs(gbDevice).getBoolean(DeviceSettingsPreferenceConst.PREFS_ACTIVITY_IN_DEVICE_CARD, true);
|
||||
if (coordinator.supportsActivityTracking() && showActivityCard) {
|
||||
final long[] stepsAndSleepData = getSteps(gbDevice, db);
|
||||
deviceActivityHashMap.put(gbDevice.getAddress(), stepsAndSleepData);
|
||||
|
@ -80,7 +80,7 @@ public class PebbleContentProvider extends ContentProvider {
|
||||
int pebbleKit = 0;
|
||||
String fwString = "unknown";
|
||||
if (mGBDevice != null && mGBDevice.getType() == DeviceType.PEBBLE && mGBDevice.isInitialized()) {
|
||||
final DevicePrefs deviceSpecificSharedPrefsrefs = GBApplication.getDevicePrefs(mGBDevice.getAddress());
|
||||
final DevicePrefs deviceSpecificSharedPrefsrefs = GBApplication.getDevicePrefs(mGBDevice);
|
||||
if (deviceSpecificSharedPrefsrefs.getBoolean("third_party_apps_set_settings", false)) {
|
||||
pebbleKit = 1;
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ public class DBHelper {
|
||||
public static List<Reminder> getReminders(@NonNull GBDevice gbDevice) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
final int reservedSlots = GBApplication.getDevicePrefs(gbDevice.getAddress()).getReservedReminderCalendarSlots(gbDevice);
|
||||
final int reservedSlots = GBApplication.getDevicePrefs(gbDevice).getReservedReminderCalendarSlots();
|
||||
final int reminderSlots = coordinator.getReminderSlotCount(gbDevice);
|
||||
|
||||
try (DBHandler db = GBApplication.acquireDB()) {
|
||||
|
@ -232,7 +232,7 @@ public class GarminRealtimeSettingsFragment extends AbstractPreferenceFragment {
|
||||
}
|
||||
|
||||
void reload() {
|
||||
final boolean debug = GBApplication.getDevicePrefs(device.getAddress()).getBoolean(PREF_DEBUG, BuildConfig.DEBUG);
|
||||
final boolean debug = GBApplication.getDevicePrefs(device).getBoolean(PREF_DEBUG, BuildConfig.DEBUG);
|
||||
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity == null) {
|
||||
@ -800,7 +800,7 @@ public class GarminRealtimeSettingsFragment extends AbstractPreferenceFragment {
|
||||
}
|
||||
|
||||
void toggleDebug() {
|
||||
final Prefs prefs = GBApplication.getDevicePrefs(device.getAddress());
|
||||
final Prefs prefs = GBApplication.getDevicePrefs(device);
|
||||
prefs.getPreferences().edit()
|
||||
.putBoolean(PREF_DEBUG, !prefs.getBoolean(PREF_DEBUG, BuildConfig.DEBUG))
|
||||
.apply();
|
||||
|
@ -181,20 +181,6 @@ public class HPlusCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return activityUser.getStepsGoal();
|
||||
}
|
||||
|
||||
public static byte getScreenTime(String address) {
|
||||
return (byte) (GBApplication.getDevicePrefs(address).getInt(HPlusConstants.PREF_HPLUS_SCREENTIME, 5) & 0xFF);
|
||||
}
|
||||
|
||||
public static byte getAllDayHR(String address) {
|
||||
boolean value = (GBApplication.getDevicePrefs(address).getBoolean(HPlusConstants.PREF_HPLUS_ALLDAYHR, true));
|
||||
|
||||
if (value) {
|
||||
return HPlusConstants.ARG_HEARTRATE_ALLDAY_ON;
|
||||
} else {
|
||||
return HPlusConstants.ARG_HEARTRATE_ALLDAY_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte getSocial(String address) {
|
||||
//TODO: Figure what this is. Returning the default value
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends AbstractActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
DevicePrefs prefs = GBApplication.getDevicePrefs(device.getAddress());
|
||||
DevicePrefs prefs = GBApplication.getDevicePrefs(device);
|
||||
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH);
|
||||
switch (activityTracker) {
|
||||
case SampleProvider.PROVIDER_PEBBLE_HEALTH:
|
||||
@ -285,7 +285,7 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
}
|
||||
|
||||
public boolean isBackgroundJsEnabled(final GBDevice device) {
|
||||
DevicePrefs deviceSpecificPreferences = GBApplication.getDevicePrefs(device.getAddress());
|
||||
DevicePrefs deviceSpecificPreferences = GBApplication.getDevicePrefs(device);
|
||||
return deviceSpecificPreferences.getBoolean(BG_JS_ENABLED, BG_JS_ENABLED_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
||||
gbDevice.setBatteryState(deviceEvent.state);
|
||||
gbDevice.setBatteryVoltage(deviceEvent.voltage, deviceEvent.batteryIndex);
|
||||
|
||||
final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(gbDevice.getAddress());
|
||||
final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(gbDevice);
|
||||
final BatteryConfig batteryConfig = gbDevice.getDeviceCoordinator().getBatteryConfig(gbDevice)[deviceEvent.batteryIndex];
|
||||
|
||||
if (deviceEvent.level == GBDevice.BATTERY_UNKNOWN) {
|
||||
@ -786,7 +786,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
||||
}
|
||||
|
||||
public DevicePrefs getDevicePrefs() {
|
||||
return GBApplication.getDevicePrefs(gbDevice.getAddress());
|
||||
return GBApplication.getDevicePrefs(gbDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,7 +202,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_BASIC) {
|
||||
SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||
|
||||
String timeformat = GBApplication.getDevicePrefs(getDevice().getAddress()).getTimeFormat();
|
||||
String timeformat = GBApplication.getDevicePrefs(getDevice()).getTimeFormat();
|
||||
|
||||
if(timeformat.equals(getContext().getString(R.string.p_timeformat_24h))) {
|
||||
data[1] |= 0x01;
|
||||
|
@ -293,7 +293,7 @@ class HPlusHandlerThread extends GBDeviceIoThread {
|
||||
sample.setProvider(provider);
|
||||
samples.add(sample);
|
||||
|
||||
if (HPlusCoordinator.getAllDayHR(gbDevice.getAddress()) == HPlusConstants.ARG_HEARTRATE_ALLDAY_ON && storedRecord.heartRate == ActivitySample.NOT_MEASURED && storedRecord.steps <= 0) {
|
||||
if (mHPlusSupport.getAllDayHR() == HPlusConstants.ARG_HEARTRATE_ALLDAY_ON && storedRecord.heartRate == ActivitySample.NOT_MEASURED && storedRecord.steps <= 0) {
|
||||
notWornSlots.add(sample.getTimestamp());
|
||||
notWornSlots.add(sample.getTimestamp() + 10 * 60);
|
||||
|
||||
|
@ -322,23 +322,33 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
|
||||
public byte getScreenTime() {
|
||||
return (byte) (getDevicePrefs().getInt(HPlusConstants.PREF_HPLUS_SCREENTIME, 5) & 0xFF);
|
||||
}
|
||||
|
||||
private HPlusSupport setScreenTime(TransactionBuilder transaction) {
|
||||
byte value = HPlusCoordinator.getScreenTime(getDevice().getAddress());
|
||||
transaction.write(ctrlCharacteristic, new byte[]{
|
||||
HPlusConstants.CMD_SET_SCREENTIME,
|
||||
value
|
||||
getScreenTime()
|
||||
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public byte getAllDayHR() {
|
||||
boolean value = (getDevicePrefs().getBoolean(HPlusConstants.PREF_HPLUS_ALLDAYHR, true));
|
||||
|
||||
if (value) {
|
||||
return HPlusConstants.ARG_HEARTRATE_ALLDAY_ON;
|
||||
} else {
|
||||
return HPlusConstants.ARG_HEARTRATE_ALLDAY_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
private HPlusSupport setAllDayHeart(TransactionBuilder transaction) {
|
||||
|
||||
byte value = HPlusCoordinator.getAllDayHR(getDevice().getAddress());
|
||||
|
||||
transaction.write(ctrlCharacteristic, new byte[]{
|
||||
HPlusConstants.CMD_SET_ALLDAY_HRM,
|
||||
value
|
||||
getAllDayHR()
|
||||
|
||||
});
|
||||
|
||||
|
@ -1028,7 +1028,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
private void sendReminders(final TransactionBuilder builder, final List<? extends Reminder> reminders) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
int reservedSlots = GBApplication.getDevicePrefs(gbDevice.getAddress()).getReservedReminderCalendarSlots(gbDevice);
|
||||
int reservedSlots = GBApplication.getDevicePrefs(gbDevice).getReservedReminderCalendarSlots();
|
||||
LOG.info("On Set Reminders. Reminders: {}, Reserved slots: {}", reminders.size(), reservedSlots);
|
||||
|
||||
// Send the reminders, skipping the reserved slots for calendar events
|
||||
@ -2754,7 +2754,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
}
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
int availableSlots = GBApplication.getDevicePrefs(gbDevice.getAddress()).getReservedReminderCalendarSlots(gbDevice);
|
||||
int availableSlots = GBApplication.getDevicePrefs(gbDevice).getReservedReminderCalendarSlots();
|
||||
|
||||
CalendarManager upcomingEvents = new CalendarManager(getContext(), getDevice().getAddress());
|
||||
List<CalendarEvent> calendarEvents = upcomingEvents.getCalendarEventList();
|
||||
@ -3373,7 +3373,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
}
|
||||
|
||||
protected HuamiSupport setTimeFormat(TransactionBuilder builder) {
|
||||
String timeFormat = GBApplication.getDevicePrefs(gbDevice.getAddress()).getTimeFormat();
|
||||
String timeFormat = GBApplication.getDevicePrefs(gbDevice).getTimeFormat();
|
||||
|
||||
LOG.info("Setting time format to " + timeFormat);
|
||||
if (timeFormat.equals(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT_24H)) {
|
||||
|
@ -1057,7 +1057,7 @@ public class HuaweiSupportProvider {
|
||||
GB.toast(context, context.getString(R.string.toast_setting_requires_reconnect), Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
case DeviceSettingsPreferenceConst.PREF_BATTERY_POLLING_ENABLE:
|
||||
if (!GBApplication.getDevicePrefs(gbDevice.getAddress()).getBatteryPollingEnabled()) {
|
||||
if (!GBApplication.getDevicePrefs(gbDevice).getBatteryPollingEnabled()) {
|
||||
stopBatteryRunnerDelayed();
|
||||
break;
|
||||
}
|
||||
@ -2118,7 +2118,7 @@ public class HuaweiSupportProvider {
|
||||
}
|
||||
|
||||
public boolean startBatteryRunnerDelayed() {
|
||||
int interval_minutes = GBApplication.getDevicePrefs(deviceMac).getBatteryPollingIntervalMinutes();
|
||||
int interval_minutes = GBApplication.getDevicePrefs(gbDevice).getBatteryPollingIntervalMinutes();
|
||||
int interval = interval_minutes * 60 * 1000;
|
||||
LOG.debug("Starting battery runner delayed by {} ({} minutes)", interval, interval_minutes);
|
||||
handler.removeCallbacks(batteryRunner);
|
||||
|
@ -64,7 +64,7 @@ public class GetBatteryLevelRequest extends Request {
|
||||
batteryInfo.level = (int)batteryLevel & 0xff;
|
||||
this.supportProvider.evaluateGBDeviceEvent(batteryInfo);
|
||||
|
||||
if (GBApplication.getDevicePrefs(getDevice().getAddress()).getBatteryPollingEnabled()) {
|
||||
if (GBApplication.getDevicePrefs(getDevice()).getBatteryPollingEnabled()) {
|
||||
if (!this.supportProvider.startBatteryRunnerDelayed()) {
|
||||
GB.toast(getContext(), R.string.battery_polling_failed_start, Toast.LENGTH_SHORT, GB.ERROR);
|
||||
LOG.error("Failed to start the battery polling");
|
||||
|
@ -1003,7 +1003,7 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||
}
|
||||
|
||||
public byte getTimeMode(SharedPreferences sharedPrefs) {
|
||||
String timeMode = new DevicePrefs(sharedPrefs).getTimeFormat();
|
||||
String timeMode = new DevicePrefs(sharedPrefs, gbDevice).getTimeFormat();
|
||||
|
||||
if (timeMode.equals(getContext().getString(R.string.p_timeformat_24h))) {
|
||||
return MakibesHR3Constants.ARG_SET_TIMEMODE_24H;
|
||||
|
@ -366,7 +366,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
// Unfortunately this extra pairing causes problems when bonding is not used/does not work
|
||||
// so we only do this when configured to keep data on the device
|
||||
|
||||
Prefs prefs = GBApplication.getDevicePrefs(gbDevice.getAddress());
|
||||
Prefs prefs = GBApplication.getDevicePrefs(gbDevice);
|
||||
if (prefs.getBoolean("keep_activity_data_on_device", false)) {
|
||||
LOG.info("Attempting to pair MI device...");
|
||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_PAIR);
|
||||
|
@ -410,7 +410,7 @@ public class FetchActivityOperation extends AbstractMiBand1Operation {
|
||||
*/
|
||||
private void sendAckDataTransfer(Calendar time, int bytesTransferred) {
|
||||
byte[] ackTime = MiBandDateConverter.calendarToRawBytes(time, getDevice().getAddress());
|
||||
Prefs prefs = GBApplication.getDevicePrefs(getDevice().getAddress());
|
||||
Prefs prefs = GBApplication.getDevicePrefs(getDevice());
|
||||
|
||||
byte[] ackChecksum = new byte[]{
|
||||
(byte) (bytesTransferred & 0xff),
|
||||
|
@ -48,7 +48,7 @@ class AppMessageHandler {
|
||||
AppMessageHandler(UUID uuid, PebbleProtocol pebbleProtocol) {
|
||||
mUUID = uuid;
|
||||
mPebbleProtocol = pebbleProtocol;
|
||||
devicePrefs = GBApplication.getDevicePrefs(pebbleProtocol.getDevice().getAddress());
|
||||
devicePrefs = GBApplication.getDevicePrefs(pebbleProtocol.getDevice());
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
@ -88,4 +88,4 @@ class AppMessageHandler {
|
||||
}
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ abstract class DatalogSessionPebbleHealth extends DatalogSession {
|
||||
DatalogSessionPebbleHealth(byte id, UUID uuid, int timestamp, int tag, byte itemType, short itemSize, GBDevice device) {
|
||||
super(id, uuid, timestamp, tag, itemType, itemSize);
|
||||
mDevice = device;
|
||||
devicePrefs = GBApplication.getDevicePrefs(mDevice.getAddress());
|
||||
devicePrefs = GBApplication.getDevicePrefs(mDevice);
|
||||
}
|
||||
|
||||
public GBDevice getDevice() {
|
||||
|
@ -149,7 +149,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
|
||||
PebbleIoThread(PebbleSupport pebbleSupport, GBDevice gbDevice, GBDeviceProtocol gbDeviceProtocol, BluetoothAdapter btAdapter, Context context) {
|
||||
super(gbDevice, context);
|
||||
devicePrefs = GBApplication.getDevicePrefs(gbDevice.getAddress());
|
||||
devicePrefs = GBApplication.getDevicePrefs(gbDevice);
|
||||
mPebbleProtocol = (PebbleProtocol) gbDeviceProtocol;
|
||||
mBtAdapter = btAdapter;
|
||||
mPebbleSupport = pebbleSupport;
|
||||
@ -193,7 +193,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
LOG.info("This is a Pebble 2 or Pebble-LE/Pebble Time LE, will use BLE");
|
||||
mInStream = new PipedInputStream();
|
||||
mOutStream = new PipedOutputStream();
|
||||
mPebbleLESupport = new PebbleLESupport(this.getContext(), btDevice, (PipedInputStream) mInStream, (PipedOutputStream) mOutStream);
|
||||
mPebbleLESupport = new PebbleLESupport(this.getContext(), gbDevice, btDevice, (PipedInputStream) mInStream, (PipedOutputStream) mOutStream);
|
||||
} else {
|
||||
ParcelUuid[] uuids = btDevice.getUuids();
|
||||
if (uuids == null) {
|
||||
|
@ -182,7 +182,7 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onNotification(NotificationSpec notificationSpec) {
|
||||
String currentPrivacyMode = GBApplication.getDevicePrefs(gbDevice.getAddress()).getString("pebble_pref_privacy_mode", getContext().getString(R.string.p_pebble_privacy_mode_off));
|
||||
String currentPrivacyMode = GBApplication.getDevicePrefs(gbDevice).getString("pebble_pref_privacy_mode", getContext().getString(R.string.p_pebble_privacy_mode_off));
|
||||
if (getContext().getString(R.string.p_pebble_privacy_mode_complete).equals(currentPrivacyMode)) {
|
||||
notificationSpec.body = null;
|
||||
notificationSpec.sender = null;
|
||||
@ -206,7 +206,7 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
if (reconnect()) {
|
||||
if ((callSpec.command != CallSpec.CALL_OUTGOING) || GBApplication.getDevicePrefs(gbDevice.getAddress()).getBoolean("pebble_enable_outgoing_call", true)) {
|
||||
if ((callSpec.command != CallSpec.CALL_OUTGOING) || GBApplication.getDevicePrefs(gbDevice).getBoolean("pebble_enable_outgoing_call", true)) {
|
||||
super.onSetCallState(callSpec);
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,11 @@ import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
|
||||
public class PebbleLESupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PebbleLESupport.class);
|
||||
private final GBDevice mgbDevice;
|
||||
private final BluetoothDevice mBtDevice;
|
||||
private PipeReader mPipeReader;
|
||||
private PebbleGATTServer mPebbleGATTServer;
|
||||
@ -45,7 +47,8 @@ public class PebbleLESupport {
|
||||
private HandlerThread mWriteHandlerThread;
|
||||
private Handler mWriteHandler;
|
||||
|
||||
public PebbleLESupport(Context context, final BluetoothDevice btDevice, PipedInputStream pipedInputStream, PipedOutputStream pipedOutputStream) throws IOException {
|
||||
public PebbleLESupport(Context context, GBDevice gbDevice, final BluetoothDevice btDevice, PipedInputStream pipedInputStream, PipedOutputStream pipedOutputStream) throws IOException {
|
||||
mgbDevice = gbDevice;
|
||||
mBtDevice = btDevice;
|
||||
mPipedInputStream = new PipedInputStream();
|
||||
mPipedOutputStream = new PipedOutputStream();
|
||||
@ -60,11 +63,11 @@ public class PebbleLESupport {
|
||||
mWriteHandlerThread.start();
|
||||
mWriteHandler = new Handler(mWriteHandlerThread.getLooper());
|
||||
|
||||
mMTULimit = GBApplication.getDevicePrefs(mBtDevice.getAddress()).getInt("pebble_mtu_limit", 512);
|
||||
mMTULimit = GBApplication.getDevicePrefs(mgbDevice).getInt("pebble_mtu_limit", 512);
|
||||
mMTULimit = Math.max(mMTULimit, 20);
|
||||
mMTULimit = Math.min(mMTULimit, 512);
|
||||
|
||||
clientOnly = GBApplication.getDevicePrefs(mBtDevice.getAddress()).getBoolean("pebble_gatt_clientonly", false);
|
||||
clientOnly = GBApplication.getDevicePrefs(mgbDevice).getBoolean("pebble_gatt_clientonly", false);
|
||||
|
||||
if (!clientOnly) {
|
||||
mPebbleGATTServer = new PebbleGATTServer(this, context, mBtDevice);
|
||||
|
@ -61,7 +61,7 @@ public abstract class AbstractXiaomiService {
|
||||
}
|
||||
|
||||
protected DevicePrefs getDevicePrefs() {
|
||||
return GBApplication.getDevicePrefs(getSupport().getDevice().getAddress());
|
||||
return GBApplication.getDevicePrefs(getSupport().getDevice());
|
||||
}
|
||||
|
||||
public void onDisconnect() {}
|
||||
|
@ -182,6 +182,6 @@ public abstract class GBDeviceProtocol {
|
||||
}
|
||||
|
||||
protected DevicePrefs getDevicePrefs() {
|
||||
return GBApplication.getDevicePrefs(getDevice().getAddress());
|
||||
return GBApplication.getDevicePrefs(getDevice());
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ public class GB {
|
||||
}
|
||||
|
||||
public static String buildDeviceBatteryString(final Context context, final GBDevice device) {
|
||||
final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device.getAddress());
|
||||
final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device);
|
||||
final List<Integer> batteryLevels = new ArrayList<>();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -32,8 +32,11 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
|
||||
public class DevicePrefs extends Prefs {
|
||||
public DevicePrefs(final SharedPreferences preferences) {
|
||||
private GBDevice gbDevice;
|
||||
|
||||
public DevicePrefs(final SharedPreferences preferences, GBDevice gbDevice) {
|
||||
super(preferences);
|
||||
this.gbDevice = gbDevice;
|
||||
}
|
||||
|
||||
public boolean getBatteryShowInNotification(final int batteryIndex) {
|
||||
@ -104,7 +107,7 @@ public class DevicePrefs extends Prefs {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public int getReservedReminderCalendarSlots(GBDevice gbDevice) {
|
||||
public int getReservedReminderCalendarSlots() {
|
||||
if (!gbDevice.getDeviceCoordinator().getReserveReminderSlotsForCalendar())
|
||||
return 0;
|
||||
if (!getBoolean(DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR, false))
|
||||
|
Loading…
Reference in New Issue
Block a user