art viewer 37 (PDF)




File information


Title: aNDROIDâ„¢ 101:
Author: Richard A. Perez

This PDF 1.5 document has been generated by Microsoft® Word 2013, and has been sent on pdf-archive.com on 04/03/2015 at 18:23, from IP address 98.226.x.x. The current document download page has been viewed 1101 times.
File size: 1.18 MB (44 pages).
Privacy: public file
















File preview


DOWNLOAD
Project git
download.

Richard A.
Perez
Android 101

ANDROID™ 101:
ART VIEWER TEMPLATE
ImageSwitcher, Animations, and Git downloading.

Table of Contents
Introduction ................................................................................................................................................ 2
Download Project Template Git ................................................................................................................ 3
Importing Your Resources.......................................................................................................................... 7
Animation XML files ................................................................................................................................. 10
Android Manifest ...................................................................................................................................... 13
UI Layout .................................................................................................................................................. 14
Menu and Action Bar Options .................................................................................................................. 16
MainActivity.java ....................................................................................................................................... 17
Data.java ................................................................................................................................................... 21
ArtViewer.java .......................................................................................................................................... 22
CommonVariables.java.............................................................................................................................. 26
CommonWork ......................................................................................................................................... 27
InOutAnimationSet ................................................................................................................................... 28
MyMediaPlayer .......................................................................................................................................... 28
MySoundPool ............................................................................................................................................ 33
NewImageSwitcherImage.java ................................................................................................................... 34
SavePhoto.java .......................................................................................................................................... 35
Lint ............................................................................................................................................................ 37
JUnit Testing ............................................................................................................................................. 38
Attribution ................................................................................................................................................ 43

Introduction
The art viewer template is intended to be used by developers who would like to integrate an
activity that uses an ImageSwitcher into their application. You should be familiar with setting up a
development environment on your own. I use Eclipse™ Luna 4.4.1 as of this writing with the Android™
ADT plugin and Java JDK 7. Most features are similar in actions to take to implement (add code), adding
listeners (click handling) and interfaces (sets of work where you add code for specific actions). I have
designed this guide and the project template so that non-developers can start learning how to
implement an Activity’s life cycle methods and how to handle UI events. Before using this guide you
should have your environment set up as well as run the Hello World! Android project on your device so
you are ready to run the project code here.
There is a running and tested Art Viewer Template project online for you to import into Eclipse
or the IDE (Integrated Development Environment) of your choice. You can use the link provided in the
import Git section to import the entire project into your IDE. The guide will walk you through
downloading the project and fixing project properties so it will compile and run. Also I introduce you to
testing the functionality of Android features by showing a JUnit test project and its classes. I will show
how to run the tests multiple times by running a loop in the test suite class.
You will need to provide your own resources to complete the template. The resources to be
included are the sound files for images saved, page turn sound effect as well as a music track to play in
the background. Images to be replaced should be added into the drawable-nodpi folder as well as adding
the image filename into the Data.PICS array in the Data.java class. You can use the create new Android
icons functionality of Eclipse to create a set of icons from a single file. There are animation files for the
page turn transitions and you can edit in place the existing ones, use your own or search the SDK for
animation files that you think are interesting. There are two arrow files for the page turn buttons that
can be edited as well. Finally there is a gradient background xml file that uses three colors to create a
linear gradient, you should choose a gradient color scheme that fits your collection or theme.
The user interface can be manipulated to some extent without hurting the code behind the view
objects. For instance the button layout can be manipulated. The button click handler will always turn the
page no matter the location of its button. The ad banner can be removed if you find it to take up too
much screen space or you simply do not want to include it. It is also possible to switch from Admob,
which is what I am using, to any other ad company that works with Android. An Android enabled phone
will be needed to run or debug the application. Simply turn on developer options in your phone’s
settings. If you are forced to use the Android emulator install Intel HAXM to help performance of the
emulator if it seems to be running slow. You should try to test your application on as many different
devices as possible to look for layout errors or any other un-expected errors.
Read the Essential Reading sections… again if needed! I’ll go into each of the source files and
explain what each class is doing. There are Javadoc’s generated for each class. I also try to further
elaborate on these as well as share hotkeys and tips for development that I use that make development
a better process. I cover the view objects that make the UI in both portrait and landscape modes. I will
also cover the menu folder and creating handlers for the menu items. The strings.xml class and the
AndroidManifest.xml will be explained. Finally I’ll introduce you to running Lint and reading
improvement suggestions from the output.

