Example #1
0
        public bool IsIntentTypeEnabled(IntentType type)
        {
            switch (type)
            {
            case IntentType.PLAY_VIDEO:
                return(YouTubeIntents.CanResolvePlayVideoIntent(this));

            case IntentType.OPEN_PLAYLIST:
                return(YouTubeIntents.CanResolveOpenPlaylistIntent(this));

            case IntentType.PLAY_PLAYLIST:
                return(YouTubeIntents.CanResolvePlayPlaylistIntent(this));

            case IntentType.OPEN_SEARCH:
                return(YouTubeIntents.CanResolveSearchIntent(this));

            case IntentType.OPEN_USER:
                return(YouTubeIntents.CanResolveUserIntent(this));

            case IntentType.OPEN_CHANNEL:
                return(YouTubeIntents.CanResolveChannelIntent(this));

            case IntentType.UPLOAD_VIDEO:
                return(YouTubeIntents.CanResolveUploadIntent(this));
            }
            return(false);
        }
            public bool IsIntentTypeEnabled(IntentType type)
            {
                switch (type)
                {
                case IntentType.PlayVideo:
                    return(YouTubeIntents.CanResolvePlayVideoIntent(context));

                case IntentType.OpenPlaylist:
                    return(YouTubeIntents.CanResolveOpenPlaylistIntent(context));

                case IntentType.PlayPlaylist:
                    return(YouTubeIntents.CanResolvePlayPlaylistIntent(context));

                case IntentType.OpenSearch:
                    return(YouTubeIntents.CanResolveSearchIntent(context));

                case IntentType.OpenUser:
                    return(YouTubeIntents.CanResolveUserIntent(context));

                case IntentType.OpenChannel:
                    return(YouTubeIntents.CanResolveChannelIntent(context));

                case IntentType.UploadVideo:
                    return(YouTubeIntents.CanResolveUploadIntent(context));
                }

                return(false);
            }
Example #3
0
        public void InitInterface()
        {
            intentItems = new List <DemoListViewItem>();
            intentItems.Add(new IntentItem()
            {
                Title = "Play Video", Type = IntentType.PLAY_VIDEO
            });

            intentItems.Add(new IntentItem()
            {
                Title = "Open Playlist", Type = IntentType.OPEN_PLAYLIST
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Play Playlist", Type = IntentType.PLAY_PLAYLIST
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Open User", Type = IntentType.OPEN_USER
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Open Channel", Type = IntentType.OPEN_CHANNEL
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Open Search Results", Type = IntentType.OPEN_SEARCH
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Upload Video", Type = IntentType.UPLOAD_VIDEO
            });

            ListView         listView = FindViewById <ListView>(Resource.Id.intent_list);
            DemoArrayAdapter adapter  = new DemoArrayAdapter(this, Resource.Layout.list_item, intentItems);

            listView.Adapter             = adapter;
            listView.OnItemClickListener = this;

            TextView youTubeVersionText = FindViewById <TextView>(Resource.Id.youtube_version_text);
            string   version            = YouTubeIntents.GetInstalledYouTubeVersionName(this);

            if (version != null)
            {
                string text = string.Format(GetString(Resource.String.youtube_currently_installed), version);
                youTubeVersionText.Text = text;
            }
            else
            {
                youTubeVersionText.Text = GetString(Resource.String.youtube_not_installed);
            }
        }
Example #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Intents);

            intentsList = FindViewById <ListView> (Resource.Id.intent_list);


            intentItems = new List <IntentItem>();
            intentItems.Add(new IntentItem()
            {
                Title = "Play Video", Type = IntentType.PlayVideo
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Open Playlist", Type = IntentType.OpenPlaylist
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Play Playlist", Type = IntentType.PlayPlaylist
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Open User", Type = IntentType.OperUser
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Open Search Results", Type = IntentType.OpenSearch
            });
            intentItems.Add(new IntentItem()
            {
                Title = "Upload Video", Type = IntentType.UploadVideo
            });


            intentsList.Adapter = new IntentsAdapter(this, intentItems);

            intentsList.ItemClick += OnListItemClick;

            TextView youTubeVersionText = FindViewById <TextView>(Resource.Id.youtube_version_text);
            String   version            = YouTubeIntents.GetInstalledYouTubeVersionName(this);

            if (version != null)
            {
                youTubeVersionText.Text = String.Format(GetString(Resource.String.youtube_currently_installed), version);
            }
            else
            {
                youTubeVersionText.Text = (GetString(Resource.String.youtube_not_installed));
            }
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (resultCode == Result.Ok)
            {
                if (requestCode == SelectVideoRequest)
                {
                    Intent intent = YouTubeIntents.CreateUploadIntent(this, data.Data);
                    StartActivity(intent);
                }
            }

            base.OnActivityResult(requestCode, resultCode, data);
        }
Example #6
0
 protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     if (resultCode == Result.Ok)
     {
         switch (requestCode)
         {
         case 1000:
             Intent intent = YouTubeIntents.CreateUploadIntent(this, data.Data);
             StartActivity(intent);
             break;
         }
     }
     base.OnActivityResult(requestCode, resultCode, data);
 }
