Exemplo n.º 1
0
        // functions called when the back button is pressed
        public override void OnBackPressed()
        {
            StopService();  // Stop the Location service if it running
            MySettings.Save(mainsave);

            base.OnBackPressed();
        }
Exemplo n.º 2
0
 // Ok Button action for changing the Units
 private void OkMeasurementAction(object sender, DialogClickEventArgs e)
 {
     if (ListPosition == 0)
     {
         // If switching from metric to Imperial then convert all the text on screen.
         if (mainsave.Measurement == MySettings.MeasurementSystem.Metric)
         {
             MaxSpeedFloat = MaxSpeedFloat * .621371;
             Speed         = Speed * .621371;
             MaxSpeed.Text = "Max Speed: " + MaxSpeedFloat.ToString("0.00") + " MPH";
             speed.Text    = "Speed: " + Speed.ToString("0.00") + " MPH";
             elev          = elev * 3.28; // Get the Ft Equivalent of Altitude's Meters
             Altitude.Text = "Elevation: " + elev.ToString("0.0") + "Ft";
         }
         // Change unit system in the User settings
         mainsave.Measurement = MySettings.MeasurementSystem.Imperial;
     }
     else
     {
         // If switching from imperial to metric then convert all the text on screen
         if (mainsave.Measurement == MySettings.MeasurementSystem.Imperial)
         {
             MaxSpeedFloat = MaxSpeedFloat * 1.60934;
             Speed         = Speed * 1.60934;
             MaxSpeed.Text = "Max Speed: " + MaxSpeedFloat.ToString("0.00") + " KPH";
             speed.Text    = "Speed: " + Speed.ToString("0.00") + " KPH";
             elev          = elev * .3048;
             Altitude.Text = "Elevation: " + elev.ToString("0.0") + "m";
         }
         // Change unit system in user settings
         mainsave.Measurement = MySettings.MeasurementSystem.Metric;
     }
     MySettings.Save(mainsave);
 }
Exemplo n.º 3
0
        // Called when the user clicks on OK for the Color selector dialog
        private void OkColorAction(object sender, DialogClickEventArgs e)
        {
            // Change color in user settings
            mainsave.color = mainsave.List2DotColor(ListPosition);

            // Save user settings
            MySettings.Save(mainsave);

            // Change the dot on the map to the new color
            mapCtrl.Map.Layers[1].Style = new SymbolStyle {
                Fill = { Color = mainsave.ReturnColor() }, SymbolScale = .4
            };
        }
Exemplo n.º 4
0
        // Checks if we have GPS permissions
        private void FirstRun()
        {
            const string PREFS_NAME         = "PrefsFile";
            const string PrefVersionCodeKey = "version_code";
            int          DoesntExist        = -1;

            // Get Current Version of Application
            int currentVersionCode = Application.Context.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionCode;


            ISharedPreferences prefs = GetSharedPreferences(PREFS_NAME, FileCreationMode.Private);
            int savedVersionCode     = prefs.GetInt(PrefVersionCodeKey, DoesntExist);

            // If current version then its a normal run.
            if (currentVersionCode == savedVersionCode)
            {
                mainsave = MySettings.Load();
            }
            else if (savedVersionCode == DoesntExist)
            {
                // New Install or User Cleared Shared Preferences
                mainsave = new MySettings();
                MySettings.Save(mainsave);
            }
            else if (currentVersionCode > savedVersionCode)
            {
                mainsave = MySettings.Load();
                // Upgrade of Application
            }

            // Update shared preferences with current version code
            prefs.Edit().PutInt(PrefVersionCodeKey, currentVersionCode).Apply();



            if (CheckSelfPermission(Android.Manifest.Permission.AccessFineLocation) != (int)Permission.Granted)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    RequestPermissions(new string[] { Android.Manifest.Permission.AccessFineLocation }, 1);
                }).ConfigureAwait(true);
                speed.Text = "Location Service Needs to Be Allowed";
            }
            else
            {
                AllowMapToLoad = true;
            }
        }
Exemplo n.º 5
0
 // Will Stop location service when user switches to another app. OnResume will be called to restart location service if the navigate back
 protected override void OnPause()
 {
     StopService();
     MySettings.Save(mainsave);
     base.OnPause();
 }