Download presentation
Presentation is loading. Please wait.
Published byRose Barrett Modified over 8 years ago
1
1
2
2
3
3 The Doodlz app enables you to paint by dragging one or more fingers across the screen. The app provides options for setting the drawing color and line width. clear the screen save the current drawing on your device, and print the current drawing.
7
Technologies Overview A Fragment’s lifecycle is tied to that of its parent Activity. This app uses Fragment lifecycle methods onResume and onPause. onResume method is called when a Fragment is on the screen and ready for the user to interact with it. MainActivityFragment overrides onResume to enable listening for the accelerometer events so the user can shake the device to erase a drawing. Using SensorManager to Listen for Accelerometer Events. shake the device to erase a drawing Supported sensors: gravity, gyroscope, light, linear acceleration, magnetic field, orientation, pressure, proximity, rotation vector and temperature.
8
Technologies Overview https://developer.android.com/reference/android/hardware/Sensor.html#REPORTING_MODE_ON_CHANGE Sensor’s sensor-type constants to specify the sensors for which your app should receive data. Define three subclasses of DialogFragment ColorDialogFragment displays an AlertDialog with a custom View containing GUI components for previewing and selecting a new ARGB drawing color. LineWidthDialogFragment displays an AlertDialog with a custom View containing a GUI for previewing and selecting the line thickness. EraseImageDialogFragment displays a standard AlertDialog asking the user to confirm whether the entire image should be erased.
9
Technologies Overview onAttach—The first Fragment lifecycle method called when a Fragment is attached to a parent Activity. onDetach—The last Fragment lifecycle method called when a Fragment is about to be detached from a parent Activity. Drawing with Canvas, Paint and Bitmap Use methods of class Canvas to draw text, lines and circles. Canvas methods draw on a View’s Bitmap (both from package android.graphics). You can associate a Canvas with a Bitmap, then use the Canvas to draw on the Bitmap, which can then be displayed on the screen. A Bitmap also can be saved into a file.
10
Technologies Overview Processing Multiple Touch Events and Storing Lines in Paths The app stores the information for each individual finger as a Path object that represents line segments and curves. Process touch events by overriding the View method onTouchEvent. method receives a MotionEvent (package android. view) that contains the type of touch event that occurred and the ID of the finger (known as a pointer) that generated the event.
11
A ContentResolver (package android.content) enables the app to read data from and store data on a device. the method insertImage of class MediaStore.Images.Media to save an image into the device’s Photos app. The MediaStore manages media files (images, audio and video) stored on a device. class PrintHelper from Android’s printing framework to print the current drawing. Technologies Overview
13
This app consists of six classes: MainActivity (discussed below)—This is the parent Activity for the app’s Fragments. MainActivityFragment: Manages the DoodleView and accelerometer event handling. DoodleView: Provides the drawing, saving and printing capabilities. ColorDialogFragment: A DialogFragment that’s displayed when the user chooses the option to set the drawing color. LineWidthDialogFragment : DialogFragment that’s displayed when the user chooses the option to set the line width. EraseImageDialogFragment : A DialogFragment that’s displayed when the user chooses the option to erase, or shakes the device to erase, the current drawing. Technologies Overview
14
Code Review
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.