Example #7
0
        public void OnItemClick(AdapterView parent, View view, int position, long id)
        {
            IntentItem clickedIntentItem = (IntentItem)intentItems[position];

            Intent intent;

            switch (clickedIntentItem.Type)
            {
            case IntentType.PLAY_VIDEO:
                intent = YouTubeIntents.CreatePlayVideoIntentWithOptions(this, VIDEO_ID, true, false);
                StartActivity(intent);
                break;

            case IntentType.OPEN_PLAYLIST:
                intent = YouTubeIntents.CreateOpenPlaylistIntent(this, PLAYLIST_ID);
                StartActivity(intent);
                break;

            case IntentType.PLAY_PLAYLIST:
                intent = YouTubeIntents.CreatePlayPlaylistIntent(this, PLAYLIST_ID);
                StartActivity(intent);
                break;

            case IntentType.OPEN_SEARCH:
                intent = YouTubeIntents.CreateSearchIntent(this, USER_ID);
                StartActivity(intent);
                break;

            case IntentType.OPEN_USER:
                intent = YouTubeIntents.CreateUserIntent(this, USER_ID);
                StartActivity(intent);
                break;

            case IntentType.OPEN_CHANNEL:
                intent = YouTubeIntents.CreateChannelIntent(this, CHANNEL_ID);
                StartActivity(intent);
                break;

            case IntentType.UPLOAD_VIDEO:
                // This will load a picker view in the users' gallery.
                // The upload activity is started in the function onActivityResult.
                intent = new Intent(Intent.ActionPick, null).SetType("video/*");
                intent.PutExtra(EXTRA_LOCAL_ONLY, true);
                StartActivityForResult(intent, SELECT_VIDEO_REQUEST);
                break;
            }
        }
        private void OnItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            var clickedIntentItem = (IntentItem)intentItems[e.Position];

            Intent intent;

            switch (clickedIntentItem.Type)
            {
            case IntentType.PlayVideo:
                intent = YouTubeIntents.CreatePlayVideoIntentWithOptions(this, VideoId, true, false);
                StartActivity(intent);
                break;

            case IntentType.OpenPlaylist:
                intent = YouTubeIntents.CreateOpenPlaylistIntent(this, PlaylistId);
                StartActivity(intent);
                break;

            case IntentType.PlayPlaylist:
                intent = YouTubeIntents.CreatePlayPlaylistIntent(this, PlaylistId);
                StartActivity(intent);
                break;

            case IntentType.OpenSearch:
                intent = YouTubeIntents.CreateSearchIntent(this, UserId);
                StartActivity(intent);
                break;

            case IntentType.OpenUser:
                intent = YouTubeIntents.CreateUserIntent(this, UserId);
                StartActivity(intent);
                break;

            case IntentType.OpenChannel:
                intent = YouTubeIntents.CreateChannelIntent(this, ChannelId);
                StartActivity(intent);
                break;

            case IntentType.UploadVideo:
                // This will load a picker view in the users' gallery.
                // The upload activity is started in the function onActivityResult.
                intent = new Intent(Intent.ActionPick, null).SetType("video/*");
                intent.PutExtra(Intent.ExtraLocalOnly, true);
                StartActivityForResult(intent, SelectVideoRequest);
                break;
            }
        }
Example #9
0
        void OnListItemClick(object sender, Android.Widget.AdapterView.ItemClickEventArgs e)
        {
            Intent intent;

            switch (intentItems [e.Position].Type)
            {
            case IntentType.PlayVideo:
                intent = YouTubeIntents.CreatePlayVideoIntentWithOptions(this, videoId, true, false);
                StartActivity(intent);
                break;

            case IntentType.OpenPlaylist:
                intent = YouTubeIntents.CreateOpenPlaylistIntent(this, playlistId);
                StartActivity(intent);
                break;

            case IntentType.PlayPlaylist:
                intent = YouTubeIntents.CreatePlayPlaylistIntent(this, playlistId);
                StartActivity(intent);
                break;

            case IntentType.OpenSearch:
                intent = YouTubeIntents.CreateSearchIntent(this, userId);
                StartActivity(intent);
                break;

            case IntentType.OperUser:
                intent = YouTubeIntents.CreateUserIntent(this, userId);
                StartActivity(intent);
                break;

            case IntentType.UploadVideo:
                // This will load a picker view in the users' gallery.
                // The upload activity is started in the function onActivityResult.
                intent = new Intent(Intent.ActionPick, null).SetType("video/*");
                intent.PutExtra(extraLocalOnly, true);
                StartActivityForResult(intent, selectVideoRequest);
                break;
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.intents_demo);

            intentItems = new List <DemoListViewItem>
            {
                new IntentItem(this, "Play Video", IntentType.PlayVideo),
                new IntentItem(this, "Open Playlist", IntentType.OpenPlaylist),
                new IntentItem(this, "Play Playlist", IntentType.PlayPlaylist),
                new IntentItem(this, "Open User", IntentType.OpenUser),
                new IntentItem(this, "Open Channel", IntentType.OpenChannel),
                new IntentItem(this, "Open Search Results", IntentType.OpenSearch),
                new IntentItem(this, "Upload Video", IntentType.UploadVideo),
            };

            var listView = FindViewById <ListView>(Resource.Id.intent_list);
            var adapter  = new DemoArrayAdapter(this, Resource.Layout.list_item, intentItems);

            listView.Adapter    = adapter;
            listView.ItemClick += OnItemClick;

            var youTubeVersionText = FindViewById <TextView>(Resource.Id.youtube_version_text);
            var version            = YouTubeIntents.GetInstalledYouTubeVersionName(this);

            if (version != null)
            {
                var text = string.Format(GetString(Resource.String.youtube_currently_installed), version);
                youTubeVersionText.Text = text;
            }
            else
            {
                youTubeVersionText.Text = GetString(Resource.String.youtube_not_installed);
            }
        }