Use a location image button on the map view to show current location.

This commit is contained in:
Jimmy Shih
2012-04-30 15:56:07 -07:00
parent 39a3fb6132
commit 5ed3968771
15 changed files with 47 additions and 19 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/my_location_pressed" />
<item android:drawable="@drawable/my_location_normal" />
</selector>
+10
View File
@@ -26,6 +26,16 @@ limitations under the License.
android:id="@+id/map_view"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
<ImageButton
android:background="@drawable/my_location"
android:contentDescription="@string/my_location"
android:id="@+id/map_my_location"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_width="wrap_content" />
<TextView
android:background="@color/warning_background"
android:drawableLeft="@android:drawable/ic_dialog_alert"
-4
View File
@@ -76,10 +76,6 @@ limitations under the License.
android:icon="@drawable/menu_delete"
android:id="@+id/track_detail_delete"
android:title="@string/menu_delete"/>
<item
android:icon="@drawable/menu_my_location"
android:id="@+id/track_detail_my_location"
android:title="@string/menu_my_location"/>
<item
android:icon="@drawable/menu_satellite_mode"
android:id="@+id/track_detail_satellite_mode"
+5 -4
View File
@@ -1070,10 +1070,6 @@ limitations under the License.
translation_description="In the menu, to show a list of markers for the current track.">
Markers
</string>
<string name="menu_my_location"
translation_description="In the menu, to display the user's current location.">
My location
</string>
<string name="menu_play"
translation_description="In the menu, to play a track.">
Play
@@ -1155,6 +1151,11 @@ limitations under the License.
</string>
<!-- My Location -->
<string name="my_location"
translation_description="The accessibility description for the My Location button on the map
view.">
My Location
</string>
<string name="my_location_approximate_location"
translation_description="When displaying the user's current location, a status message
indicating that GPS is not available and an approximate location is used instead.">
@@ -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;