StudyGroup 70-480-Implementing An Adaptive User Interface
StudyGroup 70-480-Implementing An Adaptive User Interface
StudyGroup 70-480-Implementing An Adaptive User Interface
Interface
StudyGroup 70-480: Programming in HTML5 with JavaScript
and CSS3
Agenda
This module describes how to create HTML5 pages that can
dynamically detect and adapt to different devices and form
factors.
Supporting Multiple Form Factors (The need to detect
device capabilities and react to different form factors in a
Web application).
Creating an Adaptive User Interface (Adapting Page
Layout To Fit a Different Form Factor)
Creating a Print-Friendly Stylesheet
Adaptive System
In computer science, the term “adaptive system” refers to a
process in which an interactive system adapts its behavior
to individual users based on information acquired about its
user(s), the context of use and its environment.
Examples Of Adaptive Systems (GPS)
The day and night interfaces in the GARMIN Zumo 660 adapt the
interface color so the user isn’t blinded with a bright light.
http://uxdesign.smashingmagazine.com/2012/12/10/creating-an-adaptive-
system-to-enhance-ux/
Example – Google Instant
Example – Adaptive UI
http://mobile.smashingmagazine.com/2010/11/03/how-to-build-a-mobile-website/
Variety of devices
Tons of internet-connected
devices out there
Nearly all of them have browsers.
diversity: Mac laptops, Windows
workstations, iPhones, iPads,
Kindles, Android phones
Touch input, scroll wheels,
keyboards, voice input, devices
with pressure sensitivity,
TVs, smart watches, toasters and
refrigerators, and many more
http://www.flickr.com/photos/brad_frost/61647
23945/in/set-72157627712478230/
Device Targeting- challenges
challenges solutions
Size (small screen / big Flexibility
screen)
Different output
Form factor / ratio / portait
/ landscape Different layout
Touchable / no touchable Different style/theme/skin
Static / Dynamic
Multicolor / mono
Some devices rotate!
Difficulty of data input
Browser inconsistency
Device Targeting - solution
<link rel="stylesheet"
type="text/css" href="core.css"
media="screen" />
Variety media types
all — for all the media types below
braille — for braille tactile feedback devices
embossed — for paged braille printers
handheld — for handheld devices like mobile phones
print — for printed material
projection — for projected presentations
screen — for color computer screens
speech — for speech synthesizers
tty — for teletypes, terminals, and other devices with
limited display capabilities
tv — for televisions and television like devices
3 ways to include media queries
@media in css file — @media screen and (max-width:
1200px) {css here}
link element — < link rel="stylesheet" href="my-
style.css" media="screen and (max-width: 1200px)" / >
@import in .css — @import url(“my-style.css”) screen
and (max-width: 1200px)
More than media, those are queries
@media screen and (max-width: 1200px)
and (orientation: landscape){
css here
}
@media not projection and (min-width:
1000px)
css here
}
Media queries - features
width - width of display area/viewport (min/max)
height - height of display area/viewport (min/max)
device-width - width of device rendering surface (min/max)
device-height - height of device rendering surface (min/max)
orientation - portrait or landscape
aspect-ratio - ratio of display’s width to height (16:9, 4:3) (min/max)
device-aspect-ratio - ratio of device rendering surface width to height (16:9, 4:3)
(min/max)
color - number of bits per color component of the output device (min/max)
color-index - number of entries in the color lookup table of the output device
(min/max)
monochrome - number of bits per pixel in a monochrome frame buffer (0 for
non-monochrome devices) (min/max)
resolution - resolution of the output device (pixel density; 72dpi, 300dpi)
(min/max)
scan - progressive or scan for tv devices
grid - grid or bitmap (phone display with one fixed font; tty terminal)
Media queries disadvantages
All devices get the same JavaScript, CSS, and assets
(images, videos), resulting in longer than necessary load
times.
All devices get the same initial DOM, potentially forcing
developers to write overly complicated CSS.
Little flexibility to specify custom interactions tailored to
each device.
Not supported on some browsers (IE<=8, Symbian
browsers, Blackberry < OS 6.0, Netfront, WP7 pre-Mango,
etc)
Other things to remeber - Webapps need
more than media queries (1)
Form factor detection
Browser detection
Function detection
Form factor-specific (web) apps
Form factors detection, approaches:
Server-side detection
Client-side detection (Redirect to a device-type-specific URL that
contains the version for this device type. Dynamically load the device
type-specific assets.)
Sample classifications:
small screens + touch (mostly phones)
large screens + touch (mostly tablets)
large screens + keyboard/ mouse (mostly desktops/ laptops)
Example detection strategy: if (hasTouch) { if (isSmall) { device
= PHONE; } else { device = TABLET; } } else { device =
DESKTOP; }
device.js, FormFactor.JS
http://www.html5rocks.com/en/tutorials/detection/index.html
Features detection
detectCanvas() ? showGraph() : showTable();
function detectCanvas()
{
var canvas = document.createElement("
canvas");
return canvas.getContext ? true : false;
}