Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] #3270 - add sample activity for animated coordinate change #3271

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<activity
android:name=".PolylineActivity"
android:label="@string/activity_polyline" />
<activity
android:name=".CoordinateChangeActivity"
android:label="@string/activity_animate_coordinate_change" />

<meta-data
android:name="io.fabric.ApiKey"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.mapbox.mapboxsdk.testapp;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;

public class CoordinateChangeActivity extends AppCompatActivity {

private MapView mMapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animate_coordinate);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}

mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setTag(true);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mMapView.setStyle(Style.MAPBOX_STREETS);
mMapView.setCenterCoordinate(new LatLngZoom(38.87031, -77.00897, 16));
mMapView.setCompassEnabled(false);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mMapView.setCenterCoordinate(getCoordinate(), true);
}
});
}

private LatLng getCoordinate() {
boolean first = (boolean) mMapView.getTag();
mMapView.setTag(!first);
return first ? new LatLng(38.87000, -77.00800) : new LatLng(38.87031, -77.00897);
}

@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}

@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}

@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}

@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}

@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}

@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
startActivity(new Intent(getApplicationContext(), ManualZoomActivity.class));
return true;

case R.id.action_coordinate_change:
startActivity(new Intent(getApplicationContext(), CoordinateChangeActivity.class));
return true;

case R.id.action_bulk_markers:
startActivity(new Intent(getApplicationContext(), BulkMarkerActivity.class));
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M17,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6 6,-2.69 6,-6 -2.69,-6 -6,-6zM5,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zm0,6c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M3,5H1v16c0,1.1 0.9,2 2,2h16v-2H3V5zm18,-4H7c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-2 -2,-2zm0,16H7V3h14v14z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M7.77,6.76L6.23,5.48 0.82,12l5.41,6.52 1.54,-1.28L3.42,12l4.35,-5.24zM7,13h2v-2H7v2zm10,-2h-2v2h2v-2zm-6,2h2v-2h-2v2zm6.77,-7.52l-1.54,1.28L20.58,12l-4.35,5.24 1.54,1.28L23.18,12l-5.41,-6.52z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">

<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_animate_coordinates"
app:backgroundTint="@color/white" />

</android.support.design.widget.CoordinatorLayout>

</FrameLayout>

</RelativeLayout>


Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<item
android:id="@+id/action_tilt"
android:checkable="false"
android:icon="@drawable/ic_flip_to_back_24dp"
android:icon="@drawable/ic_tilt"
android:title="@string/action_tilt" />

<item
Expand All @@ -87,13 +87,13 @@
<item
android:id="@+id/action_info_window_concurrent"
android:checkable="false"
android:icon="@drawable/ic_flip_to_front_24dp"
android:icon="@drawable/ic_flip_to_back_24dp"
android:title="@string/action_info_window_concurrent" />

<item
android:id="@+id/action_info_window_adapter"
android:checkable="false"
android:icon="@drawable/ic_flip_to_back_24dp"
android:icon="@drawable/ic_infowindow_adapter"
android:title="@string/action_info_window_adapter" />

<item
Expand All @@ -108,6 +108,12 @@
android:icon="@drawable/ic_filter_center_focus_24dp"
android:title="@string/action_manual_zoom" />

<item
android:id="@+id/action_coordinate_change"
android:checkable="false"
android:icon="@drawable/ic_animate_coordinates"
android:title="@string/action_animate_coordinate_change" />

<item
android:id="@+id/action_visible_bounds"
android:checkable="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<string name="activity_visible_coordinate_bounds">Visible Coordinate Bounds</string>
<string name="activity_user_tracking_mode">User tracking mode</string>
<string name="activity_polyline">Polyline Activity</string>
<string name="activity_animate_coordinate_change">Animate Coordinate Change</string>

<string name="navdrawer_menu_title_mainactivity_controls">Main Activity Controls</string>
<string name="navdrawer_menu_title_mainactivity_styles">Main Activity Styles</string>
Expand All @@ -30,6 +31,7 @@
<string name="action_press_for_marker">Press For Marker</string>
<string name="action_manual_zoom">Manual Zoom</string>
<string name="action_info_window">InfoWindow</string>
<string name="action_animate_coordinate_change">Animate Coordinate Change</string>
<string name="action_info_window_concurrent">InfoWindow (Concurrent)</string>
<string name="action_add_bulk_markers">Add Markers in bulk</string>
<string name="action_visible_bounds">Set Visible Bounds</string>
Expand Down