1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-10 12:09:27 +01:00

Pixoo: Support custom device name

This commit is contained in:
José Rebelo 2023-12-23 21:27:53 +00:00
parent 9c619c6c7c
commit 4a7a201971
7 changed files with 28 additions and 4 deletions

View File

@ -47,6 +47,7 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_LANGUAGE = "language";
public static final String PREF_LANGUAGE_AUTO = "auto";
public static final String PREF_DEVICE_REGION = "device_region";
public static final String PREF_DEVICE_NAME = "pref_device_name";
public static final String PREF_DATEFORMAT = "dateformat";
public static final String PREF_TIMEFORMAT = "timeformat";
public static final String PREF_TIMEFORMAT_24H = "24h";

View File

@ -339,6 +339,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
addPreferenceHandlerFor(PREF_WEARLOCATION);
addPreferenceHandlerFor(PREF_VIBRATION_ENABLE);
addPreferenceHandlerFor(PREF_NOTIFICATION_ENABLE);
addPreferenceHandlerFor(PREF_DEVICE_NAME);
addPreferenceHandlerFor(PREF_SCREEN_BRIGHTNESS);
addPreferenceHandlerFor(PREF_SCREEN_AUTO_BRIGHTNESS);
addPreferenceHandlerFor(PREF_SCREEN_ORIENTATION);

View File

@ -32,7 +32,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.divoom.PixooSupport;
public class PixooCoordinator extends AbstractBLEDeviceCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Pixoo");
return Pattern.compile("Pixoo(-.+)?");
}
@Override
@ -79,10 +79,14 @@ public class PixooCoordinator extends AbstractBLEDeviceCoordinator {
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_pixoo,
R.xml.devicesettings_header_display,
R.xml.devicesettings_screen_brightness,
R.xml.devicesettings_header_time,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_header_other,
R.xml.devicesettings_pixoo,
R.xml.devicesettings_header_connection,
R.xml.devicesettings_device_name,
};
}
}

View File

@ -29,7 +29,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;

View File

@ -52,6 +52,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
public class PixooProtocol extends GBDeviceProtocol {
private static final Logger LOG = LoggerFactory.getLogger(PixooProtocol.class);
@ -158,6 +159,14 @@ public class PixooProtocol extends GBDeviceProtocol {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
switch (config) {
case DeviceSettingsPreferenceConst.PREF_DEVICE_NAME:
final byte[] deviceName = StringUtils.truncateToBytes(prefs.getString(DeviceSettingsPreferenceConst.PREF_DEVICE_NAME, ""), 26);
return encodeProtocol(ByteBuffer.allocate(2 + deviceName.length)
.order(ByteOrder.LITTLE_ENDIAN)
.put((byte) 0x75)
.put((byte) deviceName.length)
.put(deviceName)
.array());
case DeviceSettingsPreferenceConst.PREF_SCREEN_BRIGHTNESS:
byte brightness = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_SCREEN_BRIGHTNESS, 50);
LOG.debug("setting brightness to " + brightness);

View File

@ -976,6 +976,7 @@
<string name="prefs_always_on_display_follow_watchface">Style follows Watchface</string>
<string name="prefs_always_on_display_style">Style</string>
<string name="prefs_always_on_display_summary">Keep the band\'s display always on</string>
<string name="prefs_device_name">Device name</string>
<string name="prefs_password">Password</string>
<string name="prefs_password_summary">Lock the band with a password when removed from the wrist</string>
<string name="prefs_password_enabled">Password Enabled</string>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditTextPreference
android:icon="@drawable/ic_bluetooth"
android:key="pref_device_name"
android:title="@string/prefs_device_name"
app:useSimpleSummaryProvider="true" />
</androidx.preference.PreferenceScreen>