Download Project Template Git
You should read the below link for reference on setting up your development environment.
Essential Reading: https://developer.android.com/sdk/installing/installing-adt.html
Next you can start your version of the application by implementing the code in this guide or you can
pull directly from Bitbucket™ using the link below.
Download URI:
https://mobileapplications009@bitbucket.org/mobileapplications009/art-viewer-template.git
Using this link you can import the entire project, however we will need to add the support library and
google play services library as well as fix project errors that appear. I will cover importing the project
Git however it will be up to you to add assets that you own in order to make your application comply
with Google’s application upload policy.
Important Read and follow the policies below or your application and account could be suspended or
even disabled if using dishonest practices.
Essential Reading: https://support.google.com/googleplay/android-developer/answer/4430948?rd=1
If you are using the Eclipse IDE you can start a new workspace. From there you can import the project
git using the above link. Afterwards we will import libraries needed.
Create a new Workspace
Press Alt+F then W
Select other
Rename the directory to
create a new workspace
Press OK
Import Git
Press Alt+F then I
Select Git
Projects from Git
Press Next
Select Clone URI
Press Next
The URI should auto fill if you
have it stored in clipboard

Autofill will complete the
Host and Repository Path
Press Next
Select both branches
Press Next
Select reviewing comments
Press Next
When all objects are received
Select Next
Select import existing Projects
Press Next and Finish
Package Explorer on finish

At this point you will have the project imported but you will have to also import the Android support
library which can be found in the SDK. This can be done easily if you have the SDK downloaded already.
Import appcompat
Press Alt+F then I
Select Android
Select Existing Android
Code into Workspace
Press Next
Browse to your SDK
sdk\extras\android\support\v
7
Select only appcompat
Select Copy projects into
workspace
Select Finish
Fix library errors by
Selecting Support library
Press Alt+Enter for project
properties

Select Android section
Select the most recent build
As of this writing its 5.0.1
Press OK
Perform clean and build of
the project.
Hotkey: Alt+P then N

Support Library Ready!

Next you will have to import the Google Play Services Library which can be found in the SDK. Follow
the previous steps but use the library at this location.
Import Google Play
Services
Press Alt+F then I
Select Android
Select Existing Android
Code into Workspace
Press Next
sdk\extras\google\google_play_
services\libproject
Click Finish
Google Play Services
Library Ready!

You will need to update the radical_art_template, as it has references to the previous versions of these
library projects that are no longer valid now that we have new libraries imported.
Tip: For project properties select project in Package Explorer and use Alt+Enter.

Update Project References
Open Package Explorer
Hotkey: Alt+Shift+Q then P
Select radical_art_template
Press Alt+Enter
Select Android
In the library section near the
bottom
Remove the invalid link(s) with
the red X
Select Add
Add both of the library
projects we just imported
Click Apply
Both imported successfully!
Click OK
Clean and build the
radical_art_template.
Hotkey: Alt+P then N

The only errors remaining
should be the sound assets in
the Data.java class and the
MySoundPool.java class.
You will need to import these
into your project. Which we
will cover in the next section
called Importing Your
Resources.

Importing Your Resources
Importing your resources is a critical part of customizing the template. Google Play™ may suspend your
account if do not have the appropriate permissions to use those resources.
After importing and successfully building your project to this point you will find that there are a few
errors that remain. These are the sound files that the template uses for the page turn effects and save
image sound. I use .wav files for these. Finally, a music track is needed, for this I usually use .mp3 files.
Essential Reading: http://developer.android.com/guide/appendix/media-formats.html
Add assets to res
Select the res folder
Press Alt
Select New
Select Folder
Press Enter
Name the new folder ‘raw’
Click Finish

Copy and paste the missing sound files into
the raw folder for easy access
Clean and build with Alt+P then N
Finished Project that is ready to Run!
The > arrow is from updating library project
references that were from the source control
version.

Essential Reading: http://git-scm.com/doc
At this point in the guide with no project errors and you can actually begin to test that the application
will run on your phone, though we are just getting started as far as customizing the project. You can
turn on developer options from your phone’s menu System Settings option.






Download art viewer 37



art_viewer 37.pdf (PDF, 1.18 MB)


Download PDF







Share this file on social networks



     





Link to this page



Permanent link

Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..




Short link

Use the short link to share your document on Twitter or by text message (SMS)




HTML Code

Copy the following HTML code to share your document on a Website or Blog




QR Code to this page


QR Code link to PDF file art_viewer 37.pdf






This file has been shared publicly by a user of PDF Archive.
Document ID: 0000212567.
Report illicit content