mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 08:40:43 +02:00
Pixoo: Support custom device name
This commit is contained in:
parent
9c619c6c7c
commit
4a7a201971
@ -47,6 +47,7 @@ public class DeviceSettingsPreferenceConst {
|
|||||||
public static final String PREF_LANGUAGE = "language";
|
public static final String PREF_LANGUAGE = "language";
|
||||||
public static final String PREF_LANGUAGE_AUTO = "auto";
|
public static final String PREF_LANGUAGE_AUTO = "auto";
|
||||||
public static final String PREF_DEVICE_REGION = "device_region";
|
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_DATEFORMAT = "dateformat";
|
||||||
public static final String PREF_TIMEFORMAT = "timeformat";
|
public static final String PREF_TIMEFORMAT = "timeformat";
|
||||||
public static final String PREF_TIMEFORMAT_24H = "24h";
|
public static final String PREF_TIMEFORMAT_24H = "24h";
|
||||||
|
@ -339,6 +339,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
|||||||
addPreferenceHandlerFor(PREF_WEARLOCATION);
|
addPreferenceHandlerFor(PREF_WEARLOCATION);
|
||||||
addPreferenceHandlerFor(PREF_VIBRATION_ENABLE);
|
addPreferenceHandlerFor(PREF_VIBRATION_ENABLE);
|
||||||
addPreferenceHandlerFor(PREF_NOTIFICATION_ENABLE);
|
addPreferenceHandlerFor(PREF_NOTIFICATION_ENABLE);
|
||||||
|
addPreferenceHandlerFor(PREF_DEVICE_NAME);
|
||||||
addPreferenceHandlerFor(PREF_SCREEN_BRIGHTNESS);
|
addPreferenceHandlerFor(PREF_SCREEN_BRIGHTNESS);
|
||||||
addPreferenceHandlerFor(PREF_SCREEN_AUTO_BRIGHTNESS);
|
addPreferenceHandlerFor(PREF_SCREEN_AUTO_BRIGHTNESS);
|
||||||
addPreferenceHandlerFor(PREF_SCREEN_ORIENTATION);
|
addPreferenceHandlerFor(PREF_SCREEN_ORIENTATION);
|
||||||
|
@ -32,7 +32,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.divoom.PixooSupport;
|
|||||||
public class PixooCoordinator extends AbstractBLEDeviceCoordinator {
|
public class PixooCoordinator extends AbstractBLEDeviceCoordinator {
|
||||||
@Override
|
@Override
|
||||||
protected Pattern getSupportedDeviceName() {
|
protected Pattern getSupportedDeviceName() {
|
||||||
return Pattern.compile("Pixoo");
|
return Pattern.compile("Pixoo(-.+)?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,10 +79,14 @@ public class PixooCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
@Override
|
@Override
|
||||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||||
return new int[]{
|
return new int[]{
|
||||||
R.xml.devicesettings_pixoo,
|
R.xml.devicesettings_header_display,
|
||||||
R.xml.devicesettings_screen_brightness,
|
R.xml.devicesettings_screen_brightness,
|
||||||
|
R.xml.devicesettings_header_time,
|
||||||
R.xml.devicesettings_timeformat,
|
R.xml.devicesettings_timeformat,
|
||||||
|
R.xml.devicesettings_header_other,
|
||||||
|
R.xml.devicesettings_pixoo,
|
||||||
|
R.xml.devicesettings_header_connection,
|
||||||
|
R.xml.devicesettings_device_name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
||||||
|
@ -52,6 +52,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||||
|
|
||||||
public class PixooProtocol extends GBDeviceProtocol {
|
public class PixooProtocol extends GBDeviceProtocol {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(PixooProtocol.class);
|
private static final Logger LOG = LoggerFactory.getLogger(PixooProtocol.class);
|
||||||
@ -158,6 +159,14 @@ public class PixooProtocol extends GBDeviceProtocol {
|
|||||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||||
|
|
||||||
switch (config) {
|
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:
|
case DeviceSettingsPreferenceConst.PREF_SCREEN_BRIGHTNESS:
|
||||||
byte brightness = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_SCREEN_BRIGHTNESS, 50);
|
byte brightness = (byte) prefs.getInt(DeviceSettingsPreferenceConst.PREF_SCREEN_BRIGHTNESS, 50);
|
||||||
LOG.debug("setting brightness to " + brightness);
|
LOG.debug("setting brightness to " + brightness);
|
||||||
|
@ -976,6 +976,7 @@
|
|||||||
<string name="prefs_always_on_display_follow_watchface">Style follows Watchface</string>
|
<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_style">Style</string>
|
||||||
<string name="prefs_always_on_display_summary">Keep the band\'s display always on</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">Password</string>
|
||||||
<string name="prefs_password_summary">Lock the band with a password when removed from the wrist</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>
|
<string name="prefs_password_enabled">Password Enabled</string>
|
||||||
|
9
app/src/main/res/xml/devicesettings_device_name.xml
Normal file
9
app/src/main/res/xml/devicesettings_device_name.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user