public View GetInfoWindow(Marker marker)
        {
            if (marker == null)
            {
                return(null);
            }

            //update everytime, drawcircle need it
            selectedCoordinates = new GeofenceModel {
                LatLng = new LatLng(marker.Position.Latitude, marker.Position.Longitude)
            };
            View mapInfoView = activity.LayoutInflater.Inflate(Resource.Layout.map_info_view, null);

            var radiusBar = activity.FindViewById <SeekBar>(Resource.Id.radiusBar);

            if (radiusBar.Visibility == Android.Views.ViewStates.Invisible)
            {
                radiusBar.Visibility = Android.Views.ViewStates.Visible;
                radiusBar.SetProgress(30, true);
            }

            activity.FindViewById <SeekBar>(Resource.Id.radiusBar)?.SetProgress(30, true);
            activity.DrawCircleOnMap(selectedCoordinates);
            Button button = mapInfoView.FindViewById <Button>(Resource.Id.btnInfoWindow);

            button.Click += btnInfoWindow_ClickAsync;

            return(mapInfoView);
        }
        public void OnSuccess(Java.Lang.Object obj)
        {
            var lastLocation = (Location)obj;

            if (lastLocation != null)
            {
                var txtLat  = mainActivity.FindViewById <TextView>(Resource.Id.txtLat);
                var txtLong = mainActivity.FindViewById <TextView>(Resource.Id.txtLng);
                txtLat.Text  = lastLocation.Latitude.ToString();
                txtLong.Text = lastLocation.Longitude.ToString();
            }
        }
Beispiel #3
0
        private void searchByVoice(object sender, EventArgs e)
        {
            MainActivity act        = (MainActivity)this.Activity;
            SearchView   searchView = (SearchView)act.FindViewById(Resource.Id.searchView1);

            //If coming from the text search focus, get rid of it.
            if (flagSearch)
            {
                searchView.Focusable = false;
                searchView.SetIconifiedByDefault(true);
                searchView.OnActionViewCollapsed();
            }

            Intent intent = new Intent(RecognizerIntent.ActionRecognizeSpeech);

            try
            {
                intent.PutExtra(RecognizerIntent.ActionRecognizeSpeech, "en-US");
                intent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
                intent.PutExtra(RecognizerIntent.ExtraLanguage, LocaleList.Default);
                intent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 8000);

                act.StartActivityForResult(intent, 100);
            }catch (ActivityNotFoundException)
            {
                Toast t = Toast.MakeText(this.Activity, "Your device doesn't support Speech to Text", ToastLength.Short);
                t.Show();
            }
        }
Beispiel #4
0
        public static void HideKeyboard(bool fireLostFocus)
        {
            var tb   = TextBase.CurrentFocus;
            var view = tb ?? PopoverFragment.Instance?.View?.FindViewById(Resource.Id.popover_fragment) ??
                       MainActivity.FindViewById(Resource.Id.popover_fragment) ??
                       MainActivity.FindViewById(Resource.Id.master_fragment);

            if (view == null)
            {
                return;
            }

            var hideKeyboard = new Action(() =>
            {
                var imm = (InputMethodManager)MainActivity.GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(view.WindowToken, HideSoftInputFlags.None);
            });

            if (tb != null)
            {
                tb.Blur(false, false);
                tb.Post(hideKeyboard);
            }
            else
            {
                hideKeyboard();
            }
        }
        private void AddSearchToToolBar()
        {
            if (Element is SearchPage)
            {
                MainActivity current = CrossCurrentActivity.Current.Activity as MainActivity;
                Toolbar      toolbar = current.FindViewById <Toolbar>(Resource.Id.toolbar);

                toolbar.Title = Element.Title;
                toolbar.InflateMenu(Resource.Menu.mainmenu);

                _searchView = toolbar?.Menu?.FindItem(Resource.Id.action_search)?.ActionView?.JavaCast <SearchView>();

                if (_searchView == null)
                {
                    return;
                }

                _searchView.QueryTextChange += searchView_QueryTextChange;
                _searchView.QueryTextSubmit += searchView_QueryTextSubmit;
                _searchView.QueryHint        = (Element as SearchPage)?.SearchPlaceHolderText;
                _searchView.ImeOptions       = (int)ImeAction.Search;
                _searchView.InputType        = (int)InputTypes.TextVariationNormal;
                _searchView.MaxWidth         = int.MaxValue; //Hack to go full width - http://stackoverflow.com/questions/31456102/searchview-doesnt-expand-full-width
            }
        }
