Moodle
  1. Moodle
  2. MDL-30784

Android Tablets sent to mobile theme

    Details

    • Testing Instructions:
      Hide
      1. Set the mobile theme as afterburner
      2. Set the tablet theme as standard
      3. Set the default theme as brick
      4. Access the site on a android mobile phone and see the afterburner theme
      5. Access device on android tablet and see the standard theme
      6. Access device on ipad and see the standard theme.
      Show
      Set the mobile theme as afterburner Set the tablet theme as standard Set the default theme as brick Access the site on a android mobile phone and see the afterburner theme Access device on android tablet and see the standard theme Access device on ipad and see the standard theme.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-30784-master
    • Rank:
      33720

      Description

      Android tablets are detected as mobile devices not as tablets in themes.

      I have attached a patch to lib/moodlelib.php to fix the issue. The change is that the mobile regex needs to search for android and mobile in the user agent not just android.

      The user agent for an android mobile device lists (Android version number) /4.0 Mobile Safari/
      The user agent for an android tablet device lists (Android version number) / 4.0 Safari/

      In the patch I change /android| to /android \. mobile| for the mobile regex and then I added |android to the tablet regex.

      This was tested and validated on a iPod OS 5, Galaxy Nexus on Android 4.0.2, a Motorola Xoom on Honeycomb 3.2, a Droid (original) running Android 2.3.6 and an iPad.

        Activity

        Hide
        Jason Hardin added a comment -

        well the first file was a crappy diff. the second file i sent in at 8:32 AM is the correct file.

        Show
        Jason Hardin added a comment - well the first file was a crappy diff. the second file i sent in at 8:32 AM is the correct file.
        Hide
        Michael de Raadt added a comment -

        Thanks for reporting that an sharing a solution.

        Show
        Michael de Raadt added a comment - Thanks for reporting that an sharing a solution.
        Hide
        Jason Fowler added a comment -

        there is more to this issue, My HTC Sensation running Android 2.3.4 reports this:
        Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; HTC_Sensation_Z710a; en-au) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16
        As it's user agent when I have "Mobile view" off (when it is set to desktop viewing)

        When mobile view is on, it reports
        Mozilla/5.0 (Linux; U; Android 2.3.4; en-au; HTC_Sensation_Z710a Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

        I don't have my Acer Iconia A500 to test with at the moment as it is in for repairs at the moment.

        Show
        Jason Fowler added a comment - there is more to this issue, My HTC Sensation running Android 2.3.4 reports this: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; HTC_Sensation_Z710a; en-au) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 As it's user agent when I have "Mobile view" off (when it is set to desktop viewing) When mobile view is on, it reports Mozilla/5.0 (Linux; U; Android 2.3.4; en-au; HTC_Sensation_Z710a Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 I don't have my Acer Iconia A500 to test with at the moment as it is in for repairs at the moment.
        Hide
        Jason Fowler added a comment -

        My Acer Iconia A500 running 3.2 reports this
        Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16
        when running in desktop mode

        And this:
        Mozilla/5.0 (Linux; U; Android 3.2; en-us; A500 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
        when running in tablet mode

        So I never see the tablet theme ...

        Show
        Jason Fowler added a comment - My Acer Iconia A500 running 3.2 reports this Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 when running in desktop mode And this: Mozilla/5.0 (Linux; U; Android 3.2; en-us; A500 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13 when running in tablet mode So I never see the tablet theme ...
        Hide
        Jason Fowler added a comment -

        Having added the patch, the tablet view now shows the right theme. Pushing this for peer review, and then porting back through the other versions of moodle

        Show
        Jason Fowler added a comment - Having added the patch, the tablet view now shows the right theme. Pushing this for peer review, and then porting back through the other versions of moodle
        Hide
        Rajesh Taneja added a comment -
        Show
        Rajesh Taneja added a comment - Patch looks good Jason. Looking at http://googlewebmastercentral.blogspot.com.au/2011/03/mo-better-to-also-detect-mobile-user.html , and patch make sense.
        Hide
        Jason Fowler added a comment -

        Cherry picked across to the different versions of Moodle, pushing for integration. Thanks Jason Hardin for the patch.

        Show
        Jason Fowler added a comment - Cherry picked across to the different versions of Moodle, pushing for integration. Thanks Jason Hardin for the patch.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Jason Fowler added a comment -

        Just rebased this for all three branches

        Show
        Jason Fowler added a comment - Just rebased this for all three branches
        Hide
        Aparup Banerjee added a comment -

        Thanks all, this has been integrated into 21, 22 and master.

        Tester: i'm not sure about the lowercase (A/android) used here but only testing and/or more user agent strings will help here.

        Show
        Aparup Banerjee added a comment - Thanks all, this has been integrated into 21, 22 and master. Tester: i'm not sure about the lowercase (A/android) used here but only testing and/or more user agent strings will help here.
        Hide
        Ankit Agarwal added a comment -

        Hi guys,
        I used firefox with different user agents. And all seems to be working fine.
        passing
        Thanks

        Show
        Ankit Agarwal added a comment - Hi guys, I used firefox with different user agents. And all seems to be working fine. passing Thanks
        Hide
        Aparup Banerjee added a comment -

        The code here has been spread to upstream moodle repositories and mirrors for anyone to use .

        Closing, have a good weekend!

        Show
        Aparup Banerjee added a comment - The code here has been spread to upstream moodle repositories and mirrors for anyone to use . Closing, have a good weekend!

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: