Checkbox added to the BIP settings for Button Action confirmation

This commit is contained in:
János Lakatos 2018-01-06 10:03:53 +01:00
parent 33ad3163d7
commit f231af3ae3
3 changed files with 10 additions and 7 deletions

View File

@ -151,15 +151,13 @@ public class AmazfitBipSupport extends MiBand2Support {
final String requiredButtonPressMessage = prefs.getString(MiBandConst.PREF_MIBAND_BUTTON_PRESS_BROADCAST,
this.getContext().getString(R.string.mi2_prefs_button_press_broadcast_default_value));
//TODO: based on a new preference
if (true) {
if (prefs.getBoolean("require_button_action_confirmazion", false)) {
buttonActionConfirmationReceived = false;
buttonActionApproved = false;
LOG.info("ButtonAction - Ringing the device");
LOG.debug("ButtonAction - Ringing the device");
//ringing the device
onFindDevice(true);
LOG.info("ButtonAction - timer started");
//wating for accept or reject
final Timer buttonActionAckTimer = new Timer("Mi Band Button Action Timer");
buttonActionAckTimer.scheduleAtFixedRate(new TimerTask() {
@ -169,7 +167,6 @@ public class AmazfitBipSupport extends MiBand2Support {
public void run() {
j++;
if (buttonActionConfirmationReceived) {
LOG.info("ButtonAction - timer processActionConfirmation received");
if (buttonActionApproved) {
executeButtonAction(requiredButtonPressMessage, prefs.getBoolean(MiBandConst.PREF_MIBAND_BUTTON_ACTION_VIBRATE, false));
}
@ -186,7 +183,6 @@ public class AmazfitBipSupport extends MiBand2Support {
*/
buttonActionAckTimer.cancel();
} else if (j > 20) {
LOG.info("ButtonAction - buttonActionAckTimer expired");
buttonActionAckTimer.cancel();
//stop ringing
onFindDevice(false);
@ -207,7 +203,6 @@ public class AmazfitBipSupport extends MiBand2Support {
@Override
public void processActionConfirmation(GBDeviceEventCallControl callEvent) {
// Not supported for MiBand2, but needed for BIP
LOG.info("ButtonAction - processActionConfirmation received: " + callEvent.event);
buttonActionConfirmationReceived = true;
if ((callEvent.event == GBDeviceEventCallControl.Event.IGNORE) || (callEvent.event == GBDeviceEventCallControl.Event.ACCEPT)) {

View File

@ -82,6 +82,9 @@
<string name="pref_title_language">Language</string>
<string name="pref_title_require_button_action_confirmazion">Require conformation on screen after Button Action</string>
<string name="pref_summary_require_button_action_confirmazion">You can approve or reject the button action on the screen</string>
<string name="pref_title_minimize_priority">Hide the Gadgetbridge notification</string>
<string name="pref_summary_minimize_priority_off">The icon in the status bar and the notification in the lockscreen are shown</string>
<string name="pref_summary_minimize_priority_on">The icon in the status bar and the notification in the lockscreen are hidden</string>

View File

@ -193,6 +193,11 @@
android:key="amazfitbip_language"
android:summary="%s"
android:title="@string/pref_title_language" />
<CheckBoxPreference
android:defaultValue="false"
android:key="require_button_action_confirmazion"
android:summary="@string/pref_summary_require_button_action_confirmazion"
android:title="@string/pref_title_require_button_action_confirmazion" />
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_device_pebble"