Search in sources :

Example 1 with CheckDeviceNeedsConfirmationRequest

use of nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.CheckDeviceNeedsConfirmationRequest in project Gadgetbridge by Freeyourgadget.

the class FossilHRWatchAdapter method confirmOnWatch.

private void confirmOnWatch() {
    queueWrite(new CheckDeviceNeedsConfirmationRequest() {

        @Override
        public void onResult(boolean needsConfirmation) {
            GB.log("needs confirmation: " + needsConfirmation, GB.INFO, null);
            if (needsConfirmation) {
                final Timer timer = new Timer();
                GB.toast("please confirm on device.", Toast.LENGTH_SHORT, GB.INFO);
                queueWrite(new ConfirmOnDeviceRequest() {

                    @Override
                    public void onResult(boolean confirmationSuccess) {
                        isFinished = true;
                        timer.cancel();
                        if (!confirmationSuccess) {
                            GB.toast("connection unconfirmed on watch, unauthenticated mode", Toast.LENGTH_LONG, GB.ERROR);
                        }
                        initializeAfterWatchConfirmation(confirmationSuccess);
                    }
                }, true);
                timer.schedule(confirmTimeoutRunnable, 30000);
            } else {
                initializeAfterWatchConfirmation(true);
            }
        }
    });
}
Also used : ConfirmOnDeviceRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.ConfirmOnDeviceRequest) CheckDeviceNeedsConfirmationRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.CheckDeviceNeedsConfirmationRequest) Timer(java.util.Timer)

Aggregations

Timer (java.util.Timer)1 CheckDeviceNeedsConfirmationRequest (nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.CheckDeviceNeedsConfirmationRequest)1 ConfirmOnDeviceRequest (nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.ConfirmOnDeviceRequest)1