├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── assets ├── android-places.png ├── android-sdk.png └── eraser-map.png ├── build.gradle ├── circle.yml ├── config └── checkstyle │ ├── checkstyle-suppressions.xml │ └── checkstyle.xml ├── core ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mapzen │ │ │ └── android │ │ │ ├── core │ │ │ ├── ApiKeyChangeListener.java │ │ │ ├── CoreAndroidModule.java │ │ │ ├── CoreDI.java │ │ │ ├── CoreDependencyInjector.java │ │ │ ├── GenericHttpHandler.java │ │ │ ├── MapzenManager.java │ │ │ └── http │ │ │ │ ├── CallRequest.java │ │ │ │ └── Request.java │ │ │ ├── graphics │ │ │ ├── CompassView.java │ │ │ ├── DataLayerType.java │ │ │ ├── FeaturePickListener.java │ │ │ ├── GraphicsModule.java │ │ │ ├── ImportYamlGenerator.java │ │ │ ├── LabelPickHandler.java │ │ │ ├── LabelPickListener.java │ │ │ ├── MapDataManager.java │ │ │ ├── MapFragment.java │ │ │ ├── MapInitializer.java │ │ │ ├── MapReadyInitializer.java │ │ │ ├── MapStateManager.java │ │ │ ├── MapView.java │ │ │ ├── MapzenMap.java │ │ │ ├── MapzenMapHttpHandler.java │ │ │ ├── MapzenMapPeliasLocationProvider.java │ │ │ ├── MarkerPickListener.java │ │ │ ├── OnMapReadyCallback.java │ │ │ ├── OnStyleLoadedListener.java │ │ │ ├── OverlayManager.java │ │ │ ├── PersistDataManagers.java │ │ │ ├── PersistableMapData.java │ │ │ ├── SceneUpdateManager.java │ │ │ ├── TangramMapView.java │ │ │ ├── ViewCompleteListener.java │ │ │ ├── internal │ │ │ │ ├── EaseTypeConverter.java │ │ │ │ └── StyleStringGenerator.java │ │ │ └── model │ │ │ │ ├── BitmapMarker.java │ │ │ │ ├── BitmapMarkerFactory.java │ │ │ │ ├── BitmapMarkerManager.java │ │ │ │ ├── BitmapMarkerOptions.java │ │ │ │ ├── BubbleWrapStyle.java │ │ │ │ ├── CameraType.java │ │ │ │ ├── CinnabarStyle.java │ │ │ │ ├── EaseType.java │ │ │ │ ├── MapStyle.java │ │ │ │ ├── Marker.java │ │ │ │ ├── MarkerOptions.java │ │ │ │ ├── Polygon.java │ │ │ │ ├── Polyline.java │ │ │ │ ├── RefillStyle.java │ │ │ │ ├── ThemeColor.java │ │ │ │ ├── ThemedMapStyle.java │ │ │ │ ├── TronStyle.java │ │ │ │ ├── WalkaboutStyle.java │ │ │ │ └── ZincStyle.java │ │ │ ├── location │ │ │ └── LocationFactory.java │ │ │ └── search │ │ │ ├── MapzenSearch.java │ │ │ ├── MapzenSearchHttpHandler.java │ │ │ └── SearchInitializer.java │ └── res │ │ ├── drawable-hdpi │ │ ├── mz_compass.png │ │ ├── mz_find_me_normal.png │ │ ├── mz_find_me_pressed.png │ │ ├── mz_zoom_in.png │ │ └── mz_zoom_out.png │ │ ├── drawable-mdpi │ │ ├── mz_compass.png │ │ ├── mz_find_me_normal.png │ │ ├── mz_find_me_pressed.png │ │ ├── mz_zoom_in.png │ │ └── mz_zoom_out.png │ │ ├── drawable-v21 │ │ └── mz_bg_white_gray_border.xml │ │ ├── drawable-xhdpi │ │ ├── mz_compass.png │ │ ├── mz_find_me_normal.png │ │ ├── mz_find_me_pressed.png │ │ ├── mz_zoom_in.png │ │ └── mz_zoom_out.png │ │ ├── drawable-xxhdpi │ │ ├── mz_compass.png │ │ ├── mz_find_me_normal.png │ │ ├── mz_find_me_pressed.png │ │ ├── mz_zoom_in.png │ │ └── mz_zoom_out.png │ │ ├── drawable │ │ ├── mapzen.png │ │ ├── mz_bg_ripple.xml │ │ ├── mz_bg_white_gray_border.xml │ │ └── mz_find_me.xml │ │ ├── layout │ │ ├── mz_fragment_map.xml │ │ ├── mz_fragment_map_classic.xml │ │ ├── mz_view_compass.xml │ │ ├── mz_view_map.xml │ │ └── mz_view_map_classic.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ └── strings.xml │ └── test │ └── java │ ├── com │ └── mapzen │ │ ├── TestHelper.java │ │ ├── android │ │ ├── core │ │ │ ├── MapzenManagerTest.java │ │ │ ├── TestVals.java │ │ │ ├── http │ │ │ │ └── CallRequestTest.java │ │ │ └── test │ │ │ │ └── R.java │ │ ├── graphics │ │ │ ├── ImportYamlGeneratorTest.java │ │ │ ├── MapDataManagerTest.java │ │ │ ├── MapFragmentTest.java │ │ │ ├── MapInitializerTest.java │ │ │ ├── MapReadyInitializerTest.java │ │ │ ├── MapStateManagerTest.java │ │ │ ├── MapViewTest.java │ │ │ ├── MapzenMapHttpHandlerTest.java │ │ │ ├── MapzenMapTest.java │ │ │ ├── OverlayManagerTest.java │ │ │ ├── PersistableMapDataTest.java │ │ │ ├── SceneUpdateManagerTest.java │ │ │ ├── SceneUpdatesMatcher.java │ │ │ ├── TestCallback.java │ │ │ ├── TestDoubleTapResponder.java │ │ │ ├── TestLayoutInflater.java │ │ │ ├── TestLongPressResponder.java │ │ │ ├── TestMapController.java │ │ │ ├── TestMapView.java │ │ │ ├── TestPanResponder.java │ │ │ ├── TestRotateResponder.java │ │ │ ├── TestScaleResponder.java │ │ │ ├── TestShoveResponder.java │ │ │ ├── TestTangramMapView.java │ │ │ ├── TestTapResponder.java │ │ │ ├── internal │ │ │ │ └── StyleStringGeneratorTest.java │ │ │ └── model │ │ │ │ ├── BitmapMarkerManagerTest.java │ │ │ │ ├── BitmapMarkerOptionsTest.java │ │ │ │ ├── BitmapMarkerTest.java │ │ │ │ ├── BubbleWrapStyleTest.java │ │ │ │ ├── CinnabarStyleTest.java │ │ │ │ ├── MarkerOptionsTest.java │ │ │ │ ├── RefillStyleTest.java │ │ │ │ ├── ThemeColorTest.java │ │ │ │ ├── TronStyleTest.java │ │ │ │ ├── WalkaboutStyleTest.java │ │ │ │ └── ZincStyleTest.java │ │ ├── location │ │ │ └── LocationFactoryTest.java │ │ └── search │ │ │ ├── MapzenSearchHttpHandlerTest.java │ │ │ ├── MapzenSearchTest.java │ │ │ └── SearchInitializerTest.java │ │ └── tangram │ │ └── TestMapData.java │ └── javax │ └── microedition │ └── khronos │ ├── egl │ └── EGLConfig.java │ └── opengles │ └── GL10.java ├── docs ├── autocomplete-ui.md ├── basic-functions.md ├── features.md ├── geodata-api.md ├── gesture-responders.md ├── getting-started.md ├── index.md ├── installation.md ├── javadoc.md ├── location-services.md ├── lost │ ├── geofences.md │ ├── get-started.md │ ├── last-known-location.md │ ├── location-settings.md │ ├── location-updates.md │ └── mock-locations-routes.md ├── place-detection-api.md ├── place-picker-ui.md ├── places-getting-started.md ├── places-installation.md ├── places.md ├── search.md ├── styles.md └── turn-by-turn.md ├── gradle.properties ├── gradle ├── gradle-mvn-push.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mapzen-android-sdk ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── mapzen │ │ └── android │ │ ├── core │ │ ├── AndroidModule.java │ │ ├── CommonModule.java │ │ ├── DI.java │ │ └── DependencyInjector.java │ │ └── routing │ │ ├── Converter.java │ │ ├── MapzenDistanceFormatter.java │ │ ├── MapzenRouter.java │ │ ├── MapzenRouterHttpHandler.java │ │ └── RouterInitializer.java │ └── test │ └── java │ └── com │ └── mapzen │ ├── android │ ├── TestHelper.java │ └── routing │ │ ├── MapzenRouterHttpHandlerTest.java │ │ ├── MapzenRouterTest.java │ │ └── RouterInitializerTest.java │ └── valhalla │ └── TestHttpHandlerHelper.java ├── mapzen-places-api ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mapzen │ │ │ └── places │ │ │ └── api │ │ │ ├── AutocompleteFilter.java │ │ │ ├── AutocompletePrediction.java │ │ │ ├── AutocompletePredictionBuffer.java │ │ │ ├── DataBuffer.java │ │ │ ├── GeoDataApi.java │ │ │ ├── LatLng.java │ │ │ ├── LatLngBounds.java │ │ │ ├── Place.java │ │ │ ├── Places.java │ │ │ ├── internal │ │ │ ├── AutocompleteDetailFetchListener.java │ │ │ ├── AutocompletePendingResult.java │ │ │ ├── FilterMapper.java │ │ │ ├── GeoDataApiImpl.java │ │ │ ├── OnPlaceDetailsFetchedListener.java │ │ │ ├── PeliasCallbackHandler.java │ │ │ ├── PeliasFeatureConverter.java │ │ │ ├── PeliasFilterMapper.java │ │ │ ├── PeliasLayerConsts.java │ │ │ ├── PeliasLayerToPlaceTypeConverter.java │ │ │ ├── PeliasPlaceDetailFetcher.java │ │ │ ├── PlaceAutocompleteActivity.java │ │ │ ├── PlaceAutocompleteController.java │ │ │ ├── PlaceAutocompletePresenter.java │ │ │ ├── PlaceAutocompleteView.java │ │ │ ├── PlaceDetailFetcher.java │ │ │ ├── PlaceDialogFragment.java │ │ │ ├── PlaceImpl.java │ │ │ ├── PlaceIntentConsts.java │ │ │ ├── PlacePickerActivity.java │ │ │ ├── PlacePickerPresenter.java │ │ │ ├── PlacePickerPresenterImpl.java │ │ │ ├── PlacePickerViewController.java │ │ │ ├── PlaceStore.java │ │ │ ├── PlacesBubbleWrapStyle.java │ │ │ └── PointToBoundsConverter.java │ │ │ └── ui │ │ │ ├── PlaceAutocomplete.java │ │ │ ├── PlaceAutocompleteFragment.java │ │ │ ├── PlacePicker.java │ │ │ └── PlaceSelectionListener.java │ └── res │ │ ├── drawable-hdpi-v4 │ │ ├── places_ic_clear.png │ │ └── places_ic_search.png │ │ ├── drawable-mdpi-v4 │ │ ├── places_ic_clear.png │ │ └── places_ic_search.png │ │ ├── drawable-xhdpi-v4 │ │ ├── places_ic_clear.png │ │ └── places_ic_search.png │ │ ├── drawable-xxhdpi-v4 │ │ ├── places_ic_clear.png │ │ └── places_ic_search.png │ │ ├── drawable-xxxhdpi-v4 │ │ ├── places_ic_clear.png │ │ └── places_ic_search.png │ │ ├── layout │ │ ├── place_autcomplete_activity_fullscreen.xml │ │ ├── place_autocomplete_activity_overlay.xml │ │ ├── place_autocomplete_fragment.xml │ │ ├── place_autocomplete_view.xml │ │ ├── place_fragment_map.xml │ │ └── place_picker_activity.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── mapzen │ ├── android │ └── lost │ │ └── internal │ │ └── FusedApiServiceUpdater.java │ └── places │ └── api │ ├── AutocompletePredictionBufferTest.java │ ├── AutocompletePredictionTest.java │ ├── LatLngBoundsTest.java │ ├── LatLngTest.java │ └── internal │ ├── AutocompleteDetailFetchListenerTest.java │ ├── AutocompletePendingResultTest.java │ ├── GeoDataApiImplTest.java │ ├── PeliasCallbackHandlerTest.java │ ├── PeliasFeatureConverterTest.java │ ├── PeliasLayerToPlaceTypeConverterTest.java │ ├── PeliasPlaceDetailFetcherTest.java │ ├── PlaceAutocompletePresenterTest.java │ ├── PlacePickerPresenterTest.java │ ├── PlacesBubbleWrapStyleTest.java │ ├── PlacesTest.java │ ├── PointToBoundsConverterTest.java │ ├── TestPlaceDetailFetcher.java │ └── TestPlacePickerController.java ├── release-checklist.md ├── samples ├── mapzen-android-sdk-sample │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── mapzen │ │ │ └── android │ │ │ └── sdk │ │ │ └── sample │ │ │ ├── BaseDemoActivity.java │ │ │ ├── BasicMapzenActivity.java │ │ │ ├── CustomMarkerActivity.java │ │ │ ├── CustomStylesheetActivity.java │ │ │ ├── DroppedPinActivity.java │ │ │ ├── FeaturePickListenerActivity.java │ │ │ ├── LabelPickListenerActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MapzenSearchViewActivity.java │ │ │ ├── MarkerMapzenActivity.java │ │ │ ├── OverlayActivity.java │ │ │ ├── PolygonMapzenActivity.java │ │ │ ├── PolylineMapzenActivity.java │ │ │ ├── QueueEventActivity.java │ │ │ ├── RouteLineActivity.java │ │ │ ├── RoutePinsActivity.java │ │ │ ├── RouterActivity.java │ │ │ ├── SampleDetails.java │ │ │ ├── SampleDetailsList.java │ │ │ ├── SearchResultsActivity.java │ │ │ ├── SimpleStyleSwitcherActivity.java │ │ │ ├── SwitchStyleActivity.java │ │ │ └── TouchResponderActivity.java │ │ └── res │ │ ├── layout │ │ ├── activity_clear_btn.xml │ │ ├── activity_custom_marker.xml │ │ ├── activity_main.xml │ │ ├── activity_overlay.xml │ │ ├── activity_pins.xml │ │ ├── activity_route.xml │ │ ├── activity_sample_mapzen.xml │ │ ├── activity_search.xml │ │ ├── activity_spinner.xml │ │ ├── activity_switch_style.xml │ │ ├── activity_touch_responder.xml │ │ ├── gray_spinner_dropdown_item.xml │ │ ├── gray_spinner_item.xml │ │ ├── list_item.xml │ │ ├── simple_spinner_dropdown_item.xml │ │ └── simple_spinner_item.xml │ │ ├── menu │ │ └── menu_sample_mapzen.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── mapzen.xml │ │ ├── strings.xml │ │ └── styles.xml ├── mapzen-places-api-sample │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── mapzen │ │ │ └── places │ │ │ └── api │ │ │ └── sample │ │ │ ├── AutocompleteDemoActivity.java │ │ │ ├── GeoDataApiActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── PlacePickerDemoActivity.java │ │ │ ├── SampleDetails.java │ │ │ └── SampleDetailsList.java │ │ └── res │ │ ├── layout │ │ ├── activity_autocomplete.xml │ │ ├── activity_geodata.xml │ │ ├── activity_main.xml │ │ ├── list_item.xml │ │ └── place_picker_demo.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── mapzen.xml │ │ ├── strings.xml │ │ └── styles.xml └── mapzen-sample │ ├── .editorconfig │ ├── build.gradle │ └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── mapzen │ │ │ └── com │ │ │ └── sdksampleapp │ │ │ ├── MainApplication.kt │ │ │ ├── activities │ │ │ ├── BaseActivity.kt │ │ │ ├── MainActivity.kt │ │ │ ├── PermissionActivity.kt │ │ │ └── SettingsActivity.kt │ │ │ ├── controllers │ │ │ ├── MainController.kt │ │ │ ├── RoutingController.kt │ │ │ └── SettingsController.kt │ │ │ ├── di │ │ │ ├── AppComponent.kt │ │ │ └── AppModule.kt │ │ │ ├── fragments │ │ │ ├── BaseFragment.kt │ │ │ ├── BasicMapFragment.kt │ │ │ ├── RoutePinsFragment.kt │ │ │ ├── RoutingFragment.kt │ │ │ └── SettingsFragment.kt │ │ │ ├── models │ │ │ ├── MapSampleList.kt │ │ │ ├── MoreSampleList.kt │ │ │ ├── RouteSampleList.kt │ │ │ ├── Sample.kt │ │ │ ├── SampleMap.kt │ │ │ ├── SampleVendor.kt │ │ │ ├── SearchSampleList.kt │ │ │ └── Settings.kt │ │ │ └── presenters │ │ │ ├── MainPresenter.kt │ │ │ ├── MainPresenterImpl.kt │ │ │ ├── RoutingPresenter.kt │ │ │ ├── RoutingPresenterImpl.kt │ │ │ ├── SettingsPresenter.kt │ │ │ └── SettingsPresenterImpl.kt │ └── res │ │ ├── color │ │ └── text_row_text.xml │ │ ├── drawable-hdpi │ │ └── ic_action_more.png │ │ ├── drawable-mdpi │ │ └── ic_action_more.png │ │ ├── drawable-xhdpi │ │ └── ic_action_more.png │ │ ├── drawable-xxhdpi │ │ └── ic_action_more.png │ │ ├── drawable │ │ ├── ic_directions_black_24dp.xml │ │ ├── ic_map_black_24dp.xml │ │ ├── ic_more_horiz_black_24dp.xml │ │ ├── ic_search_black_24dp.xml │ │ ├── rounded_corner.xml │ │ ├── row_bg_normal.xml │ │ ├── row_bg_selected.xml │ │ └── text_row_bg.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_permissions.xml │ │ ├── fragment_map.xml │ │ ├── fragment_routing.xml │ │ └── text_row.xml │ │ ├── menu │ │ ├── activity_main.xml │ │ └── navigation.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values │ │ ├── arrays.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── preferences.xml │ └── test │ ├── java │ └── mapzen │ │ └── com │ │ └── sdksampleapp │ │ ├── TestMainController.kt │ │ ├── TestRoutingController.kt │ │ ├── TestSettingsController.kt │ │ ├── models │ │ ├── MapSampleListTest.kt │ │ ├── MoreSampleListTest.kt │ │ ├── RouteSampleListTest.kt │ │ ├── SampleMapTest.kt │ │ ├── SampleTest.kt │ │ ├── SearchSampleListTest.kt │ │ └── SettingsTest.kt │ │ └── presenters │ │ ├── MainPresenterTest.kt │ │ ├── RoutingPresenterTest.kt │ │ └── SettingsPresenterTest.kt │ └── resources │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── scripts ├── build-android-sdk-sample-app.sh ├── build-mapzen-sample-app.sh ├── build-places-api-sample-app.sh ├── build-samples.sh ├── deploy-android-sdk-sample-app.sh ├── deploy-mapzen-sample-app-snapshot.sh ├── deploy-mapzen-sample-app.sh ├── deploy-places-api-sample-app.sh ├── deploy-samples.sh ├── deploy-snapshot.sh ├── deploy-staging.sh ├── deploy.sh ├── install-s3.sh ├── publish-docs.sh └── release.sh ├── settings.gradle └── styles ├── bubble-wrap ├── .gitignore ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ └── res │ └── values │ └── strings.xml ├── cinnabar ├── .gitignore ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ └── res │ └── values │ └── strings.xml ├── refill ├── .gitignore ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ └── res │ └── values │ └── strings.xml ├── tron ├── .gitignore ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ └── res │ └── values │ └── strings.xml └── walkabout ├── .gitignore ├── build.gradle ├── gradle.properties └── src └── main ├── AndroidManifest.xml └── res └── values └── strings.xml /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | If you would like to contribute code to the Mapzen Android SDK you can do so through 5 | GitHub by forking the repository and sending a pull request. 6 | 7 | When submitting code, please make every effort to follow existing conventions 8 | and style in order to keep the code as readable as possible. Please also make 9 | sure your code compiles by running `./gradlew clean verify`. Checkstyle failures 10 | during compilation indicate errors in your style and can be viewed in the 11 | `checkstyle.xml` file. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | ### Steps to Reproduce 4 | 5 | ### Mapzen SDK & Android Version 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Overview 2 | 3 | ### Proposed Changes 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | local.properties 4 | build 5 | captures 6 | .DS_Store 7 | *.iml 8 | venv* 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "core/src/main/assets/styles/bubble-wrap"] 2 | path = styles/bubble-wrap/src/main/assets/bubble-wrap 3 | url = https://github.com/tangrams/bubble-wrap.git 4 | [submodule "samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style"] 5 | path = styles/tron/src/main/assets/tron-style 6 | url = https://github.com/tangrams/tron-style.git 7 | [submodule "core/src/main/assets/styles/refill-style"] 8 | path = styles/refill/src/main/assets/refill-style 9 | url = https://github.com/tangrams/refill-style 10 | [submodule "core/src/main/assets/styles/cinnabar-style"] 11 | path = styles/cinnabar/src/main/assets/cinnabar-style 12 | url = https://github.com/tangrams/cinnabar-style.git 13 | [submodule "core/src/main/assets/styles/walkabout-style"] 14 | path = styles/walkabout/src/main/assets/walkabout-style 15 | url = https://github.com/tangrams/walkabout-style.git 16 | -------------------------------------------------------------------------------- /assets/android-places.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/assets/android-places.png -------------------------------------------------------------------------------- /assets/android-sdk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/assets/android-sdk.png -------------------------------------------------------------------------------- /assets/eraser-map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/assets/eraser-map.png -------------------------------------------------------------------------------- /core/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /core/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_ARTIFACT_ID=mapzen-core 2 | POM_NAME=Mapzen Android Core 3 | POM_PACKAGING=aar 4 | 5 | GROUP=com.mapzen 6 | POM_DESCRIPTION=Core classes used by the Mapzen Android SDK and Mapzen Places API. 7 | -------------------------------------------------------------------------------- /core/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sarahlensing/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/core/ApiKeyChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Listener for handling changes to API key. 7 | */ 8 | public interface ApiKeyChangeListener { 9 | /** 10 | * Called when the {@link MapzenManager}'s API key is changed. 11 | * @param apiKey the current API key 12 | */ 13 | void onApiKeyChanged(@NonNull String apiKey); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/core/CoreDI.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Public interface to dependency injection framework. 7 | */ 8 | public final class CoreDI { 9 | /** 10 | * Initializes dependency injection framework. 11 | */ 12 | public static void init(Context context) { 13 | CoreDependencyInjector.createInstance(context); 14 | } 15 | 16 | /** 17 | * Provides access to dependency injection modules. 18 | */ 19 | public static CoreDependencyInjector.CoreLibraryComponent component() { 20 | return CoreDependencyInjector.getInstance().component(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/core/http/CallRequest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core.http; 2 | 3 | import retrofit2.Call; 4 | 5 | /** 6 | * Default {@link Request} implementation. 7 | */ 8 | public class CallRequest implements Request { 9 | 10 | private Call call; 11 | 12 | /** 13 | * Public constructor. 14 | * @param call 15 | */ 16 | public CallRequest(Call call) { 17 | this.call = call; 18 | } 19 | 20 | @Override public boolean isCanceled() { 21 | return call.isCanceled(); 22 | } 23 | 24 | @Override public void cancel() { 25 | call.cancel(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/core/http/Request.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core.http; 2 | 3 | /** 4 | * Generic interface for objects abstracting http requests. 5 | */ 6 | public interface Request { 7 | /** 8 | * Returns whether or not the request has been canceled. 9 | */ 10 | boolean isCanceled(); 11 | /** 12 | * Cancels the request. 13 | */ 14 | void cancel(); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/DataLayerType.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Default data layers for bundled Mapzen stylesheets including Bubble Wrap, Cinnabar, and Refill. 7 | * Used to add client data layers to the map and optionally persist them on configuration change. 8 | */ 9 | public enum DataLayerType { 10 | CURRENT_LOCATION("mz_current_location"), 11 | POLYLINE("mz_default_line"), 12 | POLYGON("mz_default_polygon"), 13 | MARKER("mz_default_point"), 14 | ROUTE_START_PIN("mz_route_start"), 15 | ROUTE_END_PIN("mz_route_destination"), 16 | DROPPED_PIN("mz_dropped_pin"), 17 | SEARCH_RESULT_PIN("mz_search_result"), 18 | ROUTE_PIN("mz_route_location"), 19 | ROUTE_LINE("mz_route_line"), 20 | TRANSIT_ROUTE_LINE("mz_route_line_transit"), 21 | TRANSIT_ROUTE_LINE_STATION_ICON("mz_route_transit_stop"); 22 | 23 | private final String name; 24 | 25 | /** 26 | * Constructs enum with name. 27 | * @param s 28 | */ 29 | DataLayerType(String s) { 30 | name = s; 31 | } 32 | 33 | /** 34 | * Returns the enum's name. 35 | * @return 36 | */ 37 | @NonNull public String toString() { 38 | return name; 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/FeaturePickListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Interface for a callback to receive information about features picked from the map. 9 | */ 10 | public interface FeaturePickListener { 11 | /** 12 | * Receive information about features found in a call to 13 | * {@link com.mapzen.tangram.MapController#pickFeature(float, float)}. Note that a feature refers 14 | * to a {@link com.mapzen.android.graphics.model.Polygon} or 15 | * {@link com.mapzen.android.graphics.model.Polyline} and is any 16 | * {@link com.mapzen.tangram.MapData} drawn using non-point style. It does not include 17 | * {@link com.mapzen.android.graphics.model.Marker}s or points, including MapData drawn using 18 | * points style. To receive pick information for 19 | * {@link com.mapzen.android.graphics.model.Marker}s, use the {@link MarkerPickListener} interface 20 | * and to receive pick information for points, including MapData drawn using points style, use the 21 | * {@link FeaturePickListener} interface. 22 | * 23 | * @param properties A mapping of string keys to string or number values 24 | * @param positionX The horizontal screen coordinate of the center of the feature 25 | * @param positionY The vertical screen coordinate of the center of the feature 26 | */ 27 | void onFeaturePick(@NonNull Map properties, float positionX, float positionY); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/LabelPickHandler.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.LabelPickResult; 4 | import com.mapzen.tangram.MapController; 5 | 6 | /** 7 | * Takes care of calling an external label listener for a 8 | * {@link com.mapzen.android.graphics.MapzenMap}. 9 | */ 10 | public class LabelPickHandler implements MapController.LabelPickListener { 11 | 12 | private final MapView mapView; 13 | private LabelPickListener labelPickListener; 14 | 15 | /** 16 | * Construct a new handler and set it's {@link MapView}. 17 | */ 18 | public LabelPickHandler(MapView mapView) { 19 | this.mapView = mapView; 20 | } 21 | 22 | public void setListener(LabelPickListener listener) { 23 | this.labelPickListener = listener; 24 | } 25 | 26 | @Override 27 | public void onLabelPick(LabelPickResult labelPickResult, float positionX, float positionY) { 28 | if (labelPickResult != null) { 29 | postLabelPickRunnable(labelPickResult, positionX, positionY, labelPickListener); 30 | } 31 | } 32 | 33 | private void postLabelPickRunnable(final LabelPickResult result, final float positionX, 34 | final float positionY, final LabelPickListener listener) { 35 | mapView.post(new Runnable() { 36 | @Override public void run() { 37 | listener.onLabelPicked(result, positionX, positionY); 38 | } 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/MapDataManager.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | /** 7 | * Manages {@link PersistableMapData} objects for handling recreation of 8 | * {@link com.mapzen.tangram.MapData} objects 9 | * across orientation changes. 10 | */ 11 | class MapDataManager { 12 | 13 | private Set data = new HashSet<>(); 14 | private boolean persistMapData = false; 15 | 16 | /** 17 | * Adds a {@link PersistableMapData} to the set of data to be restored. 18 | * @param mapData 19 | */ 20 | public void addMapData(PersistableMapData mapData) { 21 | data.add(mapData); 22 | } 23 | 24 | /** 25 | * Removes a type of {@link PersistableMapData} from the set of data to be restored. 26 | * @param dataLayerType 27 | */ 28 | public void removeMapData(DataLayerType dataLayerType) { 29 | Set toRemove = new HashSet<>(); 30 | for (PersistableMapData mapData : data) { 31 | if (mapData.getDataLayerType() == dataLayerType) { 32 | toRemove.add(mapData); 33 | } 34 | } 35 | data.removeAll(toRemove); 36 | } 37 | 38 | /** 39 | * Returns the set of {@link PersistableMapData} to be restored. 40 | * @return 41 | */ 42 | public Set getMapData() { 43 | return data; 44 | } 45 | 46 | public void setPersistMapData(boolean persist) { 47 | this.persistMapData = persist; 48 | } 49 | 50 | public boolean getPersistMapData() { 51 | return persistMapData; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/MarkerPickListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.android.graphics.model.BitmapMarker; 4 | 5 | import android.support.annotation.NonNull; 6 | 7 | /** 8 | * Listener invoked when a marker on the map is selected. Note that all 9 | * {@link com.mapzen.android.graphics.model.Polygon}s, 10 | * {@link com.mapzen.android.graphics.model.Polyline}s, and 11 | * search/routing pins are not markers and will receive pick events via either the 12 | * {@link LabelPickListener} or {@link FeaturePickListener} interfaces. 13 | */ 14 | public interface MarkerPickListener { 15 | /** 16 | * Receives information about markers found in a call to {@link 17 | * com.mapzen.tangram.MapController#pickMarker(float, float)} (float, float)}. 18 | */ 19 | void onMarkerPick(@NonNull BitmapMarker marker); 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/OnMapReadyCallback.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Interface for receiving a {@code MapController} once it is ready to be used. 7 | */ 8 | public interface OnMapReadyCallback { 9 | /** 10 | * Called when the map is ready to be used. 11 | * 12 | * @param mapzenMap A non-null {@link MapzenMap} instance for this {@code MapView}. 13 | */ 14 | void onMapReady(@NonNull MapzenMap mapzenMap); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/OnStyleLoadedListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | /** 4 | * Callback used when loading a new {@link com.mapzen.android.graphics.model.MapStyle} 5 | * asynchronously. 6 | */ 7 | public interface OnStyleLoadedListener { 8 | /** 9 | * Called when the style has finished loaded. 10 | */ 11 | void onStyleLoaded(); 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/TangramMapView.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | 6 | /** 7 | * Entry point for interaction with Tangram map. Wrapped inside of {@link MapView}. 8 | * Do not use this class directly, instead access it via {@link MapView}. 9 | */ 10 | public class TangramMapView extends com.mapzen.tangram.MapView { 11 | 12 | /** 13 | * Creates a new {@link TangramMapView}. 14 | */ 15 | public TangramMapView(Context context) { 16 | super(context); 17 | } 18 | 19 | /** 20 | * Creates a new {@link TangramMapView}. 21 | */ 22 | public TangramMapView(Context context, AttributeSet attrs) { 23 | super(context, attrs); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/ViewCompleteListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | /** 4 | * Listener for when view is fully loaded and no ease or label animation running. 5 | */ 6 | public interface ViewCompleteListener { 7 | /** 8 | * Called on the render-thread at the end of whenever the view is fully loaded and 9 | * no ease- or label-animation is running. 10 | */ 11 | void onViewComplete(); 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/internal/EaseTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.internal; 2 | 3 | import com.mapzen.android.graphics.model.EaseType; 4 | import com.mapzen.tangram.MapController; 5 | 6 | import java.util.HashMap; 7 | 8 | /** 9 | * Converts between SDK {@link EaseType} and internal {@link MapController.EaseType}. 10 | */ 11 | public class EaseTypeConverter { 12 | 13 | public static final HashMap 14 | EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE = new HashMap(); 15 | 16 | static { 17 | EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.put(EaseType.LINEAR, MapController.EaseType.LINEAR); 18 | EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.put(EaseType.CUBIC, MapController.EaseType.CUBIC); 19 | EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.put(EaseType.QUINT, MapController.EaseType.QUINT); 20 | EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.put(EaseType.SINE, MapController.EaseType.SINE); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/internal/StyleStringGenerator.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.internal; 2 | 3 | /** 4 | * Handles updating properties used to generate a style string for a Tangram 5 | * {@link com.mapzen.tangram.Marker}. Used directly by 6 | * {@link com.mapzen.android.graphics.model.BitmapMarker}. 7 | */ 8 | public class StyleStringGenerator { 9 | 10 | /** 11 | * Return the style string given the current property configurations. 12 | * @return 13 | */ 14 | public String getStyleString(int width, int height, boolean interactive, String colorHex) { 15 | return new StringBuilder() 16 | .append("{ style: 'points', color: '") 17 | .append(colorHex) 18 | .append("', size: [") 19 | .append(width) 20 | .append("px, ") 21 | .append(height) 22 | .append("px], ") 23 | .append("collide: false, interactive: ") 24 | .append(interactive) 25 | .append(" }") 26 | .toString(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/BitmapMarkerFactory.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import com.mapzen.android.graphics.internal.StyleStringGenerator; 4 | 5 | /** 6 | * Creates {@link BitmapMarker} objects. 7 | */ 8 | public class BitmapMarkerFactory { 9 | 10 | /** 11 | * Creates new {@link BitmapMarker} with the given parameters. 12 | * @param manager 13 | * @param marker 14 | * @param styleStringGenerator 15 | * @return 16 | */ 17 | BitmapMarker createMarker(BitmapMarkerManager manager, com.mapzen.tangram.Marker marker, 18 | StyleStringGenerator styleStringGenerator) { 19 | return new BitmapMarker(manager, marker, styleStringGenerator); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/BubbleWrapStyle.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.annotation.Nullable; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * BubbleWrap default map style. 10 | */ 11 | public class BubbleWrapStyle extends ThemedMapStyle { 12 | 13 | /** 14 | * Creates a new instance. 15 | */ 16 | public BubbleWrapStyle() { 17 | super("bubble-wrap/bubble-wrap-style.yaml"); 18 | } 19 | 20 | @NonNull @Override public String getBaseStyleFilename() { 21 | return "bubble-wrap-style.yaml"; 22 | } 23 | 24 | @NonNull @Override public String getStyleRootPath() { 25 | return "bubble-wrap/"; 26 | } 27 | 28 | @NonNull @Override public String getThemesPath() { 29 | return "themes/"; 30 | } 31 | 32 | @Override public int getDefaultLod() { 33 | return NONE; 34 | } 35 | 36 | @Override public int getLodCount() { 37 | return NONE; 38 | } 39 | 40 | @Override public int getDefaultLabelLevel() { 41 | return 5; 42 | } 43 | 44 | @Override public int getLabelCount() { 45 | return 12; 46 | } 47 | 48 | @NonNull @Override public ThemeColor getDefaultColor() { 49 | return ThemeColor.NONE; 50 | } 51 | 52 | @Nullable @Override public Set getColors() { 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/CameraType.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | /** 4 | * Camera types. 5 | */ 6 | public enum CameraType { 7 | PERSPECTIVE, 8 | ISOMETRIC, 9 | FLAT, 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/EaseType.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | /** 4 | * Animation ease types. 5 | */ 6 | public enum EaseType { 7 | LINEAR, 8 | CUBIC, 9 | QUINT, 10 | SINE, 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/MapStyle.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Map style given a scene file. 7 | */ 8 | public class MapStyle { 9 | 10 | private final String sceneFile; 11 | 12 | /** 13 | * Creates a new instance. 14 | */ 15 | public MapStyle(@NonNull String sceneFile) { 16 | this.sceneFile = sceneFile; 17 | } 18 | 19 | /** 20 | * Get the underlying scene filename. 21 | */ 22 | @NonNull public String getSceneFile() { 23 | return sceneFile; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/Marker.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import com.mapzen.tangram.LngLat; 4 | 5 | import android.support.annotation.NonNull; 6 | 7 | /** 8 | * Represents a pin marker on a map backed by {@link com.mapzen.tangram.MapData} objects. 9 | */ 10 | public class Marker { 11 | 12 | private final LngLat latLng; 13 | 14 | /** 15 | * Constructs a new object. 16 | */ 17 | public Marker(double longitude, double latitude) { 18 | this.latLng = new LngLat(longitude, latitude); 19 | } 20 | 21 | /** 22 | * Return the marker's coordinate location. 23 | */ 24 | public @NonNull LngLat getLocation() { 25 | return latLng; 26 | } 27 | 28 | @Override public boolean equals(Object o) { 29 | if (this == o) { 30 | return true; 31 | } 32 | if (o == null || getClass() != o.getClass()) { 33 | return false; 34 | } 35 | 36 | Marker marker = (Marker) o; 37 | 38 | return !(latLng != null ? !latLng.equals(marker.latLng) : marker.latLng != null); 39 | } 40 | 41 | @Override public int hashCode() { 42 | return latLng != null ? latLng.hashCode() : 0; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/Polygon.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import com.mapzen.tangram.LngLat; 4 | 5 | import android.support.annotation.NonNull; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Polygon to be drawn on a map. 12 | */ 13 | public class Polygon extends Polyline { 14 | 15 | /** 16 | * Constructs a new {@link Polyline} object. 17 | */ 18 | public Polygon(List coordinates) { 19 | super(coordinates); 20 | } 21 | 22 | /** 23 | * Polygon's builder class. 24 | */ 25 | public static class Builder { 26 | private List coordinates = new ArrayList<>(); 27 | 28 | /** 29 | * Construct a new builder. 30 | */ 31 | public Builder() { 32 | } 33 | 34 | /** 35 | * Add a new coordinate pair to the {@link Polygon}. 36 | */ 37 | @NonNull public Builder add(@NonNull LngLat c) { 38 | coordinates.add(c); 39 | return this; 40 | } 41 | 42 | /** 43 | * Builds the {@link Polygon} and configures it's properties. 44 | * 45 | * @return the configured {@link Polygon} 46 | */ 47 | @NonNull public Polygon build() { 48 | return new Polygon(coordinates); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/ThemeColor.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Available color themes for {@link RefillStyle}. 7 | */ 8 | public enum ThemeColor { 9 | NONE(null), 10 | BLACK("black"), 11 | BLUE("blue"), 12 | BLUEGRAY("blue-gray"), 13 | BROWNORANGE("brown-orange"), 14 | GRAY("gray"), 15 | GRAYGOLD("gray-gold"), 16 | HIGHCONTRAST("high-contrast"), 17 | INTROVERTED("introverted"), 18 | INTROVERTEDBLUE("introverted-blue"), 19 | PINK("pink"), 20 | PINKYELLOW("pink-yellow"), 21 | PURPLEGREEN("purple-green"), 22 | SEPIA("sepia"), 23 | CINNABAR("cinnabar"), 24 | ZINC("zinc"); 25 | 26 | private final String color; 27 | 28 | /** 29 | * Constructor. 30 | * @param color 31 | */ 32 | ThemeColor(String color) { 33 | this.color = color; 34 | } 35 | 36 | /** 37 | * Returns string value of theme color. 38 | * @return 39 | */ 40 | @NonNull public String toString() { 41 | return color; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/TronStyle.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.annotation.Nullable; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * Tron 2.0 map style. 10 | */ 11 | public class TronStyle extends ThemedMapStyle { 12 | 13 | /** 14 | * Creates a new instance. 15 | */ 16 | public TronStyle() { 17 | super("tron-style/tron-style.yaml"); 18 | } 19 | 20 | @NonNull @Override public String getBaseStyleFilename() { 21 | return "tron-style.yaml"; 22 | } 23 | 24 | @NonNull @Override public String getStyleRootPath() { 25 | return "tron-style/"; 26 | } 27 | 28 | @NonNull @Override public String getThemesPath() { 29 | return "themes/"; 30 | } 31 | 32 | @Override public int getDefaultLod() { 33 | return NONE; 34 | } 35 | 36 | @Override public int getLodCount() { 37 | return NONE; 38 | } 39 | 40 | @Override public int getDefaultLabelLevel() { 41 | return 5; 42 | } 43 | 44 | @Override public int getLabelCount() { 45 | return 12; 46 | } 47 | 48 | @NonNull @Override public ThemeColor getDefaultColor() { 49 | return ThemeColor.NONE; 50 | } 51 | 52 | @Nullable @Override public Set getColors() { 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/WalkaboutStyle.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.annotation.Nullable; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * Walkabout outdoor map style. 10 | */ 11 | public class WalkaboutStyle extends ThemedMapStyle { 12 | 13 | /** 14 | * Creates a new instance. 15 | */ 16 | public WalkaboutStyle() { 17 | super("walkabout-style/walkabout-style.yaml"); 18 | } 19 | 20 | @NonNull @Override public String getBaseStyleFilename() { 21 | return "walkabout-style.yaml"; 22 | } 23 | 24 | @NonNull @Override public String getStyleRootPath() { 25 | return "walkabout-style/"; 26 | } 27 | 28 | @NonNull @Override public String getThemesPath() { 29 | return "themes/"; 30 | } 31 | 32 | @Override public int getDefaultLod() { 33 | return NONE; 34 | } 35 | 36 | @Override public int getLodCount() { 37 | return NONE; 38 | } 39 | 40 | @Override public int getDefaultLabelLevel() { 41 | return 5; 42 | } 43 | 44 | @Override public int getLabelCount() { 45 | return 12; 46 | } 47 | 48 | @NonNull @Override public ThemeColor getDefaultColor() { 49 | return ThemeColor.NONE; 50 | } 51 | 52 | @Nullable @Override public Set getColors() { 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/graphics/model/ZincStyle.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.model; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import static com.mapzen.android.graphics.model.ThemeColor.ZINC; 7 | 8 | /** 9 | * Zinc more labels map style. 10 | * 11 | * Deprecated in favor of {@link RefillStyle} with {@link ThemeColor#ZINC}. 12 | */ 13 | @Deprecated 14 | public class ZincStyle extends ThemedMapStyle { 15 | 16 | private final Set supportedColors = new HashSet() { 17 | { 18 | add(ZINC); 19 | } 20 | }; 21 | 22 | /** 23 | * Creates a new instance. 24 | */ 25 | public ZincStyle() { 26 | super("refill-style/refill-style.yaml"); 27 | } 28 | 29 | @Override public String getBaseStyleFilename() { 30 | return "refill-style.yaml"; 31 | } 32 | 33 | @Override public String getStyleRootPath() { 34 | return "refill-style/"; 35 | } 36 | 37 | @Override public String getThemesPath() { 38 | return "themes/"; 39 | } 40 | 41 | @Override public int getDefaultLod() { 42 | return 10; 43 | } 44 | 45 | @Override public int getLodCount() { 46 | return 12; 47 | } 48 | 49 | @Override public int getDefaultLabelLevel() { 50 | return 5; 51 | } 52 | 53 | @Override public int getLabelCount() { 54 | return 12; 55 | } 56 | 57 | @Override public ThemeColor getDefaultColor() { 58 | return ZINC; 59 | } 60 | 61 | @Override public Set getColors() { 62 | return supportedColors; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/src/main/java/com/mapzen/android/search/SearchInitializer.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.search; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Handles setting the api key and a request handler for given {@link MapzenSearch} objects. 10 | */ 11 | public class SearchInitializer { 12 | private MapzenSearchHttpHandler requestHandler; 13 | 14 | /** 15 | * Constructor. 16 | * @param context 17 | */ 18 | public SearchInitializer(@NonNull Context context) { 19 | requestHandler = new MapzenSearchHttpHandler(context) { 20 | @Override public Map queryParamsForRequest() { 21 | return null; 22 | } 23 | 24 | @Override public Map headersForRequest() { 25 | return null; 26 | } 27 | }; 28 | } 29 | 30 | /** 31 | * Set the {@link MapzenSearch}'s {@link MapzenSearchHttpHandler}. 32 | * @param search 33 | */ 34 | public void initSearch(@NonNull MapzenSearch search) { 35 | search.getPelias().setRequestHandler(requestHandler.searchHandler()); 36 | } 37 | 38 | 39 | /** 40 | * Returns the request handler. 41 | * @return 42 | */ 43 | @NonNull public MapzenSearchHttpHandler getRequestHandler() { 44 | return requestHandler; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/res/drawable-hdpi/mz_compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-hdpi/mz_compass.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-hdpi/mz_find_me_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-hdpi/mz_find_me_normal.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-hdpi/mz_find_me_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-hdpi/mz_find_me_pressed.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-hdpi/mz_zoom_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-hdpi/mz_zoom_in.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-hdpi/mz_zoom_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-hdpi/mz_zoom_out.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-mdpi/mz_compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-mdpi/mz_compass.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-mdpi/mz_find_me_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-mdpi/mz_find_me_normal.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-mdpi/mz_find_me_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-mdpi/mz_find_me_pressed.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-mdpi/mz_zoom_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-mdpi/mz_zoom_in.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-mdpi/mz_zoom_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-mdpi/mz_zoom_out.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-v21/mz_bg_white_gray_border.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /core/src/main/res/drawable-xhdpi/mz_compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xhdpi/mz_compass.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xhdpi/mz_find_me_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xhdpi/mz_find_me_normal.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xhdpi/mz_find_me_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xhdpi/mz_find_me_pressed.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xhdpi/mz_zoom_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xhdpi/mz_zoom_in.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xhdpi/mz_zoom_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xhdpi/mz_zoom_out.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xxhdpi/mz_compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xxhdpi/mz_compass.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xxhdpi/mz_find_me_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xxhdpi/mz_find_me_normal.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xxhdpi/mz_find_me_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xxhdpi/mz_find_me_pressed.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xxhdpi/mz_zoom_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xxhdpi/mz_zoom_in.png -------------------------------------------------------------------------------- /core/src/main/res/drawable-xxhdpi/mz_zoom_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable-xxhdpi/mz_zoom_out.png -------------------------------------------------------------------------------- /core/src/main/res/drawable/mapzen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/core/src/main/res/drawable/mapzen.png -------------------------------------------------------------------------------- /core/src/main/res/drawable/mz_bg_ripple.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /core/src/main/res/drawable/mz_bg_white_gray_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /core/src/main/res/drawable/mz_find_me.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /core/src/main/res/layout/mz_fragment_map.xml: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /core/src/main/res/layout/mz_fragment_map_classic.xml: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /core/src/main/res/layout/mz_view_compass.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /core/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /core/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFF 4 | #999 5 | #A3ABAD 6 | 7 | -------------------------------------------------------------------------------- /core/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 44dp 4 | 44dp 5 | 16dp 6 | 16dp 7 | 44dp 8 | 44dp 9 | 16dp 10 | 16dp 11 | 44dp 12 | 44dp 13 | 16dp 14 | 55dp 15 | 16dp 16 | 16dp 17 | 44dp 18 | 44dp 19 | 16dp 20 | 16dp 21 | 16dp 22 | 55dp 23 | 16dp 24 | 16dp 25 | 10sp 26 | 27 | -------------------------------------------------------------------------------- /core/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | core 3 | Powered by Mapzen 4 | Compass 5 | Find Me 6 | Zoom in 7 | Zoom out 8 | 9 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/TestHelper.java: -------------------------------------------------------------------------------- 1 | package com.mapzen; 2 | 3 | import org.powermock.api.mockito.PowerMockito; 4 | 5 | import android.content.Context; 6 | import android.content.res.Resources; 7 | 8 | import static org.mockito.Mockito.mock; 9 | import static org.mockito.Mockito.when; 10 | 11 | public final class TestHelper { 12 | public static Context getMockContext() { 13 | final Context context = PowerMockito.mock(Context.class); 14 | when(context.getApplicationContext()).thenReturn(context); 15 | when(context.getResources()).thenReturn(mock(Resources.class)); 16 | return context; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/core/TestVals.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class TestVals { 7 | 8 | public static Map testParams() { 9 | Map map = new HashMap<>(); 10 | map.put("param1", "val1"); 11 | map.put("param2", "val2"); 12 | return map; 13 | } 14 | 15 | public static Map testHeaders() { 16 | Map map = new HashMap<>(); 17 | map.put("header1", "val1"); 18 | map.put("header2", "val2"); 19 | return map; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/core/http/CallRequestTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core.http; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.mockito.Mockito.mock; 6 | import static org.mockito.Mockito.verify; 7 | import retrofit2.Call; 8 | 9 | public class CallRequestTest { 10 | 11 | Call call = mock(Call.class); 12 | CallRequest request = new CallRequest(call); 13 | 14 | @Test 15 | public void cancel_shouldCancelCall() throws Exception { 16 | request.cancel(); 17 | verify(call).cancel(); 18 | } 19 | 20 | @Test 21 | public void isCanceled_shouldCallCall() throws Exception { 22 | request.isCanceled(); 23 | verify(call).isCanceled(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/core/test/R.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core.test; 2 | 3 | public final class R { 4 | public static final class id { 5 | public static final int mapzen_api_key = 0x00000001; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/SceneUpdatesMatcher.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.SceneUpdate; 4 | 5 | import org.mockito.ArgumentMatcher; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | /** 11 | * Custom Mockito matcher for a list of SceneUpdates. Verifies paths and values are all equal. 12 | */ 13 | class SceneUpdatesMatcher extends ArgumentMatcher> { 14 | List updates; 15 | 16 | public SceneUpdatesMatcher(SceneUpdate update) { 17 | this.updates = Arrays.asList(update); 18 | } 19 | 20 | public SceneUpdatesMatcher(List updates) { 21 | this.updates = updates; 22 | } 23 | 24 | @Override public boolean matches(Object argument) { 25 | List otherObject = (List) argument; 26 | if (updates.size() != otherObject.size()) { 27 | return false; 28 | } 29 | for (int i = 0; i < updates.size(); i++) { 30 | if (!updateEqualToUpdate(updates.get(i), otherObject.get(i))) { 31 | return false; 32 | } 33 | } 34 | return true; 35 | } 36 | 37 | private boolean updateEqualToUpdate(SceneUpdate update, SceneUpdate otherUpdate) { 38 | if (!update.getPath().equals(otherUpdate.getPath())) { 39 | return false; 40 | } 41 | if (!update.getValue().equals(otherUpdate.getValue())) { 42 | return false; 43 | } 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestCallback.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | public class TestCallback implements OnMapReadyCallback { 4 | MapzenMap map; 5 | 6 | @Override public void onMapReady(MapzenMap map) { 7 | this.map = map; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestDoubleTapResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | /** 6 | * Implementation of interface for use in {@code MapzenMapTest} 7 | */ 8 | public class TestDoubleTapResponder implements TouchInput.DoubleTapResponder { 9 | @Override public boolean onDoubleTap(float x, float y) { 10 | return false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestLayoutInflater.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | class TestLayoutInflater extends LayoutInflater { 9 | private int resource; 10 | private ViewGroup root; 11 | 12 | TestLayoutInflater(Context context) { 13 | super(context); 14 | } 15 | 16 | @Override public View inflate(int resource, ViewGroup root) { 17 | this.resource = resource; 18 | this.root = root; 19 | return null; 20 | } 21 | 22 | @Override public View inflate(int resource, ViewGroup root, boolean attachToRoot) { 23 | this.resource = resource; 24 | this.root = root; 25 | return null; 26 | } 27 | 28 | @Override public LayoutInflater cloneInContext(Context newContext) { 29 | return null; 30 | } 31 | 32 | int getResId() { 33 | return resource; 34 | } 35 | 36 | ViewGroup getRoot() { 37 | return root; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestLongPressResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | /** 6 | * 7 | */ 8 | public class TestLongPressResponder implements TouchInput.LongPressResponder { 9 | @Override public void onLongPress(float x, float y) { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestPanResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | public class TestPanResponder implements TouchInput.PanResponder { 6 | public float startX = 0f; 7 | public float startY = 0f; 8 | public float endX = 0f; 9 | public float endY = 0f; 10 | 11 | public float posX = 0f; 12 | public float posY = 0f; 13 | public float velocityX = 0f; 14 | public float velocityY = 0f; 15 | 16 | @Override public boolean onPan(float startX, float startY, float endX, float endY) { 17 | this.startX = startX; 18 | this.startY = startY; 19 | this.endX = endX; 20 | this.endY = endY; 21 | return false; 22 | } 23 | 24 | @Override public boolean onFling(float posX, float posY, float velocityX, float velocityY) { 25 | this.posX = posX; 26 | this.posY = posY; 27 | this.velocityX = velocityX; 28 | this.velocityY = velocityY; 29 | return false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestRotateResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | /** 6 | * 7 | */ 8 | public class TestRotateResponder implements TouchInput.RotateResponder { 9 | @Override public boolean onRotate(float x, float y, float rotation) { 10 | return false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestScaleResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | /** 6 | * 7 | */ 8 | public class TestScaleResponder implements TouchInput.ScaleResponder { 9 | @Override public boolean onScale(float x, float y, float scale, float velocity) { 10 | return false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestShoveResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | /** 6 | * 7 | */ 8 | public class TestShoveResponder implements TouchInput.ShoveResponder { 9 | @Override public boolean onShove(float distance) { 10 | return false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/TestTapResponder.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics; 2 | 3 | import com.mapzen.tangram.TouchInput; 4 | 5 | /** 6 | * 7 | */ 8 | public class TestTapResponder implements TouchInput.TapResponder { 9 | 10 | boolean singleTapUp = false; 11 | 12 | boolean singleTapConfirmed = false; 13 | 14 | @Override public boolean onSingleTapUp(float x, float y) { 15 | singleTapUp = true; 16 | return false; 17 | } 18 | 19 | @Override public boolean onSingleTapConfirmed(float x, float y) { 20 | singleTapConfirmed = true; 21 | return false; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/graphics/internal/StyleStringGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.graphics.internal; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | public class StyleStringGeneratorTest { 8 | 9 | private StyleStringGenerator generator = new StyleStringGenerator(); 10 | 11 | @Test public void defaultStyleString() throws Exception { 12 | assertThat(generator.getStyleString(50, 50, true, "#FFFFFF")).isEqualTo("{ style: 'points', " 13 | + "color: '#FFFFFF', size: [50px, 50px], collide: false, interactive: true }"); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/android/search/SearchInitializerTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.search; 2 | 3 | import com.mapzen.android.core.MapzenManager; 4 | import com.mapzen.pelias.Pelias; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import static com.mapzen.TestHelper.getMockContext; 11 | import static org.mockito.Mockito.mock; 12 | import static org.mockito.Mockito.verify; 13 | 14 | public class SearchInitializerTest { 15 | private SearchInitializer searchInitializer; 16 | private MapzenSearch search; 17 | private Pelias pelias; 18 | 19 | @Before public void setUp() throws Exception { 20 | MapzenManager.instance(getMockContext()).setApiKey("fake-mapzen-api-key"); 21 | searchInitializer = new SearchInitializer(getMockContext()); 22 | pelias = mock(Pelias.class); 23 | search = new MapzenSearch(getMockContext(), pelias); 24 | } 25 | 26 | @After public void tearDown() throws Exception { 27 | MapzenManager.instance(getMockContext()).setApiKey(null); 28 | } 29 | 30 | @Test public void initSearch_shouldSetHttpHandler() { 31 | searchInitializer.initSearch(search); 32 | verify(pelias).setRequestHandler(searchInitializer.getRequestHandler().searchHandler()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/com/mapzen/tangram/TestMapData.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangram; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Returned by {@link com.mapzen.android.graphics.TestMapController} 8 | */ 9 | public class TestMapData extends MapData { 10 | public LngLat point; 11 | public List polyline; 12 | public List> polygon; 13 | 14 | public TestMapData(String name) { 15 | super(name, 0, null); 16 | } 17 | 18 | @Override public MapData addPoint(LngLat point, Map properties) { 19 | this.point = point; 20 | return this; 21 | } 22 | 23 | @Override public MapData addPolyline(List polyline, Map properties) { 24 | this.polyline = polyline; 25 | return this; 26 | } 27 | 28 | @Override public MapData addPolygon(List> polygon, Map properties) { 29 | this.polygon = polygon; 30 | return this; 31 | } 32 | 33 | @Override public MapData clear() { 34 | point = null; 35 | polyline = null; 36 | polygon = null; 37 | return this; 38 | } 39 | 40 | @Override public void remove() { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/test/java/javax/microedition/khronos/egl/EGLConfig.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.khronos.egl; 2 | 3 | public class EGLConfig { 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/java/javax/microedition/khronos/opengles/GL10.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.khronos.opengles; 2 | 3 | public class GL10 { 4 | } 5 | -------------------------------------------------------------------------------- /docs/basic-functions.md: -------------------------------------------------------------------------------- 1 | # Position, rotation, and zoom 2 | 3 | Use the `MapzenMap` instance returned by `getMapAsync(OnMapReadyCallback)` to set the position, rotation, and zoom level. 4 | 5 | ```java 6 | MapFragment mapFragment = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment); 7 | mapFragment.getMapAsync(new OnMapReadyCallback() { 8 | @Override public void onMapReady(MapzenMap map) { 9 | map.setPosition(new LngLat(-73.9903, 40.74433)); 10 | map.setRotation(0f); 11 | map.setZoom(17f); 12 | map.setTilt(0f); 13 | } 14 | }); 15 | ``` 16 | 17 | For advanced map controls (animation, etc.) you can subclass `MapzenMap` and access the Tangram `MapController` directly. 18 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Mapzen Android SDK 2 | 3 | The Mapzen Android SDK is a thin wrapper that packages up everything you need to use Mapzen services in your Android applications. It also simplifies setup, installation, API key management and generally makes your life better. 4 | 5 | # Mapzen Places API 6 | 7 | The Mapzen Places API is a drop in replacement for the Google Places API. It provides UI and data components to make interaction between search and maps extremely easy to integrate into your application. 8 | 9 | # Greater than the sum of their parts 10 | Together, these two libraries include map rendering, search/geocoding, turn-by-turn directions, and location tracking. They are built using the following standalone libraries and services from Mapzen: 11 | 12 | - **[Tangram ES](https://github.com/tangrams/tangram-es/)** Our 2D and 3D map renderer using OpenGL ES 13 | - **[Pelias Android SDK](https://github.com/pelias/pelias-android-sdk)** Mapzen Search client and custom `SearchView` extension 14 | - **[On the Road](https://github.com/mapzen/on-the-road)** Mapzen Turn-by-Turn client and navigation utilities 15 | - **[Lost](https://github.com/mapzen/lost)** Our drop-in replacement for Google Play services Location APIs 16 | 17 | ## Find out more 18 | Check out the rest of the documentation for how to get started or you can cruise around the [source code on GitHub](https://github.com/mapzen/android). 19 | -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | The Mapzen Android SDK and Mapzen Places API can be included in any Android app via download, Maven, or Gradle. It includes everything you need to get started. No other mapping or location services dependencies are required. 4 | 5 | ## Download 6 | 7 | - [Mapzen SDK](http://search.maven.org/remotecontent?filepath=com/mapzen/mapzen-android-sdk/1.6.1/mapzen-android-sdk-1.6.1.aar) 8 | - [Mapzen Places SDK](http://search.maven.org/remotecontent?filepath=com/mapzen/mapzen-places-api/1.6.1/mapzen-places-api-1.6.1.aar), more on installing the Places SDK is [here](places.md) 9 | 10 | ## Maven 11 | 12 | Include dependency using Maven. 13 | 14 | ```xml 15 | 16 | com.mapzen 17 | mapzen-android-sdk 18 | 1.6.1 19 | aar 20 | 21 | ``` 22 | 23 | ## Gradle 24 | 25 | Include dependency using Gradle. 26 | 27 | ```groovy 28 | repositories { 29 | mavenCentral() 30 | } 31 | 32 | dependencies { 33 | compile 'com.mapzen:mapzen-android-sdk:1.6.1' 34 | ... 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/javadoc.md: -------------------------------------------------------------------------------- 1 | # Javadoc 2 | 3 | ### [Mapzen Core](http://mapzen.github.io/android/mapzen-core/) 4 | Shared module with common components used by both the Mapzen Android SDK and Mapzen Places API for Android. 5 | 6 | ### [Mapzen Android SDK](http://mapzen.github.io/android/mapzen-android-sdk/) 7 | Maps, search, routing, and location services. 8 | 9 | ### [Mapzen Places API](http://mapzen.github.io/android/mapzen-places-api/) 10 | Place autocomplete and place picker UI components. 11 | -------------------------------------------------------------------------------- /docs/lost/geofences.md: -------------------------------------------------------------------------------- 1 | # Creating and Monitoring Geofences 2 | 3 | A geofence is a geographic boundary defined by a set of geographic coordinates. 4 | 5 | With Lost you can create `Geofence`s to monitor when a user enters or exits an area and get notifications when this occurs. 6 | 7 | First create a `Geofence` object: 8 | ```java 9 | Geofence geofence = new Geofence.Builder() 10 | .setRequestId(requestId) 11 | .setCircularRegion(latitude, longitude, radius) 12 | .setExpirationDuration(NEVER_EXPIRE) 13 | .build(); 14 | ``` 15 | 16 | Then create a `GeofencingRequest` from all relevant `Geofences`: 17 | 18 | ```java 19 | GeofencingRequest request = new GeofencingRequest.Builder() 20 | .addGeofence(geofence) 21 | .build(); 22 | ``` 23 | 24 | After this is done, you can create a `PendingIntent` to fire when the user enters/exits the `Geofence`. Usually this will send an `Intent` to an `IntentService`: 25 | ```java 26 | Intent serviceIntent = new Intent(getApplicationContext(), GeofenceIntentService.class); 27 | PendingIntent pendingIntent = PendingIntent.getService(this, 0, serviceIntent, 0); 28 | ``` 29 | 30 | Finally, invoke the `GeofencingApi` method to register for updates: 31 | 32 | ```java 33 | LocationServices.GeofencingApi.addGeofences(client, request, pendingIntent); 34 | ``` 35 | 36 | Your `IntentService` will continue to receive updates as the user enters/exits the relevant `Geofences` until you remove the `PendingIntent`. 37 | -------------------------------------------------------------------------------- /docs/lost/get-started.md: -------------------------------------------------------------------------------- 1 | # Get Started 2 | 3 | LOST is an open source alternative to the Google Play services location APIs that depends only on the Android SDK. It provides 1:1 replacements for the FusedLocationProviderApi, GeofencingApi, and SettingsApi. 4 | 5 | Lost operates by making calls directly to the LocationManger. Lost can run on any Android device running API 15 or higher regardless of whether or not it supports the Google Play ecosystem. 6 | 7 | When using Lost, [`GoogleApiClient`](https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html) is replaced by [`LostApiClient`](https://github.com/mapzen/lost/blob/master/lost/src/main/java/com/mapzen/android/lost/api/LostApiClient.java). 8 | 9 | ## Create and connect a LostApiClient 10 | 11 | After calling `lostApiClient.connect()` you should wait for `ConnectionCallbacks#onConnected()` before performing other operations like getting the last known location or requesting location updates. 12 | 13 | ```java 14 | LostApiClient lostApiClient = new LostApiClient.Builder(this).addConnectionCallbacks(this).build(); 15 | lostApiClient.connect(); 16 | 17 | @Override public void onConnected() { 18 | // Client is connected and ready to for use 19 | } 20 | 21 | @Override public void onConnectionSuspended() { 22 | // Fused location provider service has been suspended 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /docs/lost/last-known-location.md: -------------------------------------------------------------------------------- 1 | # Getting the Last Known Location 2 | 3 | Once the `LostApiClient` is connected you can request the last known location. 4 | 5 | The actual logic to determine the best most recent location is based this classic [blog post by Reto Meier](http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html). 6 | 7 | ```java 8 | Location location = LocationServices.FusedLocationApi.getLastLocation(lostApiClient); 9 | if (location != null) { 10 | // Do stuff 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/lost/location-updates.md: -------------------------------------------------------------------------------- 1 | # Requesting Location Updates 2 | 3 | Lost provides the ability to request ongoing location updates. You can specify the update interval, minimum displacement, and priority. The priority determines which location providers will be activated. 4 | 5 | ```java 6 | LocationRequest request = LocationRequest.create() 7 | .setPriority(LocationRequest.PRIORITY_LOW_POWER) 8 | .setInterval(5000) 9 | .setSmallestDisplacement(10); 10 | 11 | LocationListener listener = new LocationListener() { 12 | @Override 13 | public void onLocationChanged(Location location) { 14 | // Do stuff 15 | } 16 | }; 17 | 18 | LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, listener); 19 | ``` 20 | 21 | For situations where you want to receive location updates in the background, you can request location updates using the `PendingIntent` API. 22 | 23 | ```java 24 | LocationRequest request = LocationRequest.create() 25 | .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); 26 | .setInterval(100); 27 | 28 | Intent intent = new Intent(MyIntentService.ACTION); 29 | PendingIntent pendingIntent = PendingIntent.getService(MyActivity.this, requestCode, intent, flags); 30 | LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, pendingIntent); 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/place-detection-api.md: -------------------------------------------------------------------------------- 1 | Coming soon 2 | -------------------------------------------------------------------------------- /docs/places-getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | ## 1. Sign up for a Mapzen API key 4 | 5 | Sign up for an API key from the [Mapzen developer portal](https://mapzen.com/documentation/overview/). 6 | 7 | ### Set API key using a string resource 8 | 9 | You can set your Mapzen API key via an XML string resource. Add a file `app/src/main/res/values/mapzen.xml` and copy the following code. 10 | 11 | ```xml 12 | 13 | your-mapzen-api-key 14 | 15 | ``` 16 | 17 | ### Set API key using `MapzenManager` class 18 | 19 | Alternatively you can set your Mapzen API key via the `MapzenManager` class. Just make sure you call the following method prior to calling `MapView#getMapAsyc(...)` or creating an instance of `MapzenSearch` or `MapzenRouter`. 20 | 21 | ```java 22 | MapzenManager.instance(context).setApiKey("your-mapzen-api-key"); 23 | ``` 24 | -------------------------------------------------------------------------------- /docs/places-installation.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | The Mapzen Places API for Android can be included in any Android app via download, Maven, or Gradle. To get started, download the [latest AAR](http://search.maven.org/remotecontent?filepath=com/mapzen/mapzen-places-api/1.6.1/mapzen-places-api-1.6.1.aar). 4 | 5 | ### Maven 6 | 7 | Include dependency using Maven. 8 | 9 | ```xml 10 | 11 | com.mapzen 12 | mapzen-places-api 13 | 1.6.1 14 | aar 15 | 16 | ``` 17 | 18 | ### Gradle 19 | 20 | Include dependency using Gradle. 21 | 22 | ```groovy 23 | repositories { 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'com.mapzen:mapzen-places-api:1.6.1' 29 | ... 30 | } 31 | ``` 32 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=1.6.2-SNAPSHOT 2 | 3 | VERSION_NAME=1.6.2-SNAPSHOT 4 | 5 | POM_URL=https://github.com/mapzen/android 6 | POM_SCM_URL=http://github.com/mapzen/android 7 | POM_SCM_CONNECTION=scm:git:git://github.com/mapzen/android.git 8 | POM_SCM_DEV_CONNECTION=scm:git:git@github.com:mapzen/android.git 9 | 10 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 11 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 12 | POM_LICENCE_DIST=repo 13 | 14 | POM_DEVELOPER_ID=Mapzen 15 | POM_DEVELOPER_NAME=Mapzen 16 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 26 16:45:08 MDT 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /mapzen-android-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /mapzen-android-sdk/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_ARTIFACT_ID=mapzen-android-sdk 2 | POM_NAME=Mapzen Android SDK 3 | POM_PACKAGING=aar 4 | 5 | GROUP=com.mapzen 6 | POM_DESCRIPTION=Unified SDK for Mapzen tools and services on Android. 7 | -------------------------------------------------------------------------------- /mapzen-android-sdk/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /opt/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/core/AndroidModule.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import com.mapzen.android.routing.RouterInitializer; 4 | 5 | import android.content.Context; 6 | import android.content.res.Resources; 7 | 8 | import javax.inject.Singleton; 9 | 10 | import dagger.Module; 11 | import dagger.Provides; 12 | 13 | /** 14 | * Dependency injection module for components that depend on an Android {@link Context}. 15 | */ 16 | @Module public class AndroidModule { 17 | private final Context context; 18 | 19 | /** 20 | * Creates module to provide components that depend on an Android {@link Context}. The 21 | * application context is used so it will persist on configuration changes. 22 | * 23 | * @param context The context that should be used to inject Android-specific components. 24 | */ 25 | AndroidModule(Context context) { 26 | this.context = context.getApplicationContext(); 27 | } 28 | 29 | /** 30 | * Provides Android application context. 31 | */ 32 | @Provides @Singleton public Context provideApplicationContext() { 33 | return context; 34 | } 35 | 36 | /** 37 | * Provides Android application resources. 38 | */ 39 | @Provides @Singleton public Resources provideResources() { 40 | return context.getResources(); 41 | } 42 | 43 | /** 44 | * Provides HTTP handler to append API key to outgoing turn-by-turn requests. 45 | */ 46 | @Provides @Singleton public RouterInitializer provideRouterInitializer(Context context) { 47 | return new RouterInitializer(context); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/core/CommonModule.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import dagger.Module; 4 | 5 | /** 6 | * Dependency injection module for components that do not depend on Android components. 7 | */ 8 | @Module public class CommonModule { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/core/DI.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Public interface to dependency injection framework. 7 | */ 8 | public final class DI { 9 | /** 10 | * Initializes dependency injection framework. 11 | */ 12 | public static void init(Context context) { 13 | DependencyInjector.createInstance(context); 14 | } 15 | 16 | /** 17 | * Provides access to dependency injection modules. 18 | */ 19 | public static DependencyInjector.LibraryComponent component() { 20 | return DependencyInjector.getInstance().component(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/core/DependencyInjector.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.core; 2 | 3 | import com.mapzen.android.routing.MapzenRouter; 4 | 5 | import android.content.Context; 6 | 7 | import javax.inject.Singleton; 8 | 9 | import dagger.Component; 10 | 11 | /** 12 | * Manages library dependencies. 13 | */ 14 | class DependencyInjector { 15 | /** 16 | * Library component interface. 17 | */ 18 | @Singleton @Component(modules = { AndroidModule.class, CommonModule.class }) 19 | public interface LibraryComponent { 20 | void inject(MapzenRouter router); 21 | } 22 | 23 | private LibraryComponent component; 24 | 25 | private static DependencyInjector instance; 26 | 27 | /** 28 | * Creates a new instance of the dependency injection framework if not already initialized. 29 | */ 30 | static void createInstance(Context context) { 31 | if (instance == null) { 32 | instance = new DependencyInjector(context); 33 | } 34 | } 35 | 36 | /** 37 | * Returns the singleton instance of the dependency injection framework. 38 | */ 39 | static DependencyInjector getInstance() { 40 | return instance; 41 | } 42 | 43 | private DependencyInjector(Context context) { 44 | component = DaggerDependencyInjector_LibraryComponent.builder() 45 | .androidModule(new AndroidModule(context)) 46 | .build(); 47 | } 48 | 49 | /** 50 | * Returns the module component. 51 | */ 52 | LibraryComponent component() { 53 | return component; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/routing/Converter.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.routing; 2 | 3 | import com.mapzen.valhalla.Router; 4 | 5 | import android.support.annotation.NonNull; 6 | 7 | import java.util.HashMap; 8 | 9 | /** 10 | * Converts distance units between {@link MapzenRouter.DistanceUnits} and 11 | * {@link Router.DistanceUnits}. 12 | */ 13 | public class Converter { 14 | 15 | @NonNull public static final HashMap UNITS_TO_ROUTER_UNITS = new HashMap<>(); 17 | static { 18 | UNITS_TO_ROUTER_UNITS.put(MapzenRouter.DistanceUnits.MILES, Router.DistanceUnits.MILES); 19 | UNITS_TO_ROUTER_UNITS.put(MapzenRouter.DistanceUnits.KILOMETERS, 20 | Router.DistanceUnits.KILOMETERS); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenDistanceFormatter.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.routing; 2 | 3 | import com.mapzen.helpers.DistanceFormatter; 4 | import com.mapzen.valhalla.Router; 5 | 6 | import android.support.annotation.NonNull; 7 | 8 | /** 9 | * Formatter for dealing with {@link MapzenRouter.DistanceUnits}. 10 | */ 11 | public class MapzenDistanceFormatter { 12 | 13 | /** 14 | * Format distance for display using specified distance units. 15 | * 16 | * @param distanceInMeters the actual distance in meters. 17 | * @param realTime boolean flag for navigation vs. list view. 18 | * @param units miles or kilometers. 19 | * @return distance string formatted according to the rules of the formatter. 20 | */ 21 | @NonNull public static String format(int distanceInMeters, boolean realTime, 22 | MapzenRouter.DistanceUnits units) { 23 | Router.DistanceUnits routerUnits = Converter.UNITS_TO_ROUTER_UNITS.get(units); 24 | return DistanceFormatter.format(distanceInMeters, realTime, routerUnits); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/main/java/com/mapzen/android/routing/RouterInitializer.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.routing; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Handles setting the request handler for given {@link MapzenRouter} objects. 10 | */ 11 | public class RouterInitializer { 12 | 13 | final MapzenRouterHttpHandler requestHandler; 14 | 15 | /** 16 | * Constructor. 17 | * @param context 18 | */ 19 | public RouterInitializer(@NonNull Context context) { 20 | requestHandler = new MapzenRouterHttpHandler(context) { 21 | @Override public Map queryParamsForRequest() { 22 | return null; 23 | } 24 | 25 | @Override public Map headersForRequest() { 26 | return null; 27 | } 28 | }; 29 | } 30 | 31 | /** 32 | * Set the {@link MapzenRouter}'s {@link MapzenRouterHttpHandler}. 33 | * @param router 34 | */ 35 | public void initRouter(@NonNull MapzenRouter router) { 36 | router.getRouter().setHttpHandler(requestHandler.turnByTurnHandler()); 37 | } 38 | 39 | /** 40 | * Returns the request handler. 41 | * @return 42 | */ 43 | @NonNull public MapzenRouterHttpHandler getRequestHandler() { 44 | return requestHandler; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/test/java/com/mapzen/android/TestHelper.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android; 2 | 3 | import org.powermock.api.mockito.PowerMockito; 4 | 5 | import android.content.Context; 6 | import android.content.res.Resources; 7 | 8 | import static org.mockito.Mockito.mock; 9 | import static org.mockito.Mockito.when; 10 | 11 | public class TestHelper { 12 | public static Context getMockContext() { 13 | final Context context = PowerMockito.mock(Context.class); 14 | when(context.getApplicationContext()).thenReturn(context); 15 | when(context.getResources()).thenReturn(mock(Resources.class)); 16 | return context; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/test/java/com/mapzen/android/routing/RouterInitializerTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.routing; 2 | 3 | import com.mapzen.android.core.MapzenManager; 4 | import com.mapzen.valhalla.Router; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import static com.mapzen.android.TestHelper.getMockContext; 11 | import static org.mockito.Mockito.mock; 12 | import static org.mockito.Mockito.verify; 13 | import static org.mockito.Mockito.when; 14 | 15 | public class RouterInitializerTest { 16 | private RouterInitializer routerInitializer; 17 | private MapzenRouter router; 18 | 19 | @Before public void setUp() throws Exception { 20 | MapzenManager.instance(getMockContext()).setApiKey("api-key"); 21 | routerInitializer = new RouterInitializer(getMockContext()); 22 | router = mock(MapzenRouter.class); 23 | when(router.getRouter()).thenReturn(mock(Router.class)); 24 | } 25 | 26 | @After public void tearDown() throws Exception { 27 | MapzenManager.instance(getMockContext()).setApiKey(null); 28 | } 29 | 30 | @Test public void initRouter_shouldSetHttpHandler() throws Exception { 31 | routerInitializer.initRouter(router); 32 | verify(router.getRouter()).setHttpHandler( 33 | routerInitializer.getRequestHandler().turnByTurnHandler()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /mapzen-android-sdk/src/test/java/com/mapzen/valhalla/TestHttpHandlerHelper.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.valhalla; 2 | 3 | 4 | import okhttp3.logging.HttpLoggingInterceptor; 5 | 6 | /** 7 | * Used to get access to internal variables for 8 | * {@link com.mapzen.android.routing.MapzenRouterHttpHandlerTest}. 9 | */ 10 | public class TestHttpHandlerHelper { 11 | 12 | public static String getEndpoint(HttpHandler httpHandler) { 13 | return httpHandler.endpoint; 14 | } 15 | 16 | public static HttpLoggingInterceptor.Level getLogLevel(HttpHandler httpHandler) { 17 | return httpHandler.logLevel; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mapzen-places-api/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /mapzen-places-api/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_ARTIFACT_ID=mapzen-places-api 2 | POM_NAME=Mapzen Places API 3 | POM_PACKAGING=aar 4 | 5 | GROUP=com.mapzen 6 | POM_DESCRIPTION=Add information about millions of open data locations to your Android app. 7 | -------------------------------------------------------------------------------- /mapzen-places-api/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sarahlensing/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePredictionBuffer.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api; 2 | 3 | import com.mapzen.android.lost.api.Result; 4 | import com.mapzen.android.lost.api.Status; 5 | 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.Nullable; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Represents a list of autocomplete results. 13 | */ 14 | public class AutocompletePredictionBuffer implements Result, DataBuffer { 15 | 16 | private final Status status; 17 | private final List predictions; 18 | 19 | /** 20 | * Constructs a new buffer given a status and list of autocomplete results. 21 | * @param status 22 | * @param predictions 23 | */ 24 | public AutocompletePredictionBuffer(@NonNull Status status, 25 | @Nullable List predictions) { 26 | this.status = status; 27 | this.predictions = predictions; 28 | } 29 | 30 | @NonNull @Override public Status getStatus() { 31 | return status; 32 | } 33 | 34 | @Override public int getCount() { 35 | if (predictions == null) { 36 | return 0; 37 | } 38 | return predictions.size(); 39 | } 40 | 41 | @Nullable @Override public AutocompletePrediction get(int index) { 42 | if (predictions == null || index < 0 || index > predictions.size() - 1) { 43 | return null; 44 | } 45 | return predictions.get(index); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/DataBuffer.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api; 2 | 3 | /** 4 | * Generic interface for representing data contained in a buffer. 5 | * @param 6 | */ 7 | public interface DataBuffer { 8 | /** 9 | * Returns the number of objects in the buffer. 10 | * @return 11 | */ 12 | int getCount(); 13 | 14 | /** 15 | * Returns the object at a given index. 16 | * @param index 17 | * @return 18 | */ 19 | T get(int index); 20 | } 21 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/GeoDataApi.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api; 2 | 3 | import com.mapzen.android.lost.api.LostApiClient; 4 | import com.mapzen.android.lost.api.PendingResult; 5 | 6 | import android.support.annotation.NonNull; 7 | 8 | /** 9 | * Main entry point for the Mapzen Places Geo Data API. 10 | */ 11 | public interface GeoDataApi { 12 | /** 13 | * Returns an object which can be used to retrieve autocomplete results. 14 | * @param client 15 | * @param query 16 | * @param bounds 17 | * @param filter 18 | * @return 19 | */ 20 | @NonNull PendingResult getAutocompletePredictions( 21 | @NonNull LostApiClient client, @NonNull String query, @NonNull LatLngBounds bounds, 22 | @NonNull AutocompleteFilter filter); 23 | } 24 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/Places.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api; 2 | 3 | import com.mapzen.places.api.internal.GeoDataApiImpl; 4 | 5 | import android.support.annotation.NonNull; 6 | 7 | /** 8 | * Main entry point for Mapzen Places API. 9 | */ 10 | public class Places { 11 | @NonNull public static final GeoDataApi GeoDataApi = new GeoDataApiImpl(); 12 | } 13 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/AutocompleteDetailFetchListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.android.lost.api.Status; 4 | import com.mapzen.places.api.Place; 5 | 6 | /** 7 | * Handles notifying the {@link PlaceAutocompleteController} after a place's details have either 8 | * been successfully retrieved or failed to be retrieved. 9 | */ 10 | class AutocompleteDetailFetchListener implements OnPlaceDetailsFetchedListener { 11 | 12 | final PlaceAutocompleteController controller; 13 | 14 | /** 15 | * Construct new {@link AutocompleteDetailFetchListener} and set its controller. 16 | * @param controller 17 | */ 18 | AutocompleteDetailFetchListener(PlaceAutocompleteController controller) { 19 | this.controller = controller; 20 | } 21 | 22 | @Override public void onFetchSuccess(Place place, String details) { 23 | Status status = new Status(Status.SUCCESS); 24 | setResultAndFinish(place, details, status); 25 | } 26 | 27 | @Override public void onFetchFailure() { 28 | Status status = new Status(Status.INTERNAL_ERROR); 29 | setResultAndFinish(null, null, status); 30 | } 31 | 32 | private void setResultAndFinish(Place place, String details, Status status) { 33 | controller.setResult(place, details, status); 34 | controller.finish(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/FilterMapper.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | /** 4 | * Maps internal filter values to external, {@link com.mapzen.places.api.AutocompleteFilter} values. 5 | */ 6 | public interface FilterMapper { 7 | /** 8 | * Given a type filter defined in {@link com.mapzen.places.api.AutocompleteFilter}, return the 9 | * internal filter value so that autocomplete results can be properly limited. 10 | * @param autocompleteFilter 11 | * @return 12 | */ 13 | String getInternalFilter(int autocompleteFilter); 14 | } 15 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/GeoDataApiImpl.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.android.lost.api.LostApiClient; 4 | import com.mapzen.android.lost.api.PendingResult; 5 | import com.mapzen.pelias.Pelias; 6 | import com.mapzen.places.api.AutocompleteFilter; 7 | import com.mapzen.places.api.AutocompletePredictionBuffer; 8 | import com.mapzen.places.api.GeoDataApi; 9 | import com.mapzen.places.api.LatLngBounds; 10 | 11 | /** 12 | * {@link GeoDataApi} implementation for {@link com.mapzen.places.api.Places}. 13 | */ 14 | public class GeoDataApiImpl implements GeoDataApi { 15 | 16 | private Pelias pelias = new Pelias(); 17 | 18 | @Override public PendingResult getAutocompletePredictions( 19 | LostApiClient client, String query, LatLngBounds bounds, AutocompleteFilter filter) { 20 | return new AutocompletePendingResult(pelias, query, bounds, filter); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/OnPlaceDetailsFetchedListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.places.api.Place; 4 | 5 | /** 6 | * Listener that is invoked by {@link PlaceDetailFetcher} when details for a place are retrieved. 7 | */ 8 | interface OnPlaceDetailsFetchedListener { 9 | /** 10 | * Called when details for a place have been fetched. 11 | * @param details 12 | */ 13 | void onFetchSuccess(Place place, String details); 14 | 15 | /** 16 | * Called when details for a place fail to be fetched. 17 | */ 18 | void onFetchFailure(); 19 | } 20 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PeliasLayerConsts.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | /** 4 | * Layers available in the Pelias service. 5 | */ 6 | class PeliasLayerConsts { 7 | static final String PELIAS_LAYER_ADDRESS = "address"; 8 | static final String PELIAS_LAYER_LOCALITY = "locality"; 9 | static final String PELIAS_LAYER_VENUE = "venue"; 10 | static final String PELIAS_LAYER_COARSE = "coarse"; 11 | static final String PELIAS_LAYER_NONE = ""; 12 | static final String PELIAS_LAYER_COUNTRY = "country"; 13 | static final String PELIAS_LAYER_MACRO_COUNTY = "macrocounty"; 14 | static final String PELIAS_LAYER_COUNTY = "county"; 15 | static final String PELIAS_LAYER_LOCAL_ADMIN = "localadmin"; 16 | static final String PELIAS_LAYER_BOROUGH = "borough"; 17 | static final String PELIAS_LAYER_NEIGHBOURHOOD = "neighbourhood"; 18 | static final String PELIAS_LAYER_STREET = "street"; 19 | static final String PELIAS_LAYER_REGION = "region"; 20 | static final String PELIAS_LAYER_MACRO_REGION = "macroregion"; 21 | } 22 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlaceAutocompleteController.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.android.lost.api.Status; 4 | import com.mapzen.places.api.Place; 5 | 6 | /** 7 | * Interface for place autocomplete wrapper Activity. 8 | */ 9 | interface PlaceAutocompleteController { 10 | 11 | /** 12 | * Set result code and data to return to calling activity/fragment. 13 | * @param result Selected{@code Place} object. 14 | * @param status Selection status. 15 | */ 16 | void setResult(Place result, String details, Status status); 17 | 18 | /** 19 | * Finish place autocomplete wrapper activity and return to calling application. 20 | */ 21 | void finish(); 22 | } 23 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlaceDetailFetcher.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Interface for fetching details about a place. 7 | */ 8 | interface PlaceDetailFetcher { 9 | 10 | String PROP_ID = "id"; 11 | String PROP_AREA = "area"; 12 | 13 | String PELIAS_GID_BASE = "openstreetmap:venue:"; 14 | String PELIAS_GID_NODE = "node:"; 15 | String PELIAS_GID_WAY = "way:"; 16 | 17 | /** 18 | * Called when details for a place selected from the map should be retrieved. 19 | * 20 | * @param properties map properties for the given feature. 21 | * @param listener callback to be notified of success or failure. 22 | */ 23 | void fetchDetails(Map properties, OnPlaceDetailsFetchedListener listener); 24 | 25 | /** 26 | * Called when details for a place selected from autocomplete should be retrieved. 27 | * 28 | * @param gid global ID for the given feature 29 | * @param listener callback to be notified of success or failure. 30 | */ 31 | void fetchDetails(String gid, OnPlaceDetailsFetchedListener listener); 32 | } 33 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlaceIntentConsts.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | /** 4 | * Intent constants for {@link com.mapzen.places.api.ui.PlaceAutocomplete} and 5 | * {@link com.mapzen.places.api.ui.PlacePicker} APIs. 6 | */ 7 | public class PlaceIntentConsts { 8 | public static final String EXTRA_PLACE = "extra_place"; 9 | public static final String EXTRA_BOUNDS = "extra_bounds"; 10 | public static final String EXTRA_STATUS = "extra_status"; 11 | public static final String EXTRA_FILTER = "extra_filter"; 12 | public static final String EXTRA_DETAILS = "extra_details"; 13 | public static final String EXTRA_TEXT = "extra_text"; 14 | public static final String EXTRA_MODE = "extra_mode"; 15 | } 16 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlacePickerViewController.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.places.api.Place; 4 | 5 | /** 6 | * Interface for use with the {@link PlacePickerPresenter} and 7 | * {@link PlacePickerActivity}. 8 | */ 9 | interface PlacePickerViewController { 10 | /** 11 | * Show an alert dialog to represent the place selected by the user. 12 | * @param id the selected {@link Place}'s id. 13 | * @param title the dialog title. 14 | */ 15 | void showDialog(String id, String title); 16 | 17 | /** 18 | * Update the visible dialog with more details about the selected place. 19 | * @param id the selected {@link Place}'s id. 20 | * @param message the dialog message. 21 | */ 22 | void updateDialog(String id, String message); 23 | 24 | /** 25 | * When the user has confirmed that they would like to select a place, this method handles 26 | * constructing an intent to pass back to the activity that started the 27 | * {@link PlacePickerActivity}. 28 | */ 29 | void finishWithPlace(Place place); 30 | 31 | /** 32 | * Toggles the connection to the location services layer. Location services should be disabled 33 | * when the place picker is not visible on the screen. 34 | * 35 | * @param enabled {@code true} to enable the location services layer, {@code false} to disable it. 36 | */ 37 | void setMyLocationEnabled(boolean enabled); 38 | } 39 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlaceStore.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.places.api.Place; 4 | 5 | /** 6 | * In-memory store used to persist data for currently selected place. 7 | */ 8 | public class PlaceStore { 9 | private static PlaceStore instance = new PlaceStore(); 10 | 11 | /** 12 | * Return place store singleton instance. 13 | * 14 | * @return the place store instance. 15 | */ 16 | public static PlaceStore instance() { 17 | return instance; 18 | } 19 | 20 | private PlaceStore() { 21 | } 22 | 23 | private Place currentSelectedPlace; 24 | 25 | public Place getCurrentSelectedPlace() { 26 | return currentSelectedPlace; 27 | } 28 | 29 | public void setCurrentSelectedPlace(Place currentSelectedPlace) { 30 | this.currentSelectedPlace = currentSelectedPlace; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlacesBubbleWrapStyle.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.android.graphics.model.BubbleWrapStyle; 4 | 5 | /** 6 | * Style used for place picker UI. Sets highest label level as default label level. 7 | */ 8 | class PlacesBubbleWrapStyle extends BubbleWrapStyle { 9 | 10 | @Override public int getDefaultLabelLevel() { 11 | return 11; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PointToBoundsConverter.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.pelias.BoundingBox; 4 | import com.mapzen.places.api.LatLng; 5 | import com.mapzen.places.api.LatLngBounds; 6 | 7 | /** 8 | * Constructs a {@link LatLngBounds} given a {@link LatLng}. 9 | */ 10 | public class PointToBoundsConverter { 11 | 12 | private static final double BOUNDS_RADIUS = 0.02; 13 | 14 | /** 15 | * Creates a bounding box with reasonable radius from the given point. 16 | * @param point 17 | * @return 18 | */ 19 | public LatLngBounds boundsFromPoint(LatLng point) { 20 | double minLat = point.getLatitude() - BOUNDS_RADIUS; 21 | double minLon = point.getLongitude() - BOUNDS_RADIUS; 22 | double maxLat = point.getLatitude() + BOUNDS_RADIUS; 23 | double maxLon = point.getLongitude() + BOUNDS_RADIUS; 24 | LatLng sw = new LatLng(minLat, minLon); 25 | LatLng ne = new LatLng(maxLat, maxLon); 26 | return new LatLngBounds(sw, ne); 27 | } 28 | 29 | /** 30 | * Creates a bounding box with reasonable radius from the given point information. 31 | * @param latitude 32 | * @param longitude 33 | * @return 34 | */ 35 | public BoundingBox boundingBoxFromPoint(double latitude, double longitude) { 36 | double minLat = latitude - BOUNDS_RADIUS; 37 | double minLon = longitude - BOUNDS_RADIUS; 38 | double maxLat = latitude + BOUNDS_RADIUS; 39 | double maxLon = longitude + BOUNDS_RADIUS; 40 | return new BoundingBox(minLat, minLon, maxLat, maxLon); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceSelectionListener.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.ui; 2 | 3 | import com.mapzen.android.lost.api.Status; 4 | import com.mapzen.places.api.Place; 5 | 6 | import android.support.annotation.NonNull; 7 | 8 | /** 9 | * Interface for receiving information about a {@link Place} after it is selected from a 10 | * {@link PlaceAutocompleteFragment}. 11 | */ 12 | public interface PlaceSelectionListener { 13 | 14 | /** 15 | * Called when the user selects a {@link Place}. 16 | * @param place 17 | */ 18 | void onPlaceSelected(@NonNull Place place); 19 | 20 | /** 21 | * Called when an error occurs while trying to select a {@link Place}. 22 | * @param status 23 | */ 24 | void onError(@NonNull Status status); 25 | } 26 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-hdpi-v4/places_ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-hdpi-v4/places_ic_clear.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-hdpi-v4/places_ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-hdpi-v4/places_ic_search.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-mdpi-v4/places_ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-mdpi-v4/places_ic_clear.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-mdpi-v4/places_ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-mdpi-v4/places_ic_search.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-xhdpi-v4/places_ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-xhdpi-v4/places_ic_clear.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-xhdpi-v4/places_ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-xhdpi-v4/places_ic_search.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-xxhdpi-v4/places_ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-xxhdpi-v4/places_ic_clear.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-xxhdpi-v4/places_ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-xxhdpi-v4/places_ic_search.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-xxxhdpi-v4/places_ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-xxxhdpi-v4/places_ic_clear.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/drawable-xxxhdpi-v4/places_ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapzen/android/0cbf18945cdb03cad5859fc9cff4804333ac29bb/mapzen-places-api/src/main/res/drawable-xxxhdpi-v4/places_ic_search.png -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/layout/place_autcomplete_activity_fullscreen.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/layout/place_autocomplete_activity_overlay.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 21 | 22 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/layout/place_autocomplete_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/layout/place_fragment_map.xml: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/layout/place_picker_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #212121 4 | #757575 5 | #757575 6 | #BDBDBD 7 | #212121 8 | #1F000000 9 | 10 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 5 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | mapzen-places-api 3 | Use this place? 4 | Change Location 5 | Select 6 | Clear search 7 | Search 8 | 9 | -------------------------------------------------------------------------------- /mapzen-places-api/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 15 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/android/lost/internal/FusedApiServiceUpdater.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.lost.internal; 2 | 3 | /** 4 | * Created by sarahlensing on 5/11/17. 5 | */ 6 | 7 | public class FusedApiServiceUpdater { 8 | 9 | public static void updateApiService(FusedLocationProviderApiImpl api, 10 | IFusedLocationProviderService service) { 11 | api.service = service; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/AutocompletePredictionTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | 6 | import static org.assertj.core.api.Assertions.assertThat; 7 | 8 | public class AutocompletePredictionTest { 9 | 10 | AutocompletePrediction prediction; 11 | String id = "abc123"; 12 | String primaryText = "Roberta's Pizza"; 13 | 14 | @Before public void setup() { 15 | prediction = new AutocompletePrediction(id, primaryText); 16 | } 17 | 18 | @Test(expected = RuntimeException.class) 19 | public void getFullText_shouldThrowException() { 20 | prediction.getFullText(null); 21 | } 22 | 23 | @Test public void getPrimaryText_shouldReturnCorrectText() { 24 | CharSequence text = prediction.getPrimaryText(null); 25 | assertThat(text.toString()).isEqualTo(primaryText); 26 | } 27 | 28 | @Test(expected = RuntimeException.class) 29 | public void getSecondaryText_shouldThrowException() { 30 | prediction.getSecondaryText(null); 31 | } 32 | 33 | @Test public void getPlaceId_shouldReturnCorrectId() { 34 | String placeId = prediction.getPlaceId(); 35 | assertThat(placeId).isEqualTo(id); 36 | } 37 | 38 | @Test(expected = RuntimeException.class) 39 | public void getPlaceTypes_shouldThrowException() { 40 | prediction.getPlaceTypes(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/LatLngTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | public class LatLngTest { 8 | 9 | LatLng latLng = new LatLng(40, 70); 10 | 11 | @Test public void shouldSetLat() { 12 | assertThat(latLng.getLatitude()).isEqualTo(40); 13 | } 14 | 15 | @Test public void shouldSetLng() { 16 | assertThat(latLng.getLongitude()).isEqualTo(70); 17 | } 18 | 19 | @Test public void shouldSetMinLat() { 20 | LatLng minLat = new LatLng(-100, 70); 21 | assertThat(minLat.getLatitude()).isEqualTo(-90); 22 | } 23 | 24 | @Test public void shouldSetMaxLat() { 25 | LatLng maxLat = new LatLng(100, 70); 26 | assertThat(maxLat.getLatitude()).isEqualTo(90); 27 | } 28 | 29 | @Test public void shouldSetLng_160() { 30 | LatLng minLng = new LatLng(40, -200); 31 | assertThat(minLng.getLongitude()).isEqualTo(160); 32 | } 33 | 34 | @Test public void shouldSetLng_neg160() { 35 | LatLng maxLng = new LatLng(40, 200); 36 | assertThat(maxLng.getLongitude()).isEqualTo(-160); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/internal/GeoDataApiImplTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.android.lost.api.PendingResult; 4 | import com.mapzen.places.api.AutocompletePredictionBuffer; 5 | 6 | import org.junit.Test; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | public class GeoDataApiImplTest { 11 | 12 | GeoDataApiImpl geoDataApi = new GeoDataApiImpl(); 13 | 14 | @Test public void getAutocompletePredictions_shouldReturnAutocompletePendingResult() { 15 | PendingResult result = 16 | geoDataApi.getAutocompletePredictions(null, null, null, null); 17 | assertThat(result).isInstanceOf(AutocompletePendingResult.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/internal/PlacesBubbleWrapStyleTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | public class PlacesBubbleWrapStyleTest { 8 | 9 | PlacesBubbleWrapStyle bubbleWrap = new PlacesBubbleWrapStyle(); 10 | 11 | @Test public void shouldReturnCorrectLabelLevel() throws Exception { 12 | assertThat(bubbleWrap.getDefaultLabelLevel()).isEqualTo(11); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/internal/PlacesTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.places.api.Places; 4 | 5 | import org.junit.Test; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | 9 | public class PlacesTest { 10 | 11 | @Test public void geoDataApiShouldNotBeNull() { 12 | assertThat(Places.GeoDataApi).isNotNull(); 13 | } 14 | 15 | @Test public void geoDataApiShouldBeOfCorrectClass() { 16 | assertThat(Places.GeoDataApi).isInstanceOf(GeoDataApiImpl.class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/internal/PointToBoundsConverterTest.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.pelias.BoundingBox; 4 | import com.mapzen.places.api.LatLng; 5 | import com.mapzen.places.api.LatLngBounds; 6 | 7 | import org.junit.Test; 8 | 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | 11 | public class PointToBoundsConverterTest { 12 | 13 | private PointToBoundsConverter pointConverter = new PointToBoundsConverter(); 14 | 15 | @Test public void boundsFromPoint_shouldCreateCorrectBounds() throws Exception { 16 | LatLng point = new LatLng(40.0, 70.0); 17 | LatLngBounds bounds = pointConverter.boundsFromPoint(point); 18 | assertThat(bounds.getCenter().getLatitude()).isEqualTo(40.0); 19 | assertThat(bounds.getCenter().getLongitude()).isEqualTo(70.0); 20 | assertThat(bounds.getSouthwest().getLatitude()).isEqualTo(39.98); 21 | assertThat(bounds.getSouthwest().getLongitude()).isEqualTo(69.98); 22 | assertThat(bounds.getNortheast().getLatitude()).isEqualTo(40.02); 23 | assertThat(bounds.getNortheast().getLongitude()).isEqualTo(70.02); 24 | } 25 | 26 | @Test public void boundingBoxFromPoint_shouldCreateCorrectBounds() throws Exception { 27 | BoundingBox bounds = pointConverter.boundingBoxFromPoint(40.0, 70.0); 28 | assertThat(bounds.getMinLat()).isEqualTo(39.98); 29 | assertThat(bounds.getMinLon()).isEqualTo(69.98); 30 | assertThat(bounds.getMaxLat()).isEqualTo(40.02); 31 | assertThat(bounds.getMaxLon()).isEqualTo(70.02); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/internal/TestPlaceDetailFetcher.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import java.util.Map; 4 | 5 | 6 | class TestPlaceDetailFetcher implements PlaceDetailFetcher { 7 | 8 | @Override public void fetchDetails(Map properties, 9 | OnPlaceDetailsFetchedListener listener) { 10 | } 11 | 12 | @Override public void fetchDetails(String gid, OnPlaceDetailsFetchedListener listener) { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mapzen-places-api/src/test/java/com/mapzen/places/api/internal/TestPlacePickerController.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.places.api.internal; 2 | 3 | import com.mapzen.places.api.Place; 4 | 5 | class TestPlacePickerController implements PlacePickerViewController { 6 | 7 | boolean dialogShown = false; 8 | String dialogTitle = null; 9 | boolean finished = false; 10 | boolean myLocationEnabled = false; 11 | Place place = null; 12 | 13 | @Override public void showDialog(String id, String title) { 14 | dialogShown = true; 15 | dialogTitle = title; 16 | } 17 | 18 | @Override public void updateDialog(String id, String message) { 19 | 20 | } 21 | 22 | @Override public void finishWithPlace(Place place) { 23 | this.place = place; 24 | finished = true; 25 | } 26 | 27 | @Override public void setMyLocationEnabled(boolean enabled) { 28 | myLocationEnabled = enabled; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/README.md: -------------------------------------------------------------------------------- 1 | # Mapzen Android SDK Sample Application 2 | 3 | The Mapzen Android SDK sample application provides working examples of many features of the SDK including map rendering, search, routing, and location services. 4 | 5 | ## Get a Mapzen API key 6 | Before using the sample app, sign up for a Mapzen API key on the [Mapzen developer portal](https://mapzen.com/developers). 7 | 8 | ## Add your Mapzen API key to mapzen.xml 9 | Add your Mapzen API key to the sample app by replacing the dummy text value of `mapzen_api_key` with your API key in [mapzen.xml](https://github.com/mapzen/android/blob/master/samples/mapzen-android-sdk-sample/src/main/res/values/mapzen.xml). 10 | 11 | ```xml 12 | 13 | 14 | [YOUR_MAPZEN_API_KEY] 15 | 16 | ``` 17 | 18 | ## Build and install 19 | 20 | Run the following commands from the root folder of the project to build and install the app. 21 | 22 | ```bash 23 | git submodule update --init --recursive 24 | ./gradlew installSdkDemo 25 | ``` 26 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'checkstyle' 3 | 4 | def MAPZEN_API_KEY = hasProperty('mapzenApiKey') ? '"' + mapzenApiKey + '"' : "null"; 5 | 6 | android { 7 | compileSdkVersion 26 8 | buildToolsVersion '26.0.2' 9 | 10 | defaultConfig { 11 | applicationId "com.mapzen.android.sdk.sample" 12 | minSdkVersion 15 13 | targetSdkVersion 26 14 | versionCode 1 15 | versionName "1.0" 16 | buildConfigField "String", "MAPZEN_API_KEY", MAPZEN_API_KEY 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | lintOptions { 26 | abortOnError false 27 | } 28 | } 29 | 30 | task checkstyle(type: Checkstyle) { 31 | configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") 32 | source 'src' 33 | include '**/*.java' 34 | exclude '**/gen/**' 35 | 36 | classpath = files() 37 | } 38 | 39 | dependencies { 40 | implementation(project(':mapzen-android-sdk')) 41 | implementation(project(':tron')) 42 | implementation 'com.android.support:appcompat-v7:26.1.0' 43 | implementation 'com.android.support:design:26.1.0' 44 | } 45 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /opt/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/BaseDemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.sdk.sample; 2 | 3 | import com.mapzen.android.core.MapzenManager; 4 | 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v7.app.AppCompatActivity; 8 | 9 | /** 10 | * Base demo activity that sets Mapzen API key if provided via Gradle properties. 11 | */ 12 | public class BaseDemoActivity extends AppCompatActivity { 13 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 14 | if (BuildConfig.MAPZEN_API_KEY != null && 15 | !BuildConfig.MAPZEN_API_KEY.equals(MapzenManager.API_KEY_DEFAULT_VALUE)) { 16 | MapzenManager.instance(this).setApiKey(BuildConfig.MAPZEN_API_KEY); 17 | } 18 | 19 | super.onCreate(savedInstanceState); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/CustomStylesheetActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.sdk.sample; 2 | 3 | import com.mapzen.android.graphics.MapFragment; 4 | import com.mapzen.android.graphics.MapzenMap; 5 | import com.mapzen.android.graphics.OnMapReadyCallback; 6 | import com.mapzen.android.graphics.model.MapStyle; 7 | import com.mapzen.android.graphics.model.TronStyle; 8 | 9 | import android.os.Bundle; 10 | 11 | /** 12 | * Demonstrates how to set a custom stylesheet. 13 | */ 14 | public class CustomStylesheetActivity extends BaseDemoActivity { 15 | 16 | public static final MapStyle TRON_STYLE = new TronStyle(); 17 | 18 | @Override protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_sample_mapzen); 21 | 22 | final MapFragment mapFragment = 23 | (MapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment); 24 | 25 | final Bundle state = savedInstanceState; 26 | mapFragment.getMapAsync(TRON_STYLE, new OnMapReadyCallback() { 27 | @Override public void onMapReady(MapzenMap map) { 28 | if (state == null) { 29 | map.setStyle(TRON_STYLE); 30 | } 31 | map.setPersistMapState(true); 32 | } 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/SampleDetails.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.android.sdk.sample; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | 5 | /** 6 | * Data object for representing an SDK demo. 7 | */ 8 | public class SampleDetails { 9 | 10 | private final int titleId; 11 | 12 | private final int detailId; 13 | 14 | private final Class activityClass; 15 | 16 | /** 17 | * Create object to represent a demoable component of the sdk. 18 | * 19 | * @param titleId title of demo 20 | * @param detailId details about demo 21 | * @param activityClass activity to launch when this list item is clicked 22 | */ 23 | public SampleDetails(int titleId, int detailId, Class activityClass) { 24 | this.titleId = titleId; 25 | this.detailId = detailId; 26 | this.activityClass = activityClass; 27 | } 28 | 29 | /** 30 | * Resource id for title string. 31 | */ 32 | public int getTitleId() { 33 | return titleId; 34 | } 35 | 36 | /** 37 | * Resource id for detail string. 38 | */ 39 | public int getDetailId() { 40 | return detailId; 41 | } 42 | 43 | /** 44 | * Activity class to launch when this demo item is selected from list. 45 | */ 46 | public Class getActivityClass() { 47 | return activityClass; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /samples/mapzen-android-sdk-sample/src/main/res/layout/activity_clear_btn.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | 16 |