#Research
This is a research document, used to settle a knowledge base to develop cgeo in Android Studio. It is written for those who come from eclipse, has no experience of Android Studio and has not been into the cgeo code base before.
##Packages structure
By selecting "Packages" in the dropdown in the "1: Project" tab, you will see that cgeo consists of 5 projects: cgeo-calendar, cgeo-contacts, main, mapswithme-api and showcaseview.
The list comes from the file settings.gradle.
The preferred view in the dropdown however, is "project", because that will reflect the file system.
##Tests
There are a lot of tests in the project "main" and none in the others. Those extends TestCase or AndroidTestCase. You are not required to extends AndroidTestCase in tests that involve running an android emulator/on a device and not all such tests extends AndroidTestCase.
An easy way to get a list of all tests is to find the word TestCase somewhere in the code and press alt+f7 (find usages). To open a class in the resulting treeview with search results, you double click the class name. To open a file, you click the file and press F4.
If you click the crosshair icon (scroll to source) above the list of packages, you will see where in the file system the file currently selected in the editor resides. Tests are marked with a green background. Test classes are in the same folder as the tested classes and has a name ending with the word Test. In other words, if the list of packages is striped, you may have a good test coverage.
Many tests are networked and requires an android emulator to run. Some tests are unit tests and simple calculations. I do not think there is a lot of unit tests that specifies logic beyond those calculations.
With 132 tests, the project is actually tested, but the number of unit tests could be made higher. Also, as I have understood it, not all developers runs test regularily.
The start activity is cgeo.geocaching.MainActivity.
Other activites are CacheDetailActivity, AboutActivity, CacheListActivity, CompassActivity, CreateShortcutActivity, EditWaypointActivity, ImagesActivity, ImageSelectActivity, SearchActivity, SelectMapfileActivity, TrackableActivity.
To find out which views there are, check out main/res/layout, there are too many to list them.
Normal files have white background, test have lime green background and library classes have yellow background.
When the program starts, CgeoAppliation is instanced (as it is the Application specified in main/AndroidManifest.xml) and MainActivity is the entry point of the appliacation (because that Activity is marked with the intent filter "android.intent.action.MAIN" in main/AndroidManifest.xml).
MainActivity.onCreate will be called and that method will do the following:
- Setup the navigation bar
- Set the content view to R.layout.main_activity, which is the well known 2x3 icon button panel that is the start screen.
The following views are "bound" to MainActivity
- navSatellites
Shows satellites in the form fixed/visible
-
filterTitle
This view shows cache type.
-
findOnMap
This button starts an for me unknown activity.
-
findByOffline
This button starts the CacheListActivity with the option offline.
-
advanced
-
any
-
filter
-
nearestView
This button starts the CacheListActivity with the option nearest.
-
navType
-
navAccuracy
-
navLocation
-
countBubble
-
infoArea