Ejemplo n.º 1
0
 public void initializeSlidingPanelDelegates(SlidingUpPanelLayout view, NavigationLayoutManager manager)
 {
     //Binds a delegate that enables recyclerView scrolling iff the panel has been expanded, otherwise it disables it; it runs every time the panel state changes.
     //Also enables map scrolling iff the panel has been collapsed, otherwise disables it.
     view.PanelStateChanged += delegate
     {
         manager.scrollable = (view.GetPanelState() == SlidingUpPanelLayout.PanelState.Expanded);
         map.UiSettings.ScrollGesturesEnabled = (view.GetPanelState() == SlidingUpPanelLayout.PanelState.Collapsed);
     };
 }
Ejemplo n.º 2
0
        /** Method Declarations **/
        /** Route Selection Screen **/
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.MapLayout);
            mapView = FindViewById <MapView>(Resource.Id.mapview);

            //Registers the device if it's not already in the database, puts it on another thread
            registerDeviceAsync();

            //Loads the map background
            await loadMap(bundle);

            //Binds layout elements to a set of variables
            AutoCompleteTextView destinationBox   = FindViewById <AutoCompleteTextView>(Resource.Id.destinationSearchView);
            AutoCompleteTextView originBox        = FindViewById <AutoCompleteTextView>(Resource.Id.originSearchView);
            FrameLayout          originFrame      = FindViewById <FrameLayout>(Resource.Id.originFrame);
            FrameLayout          destinationFrame = FindViewById <FrameLayout>(Resource.Id.destinationFrame);
            Button routeButton               = FindViewById <Button>(Resource.Id.routeButton);
            Button originClear               = FindViewById <Button>(Resource.Id.originClearButton);
            Button destinationClear          = FindViewById <Button>(Resource.Id.destinationClearButton);
            SlidingUpPanelLayout view        = FindViewById <SlidingUpPanelLayout>(Resource.Id.sliding_layout);
            Button               startButton = FindViewById <Button>(Resource.Id.startButton);
            FloatingActionMenu   fam         = FindViewById <FloatingActionMenu>(Resource.Id.fabMenu);
            FloatingActionButton delayFab    = FindViewById <FloatingActionButton>(Resource.Id.delayFab);
            FloatingActionButton closureFab  = FindViewById <FloatingActionButton>(Resource.Id.closureFab);

            //Configures the autocomplete text views
            configureActv(destinationBox, originBox, destinationFrame, destinationClear, routeButton);
            configureActv(originBox, destinationBox, originFrame, originClear, routeButton);

            //Turns the originBox green if it already contains a valid value
            makeActvTurnGreenWhenAddressesAreValid(originBox, originFrame);

            //Sets up the sliding panel on the bottom
            var manager = initializeSlidingPanel();

            initializeSlidingPanelDelegates(view, manager);

            //Sets up delegates for the stawrt and select buttons
            bindStartSelectButtonDelegates(startButton, routeButton, originBox, destinationBox);

            //Sets focus on the destination box so the user can immediately begin typing there
            destinationBox.RequestFocus();

            //Binds the delegates to each floating action menu option
            bindFloatingActionMenuOptionDelegates(fam, delayFab, closureFab);
        }
