Ejemplo n.º 1
0
        void StartIfStopped()
        {
            Task.Run(async() =>
            {
                if (await _viewModel.IsRunning() == false)
                {
                    await _viewModel.StartENService();

                    /// If EN is disabled, then the OS dialog will pop up.
                    /// Calling the StartENService method again seems to make the EN api properly update its state, before we update our UI.
                    /// This is not an optimal solution, but seems to work fine as a workaround for now.
                    /// A better way would be for us to be able to listen to state changes in the EN api.
                    if (await _viewModel.IsEnabled() == false)
                    {
                        await _viewModel.StartENService();
                    }

                    if (await _permissionManager.PoweredOff())
                    {
                        DialogHelper.ShowBluetoothTurnedOffDialog(this);
                    }

                    InvokeOnMainThread(() =>
                    {
                        UpdateUI();
                    });
                }
            });
        }
        private async void PreventMultiplePermissionsDialogsForAction(Func <Task <bool> > action)
        {
            bool isRunning = await _viewModel.IsRunning();

            if ((!isRunning || !_permissionUtils.HasPermissionsWithoutDialogs()) &&
                _dialogDisplayed == false)
            {
                _dialogDisplayed = true;
                if (action != null)
                {
                    await action.Invoke();
                }
                _dialogDisplayed = false;
                // wait until BT state change will be completed
                await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI);
            }
            UpdateUI();
        }
Ejemplo n.º 3
0
 private async Task <bool> IsRunning() =>
 await _viewModel.IsRunning() && _permissionUtils.IsLocationEnabled();