Exemple #1
0
        /// <summary>
        /// Add a predefined Element that the opens the Twitter app with a deep link to the specified user id
        /// If the Twitter application is not installed this will open a web page instead.
        /// </summary>
        /// <param name="id">the id of the Twitter user to display in the Twitter app</param>
        /// <param name="title">the title to display on this item</param>
        /// <returns>AboutPage instance for builder pattern support</returns>
        public AboutPage AddTwitter(string id, string title)
        {
            var intent = new Intent();

            intent.SetAction(Intent.ActionView);
            intent.AddCategory(Intent.CategoryBrowsable);

            if (AboutPageUtils.IsAppInstalled(_mContext, "com.twitter.android"))
            {
                intent.SetPackage("com.twitter.android");
                intent.SetData(Uri.Parse($"twitter://user?screen_name={id}"));
            }
            else
            {
                intent.SetData(Uri.Parse($"http://twitter.com/intent/user?screen_name={id}"));
            }

            var element = new Element
            {
                Title        = _mContext.GetString(Resource.String.about_twitter),
                IconDrawable = Resource.Drawable.about_icon_twitter,
                IconTint     = Resource.Color.about_twitter_color,
                Intent       = intent,
                Value        = id
            };

            AddItem(element);
            return(this);
        }
Exemple #2
0
        /// <summary>
        /// Add a predefined Element that the opens Facebook app with a deep link to the specified user id
        /// If the Facebook application is not installed this will open a web page instead.
        /// </summary>
        /// <param name="id">the id of the Facebook user to display in the Facebook app</param>
        /// <param name="title">the title to display on this item</param>
        /// <returns>AboutPage instance for builder pattern support</returns>
        public AboutPage AddFacebook(string id, string title)
        {
            var intent = new Intent();

            intent.SetAction(Intent.ActionView);
            intent.AddCategory(Intent.CategoryBrowsable);

            if (AboutPageUtils.IsAppInstalled(_mContext, "com.facebook.katana"))
            {
                intent.SetPackage("com.facebook.katana");
                int versionCode = 0;
                try
                {
                    versionCode = _mContext.PackageManager.GetPackageInfo("com.facebook.katana", 0).VersionCode;
                }
                catch (PackageManager.NameNotFoundException e)
                {
                    e.PrintStackTrace();
                }

                if (versionCode >= 3002850)
                {
                    var uri = Uri.Parse($"fb://facewebmodal/f?href=http://m.facebook.com/{id}");
                    intent.SetData(uri);
                }
                else
                {
                    var uri = Uri.Parse($"fb://page/{id}");
                    intent.SetData(uri);
                }
            }
            else
            {
                intent.SetData(Uri.Parse($"http://m.facebook.com/{id}"));
            }

            var element = new Element
            {
                Title        = _mContext.GetString(Resource.String.about_facebook),
                IconDrawable = Resource.Drawable.about_icon_facebook,
                IconTint     = Resource.Color.about_facebook_color,
                Intent       = intent,
                Value        = id
            };

            AddItem(element);
            return(this);
        }
Exemple #3
0
        /// <summary>
        /// Add a predefined Element that the opens the Instagram app with a deep link to the
        /// specified user id.
        /// If the Instagram app is not installed this will open the Intagram web page instead.
        /// </summary>
        /// <param name="id">the user id to deep link to</param>
        /// <param name="title">the title to display on this item</param>
        /// <returns>AboutPage instance for builder pattern support</returns>
        public AboutPage AddInstagram(string id, string title)
        {
            var intent = new Intent();

            intent.SetAction(Intent.ActionView);
            intent.SetData(Uri.Parse("http://instagram.com/_u/" + id));

            if (AboutPageUtils.IsAppInstalled(_mContext, "com.instagram.android"))
            {
                intent.SetPackage("com.instagram.android");
            }

            var element = new Element
            {
                Title        = _mContext.GetString(Resource.String.about_instagram),
                IconDrawable = Resource.Drawable.about_icon_instagram,
                IconTint     = Resource.Color.about_instagram_color,
                Intent       = intent,
                Value        = id
            };

            AddItem(element);
            return(this);
        }
Exemple #4
0
        /// <summary>
        /// Add a predefined Element that the opens the Youtube app with a deep link to the
        /// specified channel id.
        /// If the Youtube app is not installed this will open the Youtube web page instead.
        /// </summary>
        /// <param name="id">the id of the channel to deep link to</param>
        /// <param name="title">the title to display on this item</param>
        /// <returns>AboutPage instance for builder pattern support</returns>
        public AboutPage AddYoutube(string id, string title)
        {
            var intent = new Intent();

            intent.SetAction(Intent.ActionView);
            intent.SetData(Uri.Parse($"http://youtube.com/channel/{id}"));

            if (AboutPageUtils.IsAppInstalled(_mContext, "com.google.android.youtube"))
            {
                intent.SetPackage("com.google.android.youtube");
            }

            var element = new Element
            {
                Title        = _mContext.GetString(Resource.String.about_youtube),
                IconDrawable = Resource.Drawable.about_icon_youtube,
                IconTint     = Resource.Color.about_youtube_color,
                Intent       = intent,
                Value        = id
            };

            AddItem(element);
            return(this);
        }