YAFLogo

yesimahuman
  • yesimahuman
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
Hi.

I have enabled the mobile theme for my yaf.net installation, but neither the iphone or android devices tested get served the mobile theme (and doing a user-agent switch on my browser doesn't work either).

I am using yaf-1.9.5-final.

Any ideas? Thanks.

EDIT:

in UserPageBase.cs, the check on line 808:

bool isMobileDevice = UserAgentHelper.IsMobileDevice(userAgent) || YafContext.Current.Get().Browser.IsMobileDevice;

returns false for the iphone 3.0 useragent:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16

Sponsor
yesimahuman
  • yesimahuman
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
I fixed it. The problem was a case-sensitive contains() in UserAgentHelper.IsMobileDevice. I changed it to indexof and it works:


public static bool IsMobileDevice([CanBeNull] string userAgent)
    {
      var mobileContains =
        Config.MobileUserAgents.Split(',').Where(m => m.IsSet()).Select(m => m.Trim().ToLowerInvariant());

      return userAgent.IsSet() && mobileContains.Any(s => userAgent.IndexOf(s, StringComparison.OrdinalIgnoreCase) > 0);
        //userAgent.Contains(s));
    }
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
13 years ago

I fixed it. The problem was a case-sensitive contains() in UserAgentHelper.IsMobileDevice. I changed it to indexof and it works:


public static bool IsMobileDevice([CanBeNull] string userAgent)
    {
      var mobileContains =
        Config.MobileUserAgents.Split(',').Where(m => m.IsSet()).Select(m => m.Trim().ToLowerInvariant());

      return userAgent.IsSet() && mobileContains.Any(s => userAgent.IndexOf(s, StringComparison.OrdinalIgnoreCase) > 0);
        //userAgent.Contains(s));
    }

Originally Posted by: yesimahuman 

Thx this will be fixed in 1.9.5.6