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();
                    });
                }
            });
        }
Ejemplo n.º 2
0
        private async void StartGoogleAPI()
        {
            try
            {
                await _viewModel.StartENService();

                bool isRunning = await IsRunning();

                if (isRunning)
                {
                    BackgroundFetchScheduler.ScheduleBackgroundFetch();
                }

                if (await _viewModel.IsEnabled() &&
                    !await IsRunning() &&
                    await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI) == BluetoothState.OFF)
                {
                    if (!_permissionUtils.AreAllPermissionsGranted())
                    {
                        PreventMultiplePermissionsDialogsForAction(_permissionUtils.HasPermissions);
                        // wait until BT state change will be completed
                        await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI);
                    }
                }
            }
            finally
            {
                UpdateUI();
            }

            _semaphoreSlim.Release();
        }
        private async void StartGoogleAPI()
        {
            try
            {
                await _viewModel.StartENService();

                bool isRunning = await _viewModel.IsRunning();

                if (isRunning)
                {
                    BackgroundFetchScheduler.ScheduleBackgroundFetch();
                }

                if (await _viewModel.IsEnabled() &&
                    !await _viewModel.IsRunning() &&
                    await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI) == BluetoothState.OFF)
                {
                    await _permissionUtils.HasPermissions();

                    // wait until BT state change will be completed
                    await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI);
                }
            }
            finally
            {
                UpdateUI();
            }
        }
Ejemplo n.º 4
0
        private async void StartGoogleAPI()
        {
            try
            {
                CloseReminderNotifications();
                await _viewModel.StartENService();

                bool isRunning = await IsRunning();

                if (isRunning)
                {
                    BackgroundFetchScheduler.ScheduleBackgroundFetch();
                }

                if (await _viewModel.IsEnabled() &&
                    !await IsRunning() &&
                    await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI) == BluetoothState.OFF)
                {
                    if (!_permissionUtils.AreAllPermissionsGranted())
                    {
                        PreventMultiplePermissionsDialogsForAction(_permissionUtils.HasPermissions);
                        // wait until BT state change will be completed
                        await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI);
                    }
                }
            }
            finally
            {
                UpdateUI();
            }
            //showing dialog for new user
            if (GetIsBackgroundActivityDialogShowEnableNewUser() &&
                !CheckIsEnableBatteryOptimizations())
            {
                ShowBackgroundActivityDialog();
                DialogLastShownDate = SystemTime.Now().Date;
            }
            _semaphoreSlim.Release();
        }