Touch & Gestures.  MotionEvents  Touch Handling  Gestures.

Slides:



Advertisements
Similar presentations
Rectangles moving and responding to the mouse. We want a window with a pile of rectangles in it When we click a rectangle it changes from filled to unfilled.
Advertisements

Mouse Listeners We continue our examination of GUIs by looking at how to interact with the mouse –Just as Java creates Events when the user interacts with.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
ANDROID – GESTURES L. Grewe. What and why  a great way to interact with applications on mobile devices.  With a touch screen, users can easily tap,
Programming with Android: Activities
3.3. G AME I NPUT Handling input within games. In lecture exploration of answers to frequently asked student questions.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
CSE 2501 Review Declaring a variable allocates space for the type of datum it is to store int x; // allocates space for an int int *px; // allocates space.
Event Handling. In this class we will cover: Keyboard Events Mouse Events Focus Events Action Interface Multicasting.
Data Storage: Part 1 (Preferences)
CS378 - Mobile Computing What's Next?. Fragments Added in Android 3.0, a release aimed at tablets A fragment is a portion of the UI in an Activity multiple.
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
1 Mobile Computing Advanced Touching Copyright 2014 by Janson Industries Assg Part1Assg Part1 AssgPart2AssgPart2.
Linear Layout, Screen Support, and Events. Linear Layout Supports 2 orientations: 1.Horizontal 2.Vertical I often get confused with how each orientation.
@2011 Mihail L. Sichitiu1 Android Introduction GUI Menu Many thanks to Jun Bum Lim for his help with this tutorial.
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
CS 11 java track: lecture 4 This week: arrays interfaces listener classes inner classes GUI callbacks.
Code for touch, get mouse and pen for free Pointer API captures pen motion, passing coordinates to Ink API Ink API helps render and stores motion.
Android – Fragments L. Grewe.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
Resources and RelativeLayouts. Resources Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type.
Mobile Programming Lecture 12 HierarchyViewer, Linkify, Gestures, and Version Control.
I Power Higher Computing Software Development Development Languages and Environments.
FTP Server API Implementing the FTP Server Registering FTP Command Callbacks Data and Control Port Close Callbacks Other Server Calls.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Splatter! ALPHA Presentation By: David Kikuta March 29, 2011.
Android View Stuff. TextViews Display text Display images???
Splatter! Critical Design Review By: David Kikuta March 15, 2011.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Splatter “The Multiplayer Paint” By: David Kikuta CMSI 402, Spring 2011.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Chapter 7 Touch Gestures. Figure 07.01: Common touch gestures for Android devices.
CHAPTER 7 TouchGestures. Chapter objectives: To code the detection of and response to touch gestures. Patterns of common touches to create touch gestures.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
User Interaction Radan Ganchev Astea Solutions. Content Basic input events Gestures Drag and drop Sensors.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
CS371m - Mobile Computing Gestures. Common Gestures 2.
TUTORIAL ON MULTITOUCH AND SWIPE GESTURES
GUI Programming Fundamentals
Applets.
AnDroid GoogleMaps API
Linear Layout, Screen Support, and Events
Android – Event Handling
Mobile Application Development BSCS-7 Lecture # 11
Mobile Computing With Android ACST 4550 Bitmaps, Fonts and Gestures
Android 16: Input Events Kirk Scott.
Mobile Computing With Android ACST 4550 Android Logs and Gestures
Android Programming Lecture 6
null, true, and false are also reserved.
Cannon Game App Android How to Program
More programming with "Processing"
CS371m - Mobile Computing Gestures.
Android Developer Fundamentals V2
Chapter 7: Touches and Swipes
滑動 建國科技大學 資管系 饒瑞佶.
Mobile Programming Gestures in Android.
Mobile Programming Dr. Mohsin Ali Memon.
Mobile Programmming Dr. Mohsin Ali Memon.
Activities and Fragments
Preference Activity class
CIS 470 Mobile App Development
Presentation transcript:

Touch & Gestures

 MotionEvents  Touch Handling  Gestures

 Represents a movement on the UI  e.g., Pen, trackball, mouse, finger  Records event’s time, action, pressure, location, source, etc.

 Some common MotionEvent actions  ACTION_DOWN  ACTION_MOVE  ACTION_UP  ACTION_POINTER_DOWN  ACTION_POINTER_UP

 View.OnTouchListener defines touch event callback methods  View.OnTouchListener.onTouch() is called when user performs a touch event, such as pressing, releasing or dragging an item on the screen  onTouch() should return true if it has consumed the event

 1-touch – each touch is a single event  Process ACTION_DOWN, ACTION_MOVE & ACTION_UP independently  2+-touch – multiple touches combined to form a gesture  Identify & process combinations of touches such as ACTION_DOWN, followed by ACTION_POINTER_DOWN

 Some useful MotionEvent methods  getPointerCount()  getActionIndex()  getActionMasked()  getX()  getY()

ActionID #1 touch  ACTION_DOWN0 ACTION_MOVE0 #2 touch  ACTION_POINTER_DOWN1 ACTION_MOVE0 0 #1 lift  ACTION_POINTER_UP0 #2 lift  ACTION_UP1

ActionID #1 touch  ACTION_DOWN0 ACTION_MOVE0 #2 touch  ACTION_POINTER_DOWN1 ACTION_MOVE0 0 #2 lift  ACTION_POINTER_UP1 #1 lift  ACTION_UP0

ActionID #1 touch  ACTION_DOWN0 #2 touch  ACTION_POINTER_DOWN1 #3 touch  ACTION_POINTER_DOWN2 ACTION_MOVE0 #2 lift  ACTION_POINTER_UP1 #1 lift  ACTION_POINTER_UP0 #3 lift  ACTION_UP2

public class IndicateTouchLocationActivity extends Activity { public void onCreate(Bundle savedInstanceState) { … final FrameLayout frame = … frame.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { int actionCode = event.getActionMasked(); for (int i = 0 ; i < event.getPointerCount(); i++) { switch (actionCode) { case /* interesting motion events */ : { // make a view showing touch location frame.addView(/* new view */); …

 GestureBuilder allows developers to create & save custom gestures  GestureLibraries supports loading custom gestures & recognizing then at runtime  GestureOverlayView intercepts user gestures and invokes Application code to handle them

 Comes bundled with emulator  Stores gestures to /mnt/sdcard/gestures  Copy this file to /res/raw directory

 View intercepts gestures  Invokes OnGesturePerformedListener

public class GesturesActivity extends Activity implements OnGesturePerformedListener { private GestureLibrary mLibrary; public void onCreate(Bundle savedInstanceState) { … mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures); if (!mLibrary.load()) { finish(); } GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures); gestures.addOnGesturePerformedListener(this); … } …

public void onGesturePerformed( GestureOverlayView overlay, Gesture gesture) { ArrayList predictions = mLibrary.recognize(gesture); if (predictions.size() > 0 ) { Prediction prediction = predictions.get( 0 ); if (prediction.score > 1.0 ) { Toast.makeText(this, prediction.name,…).show(); }