Mi Band: Migrate global preferences to device-specific

This commit is contained in:
José Rebelo 2024-08-23 14:22:59 +01:00 committed by José Rebelo
parent 1161fc70c5
commit 2b9987d3e5
18 changed files with 226 additions and 304 deletions

View File

@ -178,10 +178,6 @@
android:name=".activities.discovery.DiscoveryPairingPreferenceActivity" android:name=".activities.discovery.DiscoveryPairingPreferenceActivity"
android:label="@string/activity_prefs_discovery_pairing" android:label="@string/activity_prefs_discovery_pairing"
android:parentActivityName=".activities.SettingsActivity" /> android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".devices.miband.MiBandPreferencesActivity"
android:label="@string/preferences_miband_1_2_settings"
android:parentActivityName=".activities.SettingsActivity" />
<activity <activity
android:name=".activities.loyaltycards.LoyaltyCardsSettingsActivity" android:name=".activities.loyaltycards.LoyaltyCardsSettingsActivity"
android:label="@string/loyalty_cards" android:label="@string/loyalty_cards"

View File

@ -122,7 +122,7 @@ public class GBApplication extends Application {
private static SharedPreferences sharedPrefs; private static SharedPreferences sharedPrefs;
private static final String PREFS_VERSION = "shared_preferences_version"; private static final String PREFS_VERSION = "shared_preferences_version";
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version //if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
private static final int CURRENT_PREFS_VERSION = 33; private static final int CURRENT_PREFS_VERSION = 34;
private static final LimitedQueue<Integer, String> mIDSenderLookup = new LimitedQueue<>(16); private static final LimitedQueue<Integer, String> mIDSenderLookup = new LimitedQueue<>(16);
private static GBPrefs prefs; private static GBPrefs prefs;
@ -1573,6 +1573,47 @@ public class GBApplication extends Application {
} }
} }
if (oldVersion < 34) {
// Migrate Mi Band preferences to device-specific
try (DBHandler db = acquireDB()) {
final DaoSession daoSession = db.getDaoSession();
final List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
for (Device dbDevice : activeDevices) {
final DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
if (deviceType == MIBAND || deviceType == MIBAND2 || deviceType == MIBAND2_HRX) {
final SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
final SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
deviceSharedPrefsEdit.putString("mi_vibration_profile_generic_sms", sharedPrefs.getString("mi_vibration_profile_generic_sms", "staccato"));
deviceSharedPrefsEdit.putString("mi_vibration_count_generic_sms", sharedPrefs.getString("mi_vibration_count_generic_sms", "3"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_incoming_call", sharedPrefs.getString("mi_vibration_profile_incoming_call", "ring"));
deviceSharedPrefsEdit.putString("mi_vibration_count_incoming_call", sharedPrefs.getString("mi_vibration_count_incoming_call", "60"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_generic_email", sharedPrefs.getString("mi_vibration_profile_generic_email", "medium"));
deviceSharedPrefsEdit.putString("mi_vibration_count_generic_email", sharedPrefs.getString("mi_vibration_count_generic_email", "2"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_generic_chat", sharedPrefs.getString("mi_vibration_profile_generic_chat", "waterdrop"));
deviceSharedPrefsEdit.putString("mi_vibration_count_generic_chat", sharedPrefs.getString("mi_vibration_count_generic_chat", "3"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_generic_social", sharedPrefs.getString("mi_vibration_profile_generic_social", "waterdrop"));
deviceSharedPrefsEdit.putString("mi_vibration_count_generic_social", sharedPrefs.getString("mi_vibration_count_generic_social", "3"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_alarm_clock", sharedPrefs.getString("mi_vibration_profile_alarm_clock", "alarm_clock"));
deviceSharedPrefsEdit.putString("mi_vibration_count_alarm_clock", sharedPrefs.getString("mi_vibration_count_alarm_clock", "3"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_generic_navigation", sharedPrefs.getString("mi_vibration_profile_generic_navigation", "waterdrop"));
deviceSharedPrefsEdit.putString("mi_vibration_count_generic_navigation", sharedPrefs.getString("mi_vibration_count_generic_navigation", "3"));
deviceSharedPrefsEdit.putString("mi_vibration_profile_generic", sharedPrefs.getString("mi_vibration_profile_generic", "waterdrop"));
deviceSharedPrefsEdit.putString("mi_vibration_count_generic", sharedPrefs.getString("mi_vibration_count_generic", "3"));
if (deviceType == MIBAND) {
deviceSharedPrefsEdit.putBoolean("keep_activity_data_on_device", sharedPrefs.getBoolean("mi_dont_ack_transfer", false));
}
deviceSharedPrefsEdit.apply();
}
}
} catch (Exception e) {
Log.w(TAG, "error acquiring DB lock");
}
}
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION)); editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
editor.apply(); editor.apply();
} }

View File

@ -66,7 +66,6 @@ import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsPreferencesActivity; import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsPreferencesActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryPairingPreferenceActivity; import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryPairingPreferenceActivity;
import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter; import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleSettingsActivity; import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimePreferenceActivity; import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimePreferenceActivity;
import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver; import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver;
@ -128,15 +127,6 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
}); });
} }
pref = findPreference("pref_key_miband");
if (pref != null) {
pref.setOnPreferenceClickListener(preference -> {
Intent enableIntent = new Intent(requireContext(), MiBandPreferencesActivity.class);
startActivity(enableIntent);
return true;
});
}
pref = findPreference("pref_key_pebble"); pref = findPreference("pref_key_pebble");
if (pref != null) { if (pref != null) {
pref.setOnPreferenceClickListener(preference -> { pref.setOnPreferenceClickListener(preference -> {

View File

@ -159,12 +159,6 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
prefs.getPreferences().edit().putStringSet(GBPrefs.LAST_DEVICE_ADDRESSES, lastDeviceAddresses).apply(); prefs.getPreferences().edit().putStringSet(GBPrefs.LAST_DEVICE_ADDRESSES, lastDeviceAddresses).apply();
} }
String macAddress = prefs.getPreferences().getString(MiBandConst.PREF_MIBAND_ADDRESS, "");
if (gbDevice.getAddress().equals(macAddress)) {
LOG.debug("#1605 removing devel miband");
prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply();
}
GBApplication.deleteDeviceSpecificSharedPrefs(gbDevice.getAddress()); GBApplication.deleteDeviceSpecificSharedPrefs(gbDevice.getAddress());
try (DBHandler dbHandler = GBApplication.acquireDB()) { try (DBHandler dbHandler = GBApplication.acquireDB()) {

View File

@ -22,26 +22,21 @@ import android.net.Uri;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
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;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; 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.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support;
public class MiBand2Coordinator extends HuamiCoordinator { public class MiBand2Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand2Coordinator.class);
@Override @Override
protected Pattern getSupportedDeviceName() { protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.MI_BAND2_NAME, Pattern.CASE_INSENSITIVE); return Pattern.compile(HuamiConst.MI_BAND2_NAME, Pattern.CASE_INSENSITIVE);
@ -57,11 +52,6 @@ public class MiBand2Coordinator extends HuamiCoordinator {
return true; return true;
} }
@Override
public boolean supportsWeather() {
return false;
}
@Override @Override
public int getReminderSlotCount(final GBDevice device) { public int getReminderSlotCount(final GBDevice device) {
return 0; return 0;
@ -85,6 +75,7 @@ public class MiBand2Coordinator extends HuamiCoordinator {
R.xml.devicesettings_inactivity_dnd, R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_rotatewrist_cycleinfo, R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_buttonactions, R.xml.devicesettings_buttonactions,
R.xml.devicesettings_miband_vibrationpatterns,
R.xml.devicesettings_reserve_alarms_calendar, R.xml.devicesettings_reserve_alarms_calendar,
R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_overwrite_settings_on_connection,
@ -93,6 +84,12 @@ public class MiBand2Coordinator extends HuamiCoordinator {
}; };
} }
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
// For the vibration patterns, which are still legacy mi_ ones
return new MiBandSettingsCustomizer(device);
}
@NonNull @NonNull
@Override @Override
public Class<? extends DeviceSupport> getDeviceSupportClass() { public Class<? extends DeviceSupport> getDeviceSupportClass() {

View File

@ -20,28 +20,23 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband2;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
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;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; 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.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support;
public class MiBand2HRXCoordinator extends HuamiCoordinator { public class MiBand2HRXCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand2HRXCoordinator.class);
@Override @Override
protected Pattern getSupportedDeviceName() { protected Pattern getSupportedDeviceName() {
return Pattern.compile( return Pattern.compile(
@ -56,20 +51,7 @@ public class MiBand2HRXCoordinator extends HuamiCoordinator {
} }
@Override @Override
public boolean supportsFlashing() { return false; } public boolean supportsFlashing() {
@Override
public boolean supportsAlarmSnoozing() {
return true;
}
@Override
public boolean supportsHeartRateMeasurement(GBDevice device) {
return false;
}
@Override
public boolean supportsWeather() {
return false; return false;
} }
@ -89,12 +71,19 @@ public class MiBand2HRXCoordinator extends HuamiCoordinator {
R.xml.devicesettings_liftwrist_display, R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_inactivity_dnd, R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_rotatewrist_cycleinfo, R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_miband_vibrationpatterns,
R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_overwrite_settings_on_connection,
R.xml.devicesettings_huami2021_fetch_operation_time_unit, R.xml.devicesettings_huami2021_fetch_operation_time_unit,
R.xml.devicesettings_transliteration R.xml.devicesettings_transliteration
}; };
} }
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
// For the vibration patterns, which are still legacy mi_ ones
return new MiBandSettingsCustomizer(device);
}
@NonNull @NonNull
@Override @Override
public Class<? extends DeviceSupport> getDeviceSupportClass() { public Class<? extends DeviceSupport> getDeviceSupportClass() {

View File

@ -22,9 +22,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.Version; import nodomain.freeyourgadget.gadgetbridge.util.Version;
public final class MiBandConst { public final class MiBandConst {
public static final String PREF_MIBAND_ADDRESS = "development_miaddr"; // FIXME: should be prefixed mi_
public static final String PREF_MIBAND_ALARMS = "mi_alarms"; public static final String PREF_MIBAND_ALARMS = "mi_alarms";
public static final String PREF_MIBAND_DONT_ACK_TRANSFER = "mi_dont_ack_transfer";
public static final String PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS = "device_time_offset_hours"; public static final String PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS = "device_time_offset_hours";
public static final String PREF_MI2_DATEFORMAT = "mi2_dateformat"; public static final String PREF_MI2_DATEFORMAT = "mi2_dateformat";
public static final String PREF_MI2_DISPLAY_ITEM_CLOCK = "clock"; public static final String PREF_MI2_DISPLAY_ITEM_CLOCK = "clock";
@ -35,7 +33,6 @@ public final class MiBandConst {
public static final String PREF_MI2_DISPLAY_ITEM_BATTERY = "battery"; public static final String PREF_MI2_DISPLAY_ITEM_BATTERY = "battery";
public static final String PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO = "rotate_wrist_to_cycle_info"; public static final String PREF_MI2_ROTATE_WRIST_TO_SWITCH_INFO = "rotate_wrist_to_cycle_info";
public static final String PREF_MI2_ENABLE_TEXT_NOTIFICATIONS = "mi2_enable_text_notifications"; public static final String PREF_MI2_ENABLE_TEXT_NOTIFICATIONS = "mi2_enable_text_notifications";
public static final String PREF_MIBAND_SETUP_BT_PAIRING = "mi_setup_bt_pairing";
public static final String PREF_SWIPE_UNLOCK = "swipe_unlock"; public static final String PREF_SWIPE_UNLOCK = "swipe_unlock";
public static final String PREF_NIGHT_MODE = "night_mode"; public static final String PREF_NIGHT_MODE = "night_mode";

View File

@ -35,12 +35,16 @@ import org.slf4j.LoggerFactory;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder; import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; 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.devicesettings.DeviceSettingsPreferenceConst; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
@ -51,7 +55,6 @@ import nodomain.freeyourgadget.gadgetbridge.entities.MiBandActivitySampleDao;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport;
@ -73,7 +76,6 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
return Collections.singletonList(filter); return Collections.singletonList(filter);
} }
@NonNull
@Override @Override
public boolean supports(GBDeviceCandidate candidate) { public boolean supports(GBDeviceCandidate candidate) {
String macAddress = candidate.getMacAddress().toUpperCase(); String macAddress = candidate.getMacAddress().toUpperCase();
@ -128,11 +130,6 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
return true; return true;
} }
@Override
public boolean supportsScreenshots(final GBDevice device) {
return false;
}
@Override @Override
public int getAlarmSlotCount(GBDevice device) { public int getAlarmSlotCount(GBDevice device) {
return 3; return 3;
@ -153,31 +150,11 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
return "Xiaomi"; return "Xiaomi";
} }
@Override
public boolean supportsAppsManagement(final GBDevice device) {
return false;
}
@Override
public Class<? extends Activity> getAppsManagementActivity() {
return null;
}
@Override
public boolean supportsCalendarEvents() {
return false;
}
@Override @Override
public boolean supportsRealtimeData() { public boolean supportsRealtimeData() {
return true; return true;
} }
@Override
public boolean supportsWeather() {
return false;
}
@Override @Override
public boolean supportsFindDevice() { public boolean supportsFindDevice() {
return true; return true;
@ -261,14 +238,27 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
} }
@Override @Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) { public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
return new int[]{ final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_heartrate_sleep, deviceSpecificSettings.addRootScreen(R.xml.devicesettings_wearlocation);
R.xml.devicesettings_lowlatency_fwupdate, deviceSpecificSettings.addRootScreen(R.xml.devicesettings_heartrate_sleep);
R.xml.devicesettings_reserve_alarms_calendar, deviceSpecificSettings.addRootScreen(R.xml.devicesettings_miband_vibrationpatterns);
R.xml.devicesettings_fake_timeoffset deviceSpecificSettings.addRootScreen(R.xml.devicesettings_reserve_alarms_calendar);
}; deviceSpecificSettings.addRootScreen(R.xml.devicesettings_fake_timeoffset);
final List<Integer> connection = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CONNECTION);
connection.add(R.xml.devicesettings_lowlatency_fwupdate);
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
developer.add(R.xml.devicesettings_keep_activity_data_on_device);
return deviceSpecificSettings;
}
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
return new MiBandSettingsCustomizer(device);
} }
@NonNull @NonNull
@ -305,7 +295,6 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
return R.string.devicetype_miband; return R.string.devicetype_miband;
} }
@Override @Override
@DrawableRes @DrawableRes
public int getDefaultIconResource() { public int getDefaultIconResource() {

View File

@ -34,6 +34,8 @@ import android.widget.Toast;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -44,15 +46,18 @@ import nodomain.freeyourgadget.gadgetbridge.activities.AboutUserPreferencesActiv
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2; import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2;
import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryActivityV2; import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryActivityV2;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils; import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
import nodomain.freeyourgadget.gadgetbridge.util.BondingInterface; import nodomain.freeyourgadget.gadgetbridge.util.BondingInterface;
import nodomain.freeyourgadget.gadgetbridge.util.BondingUtil; import nodomain.freeyourgadget.gadgetbridge.util.BondingUtil;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper; import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class MiBandPairingActivity extends AbstractGBActivity implements BondingInterface { public class MiBandPairingActivity extends AbstractGBActivity implements BondingInterface {
private static final Logger LOG = LoggerFactory.getLogger(MiBandPairingActivity.class); private static final Logger LOG = LoggerFactory.getLogger(MiBandPairingActivity.class);
@ -140,12 +145,18 @@ public class MiBandPairingActivity extends AbstractGBActivity implements Bonding
isPairing = true; isPairing = true;
message.setText(getString(R.string.pairing, deviceCandidate)); message.setText(getString(R.string.pairing, deviceCandidate));
if (!BondingUtil.shouldUseBonding()) { final BondingInterface thiz = this;
BondingUtil.attemptToFirstConnect(getCurrentTarget().getDevice()); new MaterialAlertDialogBuilder(getContext())
return; .setCancelable(true)
} .setTitle(getContext().getString(R.string.discovery_pair_title, deviceCandidate.getName()))
.setMessage(getContext().getString(R.string.discovery_pair_question))
BondingUtil.tryBondThenComplete(this, deviceCandidate.getDevice(), deviceCandidate.getMacAddress()); .setNegativeButton(R.string.discovery_dont_pair, (dialog, which) -> {
BondingUtil.attemptToFirstConnect(getCurrentTarget().getDevice());
})
.setPositiveButton(getContext().getString(R.string.discovery_yes_pair), (dialog, which) -> {
BondingUtil.tryBondThenComplete(thiz, deviceCandidate.getDevice(), deviceCandidate.getMacAddress());
})
.show();
} }
@ -171,8 +182,15 @@ public class MiBandPairingActivity extends AbstractGBActivity implements Bonding
String macAddress = deviceCandidate.getMacAddress(); String macAddress = deviceCandidate.getMacAddress();
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(macAddress); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(macAddress);
if (device != null && device.getBondState() == BluetoothDevice.BOND_NONE) { if (device != null && device.getBondState() == BluetoothDevice.BOND_NONE) {
Prefs prefs = GBApplication.getPrefs(); // Persist the device directly to the database
prefs.getPreferences().edit().putString(MiBandConst.PREF_MIBAND_ADDRESS, macAddress).apply(); try (DBHandler db = GBApplication.acquireDB()) {
final DaoSession daoSession = db.getDaoSession();
final GBDevice gbDevice = DeviceHelper.getInstance().toSupportedDevice(deviceCandidate);
DBHelper.getDevice(gbDevice, daoSession);
gbDevice.sendDeviceUpdateIntent(this);
} catch (final Exception e) {
GB.log("Error accessing database", GB.ERROR, e);
}
} }
Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); startActivity(intent);

View File

@ -1,92 +0,0 @@
/* Copyright (C) 2015-2024 Andreas Shimokawa, Carsten Pfeiffer, Christian
Fischer, Damien Gaignon, Daniele Gobbetti, José Rebelo, Szymon Tomasz Stefanek
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 <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MIBAND_ADDRESS;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
public class MiBandPreferencesActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return MiBandPreferencesFragment.FRAGMENT_TAG;
}
@Override
protected PreferenceFragmentCompat newFragment() {
return new MiBandPreferencesFragment();
}
public static class MiBandPreferencesFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "MIBAND_PREFERENCES_FRAGMENT";
@Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.miband_preferences, rootKey);
for (final NotificationType type : NotificationType.values()) {
String countPrefKey = "mi_vibration_count_" + type.getGenericType();
setInputTypeFor(countPrefKey, InputType.TYPE_CLASS_NUMBER);
String tryPrefKey = "mi_try_" + type.getGenericType();
final Preference tryPref = findPreference(tryPrefKey);
if (tryPref != null) {
tryPref.setOnPreferenceClickListener(preference -> {
tryVibration(type);
return true;
});
}
}
final Preference developmentMiAddr = findPreference(PREF_MIBAND_ADDRESS);
if (developmentMiAddr != null) {
developmentMiAddr.setOnPreferenceChangeListener((preference, newVal) -> {
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
LocalBroadcastManager.getInstance(requireActivity().getBaseContext()).sendBroadcast(refreshIntent);
return true;
});
}
}
/**
* delayed execution so that the preferences are applied first
*/
private void invokeLater(Runnable runnable) {
getListView().post(runnable);
}
private void tryVibration(NotificationType type) {
NotificationSpec spec = new NotificationSpec();
spec.type = type;
GBApplication.deviceService().onNotification(spec);
}
}
}

View File

@ -0,0 +1,96 @@
/* Copyright (C) 2024 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 <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
import android.os.Parcel;
import android.text.InputType;
import androidx.preference.Preference;
import java.util.Collections;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class MiBandSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
private final GBDevice device;
public MiBandSettingsCustomizer(final GBDevice device) {
this.device = device;
}
@Override
public void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler) {
}
@Override
public void customizeSettings(final DeviceSpecificSettingsHandler handler, final Prefs prefs) {
for (final NotificationType type : NotificationType.values()) {
String countPrefKey = "mi_vibration_count_" + type.getGenericType();
handler.setInputTypeFor(countPrefKey, InputType.TYPE_CLASS_NUMBER);
String tryPrefKey = "mi_try_" + type.getGenericType();
final Preference tryPref = handler.findPreference(tryPrefKey);
if (tryPref != null) {
tryPref.setOnPreferenceClickListener(preference -> {
tryVibration(type);
return true;
});
}
}
}
private void tryVibration(NotificationType type) {
NotificationSpec spec = new NotificationSpec();
spec.type = type;
GBApplication.deviceService(device).onNotification(spec);
}
@Override
public Set<String> getPreferenceKeysWithSummary() {
return Collections.emptySet();
}
public static final Creator<MiBandSettingsCustomizer> CREATOR = new Creator<MiBandSettingsCustomizer>() {
@Override
public MiBandSettingsCustomizer createFromParcel(final Parcel in) {
final GBDevice device = in.readParcelable(MiBandSettingsCustomizer.class.getClassLoader());
return new MiBandSettingsCustomizer(device);
}
@Override
public MiBandSettingsCustomizer[] newArray(final int size) {
return new MiBandSettingsCustomizer[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(final Parcel dest, final int flags) {
dest.writeParcelable(device, 0);
}
}

View File

@ -847,7 +847,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
protected void performPreferredNotification(String task, String notificationOrigin, SimpleNotification simpleNotification, int alertLevel, BtLEAction extraAction) { protected void performPreferredNotification(String task, String notificationOrigin, SimpleNotification simpleNotification, int alertLevel, BtLEAction extraAction) {
try { try {
TransactionBuilder builder = performInitialized(task); TransactionBuilder builder = performInitialized(task);
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
short vibrateTimes = getPreferredVibrateCount(notificationOrigin, prefs); short vibrateTimes = getPreferredVibrateCount(notificationOrigin, prefs);
VibrationProfile profile = getPreferredVibrateProfile(notificationOrigin, prefs, vibrateTimes); VibrationProfile profile = getPreferredVibrateProfile(notificationOrigin, prefs, vibrateTimes);
profile.setAlertLevel(alertLevel); profile.setAlertLevel(alertLevel);

View File

@ -366,8 +366,8 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
// Unfortunately this extra pairing causes problems when bonding is not used/does not work // 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 // so we only do this when configured to keep data on the device
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getDevicePrefs(gbDevice.getAddress());
if (prefs.getBoolean(MiBandConst.PREF_MIBAND_DONT_ACK_TRANSFER, false)) { if (prefs.getBoolean("keep_activity_data_on_device", false)) {
LOG.info("Attempting to pair MI device..."); LOG.info("Attempting to pair MI device...");
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_PAIR); BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_PAIR);
if (characteristic != null) { if (characteristic != null) {
@ -483,7 +483,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
private void performPreferredNotification(String task, @Nullable SimpleNotification simpleNotification, String notificationOrigin, BtLEAction extraAction) { private void performPreferredNotification(String task, @Nullable SimpleNotification simpleNotification, String notificationOrigin, BtLEAction extraAction) {
try { try {
TransactionBuilder builder = performInitialized(task); TransactionBuilder builder = performInitialized(task);
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = getDevicePrefs();
int vibrateDuration = getPreferredVibrateDuration(notificationOrigin, prefs); int vibrateDuration = getPreferredVibrateDuration(notificationOrigin, prefs);
int vibratePause = getPreferredVibratePause(notificationOrigin, prefs); int vibratePause = getPreferredVibratePause(notificationOrigin, prefs);
short vibrateTimes = getPreferredVibrateCount(notificationOrigin, prefs); short vibrateTimes = getPreferredVibrateCount(notificationOrigin, prefs);

View File

@ -410,13 +410,13 @@ public class FetchActivityOperation extends AbstractMiBand1Operation {
*/ */
private void sendAckDataTransfer(Calendar time, int bytesTransferred) { private void sendAckDataTransfer(Calendar time, int bytesTransferred) {
byte[] ackTime = MiBandDateConverter.calendarToRawBytes(time, getDevice().getAddress()); byte[] ackTime = MiBandDateConverter.calendarToRawBytes(time, getDevice().getAddress());
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getDevicePrefs(getDevice().getAddress());
byte[] ackChecksum = new byte[]{ byte[] ackChecksum = new byte[]{
(byte) (bytesTransferred & 0xff), (byte) (bytesTransferred & 0xff),
(byte) (0xff & (bytesTransferred >> 8)) (byte) (0xff & (bytesTransferred >> 8))
}; };
if (prefs.getBoolean(MiBandConst.PREF_MIBAND_DONT_ACK_TRANSFER, false)) { if (prefs.getBoolean("keep_activity_data_on_device", false)) {
ackChecksum = new byte[]{ ackChecksum = new byte[]{
(byte) (~bytesTransferred & 0xff), (byte) (~bytesTransferred & 0xff),
(byte) (0xff & (~bytesTransferred >> 8)) (byte) (0xff & (~bytesTransferred >> 8))
@ -445,7 +445,7 @@ public class FetchActivityOperation extends AbstractMiBand1Operation {
//When we ack this chunk, the transfer is done. //When we ack this chunk, the transfer is done.
if (getDevice().isBusy() && bytesTransferred == 0) { if (getDevice().isBusy() && bytesTransferred == 0) {
//if we are not clearing miband's data, we have to stop the sync //if we are not clearing miband's data, we have to stop the sync
if (prefs.getBoolean(MiBandConst.PREF_MIBAND_DONT_ACK_TRANSFER, false)) { if (prefs.getBoolean("keep_activity_data_on_device", false)) {
builder = performInitialized("send acknowledge"); builder = performInitialized("send acknowledge");
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_STOP_SYNC_DATA}); builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_STOP_SYNC_DATA});
getSupport().setHighLatency(builder); getSupport().setHighLatency(builder);

View File

@ -156,19 +156,6 @@ public class BondingUtil {
} }
} }
/**
* Returns true if GB should pair
*/
public static boolean shouldUseBonding() {
// TODO: Migrate to generic "should even try bonding" preference key
// There are connection problems on certain Galaxy S devices at least
// try to connect without BT pairing (bonding)
Prefs prefs = GBApplication.getPrefs();
return prefs.getPreferences().getBoolean(MiBandConst.PREF_MIBAND_SETUP_BT_PAIRING, true);
}
/** /**
* Connects to the device and calls callback * Connects to the device and calls callback
*/ */

View File

@ -101,15 +101,10 @@ public class DeviceHelper {
Set<GBDevice> availableDevices = new LinkedHashSet<>(getDatabaseDevices()); Set<GBDevice> availableDevices = new LinkedHashSet<>(getDatabaseDevices());
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
String miAddress = prefs.getString(MiBandConst.PREF_MIBAND_ADDRESS, "");
if (miAddress.length() > 0) {
GBDevice miDevice = new GBDevice(miAddress, "MI", null, null, DeviceType.MIBAND);
availableDevices.add(miDevice);
}
String pebbleEmuAddr = prefs.getString("pebble_emu_addr", ""); String pebbleEmuAddr = prefs.getString("pebble_emu_addr", "");
String pebbleEmuPort = prefs.getString("pebble_emu_port", ""); String pebbleEmuPort = prefs.getString("pebble_emu_port", "");
if (pebbleEmuAddr.length() >= 7 && pebbleEmuPort.length() > 0) { if (pebbleEmuAddr.length() >= 7 && !pebbleEmuPort.isEmpty()) {
GBDevice pebbleEmuDevice = new GBDevice(pebbleEmuAddr + ":" + pebbleEmuPort, "Pebble qemu", "", null, DeviceType.PEBBLE); GBDevice pebbleEmuDevice = new GBDevice(pebbleEmuAddr + ":" + pebbleEmuPort, "Pebble qemu", "", null, DeviceType.PEBBLE);
availableDevices.add(pebbleEmuDevice); availableDevices.add(pebbleEmuDevice);
} }

View File

@ -1,15 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference <PreferenceScreen
android:icon="@drawable/ic_warning" android:icon="@drawable/ic_vibration"
android:key="preferences_miband_1_2_warning" android:key="vibration_patterns_key"
android:summary="@string/preferences_miband_1_2_warning" /> android:persistent="false"
android:summary="@string/pref_screen_vibration_patterns_summary"
<PreferenceCategory android:title="@string/pref_screen_vibration_patterns_title">
android:key="pref_category_miband_notification"
android:title="@string/pref_header_vibration_settings"
app:iconSpaceReserved="false">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_message_outline" android:icon="@drawable/ic_message_outline"
@ -17,11 +14,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_sms"> android:title="@string/pref_screen_notification_profile_sms">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_sms"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_staccato" android:defaultValue="@string/p_staccato"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -53,11 +45,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_incoming_call"> android:title="@string/pref_screen_notification_profile_incoming_call">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_incoming_call"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_ring" android:defaultValue="@string/p_ring"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -83,11 +70,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_email"> android:title="@string/pref_screen_notification_profile_email">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_email"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_medium" android:defaultValue="@string/p_medium"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -118,11 +100,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_generic_chat"> android:title="@string/pref_screen_notification_profile_generic_chat">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_generic_chat"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_waterdrop" android:defaultValue="@string/p_waterdrop"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -153,11 +130,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_generic_social"> android:title="@string/pref_screen_notification_profile_generic_social">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_generic_social"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_waterdrop" android:defaultValue="@string/p_waterdrop"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -188,11 +160,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_alarm_clock"> android:title="@string/pref_screen_notification_profile_alarm_clock">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_alarm_clock"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_alarm_clock" android:defaultValue="@string/p_alarm_clock"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -223,11 +190,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_generic_navigation"> android:title="@string/pref_screen_notification_profile_generic_navigation">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_generic_navigation"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_waterdrop" android:defaultValue="@string/p_waterdrop"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -258,11 +220,6 @@
android:persistent="false" android:persistent="false"
android:title="@string/pref_screen_notification_profile_generic"> android:title="@string/pref_screen_notification_profile_generic">
<!-- workaround for missing toolbar -->
<PreferenceCategory
android:title="@string/pref_screen_notification_profile_generic"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/p_waterdrop" android:defaultValue="@string/p_waterdrop"
android:entries="@array/vibration_profile" android:entries="@array/vibration_profile"
@ -287,32 +244,5 @@
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceScreen>
</androidx.preference.PreferenceScreen>
<PreferenceCategory
android:key="pref_key_development"
android:title="@string/pref_header_development"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="mi_setup_bt_pairing"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_setup_bt_pairing"
android:title="@string/pref_title_setup_bt_pairing"
app:iconSpaceReserved="false" />
<EditTextPreference
android:digits="0123456789ABCDEF:"
android:key="development_miaddr"
android:maxLength="17"
android:title="@string/pref_title_development_miaddr"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="mi_dont_ack_transfer"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_keep_data_on_device"
android:title="@string/pref_title_keep_data_on_device"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -270,11 +270,6 @@
android:title="@string/preferences_category_device_specific_settings" android:title="@string/preferences_category_device_specific_settings"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<Preference
android:icon="@drawable/ic_device_miband"
android:key="pref_key_miband"
android:title="@string/preferences_miband_1_2_settings" />
<Preference <Preference
android:icon="@drawable/ic_device_pebble" android:icon="@drawable/ic_device_pebble"
android:key="pref_key_pebble" android:key="pref_key_pebble"