cse4443 – mobile user interfaces€¦ · indentifier vs. index • when a finger, or pointer,...

24
Scott MacKenzie York University CSE4443 – Mobile User Interfaces © Scott MacKenzie (Part 1)

Upload: others

Post on 30-Apr-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Scott MacKenzieYork University

CSE4443 – Mobile User Interfaces

© Scott MacKenzie

(Part 1)

Page 2: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Concepts

© Scott MacKenzie 2

Touch Multitouch

Page 3: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Preface - Terminology

• Android documentation uses the term “gesture” for touch interaction

• That’s fine, but…• We’ll also discuss gestural input in a different

context later (unistroke recognition)

© Scott MacKenzie 3

Page 4: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Map

• Android’s “Touch Mode”• Single touch• Multitouch• Touch gestures

© Scott MacKenzie 4

Page 5: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Map

• Android’s “Touch Mode”• Single touch• Multitouch• Touch gestures

© Scott MacKenzie 5

Page 6: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Key vs. Touch Input

• Consider three input scenarios:– Physical keys

• UI widgets acquire and reveal focus• Users navigate with keys or a trackball, then select

– Touch• UI widgets do not acquire and reveal focus• “Direct input” touch to select

– Hybrid (keys + touch)• Do widgets need to acquire and reveal focus?

© Scott MacKenzie 6

Page 7: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Examples

Key vs. Touch Input

• Consider three input scenarios:– Physical keys

• UI widgets acquire and reveal focus• Users navigate with keys, then select

– Touch• UI widgets do not acquire and reveal focus• “Direct input” touch to select

– Hybrid (keys + touch)• Do widgets need to acquire and reveal focus?

© Scott MacKenzie 7

Page 8: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Hybrid Example

• HTC Dream (aka T1-Mobile G1)– 1st Android phone (2008)– Input via physical keys, trackball, or touch

© Scott MacKenzie 8

Page 9: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Android’s Touch Mode

• For apps to work well on hybrid devices, the Android platform defines “touch mode”

• Normal mode– Widgets acquire and reveal focus (key input)

• Touch mode– Widgets do not acquire and reveal focus (touch input)

• Mode transitions (next slide)

© Scott MacKenzie 9

Page 10: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Input Mode Transitions

© Scott MacKenzie 10

Normalmode

Touchmode

User touchesscreen

User presses key

Keyinteraction

Touch interaction

Page 11: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Touch Mode Explained

© Scott MacKenzie 11http://developer.android.com/guide/topics/ui/ui-events.html#TouchMode

Page 12: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Android Buttons and Touch Mode

• Android buttons:– Not focusable in touch mode– Fire click events when touched

• Writing code for Android buttons:– Do attach a click listener– Do not attach a touch listener

• Examples:

© Scott MacKenzie 12

Demo_Android Demo_Layout Demo_Buttons

Page 13: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Map

• Android’s “Touch Mode”• Single touch• Multitouch• Touch gestures

© Scott MacKenzie 13

Page 14: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Handling Touch Events

© Scott MacKenzie 14

True = the event has been consumed (no further processing is necessary)False = not consumed (further processing is necessary)

Page 15: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

The MotionEvent Object

• Carries information about the touch event• Action codes (retrieved via getAction):

– ACTION_DOWN finger touch– ACTION_MOVE finger movement – ACTION_UP finger lift– Etc.

• Retrieve values using get-methods:– getX, getY, getEventTime, getPressure, etc.

• Note: A finger is called a “pointer” in the Android documentation

© Scott MacKenzie 15

Page 16: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Demo_Touch

© Scott MacKenzie 16

EscLet’s have a look.

Page 17: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Demo_Ink

© Scott MacKenzie 17

EscLet’s have a look.

Drawing with digital ink on a canvas

Touch Mode Buttons

Page 18: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Map

• Android’s “Touch Mode”• Single touch• Multitouch• Touch gestures

© Scott MacKenzie 18

Page 19: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Compare

© Scott MacKenzie 19

Single touch:

Multitouch:

Page 20: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Multitouch Summary

• If fingers always left the tablet in the reverse order from touching, multitouch would be simple

• Of course, there is no guarantee that finger events will be so orderly

• To manage touch events for multiple fingers, each finger touch point (also called a pointer) has both an index and an identifier.

© Scott MacKenzie 20

Page 21: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Indentifier vs. Index

• When a finger, or pointer, first touches the display surface, it is assigned an identifier (id)

• The id will not change for the duration of the movement associated with that finger

• However, the index of the finger/pointer might change from one touch event to the next

• This is simply an artefact of the possibility of multiple fingers touching and leaving the display surface and in any order

© Scott MacKenzie 21

Page 22: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Changing Touch Points

• As noted in the MotionEvent API, “the number of pointers only ever changes by one as individual pointers go up and down.”

• The index of the changed pointer is retrieved from the MotionEvent object ( me) by

• The id is retrieved by

© Scott MacKenzie 22

int pointerIndex = me.getActionIndex();

int pointerId = me.getPointerId(pointerIndex);

Page 23: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Demo_Multitouch

© Scott MacKenzie 23

EscLet’s have a look.

Page 24: CSE4443 – Mobile User Interfaces€¦ · Indentifier vs. Index • When a finger, or pointer, first touches the display surface, it is assigned an identifier (id) • The idwill

Thank You

24© Scott MacKenzie