public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            locationManager = new CLLocationManager();
            locationManager.LocationsUpdated += LocationUpdated;
            locationManager.RequestWhenInUseAuthorization();

            if (thisTask == null)
            {
                AppUtils.ShowSimpleDialog(this, "ERROR", "Error loading task data", "Ok");
                NavigationController.PopViewController(true);
                return;
            }

            TaskDescLabel.Text = thisTask.Description;

            origAlpha = (float)AnimationImage.Alpha;

            target = JsonConvert.DeserializeObject <LocationHuntLocation>(thisTask.JsonData);

            if (CLLocationManager.LocationServicesEnabled)
            {
                locationManager.StartUpdatingLocation();
            }

            OpenMapButton.Alpha          = (target.MapAvailable == null || target.MapAvailable == true) ? 1f : 0f;
            OpenMapButton.TouchUpInside += OpenMapButton_TouchUpInside;
        }
예제 #2
0
        private void GMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
        {
            Selected = new LocationHuntLocation(e.Point.Latitude, e.Point.Longitude, GMap.CameraPosition.Zoom, false);

            MarkerOptions opts = new MarkerOptions();

            opts.SetPosition(new LatLng(Selected.Lat, Selected.Long));
            GMap.Clear();
            GMap.AddMarker(opts);
        }
예제 #3
0
 private void GoogleMap_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
 {
     new global::Android.Support.V7.App.AlertDialog.Builder(this)
     .SetTitle("Delete This Marker?")
     .SetMessage("Are you sure you want to delete this marker?")
     .SetPositiveButton("Delete", (a, b) =>
     {
         e.Marker.Remove();
         Selected = null;
     })
     .SetNegativeButton("Cancel", (a, b) => { })
     .Show();
 }
        protected override void FinishButton_TouchUpInside(object sender, EventArgs e)
        {
            if (thisLocation == null)
            {
                AppUtils.ShowSimpleDialog(this, "Choose a Location", "Please choose a location for the user to navigate to.", "Got it");
                return;
            }

            if (UpdateBasicTask())
            {
                LocationHuntLocation data = new LocationHuntLocation(thisLocation.Lat, thisLocation.Long, 15f, allowMap.On);

                thisTask.JsonData = JsonConvert.SerializeObject(data);

                UpdateActivity();
                Unwind();
            }
        }
예제 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateTaskLocationHunt);
            instructions = FindViewById <EditText>(Resource.Id.taskInstructions);
            scrollView   = FindViewById <ScrollView>(Resource.Id.scrollView);
            Button addTaskBtn = FindViewById <Button>(Resource.Id.addTaskBtn);

            addTaskBtn.Click += AddTaskBtn_Click;

            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                editing           = true;
                taskType          = newTask.TaskType;
                instructions.Text = newTask.Description;
                Selected          = JsonConvert.DeserializeObject <LocationHuntLocation>(newTask.JsonData);
                addTaskBtn.SetText(Resource.String.saveChanges);
            }
            else
            {
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
            }

            FindViewById <TextView>(Resource.Id.taskTypeNameText).Text = taskType.DisplayName;
            ImageViewAsync image = FindViewById <ImageViewAsync>(Resource.Id.taskIcon);

            AndroidUtils.LoadTaskTypeIcon(taskType, image);

            TouchableMapFragment mapFrag = (TouchableMapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            mapFrag.TouchUp   += (sender, args) => scrollView.RequestDisallowInterceptTouchEvent(false);
            mapFrag.TouchDown += (sender, args) => scrollView.RequestDisallowInterceptTouchEvent(true);
            mapFrag.GetMapAsync(this);
        }
예제 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LocationHunActivity);

            string thisJsonData = Intent.GetStringExtra("JSON") ?? "";

            learningTask = JsonConvert.DeserializeObject <LearningTask>(thisJsonData,
                                                                        new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto
            });

            if (learningTask == null)
            {
                learningTask = new LearningTask()
                {
                    Description = Intent.GetStringExtra("Description"),
                };
                target = JsonConvert.DeserializeObject <LocationHuntLocation>(Intent.GetStringExtra("Target"));
            }
            else
            {
                target = JsonConvert.DeserializeObject <LocationHuntLocation>(learningTask.JsonData);
            }

            SupportActionBar.Title = learningTask.Description;

            TextView taskDesc = FindViewById <TextView>(Resource.Id.taskDesc);

            taskDesc.Text = learningTask.Description;

            distanceText      = FindViewById <TextView>(Resource.Id.distanceText);
            distanceText.Text = "Please wait";

            Color.Rgb(
                Color.GetRedComponent(distanceText.CurrentTextColor),
                Color.GetGreenComponent(distanceText.CurrentTextColor),
                Color.GetBlueComponent(distanceText.CurrentTextColor));

            accuracyText      = FindViewById <TextView>(Resource.Id.accuracyText);
            accuracyText.Text = "Connecting";

            image       = FindViewById <ImageView>(Resource.Id.taskImage);
            image.Alpha = LowAlpha;

            Button openMapButton = FindViewById <Button>(Resource.Id.openMapButton);

            openMapButton.Click     += OpenMapButton_Click;
            openMapButton.Visibility = (target.MapAvailable == null || target.MapAvailable == true)
                ? ViewStates.Visible : ViewStates.Gone;

            if (!AndroidUtils.IsGooglePlayServicesInstalled(this) || googleApiClient != null)
            {
                return;
            }

            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddConnectionCallbacks(this)
                              .AddOnConnectionFailedListener(this)
                              .AddApi(LocationServices.API)
                              .Build();
            locRequest = new LocationRequest();
        }