Ejemplo n.º 3
0
        private void configureStationImage()
        {
            //Binds variable for the layers and the images in each layer
            LinearLayout thumbLayer = FindViewById <LinearLayout>(Resource.Id.subwayThumbLayer);
            ImageView    thumbImage = FindViewById <ImageView>(Resource.Id.subwayThumbImage);
            FrameLayout  fullLayer  = FindViewById <FrameLayout>(Resource.Id.subwayFullLayer);
            ImageView    fullImage  = FindViewById <ImageView>(Resource.Id.subwayFullImage);

            //Binds variable for sliding panel
            SlidingUpPanelLayout slider = FindViewById <SlidingUpPanelLayout>(Resource.Id.sliding_layout);

            //Sets the image resources of each imageView, they're invisible so they don't show up yet
            thumbImage.SetImageResource(Resource.Drawable.entrance_example);
            fullImage.SetImageResource(Resource.Drawable.entrance_example);

            //Sets the thumbnail layer to be visible and take click events
            thumbLayer.Visibility = ViewStates.Visible;
            thumbImage.Clickable  = true;

            //Hides the thumbnail layer when the sliding panel is extended
            slider.PanelStateChanged += delegate
            {
                if (slider.GetPanelState() == SlidingUpPanelLayout.PanelState.Expanded || slider.GetPanelState() == SlidingUpPanelLayout.PanelState.Dragging)
                {
                    Tools.toggleVisibility(thumbLayer);
                }
                else
                {
                    Tools.toggleVisibility(thumbLayer);
                }
            };

            //Switches view from the thumbnail view with map to a fullscreen image
            thumbImage.Click += delegate
            {
                Tools.toggleVisibility(thumbLayer);
                Tools.toggleVisibility(fullLayer);
            };

            //Switches view from the full layer to the thumbnail view
            fullLayer.Click += delegate
            {
                Tools.toggleVisibility(thumbLayer);
                Tools.toggleVisibility(fullLayer);
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Speech);

            Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this);
            Recognizer.SetRecognitionListener(this);

            SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguage, "ur-PK");
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguagePreference, "ur-PK");
            SpeechIntent.PutExtra(RecognizerIntent.ExtraOnlyReturnLanguagePreference, "ur-PK");

            sliding_layout = FindViewById <SlidingUpPanelLayout>(Resource.Id.sliding_layout);

            var button = FindViewById <Button>(Resource.Id.speakButton);

            button.Click += ButtonClick;
            //var leftButton = FindViewById<Button>(Resource.Id.leftButton);
            //leftButton.Click += LeftButtonClick;
            //var rightButton = FindViewById<Button>(Resource.Id.rightButton);
            //rightButton.Click += RightButtonClick;


            Label = FindViewById <TextView>(Resource.Id.textV);

            /*spinner = FindViewById<Spinner>(Resource.Id.spinnerSpeech);
             *
             * languagesList = new List<KeyValuePair<string, string>>
             * {
             *  new KeyValuePair<string, string>("English", "en-US"),
             *  new KeyValuePair<string, string>("Arabic", "ar-SA"),
             *  new KeyValuePair<string, string>("Greek", "el-GR"),
             *  new KeyValuePair<string, string>("Hebrew", "he-IL"),
             *  new KeyValuePair<string, string>("Spanish", "es-ES"),
             *  new KeyValuePair<string, string>("Chinese", "cmn-Hans-CN"),
             *  new KeyValuePair<string, string>("Korean", "ko-KR"),
             *  new KeyValuePair<string, string>("German", "de-DE"),
             *  new KeyValuePair<string, string>("Persian", "fa-IR"),
             *  new KeyValuePair<string, string>("Russian", "ru-RU"),
             *  new KeyValuePair<string, string>("Turkish", "tr-TR"),
             *  new KeyValuePair<string, string>("Urdu", "ur-PK"),
             *  new KeyValuePair<string, string>("French", "fr-FR"),
             *  new KeyValuePair<string, string>("Hindi", "hi-IN"),
             *  new KeyValuePair<string, string>("Japanese", "ja-JP")
             * };
             *
             * List<string> languages = new List<string>();
             * foreach (var item in languagesList)
             *  languages.Add(item.Key);
             *
             *
             *
             * spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
             * var adapter = new ArrayAdapter<string>(this,
             *  Android.Resource.Layout.SimpleSpinnerItem, languages);
             *
             * adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleListItemSingleChoice);
             * spinner.Adapter = adapter;*/
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            SetSupportActionBar(FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.main_toolbar));

            var lv = (ListView)FindViewById(Resource.Id.list);

            lv.ItemClick += delegate
            {
                Toast.MakeText(this, "onItemClick", ToastLength.Short).Show();
            };

            var your_array_list = new[] {
                "This",
                "Is",
                "An",
                "Example",
                "ListView",
                "That",
                "You",
                "Can",
                "Scroll",
                ".",
                "It",
                "Shows",
                "How",
                "Any",
                "Scrollable",
                "View",
                "Can",
                "Be",
                "Included",
                "As",
                "A",
                "Child",
                "Of",
                "SlidingUpPanelLayout"
            };

            // This is the array adapter, it takes the context of the activity as a
            // first parameter, the type of list view as a second parameter and your
            // array as a third parameter.
            var arrayAdapter = new ArrayAdapter <String>(
                this,
                Android.Resource.Layout.SimpleListItem1,
                your_array_list);

            lv.Adapter = (arrayAdapter);

            mLayout = (SlidingUpPanelLayout)FindViewById(Resource.Id.sliding_layout);

            mLayout.AddPanelSlideListener(this);
            mLayout.SetFadeOnClickListener(this);

            var t = (TextView)FindViewById(Resource.Id.name);

            t.SetText(Html.FromHtml(GetString(Resource.String.hello)), TextView.BufferType.Spannable);
            var f = (Button)FindViewById(Resource.Id.follow);

            f.SetText(Html.FromHtml(GetString(Resource.String.follow)), TextView.BufferType.Spannable);
            f.MovementMethod = LinkMovementMethod.Instance;
            f.Click         += delegate
            {
                Intent i = new Intent(Intent.ActionView);
                i.SetData(Android.Net.Uri.Parse("http://www.twitter.com/naxamco"));
                StartActivity(i);
            };
        }