Beispiel #6
0
        public ProductTracker(TextView barcodeInfo, MainActivity mainActivity)
        {
            _mainActivity = mainActivity;
            _barcodeInfo  = barcodeInfo;

            var serverUrlTextbox = (EditText)mainActivity.FindViewById(Resource.Id.server_url);

            _advertService = new AdvertService(() => serverUrlTextbox.Text);
        }
        public override void OnReceive(Context context, Intent intent)
        {
            MainActivity activity = (MainActivity)context;

            if (intent.Action.Equals(MusicPlayerService.PlayerError))
            {
                var button = activity.FindViewById <ImageButton>(Resource.Id.playButton);
                button.SetImageResource(Resource.Drawable.ic_play_circle_outline_white_48dp);
            }
        }
Beispiel #8
0
    public override bool OnVectorElementClicked(VectorElementClickInfo clickInfo)
    {
        Action manipUI = () => {
            var zoomIn = activity.FindViewById <Button>(Resource.Id.zoomIn);
            zoomIn.Text = "+";
        }
        activity.RunOnUIThread(manipUI);

        return(true);
    }
Beispiel #9
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (intent.Action.Equals(MusicPlayerService.PlayerStop))
     {
         Activity.RunOnUiThread(() =>
         {
             var button = Activity.FindViewById <ImageButton>(Resource.Id.playButton);
             button.SetImageResource(Resource.Drawable.ic_play_circle_outline_dark_blue_48dp);
         });
     }
 }
        protected override void Dispose(bool disposing)
        {
            if (_searchView != null)
            {
                _searchView.QueryTextChange -= searchView_QueryTextChange;
                _searchView.QueryTextSubmit -= searchView_QueryTextSubmit;
            }

            MainActivity current = CrossCurrentActivity.Current.Activity as MainActivity;
            Toolbar      toolbar = current.FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar?.Menu?.RemoveItem(Resource.Menu.mainmenu);

            base.Dispose(disposing);
        }
Beispiel #11
0
        private async Task getLocation()
        {
            var locateMe = CrossGeolocator.Current;

            locateMe.DesiredAccuracy = 100;

            var pos = await locateMe.GetPositionAsync(TimeSpan.FromMilliseconds(10000));

            MainActivity act = (MainActivity)this.Activity;

            Button nearButton = (Button)act.FindViewById(Resource.Id.nearMe);

            Userposition = pos;

            nearButton.Enabled = true;
        }
Beispiel #12
0
        private void searchByText(object sender, EventArgs e)
        {
            //change focus off button
            Button mButton = (Button)sender;

            mButton.Focusable = false;

            //Get activity and the searchView. Set Listener on it
            MainActivity act     = (MainActivity)this.Activity;
            SearchView   searchV = (SearchView)act.FindViewById(Resource.Id.searchView1);

            //loses focus on search view if it already given focus before ((allows for backout without querying and pressing the button again))
            if (flagSearch)
            {
                searchV.Focusable = false;
                searchV.SetIconifiedByDefault(true);
                searchV.OnActionViewCollapsed();
            }

            searchV.RequestFocus();
            searchV.SetIconifiedByDefault(false);
            searchV.OnActionViewExpanded();
            flagSearch = true;
        }
Beispiel #13
0
 protected T FindViewById <T>(int id) where T : View
 {
     return(mActivity?.FindViewById <T>(id));
 }
