mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-02-04 13:04:08 +01:00
Amazfit Bip: Make vibration after button action work
This commit is contained in:
parent
e38f50cb03
commit
e5f5a671bd
@ -141,6 +141,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VI
|
|||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VIBRATION_PROFILE;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VIBRATION_PROFILE;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.getNotificationPrefIntValue;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.getNotificationPrefIntValue;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.getNotificationPrefStringValue;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.getNotificationPrefStringValue;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL;
|
||||||
|
|
||||||
public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
@ -706,7 +707,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
protected void onAlarmClock(NotificationSpec notificationSpec) {
|
protected void onAlarmClock(NotificationSpec notificationSpec) {
|
||||||
alarmClockRinging = true;
|
alarmClockRinging = true;
|
||||||
AbortTransactionAction abortAction = new StopNotificationAction(getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL)) {
|
AbortTransactionAction abortAction = new StopNotificationAction(getCharacteristic(UUID_CHARACTERISTIC_ALERT_LEVEL)) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldAbort() {
|
protected boolean shouldAbort() {
|
||||||
return !isAlarmClockRinging();
|
return !isAlarmClockRinging();
|
||||||
@ -739,7 +740,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
public void onSetCallState(CallSpec callSpec) {
|
public void onSetCallState(CallSpec callSpec) {
|
||||||
if (callSpec.command == CallSpec.CALL_INCOMING) {
|
if (callSpec.command == CallSpec.CALL_INCOMING) {
|
||||||
telephoneRinging = true;
|
telephoneRinging = true;
|
||||||
AbortTransactionAction abortAction = new StopNotificationAction(getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL)) {
|
AbortTransactionAction abortAction = new StopNotificationAction(getCharacteristic(UUID_CHARACTERISTIC_ALERT_LEVEL)) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldAbort() {
|
protected boolean shouldAbort() {
|
||||||
return !isTelephoneRinging();
|
return !isTelephoneRinging();
|
||||||
@ -1083,8 +1084,20 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
// not supported
|
// not supported
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runButtonAction() {
|
// this could go though onion code with preferrednotification, but I this should work on all huami devices
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
private void vibrateOnce() {
|
||||||
|
BluetoothGattCharacteristic characteristic = getCharacteristic(UUID_CHARACTERISTIC_ALERT_LEVEL);
|
||||||
|
try {
|
||||||
|
TransactionBuilder builder = performInitialized("Vibrate once");
|
||||||
|
builder.write(characteristic,new byte[] {3});
|
||||||
|
builder.queue(getQueue());
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error("error while sending simple vibrate command", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runButtonAction() {
|
||||||
|
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||||
|
|
||||||
if (currentButtonTimerActivationTime != currentButtonPressTime) {
|
if (currentButtonTimerActivationTime != currentButtonPressTime) {
|
||||||
return;
|
return;
|
||||||
@ -1099,7 +1112,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
LOG.info("Sending " + requiredButtonPressMessage + " with button_id " + currentButtonActionId);
|
LOG.info("Sending " + requiredButtonPressMessage + " with button_id " + currentButtonActionId);
|
||||||
this.getContext().getApplicationContext().sendBroadcast(in);
|
this.getContext().getApplicationContext().sendBroadcast(in);
|
||||||
if (prefs.getBoolean(HuamiConst.PREF_BUTTON_ACTION_VIBRATE, false)) {
|
if (prefs.getBoolean(HuamiConst.PREF_BUTTON_ACTION_VIBRATE, false)) {
|
||||||
performPreferredNotification(null, null, null, HuamiService.ALERT_LEVEL_VIBRATE_ONLY, null);
|
vibrateOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentButtonActionId = 0;
|
currentButtonActionId = 0;
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
public static final String PREF_BUTTON_ACTION_PRESS_DELAY = "button_action_press_count_delay";
|
public static final String PREF_BUTTON_ACTION_PRESS_DELAY = "button_action_press_count_delay";
|
||||||
|
|
||||||
<CheckBoxPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="button_action_enable"
|
android:key="button_action_enable"
|
||||||
android:summary="@string/mi2_prefs_button_action_summary"
|
android:summary="@string/mi2_prefs_button_action_summary"
|
||||||
android:title="@string/mi2_prefs_button_action" />
|
android:title="@string/mi2_prefs_button_action" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:dependency="button_action_enable"
|
android:dependency="button_action_enable"
|
||||||
android:key="button_action_vibrate"
|
android:key="button_action_vibrate"
|
||||||
|
Loading…
Reference in New Issue
Block a user