Пример #1
0
        public MainViewModel()
        {
            Battery = new BatteryInfo(BatteryHelper.GetLatestBatteryStatus());

            dt          = new DispatcherTimer();
            dt.Interval = TimeSpan.FromSeconds(1);
            dt.Tick    += Dt_Tick;;
            dt.Start();
        }
Пример #2
0
        public GoogleLocationServicesAPI()
        {
            _repoManager   = App.Container.Resolve <IRepoManager>();
            _batteryHelper = App.Container.Resolve <BatteryHelper>();

            positionEntryRepository = _repoManager.PositionEntryRepository;


            currentProfile = App.CollectionProfile.AndroidProfile;
        }
Пример #3
0
 private void StopListeners()
 {
     try
     {
         LocationHelper.StopTracking();
         SensorHelper.StopTracking();
         BatteryHelper.StopTracking();
         GTalkHelper.StopTracking();
         SkypeHelper.StopTracking();
         OutlookHelper.StopTracking();
         DropboxHelper.StopTracking();
     }
     catch (Exception exception)
     {
         Log.Error(exception);
     }
 }
Пример #4
0
        public override async void Initialize()
        {
            this.IsBusy      = true;
            this.BusyMessage = ResourcesHelper.GetLocalizedString("HomeMainInitializingMessage");

            this.DeviceName = DeviceManager.DeviceName;

            var newPercentage = await DeviceManager.GetBatteryPercentageAsync();

            var oldPercentage = this.BatteryPercentage;

            this.BatteryPercentage = newPercentage;
            this.BatteryLevel      = BatteryHelper.Parse(newPercentage);

            App.RemoveWelcomePageFromBackStack();

            this.IsBusy      = false;
            this.BusyMessage = string.Empty;

            this.MessengerInstance.Register <DeviceBatteryMessage>(this, OnDeviceBatteryPercentageChanged);
        }
Пример #5
0
        public static async Task <int> GetBatteryPercentageAsync()
        {
            if (BluetoothDevice == null)
            {
                return(0);
            }

            var characteristic = await BluetoothDevice.GetGattCharacteristicAsync(GattCharacteristicUuids.BatteryLevel);

            if (characteristic == null)
            {
                return(0);
            }

            var valueResult = await characteristic.ReadValueAsync(BluetoothCacheMode.Uncached);

            if (valueResult.Status != GattCommunicationStatus.Success)
            {
                return(0);
            }

            return(BatteryHelper.GetPercentage(valueResult?.Value));
        }
Пример #6
0
        public LocationManagerImplementation(IRepoManager repoManager, ProfileiOS profile, BatteryHelper batteryHelper)
        {
            _currentProfile = profile ?? throw new ArgumentNullException(nameof(profile));
            _repoManager    = repoManager ?? throw new ArgumentNullException(nameof(repoManager));
            _batteryHelper  = batteryHelper ?? throw new ArgumentNullException(nameof(batteryHelper));

            _significantLocationManager = new CLLocationManager();
            _significantLocationManager.LocationsUpdated += _significantLocationManager_LocationsUpdated;
            _significantLocationManager.AllowsBackgroundLocationUpdates = true;

            _clManager = new CLLocationManager();
            _clManager.LocationsUpdated        += ClManager_LocationsUpdated;
            _clManager.RegionLeft              += _clManager_RegionLeft;
            _clManager.DeferredUpdatesFinished += ClManagerOnDeferredUpdatesFinished;
            _clManager.AuthorizationChanged    += ClManager_AuthorizationChanged;

            _listenLocationManager     = new CLLocationManager();
            _clManager.DesiredAccuracy = CLLocation.AccuracyThreeKilometers;
            _clManager.ActivityType    = CLActivityType.Fitness;

            _positionEntryRepo = _repoManager.PositionEntryRepository;
            _motionEntryRepo   = _repoManager.MotionEntryRepository;
        }
Пример #7
0
        private async void UpdateBatteryPercentage(int?newPercentage = null)
        {
            await DispatcherHelper.RunAsync(async() =>
            {
                if (!newPercentage.HasValue)
                {
                    newPercentage = await DeviceManager.GetBatteryPercentageAsync();
                }

                if (newPercentage > 0)
                {
                    TilesHelper.UpdateBatteryTile(newPercentage);
                }
                else
                {
                    TilesHelper.ResetBatteryTile();
                }

                var oldPercentage      = this.BatteryPercentage;
                this.BatteryPercentage = newPercentage.Value;
                this.BatteryLevel      = BatteryHelper.Parse(newPercentage.Value);
            });
        }
Пример #8
0
 private static void OnBatteryLevelValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
 {
     Messenger.Default.Send(new Messages.DeviceBatteryMessage(BatteryHelper.GetPercentage(args.CharacteristicValue)));
 }
Пример #9
0
 public object Convert(object value, Type targetType, object parameter, string language)
 {
     return(BatteryHelper.GetIcon(System.Convert.ToInt32(value ?? 0)));
 }
Пример #10
0
 private void Dt_Tick(object sender, object e)
 {
     dt.Start();
     Battery = new BatteryInfo(BatteryHelper.GetLatestBatteryStatus());
     dt.Start();
 }
Пример #11
0
 private void BatteryButton_Click(object sender, RoutedEventArgs e)
 {
     BatteryHelper.StartTracking();
     //BatteryHelper.GetBatteryRemaining();
 }