Code road map

The source code for this application consists of 12 Java source files, one of which is the R.java file, which you will recall is automatically generated based on the resources in the application. This section presents a quick introduction to each of these files. No code is explained yet; we just want to know a little bit about each file, and then it will be time to jump into the application, step-by-step. Table 12.1 lists the source files in the Android Field Service Application.

Table 12.1 The source files used to implement the Field Service Application

Source Filename

Description

Splash.java

Activity provides splash screen functionality.

ShowSettings.java

Activity provides management of username and server URL address.

FieldService.java

Activity provides the main screen of the application.

RefreshJobs.java

Activity interacts with server to obtain updated list of jobs.

ManageJobs.java

Activity provides access to list of jobs.

ShowJob.java

Activity provides detailed information on a specific job, such as an address lookup, or initiates the signature-capture process.

CloseJob.java

Activity collects electronic signature and interacts with the server to upload images and mark jobs as CLOSED.

R.java

Automatically generated source file representing identifiers in the resources.

Prefs.java

Helper class encapsulating SharedPreferences.

JobEntry.java

Class that represents a job. Includes helpful methods used when passing JobEntry objects from one Activity to another.

JobList.java

Class representing the complete list of JobEntry objects. Includes methods for marshaling and unmarshaling to nonvolatile storage.

JobListHandler.java

Class used for parsing XML document containing job data.

B drawabts

.til andiold.jpg

The application also relies on layout resources to define the visual aspect of the UI. In addition to the layout xml files, an image used by the Splash Activity is placed in the drawable subfolder of the res folder along with the stock Android icon image. This icon is used for the home application launch screen.

Figure 12.4 depicts the resources used in the application.

In an effort to make navigating the code as easy as possible, the Field Service Application resource files are presented in table 12.2. Note that each of these is clearly seen in figure 12.4, which is a screen shot from our project open in Eclipse.

Download at Boykma.Com

B drawabts

.til andiold.jpg

JÍ. fieldservke.xml ¿ managejobs.xml & refreshes.xml ¡xj showjob.xml ¡Xj showsetttngs.xml ¡ïj splash.xml

Figure 12.4 Resources used in the application

Table 12.2 Resource files used in the sample application

Filename

Description

android.jpg

Image used in the Splash Activity.

icon.jpg

Image used in the application launcher.

fieldservice.xml

Layout for main application screen, FieldService Activity.

managejobs.xml

Layout for the list of jobs, ManageJobs Activity.

refreshjobs.xml

Layout for the screen shown when refreshing job list, RefreshJobs Activity.

showjob.xml

Layout for job detail screen, ShowJob Activity.

showsettings.xml

Layout for configuration/settings screen, ShowSettings Activity.

splash.xml

Layout for splash screen, Splash Activity.

strings.xml

Strings file containing extracted strings. Ideally all text is contained in a strings file for ease of localization. This application's file contains only the application title.

An examination of the source files in this application tells us that we have more than one Activity in use. In order to enable navigation between one Activity and the next, our application must inform Android of the existence of these Activity classes. If you recall from chapter 1, this registration step is accomplished with the AndroidManifest.xml file.

0 0

Post a comment