Search in sources :

Example 16 with ActiveBgAlert

use of com.eveningoutpost.dexdrip.Models.ActiveBgAlert in project xDrip-plus by jamorham.

the class Home method onKeyDown.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch(event.getKeyCode()) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_VOLUME_MUTE:
            if (JoH.quietratelimit("button-press", 5)) {
                if (Pref.getBooleanDefaultFalse("buttons_silence_alert")) {
                    final ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
                    if (activeBgAlert != null) {
                        AlertPlayer.getPlayer().Snooze(xdrip.getAppContext(), -1);
                        final String msg = "Snoozing alert due to volume button press";
                        JoH.static_toast_long(msg);
                        UserError.Log.ueh(TAG, msg);
                    } else {
                        if (d)
                            UserError.Log.d(TAG, "no active alert to snooze");
                    }
                } else {
                    if (d)
                        UserError.Log.d(TAG, "No action as preference is disabled");
                }
            }
            break;
    }
    if (d)
        Log.d(TAG, "Keydown event: " + keyCode + " event: " + event.toString());
    return super.onKeyDown(keyCode, event);
}
Also used : ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert)

Aggregations

ActiveBgAlert (com.eveningoutpost.dexdrip.Models.ActiveBgAlert)16 AlertType (com.eveningoutpost.dexdrip.Models.AlertType)10 Date (java.util.Date)10 View (android.view.View)4 Dialog (android.app.Dialog)2 Intent (android.content.Intent)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 NumberPicker (android.widget.NumberPicker)2 TextView (android.widget.TextView)2 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)2