Beispiel #14
0
            public Controls(MainActivity activity)
            {
                Logo        = activity.FindViewById <ImageView>(Resource.Id.logo);
                MediaButton = activity.FindViewById <ImageView>(Resource.Id.mediaButton);
                PhoneLink   = activity.FindViewById <TextView>(Resource.Id.phoneLink);
                MapButton   = activity.FindViewById <ImageView>(Resource.Id.mapButton);
                MailLink    = activity.FindViewById <TextView>(Resource.Id.mailLink);

                WebsiteButton   = activity.FindViewById <ImageView>(Resource.Id.websiteButton);
                FacebookButton  = activity.FindViewById <ImageView>(Resource.Id.facebookButton);
                TwitterButton   = activity.FindViewById <ImageView>(Resource.Id.twitterButton);
                InstagramButton = activity.FindViewById <ImageView>(Resource.Id.instagramButton);

                CoverImage        = activity.FindViewById <ImageView>(Resource.Id.coverImage);
                ArtistLabel       = activity.FindViewById <TextView>(Resource.Id.artistLabel);
                TitleLabel        = activity.FindViewById <TextView>(Resource.Id.titleLabel);
                ScheduleTimeRange = activity.FindViewById <TextView>(Resource.Id.scheduleTimeRange);
                PlayingProgress   = activity.FindViewById <ProgressBar>(Resource.Id.playingProgress);
            }
