cse4443 – mobile user interfaces€¦ · android touch “gestures” • question: – is it...

19
Scott MacKenzie York University CSE4443 – Mobile User Interfaces © Scott MacKenzie (Part 2)

Upload: others

Post on 11-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Scott MacKenzieYork University

CSE4443 – Mobile User Interfaces

© Scott MacKenzie

(Part 2)

Page 2: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Demo_Multitouch

© Scott MacKenzie 2

EscLet’s have a look.

Page 3: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

What is Where!

© Scott MacKenzie 3

DemoTouchActivity.java

PaintPanel

Activity

View

onTouch

DemoInkActivity.java

PaintPanel.java

Activity

View

onTouch

Demo Touch Demo InkDemoMultitouchActivity.java

PaintPanel.java

Activity

View

onTouch

Demo Multitouch

DemoScaleActivity.java

Activity

PaintPanel.java

View

onTouchEvent

Demo Scale

Coming Up…

Page 4: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Map

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

© Scott MacKenzie 4

Page 5: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Android Touch “Gestures”

• Question:– Is it possible to detect high-level finger actions, such

as double tap, flick, drag, pinch, etc.?

• Answer: – Yes (of course) … but how?

• Two approaches:– Roll your own (use a touch listener in combination

with MotionEvent, state variables, timers, etc.) – Use Android’s gesture detector classes

© Scott MacKenzie 5

Page 6: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Android Touch “Gestures”

• Question:– Is it possible to detect high-level finger actions, such

as double tap, flick, drag, pinch, etc.?

• Answer: – Yes (of course) … but how?

• Two approaches:– Roll your own (use a touch listener in combination

with MotionEvent, state variables, timers, etc.) – Use Android’s gesture detector classes

© Scott MacKenzie 6

Page 7: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

1-Finger ( ) Gestures

Touch Longpress

Swipe ordrag

Double touchdrag

Doubletouch

7© Scott MacKenzie

Long pressdrag

Page 8: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Android’s GestureDetector Class(single touch)

• From the API:– Detects various gestures and events using the

supplied MotionEvents

• Programming approach:– Extend the “convenience” class…

… and implement methods of interest

© Scott MacKenzie 8

GestureDetector.SimpleOnGestureListener

Page 9: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

GestureDetector.SimpleOnGestureListenera “convenience” class

9© Scott MacKenzie

Page 10: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

© Scott MacKenzie 10

Minimum Implementation

Note: We are handing touch events in the view, not in the activity.

Page 11: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

2-finger ( ) Gestures

Pinchopen

Pinchclosed

11© Scott MacKenzie

Page 12: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Android’s ScaleGestureDetector Class(multitouch)

• From the API:– Detects scaling transformation gestures using the

supplied MotionEvents

• Programming approach:– Extend the “convenience” class…

… and implement methods of interest

© Scott MacKenzie 12

ScaleGestureDetector.SimpleOnScaleGestureListener

Page 13: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

ScaleGestureDetector.SimpleOnScaleGestureListener

a “convenience” class

13© Scott MacKenzie

Notes:• The listener methods above receive a ScaleGestureDetector

object. • This is different from the listener methods in GestureDetector.SimpleOnGestureListener, which receive a MotionEvent object.

• What methods are available with ScaleGestureDetector? (next slide)

Page 14: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

ScaleGestureDetector

14© Scott MacKenzie

Page 15: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

© Scott MacKenzie 15

Minimum Implementation

Page 16: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Demo Scale

Note: See PaintPanel class in Demo Scale16

© Scott MacKenzie

EscLet’s have a look.

Page 17: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Focus-point Zooming(see DemoScale for details)

© Scott MacKenzie 17

Zooming PhilosophyDo not:

• Zoom about the centre of the imageDo:

• Zoom about the focus point

Focus-point zooming is desirable because the focus point is• The point of interest to the user• Where the user is looking

Page 18: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Homework

• The usual…

• I.e.,– Download all the “demo” programs from earlier slides– Import into Android Studio projects– Connect your device and click “Run”– Observe UI behaviour– Ready the APIs (and links within)– Study source code

© Scott MacKenzie 18

Page 19: CSE4443 – Mobile User Interfaces€¦ · Android Touch “Gestures” • Question: – Is it possible to detect high -level finger actions, such as . double tap, flick, drag, pinch,

Thank You

19© Scott MacKenzie