using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI.WebControls;

/// <summary>
/// 웹브라우저 User-Agent 헤더를 분석한다.
/// </summary>
public class BrowserDetector
{
    public BrowserDetector()
    {
    }

    public static bool IsMobileDevice(HttpRequest request)
    {
        if (request.Browser.IsMobileDevice)
        {
            return true;
        }
        else
        {
            // 갤탭 네이버
            // User-Agent=Mozilla/5.0 (Linux; Android 13; SM-P610 Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0
            //   Chrome/128.0.0.0 Whale/1.0.0.0 Crosswalk/29.128.0.12 Safari/537.36 NAVER(inapp; search; 2000; 12.12.51)
            //
            // 갤탭 삼성 인터넷
            // User-Agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/28.0 Chrome/130.0.0.0 Safari/537.36
            ///
            bool mobile = false;
            string ua = request.UserAgent.ToLower();
            if ((ua.IndexOf("linux") > 0 && ua.IndexOf("android") > 0) ||
                (ua.IndexOf("linux") > 0 && ua.IndexOf("samsungbrowser") > 0) ||
                (ua.IndexOf("linux") > 0 && ua.IndexOf("x11") > 0)
                )
            {
                mobile = true;
            }
            return mobile;
        }
    }
}