Beispiel #15
0
        private async void submitQueryListener(object sender, SearchView.QueryTextSubmitEventArgs e)
        {
            MainActivity act        = (MainActivity)this.Activity;
            SearchView   searchView = (SearchView)act.FindViewById(Resource.Id.searchView1);
            string       input      = e.Query;

            searchView.SetIconifiedByDefault(true);
            searchView.OnActionViewCollapsed();
            searchView.Focusable = false;

            //Ping database by name
            string data = GetData();

            JArray        jsonArray    = JArray.Parse(data);
            List <string> searched_Loc = new List <string>();
            List <string> similar_Loc  = new List <string>();

            string debugMe    = "";
            string tempinput  = input;
            string inputBlock = tempinput;

            tempinput = RemoveSpecialCharacters(tempinput);
            tempinput = tempinput.Replace(" ", System.String.Empty);

            AddressLocator        tempAddress;
            List <AddressLocator> mAddresses = new List <AddressLocator>();

            for (int i = 0; i < jsonArray.Count; i++)
            {
                JToken json = jsonArray[i];
                string temp = (string)json["name"];
                temp = RemoveSpecialCharacters(temp);
                temp = temp.Replace(" ", System.String.Empty);
                if (((string)json["name"]).Equals(input, StringComparison.InvariantCultureIgnoreCase) || temp.Equals(tempinput, StringComparison.InvariantCultureIgnoreCase))
                {
                    //Location stuff - make sure user location permissions were give
                    if (act.CheckSelfPermission(Android.Manifest.Permission.AccessCoarseLocation) == (int)Android.Content.PM.Permission.Granted)
                    {
                        Geocoder        coder   = new Geocoder(act);
                        IList <Address> address = new List <Address>();


                        address = coder.GetFromLocationName(((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]), 5);

                        float lon = (float)address.ElementAt(0).Longitude;
                        float lat = (float)address.ElementAt(0).Latitude;

                        tempAddress = new AddressLocator((string)json["name"], ((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]), lon, lat);
                        mAddresses.Add(tempAddress);


                        userLocationObtained = true;
                    }
                    else // if not, grab list like before.
                    {
                        searched_Loc.Add(((string)json["name"]) + ": " + ((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]));
                    }
                }
            }

            if (userLocationObtained)
            {
                //calculate distances
                CalculateAddressDistance(mAddresses);
                //sort distances
                mAddresses.Sort();

                for (int x = 0; x < mAddresses.Count; x++)
                {
                    searched_Loc.Add(mAddresses.ElementAt(x).Name + ": " + mAddresses.ElementAt(x).Address + " (" + mAddresses.ElementAt(x).Distance.ToString("n2") + " miles)");
                }
            }

            for (int j = 0; j < searched_Loc.Count; j++)
            {
                debugMe += searched_Loc[j];
                debugMe += "\n";
            }

            if (searched_Loc.Count == 0)
            {
                for (int i = 0; i < jsonArray.Count; i++)
                {
                    JToken json      = jsonArray[i];
                    bool   wordMatch = false;
                    string temp      = (string)json["name"];

                    string[] outputBlock = temp.Split(" ");

                    temp = RemoveSpecialCharacters(temp);
                    temp = temp.Replace(" ", System.String.Empty);

                    wordMatch = InputsMatch(inputBlock.ToLower(), outputBlock);

                    if ((tempinput.StartsWith(temp.Substring(0, 2), StringComparison.InvariantCultureIgnoreCase) || wordMatch) && !userLocationObtained)
                    {
                        similar_Loc.Add(((string)json["name"]) + ": " + ((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]));
                    }
                    else if ((tempinput.StartsWith(temp.Substring(0, 2), StringComparison.InvariantCultureIgnoreCase) || wordMatch) && userLocationObtained)
                    {
                        Geocoder        coder   = new Geocoder(act);
                        IList <Address> address = new List <Address>();


                        address = coder.GetFromLocationName(((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]), 5);

                        float lon = (float)address.ElementAt(0).Longitude;
                        float lat = (float)address.ElementAt(0).Latitude;

                        tempAddress = new AddressLocator((string)json["name"], ((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]), lon, lat);
                        mAddresses.Add(tempAddress);
                    }
                }
                if (userLocationObtained)
                {
                    //calculate distances
                    CalculateAddressDistance(mAddresses);
                    //sort distances
                    mAddresses.Sort();

                    for (int x = 0; x < mAddresses.Count; x++)
                    {
                        similar_Loc.Add(mAddresses.ElementAt(x).Name + ": " + mAddresses.ElementAt(x).Address + " (" + mAddresses.ElementAt(x).Distance.ToString("n2") + " miles)");
                    }
                }
            }

            mTv = act.FindViewById <ListView>(Resource.Id.searchResults);
            ArrayAdapter <string> arrayAdapter;

            if (searched_Loc.Count == 0 && similar_Loc.Count == 0)
            {
                Toast.MakeText(MainActivity.activity, "There were no results for that Location.", ToastLength.Long).Show();
                arrayAdapter = new ArrayAdapter <string>(act, Android.Resource.Layout.SimpleListItem1, similar_Loc);
            }
            else if (searched_Loc.Count == 0)
            {
                arrayAdapter = new ArrayAdapter <string>(act, Android.Resource.Layout.SimpleListItem1, similar_Loc);
            }
            else
            {
                arrayAdapter = new ArrayAdapter <string>(act, Android.Resource.Layout.SimpleListItem1, searched_Loc);
            }

            mTv.Adapter = arrayAdapter;
            mTv.SetFooterDividersEnabled(true);
            mTv.SetHeaderDividersEnabled(true);
        }
