forked from upstream-mirrors/OpenTracks
Use a location image button on the map view to show current location.
This commit is contained in:
@@ -237,9 +237,7 @@ public class TrackDetailActivity extends AbstractMyTracksActivity
|
||||
menu.findItem(R.id.track_detail_chart_settings).setVisible(
|
||||
ChartFragment.CHART_FRAGMENT_TAG.equals(currentTabTag));
|
||||
menu.findItem(R.id.track_detail_stats_settings).setVisible(
|
||||
StatsFragment.STATS_FRAGMENT_TAG.equals(currentTabTag));
|
||||
menu.findItem(R.id.track_detail_my_location)
|
||||
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag));
|
||||
StatsFragment.STATS_FRAGMENT_TAG.equals(currentTabTag));
|
||||
MenuItem satelliteMode = menu.findItem(R.id.track_detail_satellite_mode)
|
||||
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag));
|
||||
|
||||
@@ -343,13 +341,6 @@ public class TrackDetailActivity extends AbstractMyTracksActivity
|
||||
DeleteOneTrackDialogFragment.newInstance(trackId).show(
|
||||
getSupportFragmentManager(), DeleteOneTrackDialogFragment.DELETE_ONE_TRACK_DIALOG_TAG);
|
||||
return true;
|
||||
case R.id.track_detail_my_location:
|
||||
mapFragment = (MapFragment) getSupportFragmentManager()
|
||||
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
|
||||
if (mapFragment != null) {
|
||||
mapFragment.showMyLocation();
|
||||
}
|
||||
return true;
|
||||
case R.id.track_detail_satellite_mode:
|
||||
mapFragment = (MapFragment) getSupportFragmentManager()
|
||||
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -86,6 +87,7 @@ public class MapFragment extends Fragment
|
||||
private View mapViewContainer;
|
||||
private MapOverlay mapOverlay;
|
||||
private MapView mapView;
|
||||
private ImageButton myLocationImageButton;
|
||||
private TextView messageTextView;
|
||||
|
||||
@Override
|
||||
@@ -100,6 +102,13 @@ public class MapFragment extends Fragment
|
||||
mapView.setOnTouchListener(this);
|
||||
mapView.setBuiltInZoomControls(true);
|
||||
mapView.getOverlays().add(mapOverlay);
|
||||
myLocationImageButton = (ImageButton) mapViewContainer.findViewById(R.id.map_my_location);
|
||||
myLocationImageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showMyLocation();
|
||||
}
|
||||
});
|
||||
messageTextView = (TextView) mapViewContainer.findViewById(R.id.map_message);
|
||||
|
||||
return mapViewContainer;
|
||||
@@ -150,7 +159,7 @@ public class MapFragment extends Fragment
|
||||
/**
|
||||
* Shows my location.
|
||||
*/
|
||||
public void showMyLocation() {
|
||||
private void showMyLocation() {
|
||||
updateTrackDataHub();
|
||||
keepMyLocationVisible = true;
|
||||
zoomToMyLocation = true;
|
||||
|
||||
Reference in New Issue
Block a user