Beispiel #1
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();
            }
        }
        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();
        }
Beispiel #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();
        }
Beispiel #5
0
        private async void PreventMultiplePermissionsDialogsForAction(Func <Task <bool> > action)
        {
            if (_dialogDisplayed || _lockUnfocusedDialogs)
            {
                return;
            }
            await _semaphoreSlim.WaitAsync();

            _dialogDisplayed = true;
            if (!await IsRunning())
            {
                if (action != null)
                {
                    await action.Invoke();
                }
                // wait until BT state change will be completed
                await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI);

                UpdateUI();
            }

            _dialogDisplayed = false;
            _semaphoreSlim.Release();
        }