/*
 *      TextToSpeech textToSpeech;
 *      Context context;
 *      private readonly int MyCheckCode = 101, NeedLang = 103;
 *      Java.Util.Locale lang;*/

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Speech);

            Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this);
            Recognizer.SetRecognitionListener(this);

            SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName);


            sliding_layout = FindViewById <SlidingUpPanelLayout>(Resource.Id.sliding_layout);

            list_of_message = FindViewById <ListView>(Resource.Id.list_of_message);



            //var button = FindViewById<Button>(Resource.Id.speakButton);
            //button.Click += ButtonClick;

            leftSpeakButton         = FindViewById <Button>(Resource.Id.leftSpeakButton);
            leftSpeakButton.Click  += LeftSpeakButtonClick;
            rightSpeakButton        = FindViewById <Button>(Resource.Id.rightSpeakButton);
            rightSpeakButton.Click += RightSpeakButtonClick;


            leftButton         = FindViewById <Button>(Resource.Id.leftButton);
            leftButton.Click  += LeftButtonClick;
            rightButton        = FindViewById <Button>(Resource.Id.rightButton);
            rightButton.Click += RightButtonClick;

            /*context = rightSpeakButton.Context;
             * textToSpeech = new TextToSpeech(context, this, "com.google.android.tts");*/
            /*var langAvailable = new List<string> { "Default" };
             *
             * // our spinner only wants to contain the languages supported by the tts and ignore the rest
             * var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();
             * foreach (var locale in localesAvailable)
             * {
             *  LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
             *  switch (res)
             *  {
             *      case LanguageAvailableResult.Available:
             *          langAvailable.Add(locale.DisplayLanguage);
             *          break;
             *      case LanguageAvailableResult.CountryAvailable:
             *          langAvailable.Add(locale.DisplayLanguage);
             *          break;
             *      case LanguageAvailableResult.CountryVarAvailable:
             *          langAvailable.Add(locale.DisplayLanguage);
             *          break;
             *  }
             *
             * }
             * langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();*/

            // set up the speech to use the default langauge
            // if a language is not available, then the default language is used.

            /*lang = Java.Util.Locale.Us;
             * textToSpeech.SetLanguage(lang);
             *
             * // set the speed and pitch
             * textToSpeech.SetPitch(.5f);
             * textToSpeech.SetSpeechRate(.5f);*/

            //Label = FindViewById<TextView>(Resource.Id.textV);

            spinner = FindViewById <Spinner>(Resource.Id.spinnerSpeech);

            languagesList = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("English", "en-US"),
                new KeyValuePair <string, string>("Arabic", "ar-SA"),
                new KeyValuePair <string, string>("Greek", "el-GR"),
                new KeyValuePair <string, string>("Hebrew", "he-IL"),
                new KeyValuePair <string, string>("Spanish", "es-ES"),
                new KeyValuePair <string, string>("Chinese", "zh-CN"),
                new KeyValuePair <string, string>("Korean", "ko-KR"),
                new KeyValuePair <string, string>("German", "de-DE"),
                new KeyValuePair <string, string>("Persian", "fa-IR"),
                new KeyValuePair <string, string>("Russian", "ru-RU"),
                new KeyValuePair <string, string>("Turkish", "tr-TR"),
                new KeyValuePair <string, string>("Urdu", "ur-PK"),
                new KeyValuePair <string, string>("French", "fr-FR"),
                new KeyValuePair <string, string>("Hindi", "hi-IN"),
                new KeyValuePair <string, string>("Japanese", "ja-JP")
            };

            List <string> languages = new List <string>();

            foreach (var item in languagesList)
            {
                languages.Add(item.Key);
            }



            spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            var adapter = new ArrayAdapter <string>(this,
                                                    Android.Resource.Layout.SimpleSpinnerItem, languages);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleListItemSingleChoice);
            spinner.Adapter = adapter;

            //lang = Java.Util.Locale.GetAvailableLocales().FirstOrDefault(t => t.DisplayLanguage == langAvailable[(int)e.Id]);
            // create intent to check the TTS has this language installed

            /*var checkTTSIntent = new Intent();
             * checkTTSIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
             * StartActivityForResult(checkTTSIntent, NeedLang);*/
        }