[android] - add javadoc to test activities. (#8203)

* [android] - add javadoc to test activities.

* fix checkstyle issue
This commit is contained in:
Tobrun
2017-02-27 23:56:06 +01:00
committed by GitHub
parent 147654a46b
commit 47dcfe7d44
46 changed files with 193 additions and 80 deletions

View File

@@ -10,6 +10,12 @@ import timber.log.Timber;
import static timber.log.Timber.DebugTree;
/**
* Application class of the test application.
* <p>
* Initialises components as LeakCanary, Strictmode, Timber and Mapbox
* </p>
*/
public class MapboxApplication extends Application {
@Override

View File

@@ -32,6 +32,13 @@ import java.util.List;
import timber.log.Timber;
/**
* Activity shown when application is started
* <p>
* This activity will generate data for RecyclerView based on the AndroidManifest entries.
* It uses tags as category and description to order the different entries.
* </p>
*/
public class FeatureOverviewActivity extends AppCompatActivity {
private static final String KEY_STATE_FEATURES = "featureList";

View File

@@ -18,6 +18,9 @@ import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
import timber.log.Timber;
/**
* Test activity showcasing updating a Marker image when changing zoom levels
*/
public class AddRemoveMarkerActivity extends AppCompatActivity {
public static final double THRESHOLD = 5.0;

View File

@@ -27,13 +27,16 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
import com.mapbox.services.commons.models.Position;
import com.mapbox.services.api.utils.turf.TurfMeasurement;
import com.mapbox.services.commons.models.Position;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Test activity showcasing animating MarkerViews.
*/
public class AnimatedMarkerActivity extends AppCompatActivity {
private MapView mapView;

View File

@@ -41,6 +41,9 @@ import java.util.Random;
import timber.log.Timber;
/**
* Test activity showcasing adding a large amount of Markers or MarkerViews.
*/
public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
private MapboxMap mapboxMap;

View File

@@ -17,6 +17,9 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
/**
* Test activity showcasing updating a Marker position, title, icon and snippet.
*/
public class DynamicMarkerChangeActivity extends AppCompatActivity {
private static final LatLng LAT_LNG_CHELSEA = new LatLng(51.481670, -0.190849);

View File

@@ -38,6 +38,13 @@ import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions;
import java.util.Random;
/**
* Test activity showcasing multiple MarkerViews above Washington D.C.
* <p>
* Shows a couple of open InfoWindows out of current Viewport.
* Updates the rotation and location of a couple of MarkerViews.
* </p>
*/
public class MarkerViewActivity extends AppCompatActivity {
private static final LatLng[] LAT_LNGS = new LatLng[] {

View File

@@ -29,9 +29,9 @@ import static com.mapbox.mapboxsdk.testapp.activity.annotation.PolygonActivity.C
import static com.mapbox.mapboxsdk.testapp.activity.annotation.PolygonActivity.Config.STAR_SHAPE_POINTS;
/**
* Activity to test the Polygon annotation API & programmatically creating a MapView.
* Test activity to showcase the Polygon annotation API & programmatically creating a MapView.
* <p>
* Showcases changing Polygon features as visibility, alpha, color and points.
* Shows how to change Polygon features as visibility, alpha, color and points.
* </p>
*/
public class PolygonActivity extends AppCompatActivity implements OnMapReadyCallback {

View File

@@ -21,6 +21,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Test activity showcasing the Polyline annotations API.
* <p>
* Shows how to add and remove polylines.
* </p>
*/
public class PolylineActivity extends AppCompatActivity {
private static final String STATE_POLYLINE_OPTIONS = "polylineOptions";

View File

@@ -18,6 +18,12 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.text.DecimalFormat;
import java.util.ArrayList;
/**
* Test activity showcasing to add a Marker on click.
* <p>
* Shows how to use a OnMapClickListener and a OnMapLongClickListener
* </p>
*/
public class PressForMarkerActivity extends AppCompatActivity {
private MapView mapView;
@@ -44,19 +50,14 @@ public class PressForMarkerActivity extends AppCompatActivity {
mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(@NonNull LatLng point) {
final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
addMarker(point);
}
});
String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", "
+ LAT_LON_FORMATTER.format(point.getLongitude());
String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y;
MarkerOptions marker = new MarkerOptions()
.position(point)
.title(title)
.snippet(snippet);
markerList.add(marker);
mapboxMap.addMarker(marker);
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
addMarker(point);
}
});
@@ -68,6 +69,22 @@ public class PressForMarkerActivity extends AppCompatActivity {
});
}
private void addMarker(LatLng point) {
final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", "
+ LAT_LON_FORMATTER.format(point.getLongitude());
String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y;
MarkerOptions marker = new MarkerOptions()
.position(point)
.title(title)
.snippet(snippet);
markerList.add(marker);
mapboxMap.addMarker(marker);
}
private void resetMap() {
if (mapboxMap == null) {
return;

View File

@@ -15,6 +15,12 @@ import com.mapbox.mapboxsdk.testapp.R;
import timber.log.Timber;
/**
* Test activity showcasing the Camera API and listen to camera updates by animating the camera above London.
* <p>
* Shows how to use animate, ease and move camera update factory methods.
* </p>
*/
public class CameraAnimationTypeActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final LatLng LAT_LNG_LONDON_EYE = new LatLng(51.50325, -0.11968);

View File

@@ -19,6 +19,13 @@ import java.util.List;
import timber.log.Timber;
/**
* Test activity showcasing using the LatLngBounds camera API.
* <p>
* This activity opens the map at zoom level 0 and animates into a bounds set by Los Angeles and New York
* with some additional padding and an animation duration of 1500 ms.
* </p>
*/
public class LatLngBoundsActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622);
@@ -69,7 +76,7 @@ public class LatLngBoundsActivity extends AppCompatActivity implements OnMapRead
// Move camera to the bounds with added padding
int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding), 1500);
// Log data
Timber.e("Move to bounds: " + bounds.toString());

View File

@@ -16,6 +16,12 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing the zoom Camera API.
* <p>
* This includes zoomIn, zoomOut, zoomTo, zoomBy (center and custom focal point).
* </p>
*/
public class ManualZoomActivity extends AppCompatActivity {
private MapboxMap mapboxMap;

View File

@@ -20,6 +20,9 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the scrollBy Camera API by moving x,y pixels above Grenada, Spain.
*/
public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCallback {
public static final int MULTIPLIER_PER_PIXEL = 50;

View File

@@ -17,6 +17,12 @@ import com.mapbox.mapboxsdk.style.layers.CustomLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer;
/**
* Test activity showcasing the Custom Layer API
* <p>
* Note: experimental API, do not use.
* </p>
*/
public class CustomLayerActivity extends AppCompatActivity {
private MapboxMap mapboxMap;

View File

@@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Base activity for instrumentation testing
* Base activity for instrumentation testing.
*/
public class EspressoTestActivity extends AppCompatActivity implements OnMapReadyCallback {

View File

@@ -19,7 +19,7 @@ import java.util.Map;
import timber.log.Timber;
/**
* Demo's query rendered features
* Test activity showcasing using the query rendered features API to count features in a rectangle.
*/
public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {

View File

@@ -30,7 +30,7 @@ import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
/**
* Demo's query rendered features on Symbols
* Test activity showcasing using the query rendered features API to count Symbols in a rectangle.
*/
public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivity {

View File

@@ -27,7 +27,7 @@ import java.util.Map;
import timber.log.Timber;
/**
* Demo's query rendered features
* Test activity showcasing using the query rendered features API to query feature properties on Map click.
*/
public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {

View File

@@ -14,6 +14,12 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the MapFragment API using SDK Fragments.
* <p>
* Uses MapboxMapOptions to initialise the Fragment.
* </p>
*/
public class MapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback {
private MapboxMap mapboxMap;

View File

@@ -5,6 +5,9 @@ import android.os.Bundle;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test Activity showcasing using multiple static map fragments in one layout.
*/
public class MultiMapActivity extends AppCompatActivity {
@Override

View File

@@ -14,6 +14,12 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the MapFragment API using Support Library Fragments.
* <p>
* Uses MapboxMapOptions to initialise the Fragment.
* </p>
*/
public class SupportMapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback {
private MapboxMap mapboxMap;

View File

@@ -14,6 +14,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the Android SDK ViewPager API to show MapFragments.
*/
public class ViewPagerActivity extends AppCompatActivity {
@Override

View File

@@ -12,6 +12,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the Snaphot API to print a Map.
*/
public class PrintActivity extends AppCompatActivity implements MapboxMap.SnapshotReadyCallback {
private MapView mapView;

View File

@@ -15,6 +15,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing the Snapshot API to create and display a bitmap of the current shown Map.
*/
public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCallback, View.OnClickListener {
private MapView mapView;

View File

@@ -22,7 +22,7 @@ import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
/**
* Shows how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter
* Test activity showcasing how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter.
*/
public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implements OnMapReadyCallback {
@@ -86,8 +86,8 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
new MarkerViewOptions()
.position(paris)
.icon(IconUtils.drawableToIcon(this, R.drawable.ic_location_city,
ResourcesCompat.getColor(getResources(),R.color.mapbox_blue, getTheme()))
));
ResourcesCompat.getColor(getResources(), R.color.mapbox_blue, getTheme()))
));
}
private void addCustomInfoWindowAdapter(final MapboxMap mapboxMap) {

View File

@@ -17,6 +17,12 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.text.DecimalFormat;
/**
* Test activity showcasing using the InfoWindow API above Washington D.C.
* <p>
* Allows to test mulitple concurrently open InfoWindows.
* </p>
*/
public class InfoWindowActivity extends AppCompatActivity
implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnMapLongClickListener,
MapboxMap.OnInfoWindowClickListener, MapboxMap.OnInfoWindowLongClickListener {

View File

@@ -14,6 +14,9 @@ import com.mapbox.mapboxsdk.testapp.R;
import timber.log.Timber;
/**
* Test Activity showcasing the different debug modes and allows to cycle between the default map styles.
*/
public class DebugModeActivity extends AppCompatActivity {
private MapView mapView;

View File

@@ -13,6 +13,12 @@ import android.widget.Button;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing showing a Map inside of a DialogFragment.
* <p>
* Uses the deprecated TextureView API to workaround the issue of seeing a grey background before the gl surface.
* </p>
*/
public class MapInDialogActivity extends AppCompatActivity {
@Override

View File

@@ -17,6 +17,12 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.TrackingSettings;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the map padding API.
* <p>
* This activity tests for correct padding around a marker (Bangalore) and correct padding around MyLocationView.
* </p>
*/
public class MapPaddingActivity extends AppCompatActivity {
private MapView mapView;

View File

@@ -6,6 +6,9 @@ import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing a simple MapView without any MapboxMap interaction.
*/
public class SimpleMapActivity extends AppCompatActivity {
private MapView mapView;

View File

@@ -33,6 +33,12 @@ import java.util.ArrayList;
import timber.log.Timber;
/**
* Test activity showcasing the Offline API.
* <p>
* Shows a map of Manhattan and allows the user to download and name a region.
* </p>
*/
public class OfflineActivity extends AppCompatActivity
implements OfflineDownloadRegionDialog.DownloadRegionDialogListener {

View File

@@ -28,6 +28,12 @@ import static com.mapbox.mapboxsdk.style.layers.Filter.in;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
/**
* Test activity showcasing adding a Circle Layer to the Map
* <p>
* Uses bus stop data from Singapore as a source and allows to filter into 1 specific route with a line layer.
* </p>
*/
public class CircleLayerActivity extends AppCompatActivity {
private static final String[] STOPS_FOR_ROUTE = new String[] {"99009", "99131", "99049", "99039", "99029", "99019",

View File

@@ -27,7 +27,7 @@ import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
/**
* Example to add a sprite image and use it in a Symbol Layer
* Test activity showcasing adding a sprite image and use it in a Symbol Layer
*/
public class CustomSpriteActivity extends AppCompatActivity {
private static final String CUSTOM_ICON = "custom-icon";

View File

@@ -42,7 +42,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
/**
* Sample Activity to show off the data driven runtime style api
* Test activity showcasing the data driven runtime style API.
*/
public class DataDrivenStyleActivity extends AppCompatActivity {

View File

@@ -33,7 +33,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
/**
* Sample Activity to show off geojson source clustering and filter usage
* Test activity showcasing using a geojson source and visualise that source as a cluster by using filters.
*/
public class GeoJsonClusteringActivity extends AppCompatActivity {

View File

@@ -20,7 +20,7 @@ import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
/**
* Use realtime GeoJSON data streams to move a symbol on your map
* Test activity showcasing using realtime GeoJSON to move a symbol on your map
* <p>
* GL-native equivalent of https://www.mapbox.com/mapbox-gl-js/example/live-geojson/
* </p>

View File

@@ -70,7 +70,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
/**
* Sample Activity to show off the runtime style api
* Test activity showcasing the runtime style API.
*/
public class RuntimeStyleActivity extends AppCompatActivity {

View File

@@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity for unit test execution
* Test activity used for instrumentation test execution.
*/
public class RuntimeStyleTestActivity extends AppCompatActivity {

View File

@@ -29,7 +29,7 @@ import java.io.Writer;
import timber.log.Timber;
/**
* Example on how to use a file:// resource for the style.json
* Test activity showcasing how to use a file:// resource for the style.json
*/
public class StyleFileActivity extends AppCompatActivity {

View File

@@ -35,7 +35,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
/**
* Example to test runtime manipulation of symbol layers
* Test activity showcasing runtime manipulation of symbol layers.
*/
public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.OnMapClickListener {

View File

@@ -24,6 +24,9 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
/**
* Test activity showcasing how to change the MyLocationView drawable.
*/
public class MyLocationDrawableActivity extends AppCompatActivity implements LocationEngineListener {
private static final int PERMISSIONS_LOCATION = 0;

View File

@@ -27,6 +27,9 @@ import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
/**
* Test activity showcasing how to tint the MyLocationView.
*/
public class MyLocationTintActivity extends AppCompatActivity implements LocationEngineListener {
private MapView mapView;

View File

@@ -22,6 +22,13 @@ import com.mapbox.mapboxsdk.maps.TrackingSettings;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing the different tracking modes the SDK exposes.
* <p>
* This includes MyLocationTracking/MyLocationBearingTracking and how the components can be configured to be dismissed
* using gesture configurations.
* </p>
*/
public class MyLocationTrackingModeActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
public static final int TRACKING_NONE_INDEX = 0;

View File

@@ -13,6 +13,12 @@ import com.mapbox.mapboxsdk.testapp.utils.FontCache;
import java.util.List;
/**
* Adapter used for FeatureOverviewActivity.
* <p>
* Adapts a Feature to a visual representation to be shown in a RecyclerView.
* </p>
*/
public class FeatureAdapter extends RecyclerView.Adapter<FeatureAdapter.ViewHolder> {
private List<Feature> features;

View File

@@ -1,49 +0,0 @@
package com.mapbox.mapboxsdk.testapp.utils;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Helper class to compose a Toolbar in an AppCompatActivity
*/
public class ToolbarComposer {
/**
* Initialises an up navigation toolbar with id R.id.toolbar on an AppCompatActivity.
*
* @param activity The activity hosting the Toolbar with id R.id.toolbar
*/
@Nullable
public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity) {
return initDefaultUpToolbar(activity, R.id.toolbar);
}
/**
* Initialises an up navigation toolbar given a view id on an AppCompatActivity.
*
* @param activity The activity hosting the Toolbar
* @param toolbarRes The view id resource used to look up the Toolbar
*/
@Nullable
public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity, @IdRes int toolbarRes) {
Toolbar toolbar = (Toolbar) activity.findViewById(toolbarRes);
if (toolbar != null) {
activity.setSupportActionBar(toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
}
return toolbar;
}
}