Beispiel #1
0
        // Overridden from UIViewController
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitNavigationBar("ic_nav_device_manager", true);
            View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("CarbonBackground"));
            NavigationItem.Title = Strings.Device.Manager.SELF.FromResources();
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Strings.Device.Manager.SCAN.FromResources(), UIBarButtonItemStyle.Plain, delegate {
                if (!ion.deviceManager.connectionManager.isEnabled)
                {
                    UIAlertController bluetoothWarning = UIAlertController.Create("Bluetooth Disconnected", "Bluetooth needs to be connected to discover peripherals", UIAlertControllerStyle.Alert);

                    bluetoothWarning.AddAction(UIAlertAction.Create(Util.Strings.SETTINGS, UIAlertActionStyle.Default, (action) => {
                        UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
                    }));
                    bluetoothWarning.AddAction(UIAlertAction.Create(Util.Strings.CLOSE, UIAlertActionStyle.Default, (action) => {
                    }));

                    bluetoothWarning.Show();
                }
                else
                {
                    if (ion.deviceManager.connectionManager.isScanning)
                    {
                        StopScan();
                    }
                    else
                    {
                        StartScan();
                    }
                }
            });

            labelEmpty.Text = Strings.Device.Manager.EMPTY;

            ion.deviceManager.onDeviceManagerEvent += OnDeviceManagerEvent;
            if (ion.deviceManager.connectionManager.isEnabled)
            {
                UpdateScanState();
            }
            tableContent.Source             = deviceSource = new DeviceManagerTableSource(ion, this, tableContent);
            deviceSource.sensorFilter       = displayFilter;
            deviceSource.onSensorAddClicked = (GaugeDeviceSensor sensor, NSIndexPath indexPath) => {
                if (onSensorReturnDelegate != null)
                {
                    onSensorReturnDelegate(sensor);
                    NavigationController.PopViewController(true);
                    return(true);
                }
                return(false);
            };
        }
        public override void WillEnterForeground(UIApplication application)
        {
            // Called as part of the transiton from background to active state.
            // Here you can undo many of the changes made on entering the background.
            var ion = AppState.context as IosION;

            if (ion.settings.report.dataLoggingInterval.Seconds == 1)
            {
                if (intervalWarning == true)
                {
                    //UIAlertView loggingWarning = new UIAlertView(Util.Strings.Report.LOGGINGINTERVAL, Util.Strings.Report.LOWINTERVAL, null, Util.Strings.CLOSE, Util.Strings.RETURNSETTINGS);
                    UIAlertController loggingWarning = UIAlertController.Create(Util.Strings.Report.LOGGINGINTERVAL, Util.Strings.Report.LOWINTERVAL, UIAlertControllerStyle.Alert);

                    loggingWarning.AddAction(UIAlertAction.Create(Util.Strings.SETTINGS, UIAlertActionStyle.Default, (action) => {
                        UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
                    }));

                    loggingWarning.AddAction(UIAlertAction.Create(Util.Strings.CLOSE, UIAlertActionStyle.Default, (action) => {}));

                    loggingWarning.Show();
                }
            }

            if (ion.settings.leaveScreenOn)
            {
                UIApplication.SharedApplication.IdleTimerDisabled = true;
            }
            if (ion.settings._location.allowsGps)
            {
                Console.WriteLine("Came back and using geolocation");
                ion.locationManager.StartAutomaticLocationPolling();
            }
            else
            {
                Console.WriteLine("Came back and not using geolocation");
                ion.locationManager.StopAutomaticLocationPolling();
            }
            var preWalkthrough = NSUserDefaults.StandardUserDefaults.StringForKey("walkthrough_complete");

            if (string.IsNullOrEmpty(preWalkthrough))
            {
                string lastDate = NSUserDefaults.StandardUserDefaults.StringForKey("rssCheck");

                if (!string.IsNullOrEmpty(lastDate) && DateTime.Parse(lastDate).ToLocalTime().AddHours(24) <= DateTime.Now.ToLocalTime())
                {
                    var feedPull = new ViewController.RssFeed.RssFeedCheck();
                    feedPull.BeginReadXMLStreamSingle();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Called by the alert when it is started.
        /// </summary>
        protected override bool OnStart()
        {
            alertView = UIAlertController.Create(alarm.name, alarm.description, UIAlertControllerStyle.Alert);

            alertView.AddAction(UIAlertAction.Create(Strings.CANCEL, UIAlertActionStyle.Cancel, (action) => {
                alarm.Cancel();
            }));

            alertView.AddAction(UIAlertAction.Create(Strings.Alarms.REENABLE, UIAlertActionStyle.Default, (action) => {
                alarm.Reset();
                alarm.enabled = true;
            }));

            alertView.Show();

            return(true);
        }