- add compass
- add 'fix orientation' option - bugfix segv in limitLoadQueue - remove redundant MapController - refactor out Location stuff from TileMap
This commit is contained in:
parent
baa40ed9ea
commit
53636cff30
@ -3,25 +3,24 @@
|
|||||||
android:id="@+id/mainView"
|
android:id="@+id/mainView"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:windowActionBarOverlay="true"
|
android:windowActionBarOverlay="true" >
|
||||||
>
|
|
||||||
|
|
||||||
<org.mapsforge.android.MapView
|
<org.mapsforge.android.MapView
|
||||||
android:id="@+id/mapView"
|
android:id="@+id/mapView"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent" />
|
android:layout_height="fill_parent" />
|
||||||
|
|
||||||
<!-- <ToggleButton
|
<ToggleButton
|
||||||
android:id="@+id/snapToLocationView"
|
android:id="@+id/snapToLocationView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginRight="10dip"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginBottom="10dip"
|
android:layout_marginBottom="10dip"
|
||||||
|
android:layout_marginRight="10dip"
|
||||||
android:background="@drawable/snap_to_position"
|
android:background="@drawable/snap_to_position"
|
||||||
android:textOff=""
|
android:textOff=""
|
||||||
android:textOn=""
|
android:textOn=""
|
||||||
android:visibility="gone" />-->
|
android:visibility="gone" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
@ -22,10 +22,18 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/menu_position_map_center"
|
android:id="@+id/menu_position_map_center"
|
||||||
android:title="@string/menu_position_map_file_center"/>
|
android:title="@string/menu_position_map_file_center"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_rotation_enable"
|
android:id="@+id/menu_rotation_enable"
|
||||||
android:title="@string/menu_rotation_enable"/>
|
android:title="@string/menu_rotation_enable"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_rotation_disable"
|
||||||
|
android:title="@string/menu_rotation_disable"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_compass_enable"
|
||||||
|
android:title="@string/menu_compass_enable"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_compass_disable"
|
||||||
|
android:title="@string/menu_compass_disable"/>
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
|
|||||||
@ -1,108 +1,114 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string-array name="preferences_map_generator_values">
|
|
||||||
<!-- <item>Mapfile</item> -->
|
|
||||||
<!-- <item>PostGIS</item>-->
|
|
||||||
<item>OpenScienceMap</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="preferences_scale_bar_unit_values">
|
<string-array name="preferences_map_generator_values">
|
||||||
<item>Imperial</item>
|
|
||||||
<item>Metric</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="preferences_text_scale_values">
|
<!-- <item>Mapfile</item> -->
|
||||||
<item>tiny</item>
|
<!-- <item>PostGIS</item> -->
|
||||||
<item>small</item>
|
<item>OpenScienceMap</item>
|
||||||
<item>normal</item>
|
</string-array>
|
||||||
<item>large</item>
|
<string-array name="preferences_scale_bar_unit_values">
|
||||||
<item>huge</item>
|
<item>Imperial</item>
|
||||||
</string-array>
|
<item>Metric</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="preferences_text_scale_values">
|
||||||
|
<item>tiny</item>
|
||||||
|
<item>small</item>
|
||||||
|
<item>normal</item>
|
||||||
|
<item>large</item>
|
||||||
|
<item>huge</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string name="application_name">OpenScienceMap</string>
|
||||||
|
<string name="cancel">Cancel</string>
|
||||||
|
<string name="error">Error</string>
|
||||||
|
<string name="error_last_location_unknown">The last location is unknown</string>
|
||||||
|
<string name="file_invalid">The selected file is invalid.</string>
|
||||||
|
<string name="file_select">Please select a file.</string>
|
||||||
|
<string name="file_size_byte">byte</string>
|
||||||
|
<string name="file_size_bytes">bytes</string>
|
||||||
|
<string name="file_size_kb">kB</string>
|
||||||
|
<string name="file_size_mb">MB</string>
|
||||||
|
<string name="file_size_gb">GB</string>
|
||||||
|
<string name="go_to_position">Go to position</string>
|
||||||
|
<string name="info_map_file_area">Area</string>
|
||||||
|
<string name="info_map_file_comment">Comment</string>
|
||||||
|
<string name="info_map_file_created_by">Created by</string>
|
||||||
|
<string name="info_map_file_date">Date</string>
|
||||||
|
<string name="info_map_file_debug">Debug information</string>
|
||||||
|
<string name="info_map_file_debug_no">not included</string>
|
||||||
|
<string name="info_map_file_debug_yes">included</string>
|
||||||
|
<string name="info_map_file_language_preference">Language preference</string>
|
||||||
|
<string name="info_map_file_name">File</string>
|
||||||
|
<string name="info_map_file_size">File size</string>
|
||||||
|
<string name="info_map_file_start_position">Start position</string>
|
||||||
|
<string name="info_map_file_start_zoom_level">Start zoom level</string>
|
||||||
|
<string name="info_map_file_version">Version</string>
|
||||||
|
<string name="latitude">Latitude</string>
|
||||||
|
<string name="longitude">Longitude</string>
|
||||||
|
<string name="menu_info">Info</string>
|
||||||
|
<string name="menu_info_map_file">Map file properties</string>
|
||||||
|
<string name="menu_info_about">About this software</string>
|
||||||
|
<string name="menu_mapfile">Map file</string>
|
||||||
|
<string name="menu_position">Position</string>
|
||||||
|
<string name="menu_rotation_enable">Enable rotation</string>
|
||||||
|
<string name="menu_compass_enable">Enable compass</string>
|
||||||
|
<string name="menu_rotation_disable">Disable rotation</string>
|
||||||
|
<string name="menu_compass_disable">Disable compass</string>
|
||||||
|
<string name="menu_position_enter_coordinates">Enter coordinates</string>
|
||||||
|
<string name="menu_position_last_known">Last known location</string>
|
||||||
|
<string name="menu_position_map_file_center">Map file center</string>
|
||||||
|
<string name="menu_position_my_location_enable">Show my location</string>
|
||||||
|
<string name="menu_position_my_location_disable">Remove my location</string>
|
||||||
|
<string name="menu_preferences">Preferences</string>
|
||||||
|
<string name="menu_render_theme">Render theme</string>
|
||||||
|
<string name="menu_render_theme_osmarender">Default Theme</string>
|
||||||
|
<string name="menu_render_theme_tronrender">Tube Theme</string>
|
||||||
|
<string name="menu_render_theme_select_file">Select XML file …</string>
|
||||||
|
<string name="menu_screenshot">Screenshot</string>
|
||||||
|
<string name="menu_screenshot_jpeg">JPEG (lossy)</string>
|
||||||
|
<string name="menu_screenshot_png">PNG (lossless)</string>
|
||||||
|
<string name="no_location_provider_available">No location source available</string>
|
||||||
|
<string name="ok">OK</string>
|
||||||
|
<string name="preferences_debug">Debug settings</string>
|
||||||
|
<string name="preferences_general">General settings</string>
|
||||||
|
<string name="preferences_cache_persistence">Cache persistence</string>
|
||||||
|
<string name="preferences_cache_persistence_desc">Keep cached images on exit</string>
|
||||||
|
<string name="preferences_cache_size">External storage</string>
|
||||||
|
<string name="preferences_cache_size_desc">Adjust the size of the cache</string>
|
||||||
|
<string name="preferences_cache_size_value">%.1f MB</string>
|
||||||
|
<string name="preferences_fullscreen">Full screen mode</string>
|
||||||
|
<string name="preferences_fullscreen_desc">Hide the status bar</string>
|
||||||
|
<string name="preferences_fix_orientation">Fix screen orientation</string>
|
||||||
|
<string name="preferences_fix_orientation_desc">Fix screen orientation</string>
|
||||||
|
<string name="preferences_map">Map settings</string>
|
||||||
|
<string name="preferences_map_view_mode">Map mode</string>
|
||||||
|
<string name="preferences_map_view_mode_desc">Select the operating mode</string>
|
||||||
|
<string name="preferences_move_speed">Move speed</string>
|
||||||
|
<string name="preferences_move_speed_desc">Adjust the move speed of the map</string>
|
||||||
|
<string name="preferences_move_speed_value">%d %% move speed</string>
|
||||||
|
<string name="preferences_scale_bar_unit">Scale bar unit</string>
|
||||||
|
<string name="preferences_scale_bar_unit_desc">Select the unit for the map scale bar</string>
|
||||||
|
<string name="preferences_show_fps_counter">Frame rate</string>
|
||||||
|
<string name="preferences_show_fps_counter_desc">Enable frames per second counter</string>
|
||||||
|
<string name="preferences_show_scale_bar">Map scale bar</string>
|
||||||
|
<string name="preferences_show_scale_bar_desc">Show the scale of the map</string>
|
||||||
|
<string name="preferences_show_tile_coordinates">Tile coordinates</string>
|
||||||
|
<string name="preferences_show_tile_coordinates_desc">Show coordinates on tiles</string>
|
||||||
|
<string name="preferences_show_unmatched_ways">Draw unmatched ways</string>
|
||||||
|
<string name="preferences_show_tile_frames">Tile boundaries</string>
|
||||||
|
<string name="preferences_show_tile_frames_desc">Draw tile boundaries</string>
|
||||||
|
<string name="preferences_disable_polygons">Disable Polygon rendering</string>
|
||||||
|
<string name="preferences_show_water_tiles_desc">Highlight tiles which have the water flag set</string>
|
||||||
|
<string name="preferences_text_scale">Font size</string>
|
||||||
|
<string name="preferences_text_scale_desc">Select the text size of map labels</string>
|
||||||
|
<string name="preferences_wake_lock">Stay awake</string>
|
||||||
|
<string name="preferences_wake_lock_desc">Stop the screen from dimming</string>
|
||||||
|
<string name="snap_to_location_enabled">Snap to position is activated</string>
|
||||||
|
<string name="snap_to_location_disabled">Snap to position is disabled</string>
|
||||||
|
<string name="unit_symbol_kilometer"> km</string>
|
||||||
|
<string name="unit_symbol_meter"> m</string>
|
||||||
|
<string name="zoomLevel">Zoom level</string>
|
||||||
|
<string name="menu_options">Options</string>
|
||||||
|
|
||||||
<string name="application_name">OpenScienceMap</string>
|
|
||||||
<string name="cancel">Cancel</string>
|
|
||||||
<string name="error">Error</string>
|
|
||||||
<string name="error_last_location_unknown">The last location is unknown</string>
|
|
||||||
<string name="file_invalid">The selected file is invalid.</string>
|
|
||||||
<string name="file_select">Please select a file.</string>
|
|
||||||
<string name="file_size_byte">byte</string>
|
|
||||||
<string name="file_size_bytes">bytes</string>
|
|
||||||
<string name="file_size_kb">kB</string>
|
|
||||||
<string name="file_size_mb">MB</string>
|
|
||||||
<string name="file_size_gb">GB</string>
|
|
||||||
<string name="go_to_position">Go to position</string>
|
|
||||||
<string name="info_map_file_area">Area</string>
|
|
||||||
<string name="info_map_file_comment">Comment</string>
|
|
||||||
<string name="info_map_file_created_by">Created by</string>
|
|
||||||
<string name="info_map_file_date">Date</string>
|
|
||||||
<string name="info_map_file_debug">Debug information</string>
|
|
||||||
<string name="info_map_file_debug_no">not included</string>
|
|
||||||
<string name="info_map_file_debug_yes">included</string>
|
|
||||||
<string name="info_map_file_language_preference">Language preference</string>
|
|
||||||
<string name="info_map_file_name">File</string>
|
|
||||||
<string name="info_map_file_size">File size</string>
|
|
||||||
<string name="info_map_file_start_position">Start position</string>
|
|
||||||
<string name="info_map_file_start_zoom_level">Start zoom level</string>
|
|
||||||
<string name="info_map_file_version">Version</string>
|
|
||||||
<string name="latitude">Latitude</string>
|
|
||||||
<string name="longitude">Longitude</string>
|
|
||||||
<string name="menu_info">Info</string>
|
|
||||||
<string name="menu_info_map_file">Map file properties</string>
|
|
||||||
<string name="menu_info_about">About this software</string>
|
|
||||||
<string name="menu_mapfile">Map file</string>
|
|
||||||
<string name="menu_position">Position</string>
|
|
||||||
<string name="menu_rotation_enable">Enable rotation</string>
|
|
||||||
<string name="menu_position_enter_coordinates">Enter coordinates</string>
|
|
||||||
<string name="menu_position_last_known">Last known location</string>
|
|
||||||
<string name="menu_position_map_file_center">Map file center</string>
|
|
||||||
<string name="menu_position_my_location_enable">Show my location</string>
|
|
||||||
<string name="menu_position_my_location_disable">Remove my location</string>
|
|
||||||
<string name="menu_preferences">Preferences</string>
|
|
||||||
<string name="menu_render_theme">Render theme</string>
|
|
||||||
<string name="menu_render_theme_osmarender">Default Theme</string>
|
|
||||||
<string name="menu_render_theme_tronrender">Tube Theme</string>
|
|
||||||
<string name="menu_render_theme_select_file">Select XML file …</string>
|
|
||||||
<string name="menu_screenshot">Screenshot</string>
|
|
||||||
<string name="menu_screenshot_jpeg">JPEG (lossy)</string>
|
|
||||||
<string name="menu_screenshot_png">PNG (lossless)</string>
|
|
||||||
<string name="no_location_provider_available">No location source available</string>
|
|
||||||
<string name="ok">OK</string>
|
|
||||||
<string name="preferences_debug">Debug settings</string>
|
|
||||||
<string name="preferences_general">General settings</string>
|
|
||||||
<string name="preferences_cache_persistence">Cache persistence</string>
|
|
||||||
<string name="preferences_cache_persistence_desc">Keep cached images on exit</string>
|
|
||||||
<string name="preferences_cache_size">External storage</string>
|
|
||||||
<string name="preferences_cache_size_desc">Adjust the size of the cache</string>
|
|
||||||
<string name="preferences_cache_size_value">%.1f MB</string>
|
|
||||||
<string name="preferences_fullscreen">Full screen mode</string>
|
|
||||||
<string name="preferences_fullscreen_desc">Hide the status bar</string>
|
|
||||||
<string name="preferences_map">Map settings</string>
|
|
||||||
<string name="preferences_map_view_mode">Map mode</string>
|
|
||||||
<string name="preferences_map_view_mode_desc">Select the operating mode</string>
|
|
||||||
<string name="preferences_move_speed">Move speed</string>
|
|
||||||
<string name="preferences_move_speed_desc">Adjust the move speed of the map</string>
|
|
||||||
<string name="preferences_move_speed_value">%d %% move speed</string>
|
|
||||||
<string name="preferences_scale_bar_unit">Scale bar unit</string>
|
|
||||||
<string name="preferences_scale_bar_unit_desc">Select the unit for the map scale bar</string>
|
|
||||||
<string name="preferences_show_fps_counter">Frame rate</string>
|
|
||||||
<string name="preferences_show_fps_counter_desc">Enable frames per second counter</string>
|
|
||||||
<string name="preferences_show_scale_bar">Map scale bar</string>
|
|
||||||
<string name="preferences_show_scale_bar_desc">Show the scale of the map</string>
|
|
||||||
<string name="preferences_show_tile_coordinates">Tile coordinates</string>
|
|
||||||
<string name="preferences_show_tile_coordinates_desc">Show coordinates on tiles</string>
|
|
||||||
<string name="preferences_show_unmatched_ways">Draw unmatched ways</string>
|
|
||||||
<string name="preferences_show_tile_frames">Tile boundaries</string>
|
|
||||||
<string name="preferences_show_tile_frames_desc">Draw tile boundaries</string>
|
|
||||||
<string name="preferences_disable_polygons">Disable Polygon rendering</string>
|
|
||||||
<string name="preferences_show_water_tiles_desc">Highlight tiles which have the water flag set</string>
|
|
||||||
<string name="preferences_text_scale">Font size</string>
|
|
||||||
<string name="preferences_text_scale_desc">Select the text size of map labels</string>
|
|
||||||
<string name="preferences_wake_lock">Stay awake</string>
|
|
||||||
<string name="preferences_wake_lock_desc">Stop the screen from dimming</string>
|
|
||||||
<string name="snap_to_location_enabled">Snap to position is activated</string>
|
|
||||||
<string name="snap_to_location_disabled">Snap to position is disabled</string>
|
|
||||||
<string name="unit_symbol_kilometer"> km</string>
|
|
||||||
<string name="unit_symbol_meter"> m</string>
|
|
||||||
<string name="zoomLevel">Zoom level</string>
|
|
||||||
<string name="menu_options">Options</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
@ -1,40 +1,71 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/menu_preferences">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<PreferenceCategory android:title="@string/preferences_map">
|
android:title="@string/menu_preferences" >
|
||||||
<!-- <CheckBoxPreference android:title="@string/preferences_show_scale_bar" android:summary="@string/preferences_show_scale_bar_desc"
|
|
||||||
android:key="showScaleBar" /> -->
|
|
||||||
<!-- <ListPreference android:title="@string/preferences_scale_bar_unit" android:summary="@string/preferences_scale_bar_unit_desc"
|
|
||||||
android:entryValues="@array/preferences_scale_bar_unit_keys" android:entries="@array/preferences_scale_bar_unit_values"
|
|
||||||
android:key="scaleBarUnit" android:defaultValue="@string/preferences_scale_bar_unit_default" android:dependency="showScaleBar" /> -->
|
|
||||||
<ListPreference android:title="@string/preferences_map_view_mode" android:summary="@string/preferences_map_view_mode_desc"
|
|
||||||
android:entryValues="@array/preferences_map_database_keys" android:entries="@array/preferences_map_generator_values"
|
|
||||||
android:key="mapDatabase" android:defaultValue="@string/preferences_map_database_default" />
|
|
||||||
<!-- <ListPreference android:title="@string/preferences_text_scale" android:summary="@string/preferences_text_scale_desc"
|
|
||||||
android:entryValues="@array/preferences_text_scale_keys" android:entries="@array/preferences_text_scale_values"
|
|
||||||
android:key="textScale" android:defaultValue="@string/preferences_text_scale_default" /> -->
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences_general">
|
<PreferenceCategory android:title="@string/preferences_map" >
|
||||||
<CheckBoxPreference android:title="@string/preferences_fullscreen" android:summary="@string/preferences_fullscreen_desc"
|
|
||||||
android:key="fullscreen" />
|
<!--
|
||||||
<CheckBoxPreference android:title="@string/preferences_wake_lock" android:summary="@string/preferences_wake_lock_desc"
|
<CheckBoxPreference android:title="@string/preferences_show_scale_bar" android:summary="@string/preferences_show_scale_bar_desc"
|
||||||
android:key="wakeLock" />
|
android:key="showScaleBar" />
|
||||||
<!-- <CheckBoxPreference android:title="@string/preferences_cache_persistence" android:summary="@string/preferences_cache_persistence_desc"
|
-->
|
||||||
|
<!--
|
||||||
|
<ListPreference android:title="@string/preferences_scale_bar_unit" android:summary="@string/preferences_scale_bar_unit_desc"
|
||||||
|
android:entryValues="@array/preferences_scale_bar_unit_keys" android:entries="@array/preferences_scale_bar_unit_values"
|
||||||
|
android:key="scaleBarUnit" android:defaultValue="@string/preferences_scale_bar_unit_default" android:dependency="showScaleBar" />
|
||||||
|
-->
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/preferences_map_database_default"
|
||||||
|
android:entries="@array/preferences_map_generator_values"
|
||||||
|
android:entryValues="@array/preferences_map_database_keys"
|
||||||
|
android:key="mapDatabase"
|
||||||
|
android:summary="@string/preferences_map_view_mode_desc"
|
||||||
|
android:title="@string/preferences_map_view_mode" />
|
||||||
|
<!--
|
||||||
|
<ListPreference android:title="@string/preferences_text_scale" android:summary="@string/preferences_text_scale_desc"
|
||||||
|
android:entryValues="@array/preferences_text_scale_keys" android:entries="@array/preferences_text_scale_values"
|
||||||
|
android:key="textScale" android:defaultValue="@string/preferences_text_scale_default" />
|
||||||
|
-->
|
||||||
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory android:title="@string/preferences_general" >
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="fullscreen"
|
||||||
|
android:summary="@string/preferences_fullscreen_desc"
|
||||||
|
android:title="@string/preferences_fullscreen" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="fixOrientation"
|
||||||
|
android:summary="@string/preferences_fix_orientation"
|
||||||
|
android:title="@string/preferences_fix_orientation_desc" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="wakeLock"
|
||||||
|
android:summary="@string/preferences_wake_lock_desc"
|
||||||
|
android:title="@string/preferences_wake_lock" />
|
||||||
|
<!--
|
||||||
|
<CheckBoxPreference android:title="@string/preferences_cache_persistence" android:summary="@string/preferences_cache_persistence_desc"
|
||||||
android:key="cachePersistence" />
|
android:key="cachePersistence" />
|
||||||
<de.sfb.pampa.preferences.CacheSizePreference
|
<de.sfb.pampa.preferences.CacheSizePreference
|
||||||
android:title="@string/preferences_cache_size" android:summary="@string/preferences_cache_size_desc" android:key="cacheSize" />
|
android:title="@string/preferences_cache_size" android:summary="@string/preferences_cache_size_desc" android:key="cacheSize" />
|
||||||
<de.sfb.pampa.preferences.MoveSpeedPreference
|
<de.sfb.pampa.preferences.MoveSpeedPreference
|
||||||
android:title="@string/preferences_move_speed" android:summary="@string/preferences_move_speed_desc" android:key="moveSpeed" /> -->
|
android:title="@string/preferences_move_speed" android:summary="@string/preferences_move_speed_desc" android:key="moveSpeed" />
|
||||||
</PreferenceCategory>
|
-->
|
||||||
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory android:title="@string/preferences_debug" >
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<CheckBoxPreference android:title="@string/preferences_show_fps_counter" android:summary="@string/preferences_show_fps_counter_desc"
|
||||||
|
android:key="showFpsCounter" />
|
||||||
|
-->
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="drawTileFrames"
|
||||||
|
android:summary="@string/preferences_show_tile_frames_desc"
|
||||||
|
android:title="@string/preferences_show_tile_frames" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="drawUnmatchedWays"
|
||||||
|
android:summary="@string/preferences_show_unmatched_ways"
|
||||||
|
android:title="@string/preferences_show_unmatched_ways" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="disablePolygons"
|
||||||
|
android:summary="@string/preferences_disable_polygons"
|
||||||
|
android:title="@string/preferences_disable_polygons" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/preferences_debug">
|
|
||||||
<!-- <CheckBoxPreference android:title="@string/preferences_show_fps_counter" android:summary="@string/preferences_show_fps_counter_desc"
|
|
||||||
android:key="showFpsCounter" /> -->
|
|
||||||
<CheckBoxPreference android:title="@string/preferences_show_tile_frames" android:summary="@string/preferences_show_tile_frames_desc"
|
|
||||||
android:key="drawTileFrames" />
|
|
||||||
<CheckBoxPreference android:title="@string/preferences_show_unmatched_ways" android:summary="@string/preferences_show_unmatched_ways"
|
|
||||||
android:key="drawUnmatchedWays" />
|
|
||||||
<CheckBoxPreference android:title="@string/preferences_disable_polygons" android:summary="@string/preferences_disable_polygons"
|
|
||||||
android:key="disablePolygons" />
|
|
||||||
</PreferenceCategory>
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
69
src/org/mapsforge/android/Compass.java
Normal file
69
src/org/mapsforge/android/Compass.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.mapsforge.android;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
import android.hardware.SensorEvent;
|
||||||
|
import android.hardware.SensorEventListener;
|
||||||
|
import android.hardware.SensorManager;
|
||||||
|
|
||||||
|
public class Compass {
|
||||||
|
private final SensorEventListener mListener = new SensorEventListener() {
|
||||||
|
@Override
|
||||||
|
public void onSensorChanged(SensorEvent event) {
|
||||||
|
// if (true) Log.d(TAG,
|
||||||
|
// "sensorChanged (" + event.values[0] + ", " + event.values[1] + ", " + event.values[2] + ")");
|
||||||
|
// mValues = event.values;
|
||||||
|
if (Math.abs(event.values[0] - mAngle) > 0.25) {
|
||||||
|
mAngle = event.values[0];
|
||||||
|
|
||||||
|
if (mMapView != null) {
|
||||||
|
mMapView.getMapPosition().setRotation(mAngle);
|
||||||
|
mMapView.redrawTiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* package */float mAngle = 0;
|
||||||
|
/* package */MapView mMapView;
|
||||||
|
|
||||||
|
private SensorManager mSensorManager;
|
||||||
|
private Sensor mSensor;
|
||||||
|
|
||||||
|
// private float[] mValues;
|
||||||
|
|
||||||
|
public Compass(MapActivity mapActivity, MapView mapView) {
|
||||||
|
mMapView = mapView;
|
||||||
|
mSensorManager = (SensorManager) mapActivity
|
||||||
|
.getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
void enable() {
|
||||||
|
mSensorManager.registerListener(mListener, mSensor,
|
||||||
|
SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable() {
|
||||||
|
mSensorManager.unregisterListener(mListener);
|
||||||
|
mMapView.getMapPosition().setRotation(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
|
||||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.mapsforge.android;
|
|
||||||
|
|
||||||
import org.mapsforge.core.GeoPoint;
|
|
||||||
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A MapController is used to programmatically modify the position and zoom level of a MapView. Each MapController is
|
|
||||||
* assigned to a single MapView instance. To retrieve a MapController for a given MapView, use the
|
|
||||||
* {@link MapView#getController()} method.
|
|
||||||
*/
|
|
||||||
public final class MapController implements View.OnKeyListener {
|
|
||||||
private final MapView mMapView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mapView
|
|
||||||
* the MapView which should be controlled by this MapController.
|
|
||||||
*/
|
|
||||||
MapController(MapView mapView) {
|
|
||||||
mMapView = mapView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
|
|
||||||
if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
|
||||||
// forward the event to the MapView
|
|
||||||
return mMapView.onKeyDown(keyCode, keyEvent);
|
|
||||||
} else if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
|
|
||||||
// forward the event to the MapView
|
|
||||||
return mMapView.onKeyUp(keyCode, keyEvent);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the center of the MapView without an animation to the given point.
|
|
||||||
*
|
|
||||||
* @param geoPoint
|
|
||||||
* the new center point of the map.
|
|
||||||
*/
|
|
||||||
public void setCenter(GeoPoint geoPoint) {
|
|
||||||
mMapView.setCenter(geoPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the zoom level of the MapView.
|
|
||||||
*
|
|
||||||
* @param zoomLevel
|
|
||||||
* the new zoom level, will be limited by the maximum and minimum possible zoom level.
|
|
||||||
* @return the new zoom level.
|
|
||||||
*/
|
|
||||||
public int setZoom(int zoomLevel) {
|
|
||||||
mMapView.zoom((byte) (zoomLevel - mMapView.getMapPosition().getZoomLevel()));
|
|
||||||
return mMapView.getMapPosition().getZoomLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increases the zoom level of the MapView, unless the maximum zoom level has been reached.
|
|
||||||
*
|
|
||||||
* @return true if the zoom level has been changed, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean zoomIn() {
|
|
||||||
return mMapView.zoom((byte) 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decreases the zoom level of the MapView, unless the minimum zoom level has been reached.
|
|
||||||
*
|
|
||||||
* @return true if the zoom level has been changed, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean zoomOut() {
|
|
||||||
return mMapView.zoom((byte) -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -53,8 +53,7 @@ import android.view.MotionEvent;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A MapView shows a map on the display of the device. It handles all user input and touch gestures to move and zoom the
|
* A MapView shows a map on the display of the device. It handles all user input and touch gestures to move and zoom the
|
||||||
* map. This MapView also includes a scale bar and zoom controls. The {@link #getController()} method returns a
|
* map. This MapView also includes a scale bar and zoom controls.
|
||||||
* {@link MapController} to programmatically modify the position and zoom level of the map.
|
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation supports offline map rendering as well as downloading map images (tiles) over an Internet
|
* This implementation supports offline map rendering as well as downloading map images (tiles) over an Internet
|
||||||
* connection. The operation mode of a MapView can be set in the constructor and changed at runtime with the
|
* connection. The operation mode of a MapView can be set in the constructor and changed at runtime with the
|
||||||
@ -78,14 +77,16 @@ public class MapView extends GLSurfaceView {
|
|||||||
private static final Byte DEFAULT_START_ZOOM_LEVEL = Byte.valueOf((byte) 16);
|
private static final Byte DEFAULT_START_ZOOM_LEVEL = Byte.valueOf((byte) 16);
|
||||||
|
|
||||||
public final static boolean debugFrameTime = false;
|
public final static boolean debugFrameTime = false;
|
||||||
public boolean enableRotation = false;
|
|
||||||
|
|
||||||
private final MapController mMapController;
|
public boolean enableRotation = false;
|
||||||
|
public boolean enableCompass = false;
|
||||||
|
|
||||||
private final MapViewPosition mMapViewPosition;
|
private final MapViewPosition mMapViewPosition;
|
||||||
|
|
||||||
private final MapZoomControls mMapZoomControls;
|
private final MapZoomControls mMapZoomControls;
|
||||||
private final Projection mProjection;
|
private final Projection mProjection;
|
||||||
private final TouchHandler mTouchEventHandler;
|
private final TouchHandler mTouchEventHandler;
|
||||||
|
private final Compass mCompass;
|
||||||
|
|
||||||
private IMapDatabase mMapDatabase;
|
private IMapDatabase mMapDatabase;
|
||||||
private MapDatabases mMapDatabaseType;
|
private MapDatabases mMapDatabaseType;
|
||||||
@ -131,6 +132,7 @@ public class MapView extends GLSurfaceView {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"context is not an instance of MapActivity");
|
"context is not an instance of MapActivity");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "create MapView: " + mapDatabaseType.name());
|
Log.d(TAG, "create MapView: " + mapDatabaseType.name());
|
||||||
|
|
||||||
// TODO make this dpi dependent
|
// TODO make this dpi dependent
|
||||||
@ -140,8 +142,6 @@ public class MapView extends GLSurfaceView {
|
|||||||
|
|
||||||
debugSettings = new DebugSettings(false, false, false, false);
|
debugSettings = new DebugSettings(false, false, false, false);
|
||||||
|
|
||||||
mMapController = new MapController(this);
|
|
||||||
|
|
||||||
mMapDatabaseType = mapDatabaseType;
|
mMapDatabaseType = mapDatabaseType;
|
||||||
|
|
||||||
mMapViewPosition = new MapViewPosition(this);
|
mMapViewPosition = new MapViewPosition(this);
|
||||||
@ -152,6 +152,8 @@ public class MapView extends GLSurfaceView {
|
|||||||
|
|
||||||
mTouchEventHandler = new TouchHandler(mapActivity, this);
|
mTouchEventHandler = new TouchHandler(mapActivity, this);
|
||||||
|
|
||||||
|
mCompass = new Compass(mapActivity, this);
|
||||||
|
|
||||||
mJobQueue = new JobQueue();
|
mJobQueue = new JobQueue();
|
||||||
|
|
||||||
mMapRenderer = MapRendererFactory.createMapRenderer(this, mapGeneratorType);
|
mMapRenderer = MapRendererFactory.createMapRenderer(this, mapGeneratorType);
|
||||||
@ -194,6 +196,8 @@ public class MapView extends GLSurfaceView {
|
|||||||
|
|
||||||
if (!debugFrameTime)
|
if (!debugFrameTime)
|
||||||
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
||||||
|
|
||||||
|
// mCompass.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMapStartPosition() {
|
private void initMapStartPosition() {
|
||||||
@ -208,13 +212,6 @@ public class MapView extends GLSurfaceView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the MapController for this MapView.
|
|
||||||
*/
|
|
||||||
public MapController getController() {
|
|
||||||
return mMapController;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the debug settings which are used in this MapView.
|
* @return the debug settings which are used in this MapView.
|
||||||
*/
|
*/
|
||||||
@ -259,7 +256,10 @@ public class MapView extends GLSurfaceView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||||
return mTouchEventHandler.handleMotionEvent(motionEvent);
|
if (this.isClickable())
|
||||||
|
return mTouchEventHandler.handleMotionEvent(motionEvent);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,17 +279,6 @@ public class MapView extends GLSurfaceView {
|
|||||||
mMapRenderer.updateMap(true);
|
mMapRenderer.updateMap(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the visibility of the zoom controls.
|
|
||||||
*
|
|
||||||
* @param showZoomControls
|
|
||||||
* true if the zoom controls should be visible, false otherwise.
|
|
||||||
*/
|
|
||||||
public void setBuiltInZoomControls(boolean showZoomControls) {
|
|
||||||
mMapZoomControls.setShowMapZoomControls(showZoomControls);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the center of the MapView and triggers a redraw.
|
* Sets the center of the MapView and triggers a redraw.
|
||||||
*
|
*
|
||||||
@ -299,6 +288,7 @@ public class MapView extends GLSurfaceView {
|
|||||||
public void setCenter(GeoPoint geoPoint) {
|
public void setCenter(GeoPoint geoPoint) {
|
||||||
MapPosition mapPosition = new MapPosition(geoPoint,
|
MapPosition mapPosition = new MapPosition(geoPoint,
|
||||||
mMapViewPosition.getZoomLevel(), 1);
|
mMapViewPosition.getZoomLevel(), 1);
|
||||||
|
|
||||||
setCenterAndZoom(mapPosition);
|
setCenterAndZoom(mapPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,12 +552,13 @@ public class MapView extends GLSurfaceView {
|
|||||||
int oldHeight) {
|
int oldHeight) {
|
||||||
|
|
||||||
mJobQueue.clear();
|
mJobQueue.clear();
|
||||||
|
mCompass.disable();
|
||||||
mapWorkersPause(true);
|
mapWorkersPause(true);
|
||||||
|
|
||||||
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
||||||
|
|
||||||
mapWorkersProceed();
|
mapWorkersProceed();
|
||||||
|
mCompass.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
@ -619,12 +610,18 @@ public class MapView extends GLSurfaceView {
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mapWorkersPause(false);
|
mapWorkersPause(false);
|
||||||
|
|
||||||
|
if (this.enableCompass)
|
||||||
|
mCompass.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mapWorkersProceed();
|
mapWorkersProceed();
|
||||||
|
|
||||||
|
if (this.enableCompass)
|
||||||
|
mCompass.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -634,7 +631,9 @@ public class MapView extends GLSurfaceView {
|
|||||||
* the new map position of this MapView.
|
* the new map position of this MapView.
|
||||||
*/
|
*/
|
||||||
void setCenterAndZoom(MapPosition mapPosition) {
|
void setCenterAndZoom(MapPosition mapPosition) {
|
||||||
|
Log.d(TAG, "setCenterAndZoom "
|
||||||
|
+ " lat: " + mapPosition.lat
|
||||||
|
+ " lon: " + mapPosition.lon);
|
||||||
mMapViewPosition.setMapCenterAndZoomLevel(mapPosition);
|
mMapViewPosition.setMapCenterAndZoomLevel(mapPosition);
|
||||||
redrawTiles();
|
redrawTiles();
|
||||||
}
|
}
|
||||||
@ -687,8 +686,40 @@ public class MapView extends GLSurfaceView {
|
|||||||
|
|
||||||
public void enableRotation(boolean enable) {
|
public void enableRotation(boolean enable) {
|
||||||
enableRotation = enable;
|
enableRotation = enable;
|
||||||
|
|
||||||
|
if (enable && this.enableCompass) {
|
||||||
|
this.enableCompass = false;
|
||||||
|
mCompass.disable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableCompass(boolean enable) {
|
||||||
|
if (enable == this.enableCompass)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.enableCompass = enable;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
this.enableRotation = false;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
mCompass.enable();
|
||||||
|
else
|
||||||
|
mCompass.disable();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Sets the visibility of the zoom controls.
|
||||||
|
// *
|
||||||
|
// * @param showZoomControls
|
||||||
|
// * true if the zoom controls should be visible, false otherwise.
|
||||||
|
// */
|
||||||
|
// public void setBuiltInZoomControls(boolean showZoomControls) {
|
||||||
|
// mMapZoomControls.setShowMapZoomControls(showZoomControls);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
// public final int
|
// public final int
|
||||||
// public Handler messageHandler = new Handler() {
|
// public Handler messageHandler = new Handler() {
|
||||||
//
|
//
|
||||||
|
|||||||
@ -60,6 +60,7 @@ public class MapViewPosition {
|
|||||||
if (!isValid()) {
|
if (!isValid()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// Log.d("MapViewPosition", "lat: " + mLatitude + " lon: " + mLongitude);
|
||||||
return new MapPosition(mLatitude, mLongitude, mZoomLevel, mScale, mRotation);
|
return new MapPosition(mLatitude, mLongitude, mZoomLevel, mScale, mRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ public class MapViewPosition {
|
|||||||
double pixelY = MercatorProjection.latitudeToPixelY(mLatitude, mZoomLevel);
|
double pixelY = MercatorProjection.latitudeToPixelY(mLatitude, mZoomLevel);
|
||||||
double dx, dy;
|
double dx, dy;
|
||||||
|
|
||||||
if (mMapView.enableRotation) {
|
if (mMapView.enableRotation || mMapView.enableCompass) {
|
||||||
float rad = (float) Math.toRadians(mRotation);
|
float rad = (float) Math.toRadians(mRotation);
|
||||||
dx = mx / mScale;
|
dx = mx / mScale;
|
||||||
dy = my / mScale;
|
dy = my / mScale;
|
||||||
@ -142,6 +143,10 @@ public class MapViewPosition {
|
|||||||
mRotation -= angle;
|
mRotation -= angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRotation(float f) {
|
||||||
|
mRotation = f;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized void setMapCenter(GeoPoint geoPoint) {
|
synchronized void setMapCenter(GeoPoint geoPoint) {
|
||||||
mLatitude = MercatorProjection.limitLatitude(geoPoint.getLatitude());
|
mLatitude = MercatorProjection.limitLatitude(geoPoint.getLatitude());
|
||||||
mLongitude = MercatorProjection.limitLongitude(geoPoint.getLongitude());
|
mLongitude = MercatorProjection.limitLongitude(geoPoint.getLongitude());
|
||||||
|
|||||||
@ -160,7 +160,7 @@ public class MapZoomControls {
|
|||||||
* true if the zoom controls should be visible, false otherwise.
|
* true if the zoom controls should be visible, false otherwise.
|
||||||
*/
|
*/
|
||||||
public void setShowMapZoomControls(boolean showMapZoomControls) {
|
public void setShowMapZoomControls(boolean showMapZoomControls) {
|
||||||
mShowMapZoomControls = false; // showMapZoomControls;
|
mShowMapZoomControls = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -461,8 +461,10 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
if (MapView.debugFrameTime)
|
if (MapView.debugFrameTime)
|
||||||
start = SystemClock.uptimeMillis();
|
start = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
mRotate = mMapView.enableRotation;
|
if (mRotate != (mMapView.enableRotation || mMapView.enableCompass)) {
|
||||||
|
Matrix.setIdentityM(mMVPMatrix, 0);
|
||||||
|
mRotate = mMapView.enableRotation || mMapView.enableCompass;
|
||||||
|
}
|
||||||
if (mUpdateColor && mClearColor != null) {
|
if (mUpdateColor && mClearColor != null) {
|
||||||
glClearColor(mClearColor[0], mClearColor[1], mClearColor[2], mClearColor[3]);
|
glClearColor(mClearColor[0], mClearColor[1], mClearColor[2], mClearColor[3]);
|
||||||
mUpdateColor = false;
|
mUpdateColor = false;
|
||||||
|
|||||||
@ -19,13 +19,18 @@ import android.util.Log;
|
|||||||
class QuadTree {
|
class QuadTree {
|
||||||
private static String TAG = "QuadTree";
|
private static String TAG = "QuadTree";
|
||||||
|
|
||||||
|
// pointer to tile 0/0/0
|
||||||
private static QuadTree root;
|
private static QuadTree root;
|
||||||
|
|
||||||
// parent pointer is used to link pool items
|
// parent pointer is used to link pool items
|
||||||
private static QuadTree pool;
|
private static QuadTree pool;
|
||||||
|
|
||||||
// TreeTile members
|
|
||||||
QuadTree parent;
|
QuadTree parent;
|
||||||
|
// .... x y
|
||||||
|
// 0 => 0 0
|
||||||
|
// 1 => 1 0
|
||||||
|
// 2 => 0 1
|
||||||
|
// 3 => 1 1
|
||||||
final QuadTree[] child = new QuadTree[4];
|
final QuadTree[] child = new QuadTree[4];
|
||||||
int refs = 0;
|
int refs = 0;
|
||||||
byte id;
|
byte id;
|
||||||
|
|||||||
@ -79,10 +79,14 @@ class TileLoader {
|
|||||||
newTiles = new TilesData(numTiles);
|
newTiles = new TilesData(numTiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateMap(boolean clear) {
|
static synchronized void updateMap(boolean clear) {
|
||||||
|
|
||||||
boolean changedPos = false;
|
boolean changedPos = false;
|
||||||
boolean changedZoom = false;
|
boolean changedZoom = false;
|
||||||
|
|
||||||
|
if (mMapView == null || mMapView.getMapPosition() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
MapPosition mapPosition = mMapView.getMapPosition().getMapPosition();
|
MapPosition mapPosition = mMapView.getMapPosition().getMapPosition();
|
||||||
|
|
||||||
if (mapPosition == null) {
|
if (mapPosition == null) {
|
||||||
@ -100,8 +104,6 @@ class TileLoader {
|
|||||||
mTiles.clear();
|
mTiles.clear();
|
||||||
mTilesLoaded.clear();
|
mTilesLoaded.clear();
|
||||||
QuadTree.init();
|
QuadTree.init();
|
||||||
// curTiles.cnt = 0;
|
|
||||||
// mBufferMemoryUsage = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,24 +163,10 @@ class TileLoader {
|
|||||||
limitCache(mapPosition, remove);
|
limitCache(mapPosition, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = mTilesLoaded.size();
|
limitLoadQueue();
|
||||||
if (size > MAX_TILES_IN_QUEUE)
|
|
||||||
limitLoadQueue(size);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage tiles that have data to be uploaded to gl
|
|
||||||
*
|
|
||||||
* @param tile
|
|
||||||
* tile processed by MapGenerator
|
|
||||||
*/
|
|
||||||
static void addTileLoaded(MapTile tile) {
|
|
||||||
synchronized (mTilesLoaded) {
|
|
||||||
mTilesLoaded.add(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean updateVisibleList(MapPosition mapPosition, int zdir) {
|
private static boolean updateVisibleList(MapPosition mapPosition, int zdir) {
|
||||||
double x = mapPosition.x;
|
double x = mapPosition.x;
|
||||||
double y = mapPosition.y;
|
double y = mapPosition.y;
|
||||||
@ -398,7 +386,7 @@ class TileLoader {
|
|||||||
int removes = remove;
|
int removes = remove;
|
||||||
|
|
||||||
int size = mTiles.size();
|
int size = mTiles.size();
|
||||||
int tmp = size;
|
// int tmp = size;
|
||||||
|
|
||||||
// remove orphaned tiles
|
// remove orphaned tiles
|
||||||
for (int i = 0; i < size;) {
|
for (int i = 0; i < size;) {
|
||||||
@ -417,7 +405,7 @@ class TileLoader {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "remove tiles: " + removes + " " + size + " " + tmp);
|
// Log.d(TAG, "remove tiles: " + removes + " " + size + " " + tmp);
|
||||||
|
|
||||||
if (removes <= 0)
|
if (removes <= 0)
|
||||||
return;
|
return;
|
||||||
@ -461,8 +449,11 @@ class TileLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void limitLoadQueue(int remove) {
|
private static void limitLoadQueue() {
|
||||||
int size = remove;
|
int size = mTilesLoaded.size();
|
||||||
|
|
||||||
|
if (size < MAX_TILES_IN_QUEUE)
|
||||||
|
return;
|
||||||
|
|
||||||
synchronized (mTilesLoaded) {
|
synchronized (mTilesLoaded) {
|
||||||
|
|
||||||
@ -481,8 +472,11 @@ class TileLoader {
|
|||||||
// clear loaded but not used tiles
|
// clear loaded but not used tiles
|
||||||
if (size < MAX_TILES_IN_QUEUE)
|
if (size < MAX_TILES_IN_QUEUE)
|
||||||
return;
|
return;
|
||||||
|
// Log.d(TAG, "queue: " + mTilesLoaded.size() + " " + size + " "
|
||||||
|
// + (size - MAX_TILES_IN_QUEUE / 2));
|
||||||
|
|
||||||
|
for (int i = 0, n = size - MAX_TILES_IN_QUEUE / 2; i < n; n--) {
|
||||||
|
|
||||||
for (int i = 0, n = size - MAX_TILES_IN_QUEUE + 20; i < n; i++) {
|
|
||||||
MapTile t = mTilesLoaded.get(i);
|
MapTile t = mTilesLoaded.get(i);
|
||||||
|
|
||||||
synchronized (t) {
|
synchronized (t) {
|
||||||
@ -493,15 +487,28 @@ class TileLoader {
|
|||||||
|
|
||||||
if (tileInUse(t)) {
|
if (tileInUse(t)) {
|
||||||
// Log.d(TAG, "keep unused tile data: " + t + " " + t.isActive);
|
// Log.d(TAG, "keep unused tile data: " + t + " " + t.isActive);
|
||||||
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log.d(TAG, "remove unused tile data: " + t);
|
||||||
mTilesLoaded.remove(i);
|
mTilesLoaded.remove(i);
|
||||||
mTiles.remove(t);
|
mTiles.remove(t);
|
||||||
// Log.d(TAG, "remove unused tile data: " + t);
|
|
||||||
clearTile(t);
|
clearTile(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage tiles that have data to be uploaded to gl
|
||||||
|
*
|
||||||
|
* @param tile
|
||||||
|
* tile processed by MapGenerator
|
||||||
|
*/
|
||||||
|
static void addTileLoaded(MapTile tile) {
|
||||||
|
synchronized (mTilesLoaded) {
|
||||||
|
mTilesLoaded.add(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
254
src/org/mapsforge/app/LocationHandler.java
Normal file
254
src/org/mapsforge/app/LocationHandler.java
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.mapsforge.app;
|
||||||
|
|
||||||
|
import org.mapsforge.core.GeoPoint;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.location.Criteria;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationListener;
|
||||||
|
import android.location.LocationManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
public class LocationHandler {
|
||||||
|
private static final int DIALOG_LOCATION_PROVIDER_DISABLED = 2;
|
||||||
|
|
||||||
|
private MyLocationListener mLocationListener;
|
||||||
|
private LocationManager mLocationManager;
|
||||||
|
private boolean mShowMyLocation;
|
||||||
|
|
||||||
|
private ToggleButton mSnapToLocationView;
|
||||||
|
private boolean mSnapToLocation;
|
||||||
|
|
||||||
|
/* package */final TileMap mTileMap;
|
||||||
|
|
||||||
|
LocationHandler(TileMap tileMap) {
|
||||||
|
mTileMap = tileMap;
|
||||||
|
mLocationManager = (LocationManager) tileMap
|
||||||
|
.getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
mLocationListener = new MyLocationListener(tileMap);
|
||||||
|
|
||||||
|
mSnapToLocationView = (ToggleButton) tileMap
|
||||||
|
.findViewById(R.id.snapToLocationView);
|
||||||
|
|
||||||
|
mSnapToLocationView.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (isSnapToLocationEnabled()) {
|
||||||
|
disableSnapToLocation(true);
|
||||||
|
} else {
|
||||||
|
enableSnapToLocation(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enableShowMyLocation(boolean centerAtFirstFix) {
|
||||||
|
Log.d("TileMap", "enableShowMyLocation " + mShowMyLocation);
|
||||||
|
|
||||||
|
if (!mShowMyLocation) {
|
||||||
|
Criteria criteria = new Criteria();
|
||||||
|
criteria.setAccuracy(Criteria.ACCURACY_FINE);
|
||||||
|
String bestProvider = mLocationManager.getBestProvider(criteria, true);
|
||||||
|
|
||||||
|
if (bestProvider == null) {
|
||||||
|
mTileMap.showDialog(DIALOG_LOCATION_PROVIDER_DISABLED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mShowMyLocation = true;
|
||||||
|
|
||||||
|
Log.d("TileMap", "enableShowMyLocation " + mShowMyLocation);
|
||||||
|
|
||||||
|
mLocationListener.setCenterAtFirstFix(centerAtFirstFix);
|
||||||
|
|
||||||
|
mLocationManager.requestLocationUpdates(bestProvider, 1000, 0,
|
||||||
|
mLocationListener);
|
||||||
|
|
||||||
|
mSnapToLocationView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gotoLastKnownPosition() {
|
||||||
|
Location currentLocation;
|
||||||
|
Location bestLocation = null;
|
||||||
|
for (String provider : mLocationManager.getProviders(true)) {
|
||||||
|
currentLocation = mLocationManager.getLastKnownLocation(provider);
|
||||||
|
if (currentLocation == null)
|
||||||
|
continue;
|
||||||
|
if (bestLocation == null
|
||||||
|
|| currentLocation.getAccuracy() < bestLocation.getAccuracy()) {
|
||||||
|
bestLocation = currentLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestLocation != null) {
|
||||||
|
GeoPoint point = new GeoPoint(bestLocation.getLatitude(),
|
||||||
|
bestLocation.getLongitude());
|
||||||
|
|
||||||
|
mTileMap.mMapView.setCenter(point);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mTileMap.showToastOnUiThread(mTileMap
|
||||||
|
.getString(R.string.error_last_location_unknown));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the "show my location" mode.
|
||||||
|
*
|
||||||
|
* @return ...
|
||||||
|
*/
|
||||||
|
boolean disableShowMyLocation() {
|
||||||
|
if (mShowMyLocation) {
|
||||||
|
mShowMyLocation = false;
|
||||||
|
disableSnapToLocation(false);
|
||||||
|
|
||||||
|
mLocationManager.removeUpdates(mLocationListener);
|
||||||
|
// if (circleOverlay != null) {
|
||||||
|
// mapView.getOverlays().remove(circleOverlay);
|
||||||
|
// mapView.getOverlays().remove(itemizedOverlay);
|
||||||
|
// circleOverlay = null;
|
||||||
|
// itemizedOverlay = null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
mSnapToLocationView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the status of the "show my location" mode.
|
||||||
|
*
|
||||||
|
* @return true if the "show my location" mode is enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean isShowMyLocationEnabled() {
|
||||||
|
return mShowMyLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the "snap to location" mode.
|
||||||
|
*
|
||||||
|
* @param showToast
|
||||||
|
* defines whether a toast message is displayed or not.
|
||||||
|
*/
|
||||||
|
void disableSnapToLocation(boolean showToast) {
|
||||||
|
if (mSnapToLocation) {
|
||||||
|
mSnapToLocation = false;
|
||||||
|
mSnapToLocationView.setChecked(false);
|
||||||
|
|
||||||
|
mTileMap.mMapView.setClickable(true);
|
||||||
|
|
||||||
|
if (showToast) {
|
||||||
|
mTileMap.showToastOnUiThread(mTileMap
|
||||||
|
.getString(R.string.snap_to_location_disabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the "snap to location" mode.
|
||||||
|
*
|
||||||
|
* @param showToast
|
||||||
|
* defines whether a toast message is displayed or not.
|
||||||
|
*/
|
||||||
|
void enableSnapToLocation(boolean showToast) {
|
||||||
|
if (!mSnapToLocation) {
|
||||||
|
mSnapToLocation = true;
|
||||||
|
|
||||||
|
mTileMap.mMapView.setClickable(false);
|
||||||
|
|
||||||
|
if (showToast) {
|
||||||
|
mTileMap.showToastOnUiThread(mTileMap
|
||||||
|
.getString(R.string.snap_to_location_enabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the status of the "snap to location" mode.
|
||||||
|
*
|
||||||
|
* @return true if the "snap to location" mode is enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean isSnapToLocationEnabled() {
|
||||||
|
return mSnapToLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyLocationListener implements LocationListener {
|
||||||
|
private final TileMap tileMap;
|
||||||
|
private boolean centerAtFirstFix;
|
||||||
|
|
||||||
|
MyLocationListener(TileMap tileMap) {
|
||||||
|
this.tileMap = tileMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged(Location location) {
|
||||||
|
|
||||||
|
Log.d("LocationListener", "onLocationChanged, "
|
||||||
|
+ " lon:" + location.getLongitude()
|
||||||
|
+ " lat:" + location.getLatitude());
|
||||||
|
|
||||||
|
if (!isShowMyLocationEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GeoPoint point = new GeoPoint(location.getLatitude(), location.getLongitude());
|
||||||
|
|
||||||
|
// this.advancedMapViewer.overlayCircle.setCircleData(point, location.getAccuracy());
|
||||||
|
// this.advancedMapViewer.overlayItem.setPoint(point);
|
||||||
|
// this.advancedMapViewer.circleOverlay.requestRedraw();
|
||||||
|
// this.advancedMapViewer.itemizedOverlay.requestRedraw();
|
||||||
|
|
||||||
|
if (this.centerAtFirstFix || isSnapToLocationEnabled()) {
|
||||||
|
this.centerAtFirstFix = false;
|
||||||
|
this.tileMap.mMapView.setCenter(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderDisabled(String provider) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderEnabled(String provider) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isCenterAtFirstFix() {
|
||||||
|
return this.centerAtFirstFix;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCenterAtFirstFix(boolean centerAtFirstFix) {
|
||||||
|
this.centerAtFirstFix = centerAtFirstFix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
|
||||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.mapsforge.app;
|
|
||||||
|
|
||||||
import org.mapsforge.core.GeoPoint;
|
|
||||||
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
class MyLocationListener implements LocationListener {
|
|
||||||
private final TileMap advancedMapViewer;
|
|
||||||
private boolean centerAtFirstFix;
|
|
||||||
|
|
||||||
MyLocationListener(TileMap advancedMapViewer) {
|
|
||||||
this.advancedMapViewer = advancedMapViewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
if (!this.advancedMapViewer.isShowMyLocationEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GeoPoint point = new GeoPoint(location.getLatitude(), location.getLongitude());
|
|
||||||
// this.advancedMapViewer.overlayCircle.setCircleData(point, location.getAccuracy());
|
|
||||||
// this.advancedMapViewer.overlayItem.setPoint(point);
|
|
||||||
// this.advancedMapViewer.circleOverlay.requestRedraw();
|
|
||||||
// this.advancedMapViewer.itemizedOverlay.requestRedraw();
|
|
||||||
if (this.centerAtFirstFix || this.advancedMapViewer.isSnapToLocationEnabled()) {
|
|
||||||
this.centerAtFirstFix = false;
|
|
||||||
this.advancedMapViewer.mMapController.setCenter(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isCenterAtFirstFix() {
|
|
||||||
return this.centerAtFirstFix;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCenterAtFirstFix(boolean centerAtFirstFix) {
|
|
||||||
this.centerAtFirstFix = centerAtFirstFix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
|
||||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.mapsforge.app;
|
|
||||||
|
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
class SeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
|
|
||||||
private final TextView textView;
|
|
||||||
|
|
||||||
SeekBarChangeListener(TextView textView) {
|
|
||||||
this.textView = textView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
||||||
this.textView.setText(String.valueOf(progress));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,7 +7,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
import org.mapsforge.android.DebugSettings;
|
import org.mapsforge.android.DebugSettings;
|
||||||
import org.mapsforge.android.MapActivity;
|
import org.mapsforge.android.MapActivity;
|
||||||
import org.mapsforge.android.MapController;
|
|
||||||
import org.mapsforge.android.MapView;
|
import org.mapsforge.android.MapView;
|
||||||
import org.mapsforge.android.mapgenerator.MapDatabases;
|
import org.mapsforge.android.mapgenerator.MapDatabases;
|
||||||
import org.mapsforge.android.rendertheme.InternalRenderTheme;
|
import org.mapsforge.android.rendertheme.InternalRenderTheme;
|
||||||
@ -30,9 +29,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.location.Criteria;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
@ -71,14 +68,12 @@ public class TileMap extends MapActivity {
|
|||||||
new FilterByFileExtension(".xml");
|
new FilterByFileExtension(".xml");
|
||||||
private static final int SELECT_MAP_FILE = 0;
|
private static final int SELECT_MAP_FILE = 0;
|
||||||
private static final int SELECT_RENDER_THEME_FILE = 1;
|
private static final int SELECT_RENDER_THEME_FILE = 1;
|
||||||
private LocationManager mLocationManager;
|
|
||||||
|
LocationHandler mLocation;
|
||||||
|
|
||||||
private MapDatabases mMapDatabase;
|
private MapDatabases mMapDatabase;
|
||||||
private MyLocationListener mMyLocationListener;
|
|
||||||
private boolean mShowMyLocation;
|
|
||||||
private boolean mSnapToLocation;
|
|
||||||
// private ToggleButton mSnapToLocationView;
|
|
||||||
private WakeLock mWakeLock;
|
private WakeLock mWakeLock;
|
||||||
MapController mMapController;
|
|
||||||
MapView mMapView;
|
MapView mMapView;
|
||||||
private Menu mMenu = null;
|
private Menu mMenu = null;
|
||||||
|
|
||||||
@ -108,36 +103,48 @@ public class TileMap extends MapActivity {
|
|||||||
|
|
||||||
case R.id.menu_rotation_enable:
|
case R.id.menu_rotation_enable:
|
||||||
mMapView.enableRotation(true);
|
mMapView.enableRotation(true);
|
||||||
|
toggleMenuRotation(mMenu,
|
||||||
|
mMapView.enableRotation,
|
||||||
|
mMapView.enableCompass);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.menu_rotation_disable:
|
||||||
|
mMapView.enableRotation(false);
|
||||||
|
toggleMenuRotation(mMenu,
|
||||||
|
mMapView.enableRotation,
|
||||||
|
mMapView.enableCompass);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.menu_compass_enable:
|
||||||
|
mMapView.enableCompass(true);
|
||||||
|
toggleMenuRotation(mMenu,
|
||||||
|
mMapView.enableRotation,
|
||||||
|
mMapView.enableCompass);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.menu_compass_disable:
|
||||||
|
mMapView.enableCompass(false);
|
||||||
|
toggleMenuRotation(mMenu,
|
||||||
|
mMapView.enableRotation,
|
||||||
|
mMapView.enableCompass);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_position_my_location_enable:
|
case R.id.menu_position_my_location_enable:
|
||||||
if (enableShowMyLocation(true)) {
|
toggleMenuItem(mMenu,
|
||||||
mMenu.findItem(R.id.menu_position_my_location_enable)
|
R.id.menu_position_my_location_enable,
|
||||||
.setVisible(false);
|
R.id.menu_position_my_location_disable,
|
||||||
mMenu.findItem(R.id.menu_position_my_location_enable)
|
!mLocation.enableShowMyLocation(true));
|
||||||
.setEnabled(false);
|
|
||||||
mMenu.findItem(R.id.menu_position_my_location_disable)
|
|
||||||
.setVisible(true);
|
|
||||||
mMenu.findItem(R.id.menu_position_my_location_disable)
|
|
||||||
.setEnabled(true);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_position_my_location_disable:
|
case R.id.menu_position_my_location_disable:
|
||||||
if (disableShowMyLocation()) {
|
toggleMenuItem(mMenu,
|
||||||
mMenu.findItem(R.id.menu_position_my_location_enable)
|
R.id.menu_position_my_location_enable,
|
||||||
.setVisible(true);
|
R.id.menu_position_my_location_disable,
|
||||||
mMenu.findItem(R.id.menu_position_my_location_enable)
|
mLocation.disableShowMyLocation());
|
||||||
.setEnabled(true);
|
|
||||||
mMenu.findItem(R.id.menu_position_my_location_disable)
|
|
||||||
.setVisible(false);
|
|
||||||
mMenu.findItem(R.id.menu_position_my_location_disable)
|
|
||||||
.setEnabled(false);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_position_last_known:
|
case R.id.menu_position_last_known:
|
||||||
gotoLastKnownPosition();
|
mLocation.gotoLastKnownPosition();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_position_enter_coordinates:
|
case R.id.menu_position_enter_coordinates:
|
||||||
@ -146,8 +153,9 @@ public class TileMap extends MapActivity {
|
|||||||
|
|
||||||
case R.id.menu_position_map_center:
|
case R.id.menu_position_map_center:
|
||||||
// disable GPS follow mode if it is enabled
|
// disable GPS follow mode if it is enabled
|
||||||
disableSnapToLocation(true);
|
mLocation.disableSnapToLocation(true);
|
||||||
mMapController.setCenter(mMapView.getMapDatabase()
|
|
||||||
|
mMapView.setCenter(mMapView.getMapDatabase()
|
||||||
.getMapFileInfo().mapCenter);
|
.getMapFileInfo().mapCenter);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -182,38 +190,68 @@ public class TileMap extends MapActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void toggleMenuRotation(Menu menu, boolean rotate, boolean compass) {
|
||||||
|
toggleMenuItem(menu,
|
||||||
|
R.id.menu_rotation_enable,
|
||||||
|
R.id.menu_rotation_disable,
|
||||||
|
!rotate);
|
||||||
|
|
||||||
|
toggleMenuItem(menu,
|
||||||
|
R.id.menu_compass_enable,
|
||||||
|
R.id.menu_compass_disable,
|
||||||
|
!compass);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleMenuItem(Menu menu, int id, int id2, boolean enable) {
|
||||||
|
menu.findItem(id).setVisible(enable);
|
||||||
|
menu.findItem(id).setEnabled(enable);
|
||||||
|
menu.findItem(id2).setVisible(!enable);
|
||||||
|
menu.findItem(id2).setEnabled(!enable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
menu.clear();
|
menu.clear();
|
||||||
onCreateOptionsMenu(menu);
|
onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
Log.d("TileMap", "prepare options...");
|
toggleMenuItem(menu,
|
||||||
|
R.id.menu_position_my_location_enable,
|
||||||
|
R.id.menu_position_my_location_disable,
|
||||||
|
!mLocation.isShowMyLocationEnabled());
|
||||||
|
|
||||||
// menu.findItem(R.id.menu_info_map_file).setEnabled(true);
|
// if (mLocation.isShowMyLocationEnabled()) {
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_enable).setVisible(false);
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_enable).setEnabled(false);
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_disable).setVisible(true);
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_disable).setEnabled(true);
|
||||||
|
// } else {
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_enable).setVisible(true);
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_enable).setEnabled(true);
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_disable).setVisible(false);
|
||||||
|
// menu.findItem(R.id.menu_position_my_location_disable).setEnabled(false);
|
||||||
|
// }
|
||||||
|
|
||||||
if (isShowMyLocationEnabled()) {
|
menu.findItem(R.id.menu_render_theme).setEnabled(true);
|
||||||
menu.findItem(R.id.menu_position_my_location_enable).setVisible(false);
|
|
||||||
menu.findItem(R.id.menu_position_my_location_enable).setEnabled(false);
|
if (mMapDatabase == MapDatabases.MAP_READER) {
|
||||||
menu.findItem(R.id.menu_position_my_location_disable).setVisible(true);
|
menu.findItem(R.id.menu_mapfile).setVisible(true);
|
||||||
menu.findItem(R.id.menu_position_my_location_disable).setEnabled(true);
|
menu.findItem(R.id.menu_position_map_center).setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
menu.findItem(R.id.menu_position_my_location_enable).setVisible(true);
|
menu.findItem(R.id.menu_mapfile).setVisible(false);
|
||||||
menu.findItem(R.id.menu_position_my_location_enable).setEnabled(true);
|
menu.findItem(R.id.menu_position_map_center).setVisible(false);
|
||||||
menu.findItem(R.id.menu_position_my_location_disable).setVisible(false);
|
|
||||||
menu.findItem(R.id.menu_position_my_location_disable).setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.findItem(R.id.menu_position_map_center).setEnabled(true);
|
toggleMenuItem(menu,
|
||||||
menu.findItem(R.id.menu_render_theme).setEnabled(true);
|
R.id.menu_compass_enable,
|
||||||
// menu.findItem(R.id.menu_mapfile).setEnabled(true);
|
R.id.menu_compass_disable,
|
||||||
|
!mMapView.enableCompass);
|
||||||
|
|
||||||
if (mMapDatabase == MapDatabases.MAP_READER)
|
toggleMenuItem(mMenu,
|
||||||
menu.findItem(R.id.menu_mapfile).setVisible(true);
|
R.id.menu_rotation_enable,
|
||||||
else
|
R.id.menu_rotation_disable,
|
||||||
menu.findItem(R.id.menu_mapfile).setVisible(false);
|
!mMapView.enableRotation);
|
||||||
|
|
||||||
return super.onPrepareOptionsMenu(menu);
|
return super.onPrepareOptionsMenu(menu);
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -225,52 +263,8 @@ public class TileMap extends MapActivity {
|
|||||||
private void configureMapView() {
|
private void configureMapView() {
|
||||||
// configure the MapView and activate the zoomLevel buttons
|
// configure the MapView and activate the zoomLevel buttons
|
||||||
mMapView.setClickable(true);
|
mMapView.setClickable(true);
|
||||||
mMapView.setBuiltInZoomControls(true);
|
// mMapView.setBuiltInZoomControls(true);
|
||||||
mMapView.setFocusable(true);
|
mMapView.setFocusable(true);
|
||||||
|
|
||||||
mMapController = mMapView.getController();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean enableShowMyLocation(boolean centerAtFirstFix) {
|
|
||||||
if (!mShowMyLocation) {
|
|
||||||
Criteria criteria = new Criteria();
|
|
||||||
criteria.setAccuracy(Criteria.ACCURACY_FINE);
|
|
||||||
String bestProvider = mLocationManager.getBestProvider(criteria, true);
|
|
||||||
if (bestProvider == null) {
|
|
||||||
showDialog(DIALOG_LOCATION_PROVIDER_DISABLED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mShowMyLocation = true;
|
|
||||||
mMyLocationListener.setCenterAtFirstFix(centerAtFirstFix);
|
|
||||||
mLocationManager.requestLocationUpdates(bestProvider, 1000, 0,
|
|
||||||
mMyLocationListener);
|
|
||||||
// mSnapToLocationView.setVisibility(View.VISIBLE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void gotoLastKnownPosition() {
|
|
||||||
Location currentLocation;
|
|
||||||
Location bestLocation = null;
|
|
||||||
for (String provider : mLocationManager.getProviders(true)) {
|
|
||||||
currentLocation = mLocationManager.getLastKnownLocation(provider);
|
|
||||||
if (currentLocation == null)
|
|
||||||
continue;
|
|
||||||
if (bestLocation == null
|
|
||||||
|| currentLocation.getAccuracy() < bestLocation.getAccuracy()) {
|
|
||||||
bestLocation = currentLocation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bestLocation != null) {
|
|
||||||
GeoPoint point = new GeoPoint(bestLocation.getLatitude(),
|
|
||||||
bestLocation.getLongitude());
|
|
||||||
mMapController.setCenter(point);
|
|
||||||
} else {
|
|
||||||
showToastOnUiThread(getString(R.string.error_last_location_unknown));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMapFilePicker() {
|
private void startMapFilePicker() {
|
||||||
@ -291,7 +285,7 @@ public class TileMap extends MapActivity {
|
|||||||
if (requestCode == SELECT_MAP_FILE) {
|
if (requestCode == SELECT_MAP_FILE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
|
||||||
disableSnapToLocation(true);
|
mLocation.disableSnapToLocation(true);
|
||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
if (intent.getStringExtra(FilePicker.SELECTED_FILE) != null) {
|
if (intent.getStringExtra(FilePicker.SELECTED_FILE) != null) {
|
||||||
@ -301,9 +295,6 @@ public class TileMap extends MapActivity {
|
|||||||
}
|
}
|
||||||
} else if (resultCode == RESULT_CANCELED) {
|
} else if (resultCode == RESULT_CANCELED) {
|
||||||
startActivity(new Intent(this, EditPreferences.class));
|
startActivity(new Intent(this, EditPreferences.class));
|
||||||
// && !mapView.getMapGenerator().requiresInternetConnection()
|
|
||||||
// && mapView.getMapFile() == null) {
|
|
||||||
// finish();
|
|
||||||
}
|
}
|
||||||
} else if (requestCode == SELECT_RENDER_THEME_FILE && resultCode == RESULT_OK
|
} else if (requestCode == SELECT_RENDER_THEME_FILE && resultCode == RESULT_OK
|
||||||
&& intent != null
|
&& intent != null
|
||||||
@ -334,41 +325,30 @@ public class TileMap extends MapActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set up the layout views
|
// set up the layout views
|
||||||
setContentView(R.layout.activity_advanced_map_viewer);
|
setContentView(R.layout.activity_tilemap);
|
||||||
|
|
||||||
// getActionBar().setDisplayOptions(ActionBar.NAVIGATION_MODE_TABS);
|
// getActionBar().setDisplayOptions(ActionBar.NAVIGATION_MODE_TABS);
|
||||||
|
|
||||||
mMapView = (MapView) findViewById(R.id.mapView);
|
mMapView = (MapView) findViewById(R.id.mapView);
|
||||||
|
|
||||||
configureMapView();
|
configureMapView();
|
||||||
|
|
||||||
// mSnapToLocationView = (ToggleButton) findViewById(R.id.snapToLocationView);
|
mLocation = new LocationHandler(this);
|
||||||
//
|
|
||||||
// mSnapToLocationView.setOnClickListener(new OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(View view) {
|
|
||||||
// if (isSnapToLocationEnabled()) {
|
|
||||||
// disableSnapToLocation(true);
|
|
||||||
// } else {
|
|
||||||
// enableSnapToLocation(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// get the pointers to different system services
|
// get the pointers to different system services
|
||||||
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
|
||||||
mMyLocationListener = new MyLocationListener(this);
|
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
|
|
||||||
mWakeLock = powerManager
|
mWakeLock = powerManager
|
||||||
.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "AMV");
|
.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "AMV");
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
if (savedInstanceState.getBoolean(BUNDLE_SHOW_MY_LOCATION)) {
|
if (savedInstanceState.getBoolean(BUNDLE_SHOW_MY_LOCATION)) {
|
||||||
|
|
||||||
enableShowMyLocation(savedInstanceState
|
// enableShowMyLocation(savedInstanceState
|
||||||
.getBoolean(BUNDLE_CENTER_AT_FIRST_FIX));
|
// .getBoolean(BUNDLE_CENTER_AT_FIRST_FIX));
|
||||||
|
|
||||||
if (savedInstanceState.getBoolean(BUNDLE_SNAP_TO_LOCATION)) {
|
if (savedInstanceState.getBoolean(BUNDLE_SNAP_TO_LOCATION)) {
|
||||||
enableSnapToLocation(false);
|
mLocation.enableSnapToLocation(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,12 +363,13 @@ public class TileMap extends MapActivity {
|
|||||||
LayoutInflater factory = LayoutInflater.from(this);
|
LayoutInflater factory = LayoutInflater.from(this);
|
||||||
final View view = factory.inflate(R.layout.dialog_enter_coordinates, null);
|
final View view = factory.inflate(R.layout.dialog_enter_coordinates, null);
|
||||||
builder.setView(view);
|
builder.setView(view);
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.go_to_position,
|
builder.setPositiveButton(R.string.go_to_position,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// disable GPS follow mode if it is enabled
|
// disable GPS follow mode if it is enabled
|
||||||
disableSnapToLocation(true);
|
mLocation.disableSnapToLocation(true);
|
||||||
|
|
||||||
// set the map center and zoom level
|
// set the map center and zoom level
|
||||||
EditText latitudeView = (EditText) view
|
EditText latitudeView = (EditText) view
|
||||||
@ -400,11 +381,13 @@ public class TileMap extends MapActivity {
|
|||||||
double longitude = Double.parseDouble(longitudeView.getText()
|
double longitude = Double.parseDouble(longitudeView.getText()
|
||||||
.toString());
|
.toString());
|
||||||
GeoPoint geoPoint = new GeoPoint(latitude, longitude);
|
GeoPoint geoPoint = new GeoPoint(latitude, longitude);
|
||||||
TileMap.this.mMapController.setCenter(geoPoint);
|
TileMap.this.mMapView.setCenter(geoPoint);
|
||||||
SeekBar zoomLevelView = (SeekBar) view
|
SeekBar zoomLevelView = (SeekBar) view
|
||||||
.findViewById(R.id.zoomLevel);
|
.findViewById(R.id.zoomLevel);
|
||||||
TileMap.this.mMapController.setZoom(zoomLevelView
|
|
||||||
.getProgress());
|
TileMap.this.mMapView.zoom((byte) (zoomLevelView
|
||||||
|
.getProgress() - mMapView.getMapPosition()
|
||||||
|
.getZoomLevel()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
@ -431,7 +414,7 @@ public class TileMap extends MapActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
disableShowMyLocation();
|
mLocation.disableShowMyLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -587,6 +570,13 @@ public class TileMap extends MapActivity {
|
|||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
if (preferences.getBoolean("fixOrientation", true)) {
|
||||||
|
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
// this all returns the orientation which is not currently active?!
|
||||||
|
// getWindow().getWindowManager().getDefaultDisplay().getRotation());
|
||||||
|
// getWindow().getWindowManager().getDefaultDisplay().getOrientation());
|
||||||
|
}
|
||||||
|
|
||||||
if (preferences.getBoolean("wakeLock", false) && !mWakeLock.isHeld()) {
|
if (preferences.getBoolean("wakeLock", false) && !mWakeLock.isHeld()) {
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
}
|
}
|
||||||
@ -628,83 +618,11 @@ public class TileMap extends MapActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, isShowMyLocationEnabled());
|
outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, mLocation.isShowMyLocationEnabled());
|
||||||
outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX,
|
// outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX,
|
||||||
mMyLocationListener.isCenterAtFirstFix());
|
// mMyLocationListener.isCenterAtFirstFix());
|
||||||
outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, mSnapToLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, mSnapToLocation);
|
||||||
* Disables the "show my location" mode.
|
|
||||||
*
|
|
||||||
* @return ...
|
|
||||||
*/
|
|
||||||
private boolean disableShowMyLocation() {
|
|
||||||
if (mShowMyLocation) {
|
|
||||||
mShowMyLocation = false;
|
|
||||||
disableSnapToLocation(false);
|
|
||||||
mLocationManager.removeUpdates(mMyLocationListener);
|
|
||||||
// if (circleOverlay != null) {
|
|
||||||
// mapView.getOverlays().remove(circleOverlay);
|
|
||||||
// mapView.getOverlays().remove(itemizedOverlay);
|
|
||||||
// circleOverlay = null;
|
|
||||||
// itemizedOverlay = null;
|
|
||||||
// }
|
|
||||||
// mSnapToLocationView.setVisibility(View.GONE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables the "snap to location" mode.
|
|
||||||
*
|
|
||||||
* @param showToast
|
|
||||||
* defines whether a toast message is displayed or not.
|
|
||||||
*/
|
|
||||||
void disableSnapToLocation(boolean showToast) {
|
|
||||||
if (mSnapToLocation) {
|
|
||||||
mSnapToLocation = false;
|
|
||||||
// mSnapToLocationView.setChecked(false);
|
|
||||||
mMapView.setClickable(true);
|
|
||||||
if (showToast) {
|
|
||||||
showToastOnUiThread(getString(R.string.snap_to_location_disabled));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables the "snap to location" mode.
|
|
||||||
*
|
|
||||||
* @param showToast
|
|
||||||
* defines whether a toast message is displayed or not.
|
|
||||||
*/
|
|
||||||
void enableSnapToLocation(boolean showToast) {
|
|
||||||
if (!mSnapToLocation) {
|
|
||||||
mSnapToLocation = true;
|
|
||||||
mMapView.setClickable(false);
|
|
||||||
if (showToast) {
|
|
||||||
showToastOnUiThread(getString(R.string.snap_to_location_enabled));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the status of the "show my location" mode.
|
|
||||||
*
|
|
||||||
* @return true if the "show my location" mode is enabled, false otherwise.
|
|
||||||
*/
|
|
||||||
boolean isShowMyLocationEnabled() {
|
|
||||||
return mShowMyLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the status of the "snap to location" mode.
|
|
||||||
*
|
|
||||||
* @return true if the "snap to location" mode is enabled, false otherwise.
|
|
||||||
*/
|
|
||||||
boolean isSnapToLocationEnabled() {
|
|
||||||
return mSnapToLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -734,4 +652,28 @@ public class TileMap extends MapActivity {
|
|||||||
// // TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
class SeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
private final TextView textView;
|
||||||
|
|
||||||
|
SeekBarChangeListener(TextView textView) {
|
||||||
|
this.textView = textView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
this.textView.setText(String.valueOf(progress));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user