Search in sources :

Example 1 with ConfirmOnDeviceRequest

use of nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.ConfirmOnDeviceRequest 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)

Example 2 with ConfirmOnDeviceRequest

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

the class FossilHRWatchAdapter method onFindDevice.

@Override
public void onFindDevice(boolean start) {
    super.onFindDevice(start);
    boolean versionSupportsConfirmation = getCleanFWVersion().compareTo(new Version("1.0.2.22")) != -1;
    if (!versionSupportsConfirmation) {
        GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
        return;
    }
    if (start) {
        queueWrite(new ConfirmOnDeviceRequest());
    }
}
Also used : ConfirmOnDeviceRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.ConfirmOnDeviceRequest) Version(nodomain.freeyourgadget.gadgetbridge.util.Version)

Aggregations

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