Beispiel #16
0
        private void searchNearMe(object sender, EventArgs e)
        {
            MainActivity MAct = (MainActivity)MainActivity.activity;
            MainActivity act  = (MainActivity)this.Activity;
            string       data = GetData();

            Button nearButton = (Button)act.FindViewById(Resource.Id.nearMe);

            nearButton.Enabled = false;

            if (MAct.CheckSelfPermission(Android.Manifest.Permission.AccessCoarseLocation) != (int)Permission.Granted)
            {
                RequestPermissions(new string[] { Android.Manifest.Permission.AccessCoarseLocation, Android.Manifest.Permission.AccessFineLocation }, 0);
            }

            JArray                jsonArray    = JArray.Parse(data);
            List <string>         searched_Loc = new List <string>();
            List <AddressLocator> mAddresses   = new List <AddressLocator>();
            AddressLocator        tempAddress;



            for (int i = 0; i < jsonArray.Count; i++)
            {
                JToken json = jsonArray[i];
                if (act.CheckSelfPermission(Android.Manifest.Permission.AccessCoarseLocation) == (int)Android.Content.PM.Permission.Granted)
                {
                    Geocoder        coder   = new Geocoder(act);
                    IList <Address> address = new List <Address>();


                    address = coder.GetFromLocationName(((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]), 5);

                    float lon = (float)address.ElementAt(0).Longitude;
                    float lat = (float)address.ElementAt(0).Latitude;

                    tempAddress = new AddressLocator((string)json["name"], ((string)json["street"]) + " " + ((string)json["city"]) + " " + ((string)json["state"]), lon, lat);
                    mAddresses.Add(tempAddress);


                    userLocationObtained = true;
                }
                else
                {
                    Toast.MakeText(MainActivity.activity, "Cannot Calculate User Location. Please allow for the application to use location permissions.", ToastLength.Long).Show();
                }
            }

            if (userLocationObtained)
            {
                //calculate distances
                CalculateAddressDistance(mAddresses);
                //sort distances
                mAddresses.Sort();

                for (int x = 0; x < mAddresses.Count; x++)
                {
                    if (mAddresses.ElementAt(x).Distance < 15.00)
                    {
                        searched_Loc.Add(mAddresses.ElementAt(x).Name + ": " + mAddresses.ElementAt(x).Address + " (" + mAddresses.ElementAt(x).Distance.ToString("n2") + " miles)");
                    }
                }
            }

            mTv = act.FindViewById <ListView>(Resource.Id.searchResults);
            ArrayAdapter <string> arrayAdapter = new ArrayAdapter <string>(act, Android.Resource.Layout.SimpleListItem1, searched_Loc);

            mTv.Adapter = arrayAdapter;
            mTv.SetFooterDividersEnabled(true);
            mTv.SetHeaderDividersEnabled(true);
            nearButton.Enabled = true;
        }
Beispiel #17
0
 protected virtual void InitConsoleText()
 {
     mConsoleText = mActivity.FindViewById <TextView>(Resource.Id.ConsoleText);
 }
Beispiel #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="mainActivity">Main activity context</param>
 /// <param name="textBoxId">Text box id</param>
 public TextContainer(MainActivity mainActivity, int textBoxId)
 {
     _text     = "";
     _textView = (TextView)mainActivity.FindViewById(Globals.ErrorTextBox);
 }
Beispiel #19
0
        public void PlayClickSound()
        {
            var view = _activity.FindViewById <View>(Android.Resource.Id.Content);

            view.PlaySoundEffect(SoundEffects.Click);
        }
        public void StartTutorial(MainActivity activity)
        {
            _mainActivity = activity;

            // hide Tools for tuto
            _mainActivity.HideTools();
            _mainActivity.HideScroll();

            //TODO : put Bed Cachou
            _mainActivity.SetCachouImg(Resource.Drawable.Cachou);

            // start audio 1
            PlayAudio(_mainActivity, Resource.Raw.audio1);

            // Add event on nurse click
            _mainActivity.FindViewById<ImageView>(Resource.Id.bear1).Click += OnCompletion;
            _mainActivity.FindViewById<ImageView>(Resource.Id.bear2).Click += OnCompletion;
            _mainActivity.FindViewById<ImageView>(Resource.Id.bear3).Click += OnCompletion;

            _mainActivity.FindViewById<ImageView>(Resource.Id.fox1).Click += OnCompletion;
            _mainActivity.FindViewById<ImageView>(Resource.Id.fox2).Click += OnCompletion;

            _mainActivity.FindViewById<ImageView>(Resource.Id.girafe1).Click += OnCompletion;
            _mainActivity.FindViewById<ImageView>(Resource.Id.girafe2).Click += OnCompletion;

            _mainActivity.FindViewById<ImageView>(Resource.Id.panda1).Click += OnCompletion;
            _mainActivity.FindViewById<ImageView>(Resource.Id.panda2).Click += OnCompletion;
        }