From: Michael Ang Date: Wed, 19 May 2010 23:55:31 +0000 (+0000) Subject: Give Android devices the same default ui mode as iPhone/iPod Touch X-Git-Url: http://git.rot13.org/?p=bookreader.git;a=commitdiff_plain;h=7140f74c9a62f3805ff0c3e7b606b87382750cf7 Give Android devices the same default ui mode as iPhone/iPod Touch --- diff --git a/BookReaderIA/inc/BookReader.inc b/BookReaderIA/inc/BookReader.inc index 56a1fd6..f5179d4 100644 --- a/BookReaderIA/inc/BookReader.inc +++ b/BookReaderIA/inc/BookReader.inc @@ -266,24 +266,11 @@ class BookReader return null; // was not handled } - // $$$ Ideally we will not rely on user agent, but for the moment we do - public static function paramsFromUserAgent($userAgent) { - $browserParams = array( - 'ipad' => array( 'ui' => 'touch' ), - 'iphone' => array( 'ui' => 'embed', 'mode' => '1up'), - ); - - $browser = BookReader::browserFromUserAgent($userAgent); - if ($browser) { - return $browserParams[$browser]; - } - return array(); - } - public static function browserFromUserAgent($userAgent) { $browserPatterns = array( 'ipad' => '/iPad/', 'iphone' => '/iPhone/', // Also cover iPod Touch + 'android' => '/Android/', ); foreach ($browserPatterns as $browser => $pattern) { @@ -293,7 +280,24 @@ class BookReader } return null; } + + // $$$ Ideally we will not rely on user agent, but for the moment we do + public static function paramsFromUserAgent($userAgent) { + // $$$ using 'embed' here for devices with assumed small screens -- really should just use CSS3 media queries + $browserParams = array( + 'ipad' => array( 'ui' => 'touch' ), + 'iphone' => array( 'ui' => 'embed', 'mode' => '1up' ), + 'android' => array( 'ui' => 'embed', 'mode' => '1up' ), + ); + + $browser = BookReader::browserFromUserAgent($userAgent); + if ($browser) { + return $browserParams[$browser]; + } + return array(); + } + } ?> \ No newline at end of file