At The Open University we're working actively on mobile support for mobile. We would be grateful for your comments on the below. The OU would expect to undertake the work involved. There also a bug here http://tracker.moodle.org/browse/MDL-25394
Introduction
This document proposes some additions to Moodle 2.1 to enable detection of mobile devices so that additional or alternative functionality can be provided. This would allow blocks, modules, etc to take advantage of mobile functionality (cameras, geo-location, etc); make more subtle adjustments within a mobile context; or to develop modules or blocks that are only for use on mobile devices.
It also specifies a means for administrators to select a theme for mobile devices. This provides an alternative to using @media rules within a ‘modern browser’ theme with the associated issues this may bring for users with larger displays (loss of features or unfamiliar layout if resizing a browser window). As a separate exercise, The Open University also intend to submit a mobile theme for possible inclusion in Moodle 2.1.
Browser Detection
A site setting enablemobiledetection will be added and set to yes by default.
The following functions would be added to lib/moodlelib.php –
is_mobile_browser() – detects whether a mobile browser is being used using a regular expression defined by detectmobilebrowser.com (see.PHP download). Returns true or false. If enablemobiledetection is set to no then will return false.
For more granular detection of browser operating systems and browsers, it is intended that the existing check_browser_operating_system and check_browser_version functions should be used and extended if required.
Mobile Theme
Administrators will be able to specify a theme to use for mobile devices through an additional ‘Use for mobile browsers’ button on the ‘theme selector’.
theme/index.php will be amended to display an additional form for selection of a mobile theme and accept an additional choosemobile parameter for theme configuration. The box will be greyed out if the theme does not have the new parameter mobileoptimised set to true.
In lib/pagelib.php, resolve_theme() will be amended under the site case to check if a browser is mobile, whether mobiledisabletheme (see below) exists and is true/false and whether a mobile theme is set.
Switching Themes
Mobile themes should provide the user with the ability to switch from the mobile theme to the ‘modern browser’ theme. This selection should persist for either the duration of the session or permanently according to the user’s selection, made via two links in the page footer. All ‘modern browser’ themes should, if is_mobile_browser() returns true, show a link to switch back to the mobile view. Template designers can specify where these links should appear.
An additional public function will be added to the core_render class in lib\outputrenderers.php, theme_switch_links(). Calling this will add the two switch links to a mobile theme or the single link to a ‘modern browser’ theme. An additional protected variable will be added to the class, switchlinkdisplayed, that will be false by default. Calling the function will cause it to be set to true.
standard_html_footer() will be amended to add a call to theme_switch_links() if switchlinkdisplayed is not set to true.
A new folder mobile folder will be created at the root. This will contain a single file, switch.php. According to the switch link selected, this will either set a session variable mobiledisabletheme to true, set a user preference mobileblocktheme to true or set both of these to false. The user will be redirected to the screen on which the link was selected.