mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Amazfit Neo: Support sound settings
This commit is contained in:
parent
6f6db01bce
commit
9dc4dde5e7
@ -69,5 +69,7 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_SONYSWR12_STAMINA = "stamina_preference";
|
||||
public static final String PREF_SONYSWR12_SMART_INTERVAL = "smart_alarm_interval_preference";
|
||||
|
||||
public static final String PREF_BT_CONNECTED_ADVERTISEMENT = "bt_connected_advertisement";
|
||||
public static final String PREF_BT_CONNECTED_ADVERTISEMENT = "bt_connected_advertisement";
|
||||
|
||||
public static final String PREF_SOUNDS = "sounds";
|
||||
}
|
@ -83,6 +83,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONYSWR12_LOW_VIBRATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONYSWR12_SMART_INTERVAL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONYSWR12_STAMINA;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SOUNDS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_VIBRATION_STRENGH_PERCENTAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
|
||||
@ -400,6 +401,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
||||
addPreferenceHandlerFor(PREF_HYDRATION_PERIOD);
|
||||
addPreferenceHandlerFor(PREF_AMPM_ENABLED);
|
||||
addPreferenceHandlerFor(PREF_LEFUN_INTERFACE_LANGUAGE);
|
||||
addPreferenceHandlerFor(PREF_SOUNDS);
|
||||
|
||||
addPreferenceHandlerFor(PREF_HYBRID_HR_DRAW_WIDGET_CIRCLES);
|
||||
addPreferenceHandlerFor(PREF_HYBRID_HR_FORCE_WHITE_COLOR);
|
||||
|
@ -147,6 +147,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LANGUAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SOUNDS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
|
||||
@ -1979,6 +1980,9 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
case PREF_WEARLOCATION:
|
||||
setWearLocation(builder);
|
||||
break;
|
||||
case PREF_SOUNDS:
|
||||
setBeepSounds(builder);
|
||||
break;
|
||||
}
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
@ -2489,6 +2493,30 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected HuamiSupport setBeepSounds(TransactionBuilder builder) {
|
||||
|
||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
||||
Set<String> sounds = prefs.getStringSet(PREF_SOUNDS, new HashSet<>(Arrays.asList(getContext().getResources().getStringArray(R.array.pref_amazfitneo_sounds_default))));
|
||||
|
||||
LOG.info("Setting sounds to " + (sounds == null ? "none" : sounds));
|
||||
|
||||
|
||||
if (sounds != null) {
|
||||
final String[] soundOrder = new String[]{"button", "calls", "alarm", "notifications", "inactivity_warning", "sms", "goal"};
|
||||
byte[] command = new byte[]{0x3c, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 7, 0, 0};
|
||||
int i = 3;
|
||||
for (String sound : soundOrder) {
|
||||
if (sounds.contains(sound)) {
|
||||
command[i] = 1;
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
writeToChunked(builder, 2, command);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private HuamiSupport setRotateWristToSwitchInfo(TransactionBuilder builder) {
|
||||
boolean enable = HuamiCoordinator.getRotateWristToSwitchInfo(gbDevice.getAddress());
|
||||
LOG.info("Setting rotate wrist to cycle info to " + enable);
|
||||
|
@ -1479,4 +1479,34 @@
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="pref_amazfitneo_sounds">
|
||||
<item>@string/prefs_operating_sounds</item>
|
||||
<item>@string/pref_title_notifications_call</item>
|
||||
<item>@string/menuitem_alarm</item>
|
||||
<item>@string/menuitem_notifications</item>
|
||||
<item>@string/mi2_prefs_inactivity_warnings</item>
|
||||
<item>@string/pref_title_notifications_sms</item>
|
||||
<item>@string/menuitem_goal</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_amazfitneo_sounds_values">
|
||||
<item>@string/p_menuitem_button</item>
|
||||
<item>@string/p_menuitem_calls</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_inactivity_warning</item>
|
||||
<item>@string/p_menuitem_sms</item>
|
||||
<item>@string/p_menuitem_goal</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_amazfitneo_sounds_default">
|
||||
<item>@string/p_menuitem_button</item>
|
||||
<item>@string/p_menuitem_calls</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_inactivity_warning</item>
|
||||
<item>@string/p_menuitem_sms</item>
|
||||
<item>@string/p_menuitem_goal</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@ -469,6 +469,9 @@
|
||||
<string name="show_ongoing_activity">Show ongoing activity popup</string>
|
||||
<string name="lack_of_sleep">Lack of sleep: %1$s</string>
|
||||
<string name="overslept">Overslept: %1$s</string>
|
||||
<string name="prefs_sounds">Sounds</string>
|
||||
<string name="prefs_sounds_summary">Configure when the device will beep</string>
|
||||
|
||||
<!-- Firmware updating -->
|
||||
<string name="devicestatus_connecting">Device is connecting</string>
|
||||
<string name="devicestatus_connected">Device is connected</string>
|
||||
|
@ -51,6 +51,12 @@
|
||||
<item name="p_menuitem_sleep" type="string">sleep</item>
|
||||
<item name="p_menuitem_pomodoro" type="string">pomodoro</item>
|
||||
|
||||
<!-- currently used for sounds -->
|
||||
<item name="p_menuitem_button" type="string">button</item>
|
||||
<item name="p_menuitem_calls" type="string">calls</item>
|
||||
<item name="p_menuitem_inactivity_warning" type="string">inactivity_warning</item>
|
||||
<item name="p_menuitem_sms" type="string">sms</item>
|
||||
|
||||
<item name="p_off" type="string">off</item>
|
||||
<item name="p_on" type="string">on</item>
|
||||
<item name="p_sunset" type="string">sunset</item>
|
||||
|
@ -19,4 +19,15 @@
|
||||
android:key="language"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_language" />
|
||||
|
||||
<MultiSelectListPreference
|
||||
android:defaultValue="@array/pref_amazfitneo_sounds_default"
|
||||
android:dialogTitle="@string/prefs_sounds"
|
||||
android:entries="@array/pref_amazfitneo_sounds"
|
||||
android:entryValues="@array/pref_amazfitneo_sounds_values"
|
||||
android:key="sounds"
|
||||
android:persistent="true"
|
||||
android:summary="@string/prefs_sounds_summary"
|
||||
android:title="@string/prefs_sounds" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user