diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5ee5fba8..b79068c4 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -15,8 +15,10 @@ android:targetSdkVersion="15" /> + android:icon="@drawable/globe2" + android:label="@string/application_name" + android:theme="@style/Theme.TileMap" > + diff --git a/gen/org/mapsforge/tilemap/R.java b/gen/org/mapsforge/tilemap/R.java index cf3b7be3..8d334d34 100644 --- a/gen/org/mapsforge/tilemap/R.java +++ b/gen/org/mapsforge/tilemap/R.java @@ -10,64 +10,69 @@ package org.mapsforge.tilemap; public final class R { public static final class array { public static final int preferences_map_database_keys=0x7f050000; - public static final int preferences_map_generator_values=0x7f050003; + public static final int preferences_map_generator_values=0x7f050004; public static final int preferences_scale_bar_unit_keys=0x7f050001; - public static final int preferences_scale_bar_unit_values=0x7f050004; + public static final int preferences_scale_bar_unit_values=0x7f050005; public static final int preferences_text_scale_keys=0x7f050002; - public static final int preferences_text_scale_values=0x7f050005; + public static final int preferences_text_scale_values=0x7f050006; + public static final int view_sections=0x7f050003; } public static final class attr { } public static final class drawable { - public static final int btn_snap_normal=0x7f020000; - public static final int btn_snap_pressed=0x7f020001; - public static final int btn_snap_selected=0x7f020002; - public static final int file_picker_back=0x7f020003; - public static final int file_picker_file=0x7f020004; - public static final int file_picker_folder=0x7f020005; - public static final int globe=0x7f020006; - public static final int ic_menu_archive=0x7f020007; - public static final int ic_menu_camera=0x7f020008; - public static final int ic_menu_info_details=0x7f020009; - public static final int ic_menu_mapmode=0x7f02000a; - public static final int ic_menu_mylocation=0x7f02000b; - public static final int ic_menu_preferences=0x7f02000c; - public static final int my_location=0x7f02000d; - public static final int snap_to_position=0x7f02000e; + public static final int action_bar=0x7f020000; + public static final int bar_globe=0x7f020001; + public static final int bar_globe2=0x7f020002; + public static final int btn_snap_normal=0x7f020003; + public static final int btn_snap_pressed=0x7f020004; + public static final int btn_snap_selected=0x7f020005; + public static final int file_picker_back=0x7f020006; + public static final int file_picker_file=0x7f020007; + public static final int file_picker_folder=0x7f020008; + public static final int globe=0x7f020009; + public static final int globe2=0x7f02000a; + public static final int ic_menu_archive=0x7f02000b; + public static final int ic_menu_camera=0x7f02000c; + public static final int ic_menu_info_details=0x7f02000d; + public static final int ic_menu_mapmode=0x7f02000e; + public static final int ic_menu_mylocation=0x7f02000f; + public static final int ic_menu_options=0x7f020010; + public static final int ic_menu_preferences=0x7f020011; + public static final int my_location=0x7f020012; + public static final int snap_to_position=0x7f020013; } public static final class id { - public static final int filePickerView=0x7f080003; - public static final int infoMapFileViewArea=0x7f08000d; - public static final int infoMapFileViewComment=0x7f080011; - public static final int infoMapFileViewCreatedBy=0x7f080012; - public static final int infoMapFileViewDate=0x7f08000c; - public static final int infoMapFileViewDebug=0x7f08000b; - public static final int infoMapFileViewLanguagePreference=0x7f080010; - public static final int infoMapFileViewName=0x7f080008; - public static final int infoMapFileViewSize=0x7f080009; - public static final int infoMapFileViewStartPosition=0x7f08000e; - public static final int infoMapFileViewStartZoomLevel=0x7f08000f; - public static final int infoMapFileViewVersion=0x7f08000a; - public static final int latitude=0x7f080004; - public static final int longitude=0x7f080005; - public static final int mainView=0x7f080000; - public static final int mapView=0x7f080001; - public static final int menu_info=0x7f080013; - public static final int menu_info_map_file=0x7f080014; - public static final int menu_mapfile=0x7f08001f; - public static final int menu_position=0x7f080015; - public static final int menu_position_enter_coordinates=0x7f080019; - public static final int menu_position_last_known=0x7f080018; - public static final int menu_position_map_center=0x7f08001a; - public static final int menu_position_my_location_disable=0x7f080017; - public static final int menu_position_my_location_enable=0x7f080016; - public static final int menu_preferences=0x7f08001b; - public static final int menu_render_theme=0x7f08001c; - public static final int menu_render_theme_osmarender=0x7f08001d; - public static final int menu_render_theme_select_file=0x7f08001e; - public static final int snapToLocationView=0x7f080002; - public static final int zoomLevel=0x7f080006; - public static final int zoomlevelValue=0x7f080007; + public static final int filePickerView=0x7f090003; + public static final int infoMapFileViewArea=0x7f09000d; + public static final int infoMapFileViewComment=0x7f090011; + public static final int infoMapFileViewCreatedBy=0x7f090012; + public static final int infoMapFileViewDate=0x7f09000c; + public static final int infoMapFileViewDebug=0x7f09000b; + public static final int infoMapFileViewLanguagePreference=0x7f090010; + public static final int infoMapFileViewName=0x7f090008; + public static final int infoMapFileViewSize=0x7f090009; + public static final int infoMapFileViewStartPosition=0x7f09000e; + public static final int infoMapFileViewStartZoomLevel=0x7f09000f; + public static final int infoMapFileViewVersion=0x7f09000a; + public static final int latitude=0x7f090004; + public static final int longitude=0x7f090005; + public static final int mainView=0x7f090000; + public static final int mapView=0x7f090001; + public static final int menu_mapfile=0x7f09001e; + public static final int menu_options=0x7f090019; + public static final int menu_position=0x7f090013; + public static final int menu_position_enter_coordinates=0x7f090017; + public static final int menu_position_last_known=0x7f090016; + public static final int menu_position_map_center=0x7f090018; + public static final int menu_position_my_location_disable=0x7f090015; + public static final int menu_position_my_location_enable=0x7f090014; + public static final int menu_preferences=0x7f09001a; + public static final int menu_render_theme=0x7f09001b; + public static final int menu_render_theme_osmarender=0x7f09001c; + public static final int menu_render_theme_select_file=0x7f09001d; + public static final int snapToLocationView=0x7f090002; + public static final int zoomLevel=0x7f090006; + public static final int zoomlevelValue=0x7f090007; } public static final class layout { public static final int activity_advanced_map_viewer=0x7f030000; @@ -76,7 +81,7 @@ public final class R { public static final int dialog_info_map_file=0x7f030003; } public static final class menu { - public static final int options_menu=0x7f070000; + public static final int options_menu=0x7f080000; } public static final class string { public static final int application_name=0x7f060003; @@ -101,7 +106,7 @@ public final class R { public static final int info_map_file_language_preference=0x7f060016; public static final int info_map_file_name=0x7f060017; public static final int info_map_file_size=0x7f060018; - public static final int info_map_file_start=0x7f060055; + public static final int info_map_file_start=0x7f060056; public static final int info_map_file_start_position=0x7f060019; public static final int info_map_file_start_zoom_level=0x7f06001a; public static final int info_map_file_version=0x7f06001b; @@ -111,6 +116,7 @@ public final class R { public static final int menu_info_about=0x7f060020; public static final int menu_info_map_file=0x7f06001f; public static final int menu_mapfile=0x7f060021; + public static final int menu_options=0x7f060055; public static final int menu_position=0x7f060022; public static final int menu_position_enter_coordinates=0x7f060023; public static final int menu_position_last_known=0x7f060024; @@ -154,7 +160,7 @@ public final class R { public static final int preferences_show_tile_coordinates_desc=0x7f060047; public static final int preferences_show_tile_frames=0x7f060048; public static final int preferences_show_tile_frames_desc=0x7f060049; - public static final int preferences_show_water_tiles=0x7f060056; + public static final int preferences_show_water_tiles=0x7f060057; public static final int preferences_show_water_tiles_desc=0x7f06004b; public static final int preferences_text_scale=0x7f06004c; public static final int preferences_text_scale_default=0x7f060002; @@ -167,6 +173,18 @@ public final class R { public static final int unit_symbol_meter=0x7f060053; public static final int zoomLevel=0x7f060054; } + public static final class style { + public static final int MyActionBar=0x7f070000; + /** + @style/MyDropDownListView + @style/MyActionBarTabStyle + @style/MyDropDownNav + @drawable/ad_btn_check_holo_light + @drawable/ad_btn_radio_holo_light + + */ + public static final int Theme_TileMap=0x7f070001; + } public static final class xml { public static final int preferences=0x7f040000; } diff --git a/res/drawable-hdpi/bar_globe.png b/res/drawable-hdpi/bar_globe.png new file mode 100644 index 00000000..4a5756d8 Binary files /dev/null and b/res/drawable-hdpi/bar_globe.png differ diff --git a/res/drawable-hdpi/bar_globe2.png b/res/drawable-hdpi/bar_globe2.png new file mode 100644 index 00000000..750487f0 Binary files /dev/null and b/res/drawable-hdpi/bar_globe2.png differ diff --git a/res/drawable-hdpi/globe.png b/res/drawable-hdpi/globe.png deleted file mode 100644 index 2232b634..00000000 Binary files a/res/drawable-hdpi/globe.png and /dev/null differ diff --git a/res/drawable-hdpi/ic_menu_archive.png b/res/drawable-hdpi/ic_menu_archive.png index 9ca5c624..6f441b41 100644 Binary files a/res/drawable-hdpi/ic_menu_archive.png and b/res/drawable-hdpi/ic_menu_archive.png differ diff --git a/res/drawable-hdpi/ic_menu_mylocation.png b/res/drawable-hdpi/ic_menu_mylocation.png index 1bcb0cd4..d7fae7e9 100644 Binary files a/res/drawable-hdpi/ic_menu_mylocation.png and b/res/drawable-hdpi/ic_menu_mylocation.png differ diff --git a/res/drawable-hdpi/ic_menu_options.png b/res/drawable-hdpi/ic_menu_options.png new file mode 100644 index 00000000..3e4580e0 Binary files /dev/null and b/res/drawable-hdpi/ic_menu_options.png differ diff --git a/res/drawable-mdpi/bar_globe2.png b/res/drawable-mdpi/bar_globe2.png new file mode 100644 index 00000000..ac676e3c Binary files /dev/null and b/res/drawable-mdpi/bar_globe2.png differ diff --git a/res/drawable-mdpi/globe.png b/res/drawable-mdpi/globe.png index 68a88971..f7a97a64 100644 Binary files a/res/drawable-mdpi/globe.png and b/res/drawable-mdpi/globe.png differ diff --git a/res/drawable-mdpi/ic_menu_archive.png b/res/drawable-mdpi/ic_menu_archive.png old mode 100755 new mode 100644 index a4599e37..cc81e57f Binary files a/res/drawable-mdpi/ic_menu_archive.png and b/res/drawable-mdpi/ic_menu_archive.png differ diff --git a/res/drawable-mdpi/ic_menu_mylocation.png b/res/drawable-mdpi/ic_menu_mylocation.png old mode 100755 new mode 100644 index fdbd5ca1..9d1f4403 Binary files a/res/drawable-mdpi/ic_menu_mylocation.png and b/res/drawable-mdpi/ic_menu_mylocation.png differ diff --git a/res/drawable-mdpi/ic_menu_options.png b/res/drawable-mdpi/ic_menu_options.png new file mode 100644 index 00000000..d3e42edc Binary files /dev/null and b/res/drawable-mdpi/ic_menu_options.png differ diff --git a/res/drawable/action_bar.xml b/res/drawable/action_bar.xml new file mode 100644 index 00000000..11c7f98d --- /dev/null +++ b/res/drawable/action_bar.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/res/drawable/globe2.png b/res/drawable/globe2.png new file mode 100644 index 00000000..64c4e31a Binary files /dev/null and b/res/drawable/globe2.png differ diff --git a/res/layout/activity_advanced_map_viewer.xml b/res/layout/activity_advanced_map_viewer.xml index 842a59e8..0bddfd17 100644 --- a/res/layout/activity_advanced_map_viewer.xml +++ b/res/layout/activity_advanced_map_viewer.xml @@ -2,7 +2,9 @@ + android:layout_height="fill_parent" + android:windowActionBarOverlay="true" + > - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 9cf0efeb..2a7f286e 100755 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -18,7 +18,7 @@ riesig - VectorTileMap + OpenScienceMap Abbrechen Fehler Die letzte Position ist unbekannt diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index ed0cc383..1929f577 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -13,7 +13,7 @@ hyvin suuri - VectorTileMap + OpenScienceMap Peruuta Virhe Viimeinen sijainti ei ole tiedossa diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 745b2aa2..312f0e2f 100755 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -13,7 +13,7 @@ enorme - VectorTileMap + OpenScienceMap Annulla Errore L\'ultima posizione รจ sconosciuta diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 2bc4667b..04b7c6fe 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -4,7 +4,7 @@ MAP_READER POSTGIS_READER - MAP_READER + POSTGIS_READER imperial @@ -20,4 +20,11 @@ 1.6 1.0 + + + Map + Routes + Overlays + etc + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index ffe3c179..55e2ad76 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -18,7 +18,7 @@ huge - VectorTileMap + OpenScienceMap Cancel Error The last location is unknown @@ -100,4 +100,5 @@  km  m Zoom level + Options \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml new file mode 100644 index 00000000..705ab3a2 --- /dev/null +++ b/res/values/styles.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/src/org/mapsforge/android/MapActivity.java b/src/org/mapsforge/android/MapActivity.java index 5e367267..85e99807 100644 --- a/src/org/mapsforge/android/MapActivity.java +++ b/src/org/mapsforge/android/MapActivity.java @@ -40,7 +40,8 @@ public abstract class MapActivity extends Activity { private static final String PREFERENCES_FILE = "MapActivity"; private static boolean containsMapViewPosition(SharedPreferences sharedPreferences) { - return sharedPreferences.contains(KEY_LATITUDE) && sharedPreferences.contains(KEY_LONGITUDE) + return sharedPreferences.contains(KEY_LATITUDE) + && sharedPreferences.contains(KEY_LONGITUDE) && sharedPreferences.contains(KEY_ZOOM_LEVEL); } @@ -59,10 +60,14 @@ public abstract class MapActivity extends Activity { } private void restoreMapView(MapView mapView) { - SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE); + SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE, + MODE_PRIVATE); if (containsMapViewPosition(sharedPreferences)) { + MapGenerator mapGenerator = mapView.getMapGenerator(); - if (!mapGenerator.requiresInternetConnection() && sharedPreferences.contains(KEY_MAP_FILE)) { + + if (!mapGenerator.requiresInternetConnection() + && sharedPreferences.contains(KEY_MAP_FILE)) { // get and set the map file mapView.setMapFile(sharedPreferences.getString(KEY_MAP_FILE, null)); } @@ -101,7 +106,8 @@ public abstract class MapActivity extends Activity { editor.putInt(KEY_ZOOM_LEVEL, mapPosition.zoomLevel); } - if (!mMapView.getMapGenerator().requiresInternetConnection() && mMapView.getMapFile() != null) { + if (!mMapView.getMapGenerator().requiresInternetConnection() + && mMapView.getMapFile() != null) { // save the map file editor.putString(KEY_MAP_FILE, mMapView.getMapFile()); } diff --git a/src/org/mapsforge/android/MapView.java b/src/org/mapsforge/android/MapView.java index 0bfd1d9f..a04a0ff0 100644 --- a/src/org/mapsforge/android/MapView.java +++ b/src/org/mapsforge/android/MapView.java @@ -25,6 +25,7 @@ import org.mapsforge.android.mapgenerator.MapDatabaseFactory; import org.mapsforge.android.mapgenerator.MapDatabaseInternal; import org.mapsforge.android.mapgenerator.MapGenerator; import org.mapsforge.android.mapgenerator.MapGeneratorFactory; +import org.mapsforge.android.mapgenerator.MapGeneratorInternal; import org.mapsforge.android.mapgenerator.MapWorker; import org.mapsforge.android.rendertheme.ExternalRenderTheme; import org.mapsforge.android.rendertheme.InternalRenderTheme; @@ -93,7 +94,9 @@ public class MapView extends GLSurfaceView { * if the context object is not an instance of {@link MapActivity} . */ public MapView(Context context) { - this(context, null, new org.mapsforge.android.glrenderer.DatabaseRenderer()); + this(context, null, + MapGeneratorFactory.createMapGenerator(MapGeneratorInternal.GL_RENDERER), + MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.MAP_READER)); } /** @@ -105,7 +108,9 @@ public class MapView extends GLSurfaceView { * if the context object is not an instance of {@link MapActivity} . */ public MapView(Context context, AttributeSet attributeSet) { - this(context, attributeSet, MapGeneratorFactory.createMapGenerator(attributeSet)); + this(context, attributeSet, + MapGeneratorFactory.createMapGenerator(attributeSet), + MapDatabaseFactory.createMapDatabase(attributeSet)); } /** @@ -117,10 +122,12 @@ public class MapView extends GLSurfaceView { * if the context object is not an instance of {@link MapActivity} . */ public MapView(Context context, MapGenerator mapGenerator) { - this(context, null, mapGenerator); + this(context, null, mapGenerator, MapDatabaseFactory + .createMapDatabase(MapDatabaseInternal.MAP_READER)); } - private MapView(Context context, AttributeSet attributeSet, MapGenerator mapGenerator) { + private MapView(Context context, AttributeSet attributeSet, + MapGenerator mapGenerator, IMapDatabase mapDatabase) { super(context, attributeSet); @@ -128,6 +135,7 @@ public class MapView extends GLSurfaceView { throw new IllegalArgumentException( "context is not an instance of MapActivity"); } + setWillNotDraw(true); setWillNotCacheDrawing(true); @@ -139,8 +147,9 @@ public class MapView extends GLSurfaceView { mMapController = new MapController(this); // mMapDatabase = MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.POSTGIS_READER); - mMapDatabase = MapDatabaseFactory - .createMapDatabase(MapDatabaseInternal.MAP_READER); + mMapDatabase = mapDatabase; + // MapDatabaseFactory + // .createMapDatabase(MapDatabaseInternal.MAP_READER); mMapViewPosition = new MapViewPosition(this); mMapScaleBar = new MapScaleBar(this); @@ -354,14 +363,21 @@ public class MapView extends GLSurfaceView { * if the current MapGenerator mode works with an Internet connection. */ public boolean setMapFile(String mapFile) { + FileOpenResult fileOpenResult = null; + if (mMapGenerator.requiresInternetConnection()) { throw new UnsupportedOperationException(); } Log.d(TAG, "set mapfile " + mapFile); - if (mapFile == null) { - // no map file specified - return false; - } else if (mapFile.equals(mMapFile)) { + // if (mapFile == null) { + // if (mMapDatabase instanceof org.mapsforge.database.postgis.MapDatabase) { + // fileOpenResult = mMapDatabase.openFile(null); + // } else { + // // no map file specified + // return false; + // } + // } else + if (mapFile != null && mapFile.equals(mMapFile)) { // same map file as before return false; } @@ -378,8 +394,13 @@ public class MapView extends GLSurfaceView { mMapWorker.proceed(); mMapDatabase.closeFile(); - FileOpenResult fileOpenResult = mMapDatabase.openFile(new File(mapFile)); - if (fileOpenResult.isSuccess()) { + + if (mapFile != null) + fileOpenResult = mMapDatabase.openFile(new File(mapFile)); + else + fileOpenResult = mMapDatabase.openFile(null); + + if (fileOpenResult != null && fileOpenResult.isSuccess()) { mMapFile = mapFile; GeoPoint startPoint = mMapGenerator.getStartPoint(); @@ -454,19 +475,24 @@ public class MapView extends GLSurfaceView { if (mapDatabase == null) { throw new IllegalArgumentException("MapDatabase must not be null"); } - // mMapWorker.pause(); - // mMapWorker.awaitPausing(); + if (!mMapWorker.isPausing()) { + mMapWorker.pause(); + mMapWorker.awaitPausing(); + } + + mJobQueue.clear(); mMapDatabase = mapDatabase; mMapGenerator.setMapDatabase(mMapDatabase); Log.d(TAG, "setMapDatabaseInternal " + mapDatabase.getClass()); - // mMapWorker.proceed(); String mapFile = mMapFile; mMapFile = null; setMapFile(mapFile); + mMapWorker.proceed(); + // mMapWorker.setMapDatabase(mMapDatabase); } @@ -559,28 +585,28 @@ public class MapView extends GLSurfaceView { return true; } - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - // mMapZoomControls.onLayout(changed, left, top, right, bottom); - } + // @Override + // protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + // super.onLayout(changed, left, top, right, bottom); + // // mMapZoomControls.onLayout(changed, left, top, right, bottom); + // } - @Override - protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - // find out how big the zoom controls should be - mMapZoomControls.measure( - MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), - MeasureSpec.AT_MOST), - MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), - MeasureSpec.AT_MOST)); - - // make sure that MapView is big enough to display the zoom controls - setMeasuredDimension( - Math.max(MeasureSpec.getSize(widthMeasureSpec), - mMapZoomControls.getMeasuredWidth()), - Math.max(MeasureSpec.getSize(heightMeasureSpec), - mMapZoomControls.getMeasuredHeight())); - } + // @Override + // protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // // find out how big the zoom controls should be + // mMapZoomControls.measure( + // MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), + // MeasureSpec.AT_MOST), + // MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), + // MeasureSpec.AT_MOST)); + // + // // make sure that MapView is big enough to display the zoom controls + // setMeasuredDimension( + // Math.max(MeasureSpec.getSize(widthMeasureSpec), + // mMapZoomControls.getMeasuredWidth()), + // Math.max(MeasureSpec.getSize(heightMeasureSpec), + // mMapZoomControls.getMeasuredHeight())); + // } @Override protected synchronized void onSizeChanged(int width, int height, int oldWidth, diff --git a/src/org/mapsforge/tilemap/TileMap.java b/src/org/mapsforge/tilemap/TileMap.java index ec7001b9..e58ee17a 100755 --- a/src/org/mapsforge/tilemap/TileMap.java +++ b/src/org/mapsforge/tilemap/TileMap.java @@ -8,7 +8,6 @@ import java.util.Date; import org.mapsforge.android.DebugSettings; import org.mapsforge.android.MapActivity; import org.mapsforge.android.MapController; -import org.mapsforge.android.MapScaleBar; import org.mapsforge.android.MapView; import org.mapsforge.android.mapgenerator.MapDatabaseFactory; import org.mapsforge.android.mapgenerator.MapDatabaseInternal; @@ -25,6 +24,7 @@ import org.mapsforge.tilemap.filefilter.ValidRenderTheme; import org.mapsforge.tilemap.filepicker.FilePicker; import org.mapsforge.tilemap.preferences.EditPreferences; +import android.app.ActionBar; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; @@ -46,8 +46,10 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager; +import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.SeekBar; +import android.widget.SpinnerAdapter; import android.widget.TextView; import android.widget.Toast; import android.widget.ToggleButton; @@ -57,31 +59,36 @@ import android.widget.ToggleButton; * location. A simple file browser for selecting the map file is also included. Some preferences can be adjusted via the * {@link EditPreferences} activity. */ -public class TileMap extends MapActivity { +public class TileMap extends MapActivity implements ActionBar.OnNavigationListener { private static final String BUNDLE_CENTER_AT_FIRST_FIX = "centerAtFirstFix"; private static final String BUNDLE_SHOW_MY_LOCATION = "showMyLocation"; private static final String BUNDLE_SNAP_TO_LOCATION = "snapToLocation"; private static final int DIALOG_ENTER_COORDINATES = 0; private static final int DIALOG_INFO_MAP_FILE = 1; private static final int DIALOG_LOCATION_PROVIDER_DISABLED = 2; - private static final FileFilter FILE_FILTER_EXTENSION_MAP = new FilterByFileExtension(".map"); - private static final FileFilter FILE_FILTER_EXTENSION_XML = new FilterByFileExtension(".xml"); + private static final FileFilter FILE_FILTER_EXTENSION_MAP = + new FilterByFileExtension(".map"); + private static final FileFilter FILE_FILTER_EXTENSION_XML = + new FilterByFileExtension(".xml"); private static final int SELECT_MAP_FILE = 0; private static final int SELECT_RENDER_THEME_FILE = 1; - private LocationManager locationManager; - private MapDatabaseInternal mapDatabaseInternal; - private MyLocationListener myLocationListener; - private boolean showMyLocation; - private boolean snapToLocation; - private ToggleButton snapToLocationView; - private WakeLock wakeLock; - MapController mapController; - MapView mapView; + private LocationManager mLocationManager; + private MapDatabaseInternal mMapDatabaseInternal; + private MyLocationListener mMyLocationListener; + private boolean mShowMyLocation; + private boolean mSnapToLocation; + private ToggleButton mSnapToLocationView; + private WakeLock mWakeLock; + MapController mMapController; + MapView mMapView; private Menu mMenu = null; + SpinnerAdapter mSpinnerAdapter; + @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.options_menu, menu); + mMenu = menu; return true; } @@ -89,31 +96,37 @@ public class TileMap extends MapActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_info: - return true; - case R.id.menu_info_map_file: - showDialog(DIALOG_INFO_MAP_FILE); - return true; + // case R.id.menu_info_map_file: + // showDialog(DIALOG_INFO_MAP_FILE); + // return true; case R.id.menu_position: return true; case R.id.menu_position_my_location_enable: if (enableShowMyLocation(true)) { - mMenu.findItem(R.id.menu_position_my_location_enable).setVisible(false); - mMenu.findItem(R.id.menu_position_my_location_enable).setEnabled(false); - mMenu.findItem(R.id.menu_position_my_location_disable).setVisible(true); - mMenu.findItem(R.id.menu_position_my_location_disable).setEnabled(true); + mMenu.findItem(R.id.menu_position_my_location_enable) + .setVisible(false); + mMenu.findItem(R.id.menu_position_my_location_enable) + .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; case R.id.menu_position_my_location_disable: if (disableShowMyLocation()) { - mMenu.findItem(R.id.menu_position_my_location_enable).setVisible(true); - mMenu.findItem(R.id.menu_position_my_location_enable).setEnabled(true); - mMenu.findItem(R.id.menu_position_my_location_disable).setVisible(false); - mMenu.findItem(R.id.menu_position_my_location_disable).setEnabled(false); + mMenu.findItem(R.id.menu_position_my_location_enable) + .setVisible(true); + mMenu.findItem(R.id.menu_position_my_location_enable) + .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; @@ -128,7 +141,8 @@ public class TileMap extends MapActivity { case R.id.menu_position_map_center: // disable GPS follow mode if it is enabled disableSnapToLocation(true); - this.mapController.setCenter(this.mapView.getMapDatabase().getMapFileInfo().mapCenter); + mMapController.setCenter(mMapView.getMapDatabase() + .getMapFileInfo().mapCenter); return true; case R.id.menu_preferences: @@ -138,8 +152,11 @@ public class TileMap extends MapActivity { case R.id.menu_render_theme: return true; + case R.id.menu_options: + return true; + case R.id.menu_render_theme_osmarender: - this.mapView.setRenderTheme(InternalRenderTheme.OSMARENDER); + mMapView.setRenderTheme(InternalRenderTheme.OSMARENDER); return true; case R.id.menu_render_theme_select_file: @@ -157,13 +174,13 @@ public class TileMap extends MapActivity { @Override public boolean onPrepareOptionsMenu(Menu menu) { - MapGenerator mapGenerator = this.mapView.getMapGenerator(); + MapGenerator mapGenerator = mMapView.getMapGenerator(); - if (mapGenerator.requiresInternetConnection()) { - menu.findItem(R.id.menu_info_map_file).setEnabled(false); - } else { - menu.findItem(R.id.menu_info_map_file).setEnabled(true); - } + // if (mapGenerator.requiresInternetConnection()) { + // menu.findItem(R.id.menu_info_map_file).setEnabled(false); + // } else { + // menu.findItem(R.id.menu_info_map_file).setEnabled(true); + // } if (isShowMyLocationEnabled()) { menu.findItem(R.id.menu_position_my_location_enable).setVisible(false); @@ -201,32 +218,33 @@ public class TileMap extends MapActivity { @Override public boolean onTrackballEvent(MotionEvent event) { // forward the event to the MapView - return this.mapView.onTrackballEvent(event); + return mMapView.onTrackballEvent(event); } private void configureMapView() { // configure the MapView and activate the zoomLevel buttons - this.mapView.setClickable(true); - this.mapView.setBuiltInZoomControls(true); - this.mapView.setFocusable(true); + mMapView.setClickable(true); + mMapView.setBuiltInZoomControls(true); + mMapView.setFocusable(true); - this.mapController = this.mapView.getController(); + mMapController = mMapView.getController(); } private boolean enableShowMyLocation(boolean centerAtFirstFix) { - if (!this.showMyLocation) { + if (!mShowMyLocation) { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); - String bestProvider = this.locationManager.getBestProvider(criteria, true); + String bestProvider = mLocationManager.getBestProvider(criteria, true); if (bestProvider == null) { showDialog(DIALOG_LOCATION_PROVIDER_DISABLED); return false; } - this.showMyLocation = true; - this.myLocationListener.setCenterAtFirstFix(centerAtFirstFix); - this.locationManager.requestLocationUpdates(bestProvider, 1000, 0, this.myLocationListener); - this.snapToLocationView.setVisibility(View.VISIBLE); + mShowMyLocation = true; + mMyLocationListener.setCenterAtFirstFix(centerAtFirstFix); + mLocationManager.requestLocationUpdates(bestProvider, 1000, 0, + mMyLocationListener); + mSnapToLocationView.setVisibility(View.VISIBLE); return true; } return false; @@ -235,16 +253,20 @@ public class TileMap extends MapActivity { private void gotoLastKnownPosition() { Location currentLocation; Location bestLocation = null; - for (String provider : this.locationManager.getProviders(true)) { - currentLocation = this.locationManager.getLastKnownLocation(provider); - if (bestLocation == null || currentLocation.getAccuracy() < bestLocation.getAccuracy()) { + 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()); - this.mapController.setCenter(point); + GeoPoint point = new GeoPoint(bestLocation.getLatitude(), + bestLocation.getLongitude()); + mMapController.setCenter(point); } else { showToastOnUiThread(getString(R.string.error_last_location_unknown)); } @@ -259,25 +281,35 @@ public class TileMap extends MapActivity { private void startRenderThemePicker() { FilePicker.setFileDisplayFilter(FILE_FILTER_EXTENSION_XML); FilePicker.setFileSelectFilter(new ValidRenderTheme()); - startActivityForResult(new Intent(this, FilePicker.class), SELECT_RENDER_THEME_FILE); + startActivityForResult(new Intent(this, FilePicker.class), + SELECT_RENDER_THEME_FILE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == SELECT_MAP_FILE) { if (resultCode == RESULT_OK) { + disableSnapToLocation(true); - if (intent != null && intent.getStringExtra(FilePicker.SELECTED_FILE) != null) { - this.mapView.setMapFile(intent.getStringExtra(FilePicker.SELECTED_FILE)); + + if (intent != null) { + if (intent.getStringExtra(FilePicker.SELECTED_FILE) != null) { + mMapView.setMapFile(intent + .getStringExtra(FilePicker.SELECTED_FILE)); + } } - } else if (resultCode == RESULT_CANCELED && !this.mapView.getMapGenerator().requiresInternetConnection() - && this.mapView.getMapFile() == null) { - finish(); + } else if (resultCode == RESULT_CANCELED) { + startActivity(new Intent(this, EditPreferences.class)); + // && !mapView.getMapGenerator().requiresInternetConnection() + // && mapView.getMapFile() == null) { + // finish(); } - } else if (requestCode == SELECT_RENDER_THEME_FILE && resultCode == RESULT_OK && intent != null + } else if (requestCode == SELECT_RENDER_THEME_FILE && resultCode == RESULT_OK + && intent != null && intent.getStringExtra(FilePicker.SELECTED_FILE) != null) { try { - this.mapView.setRenderTheme(intent.getStringExtra(FilePicker.SELECTED_FILE)); + mMapView.setRenderTheme(intent + .getStringExtra(FilePicker.SELECTED_FILE)); } catch (FileNotFoundException e) { showToastOnUiThread(e.getLocalizedMessage()); } @@ -288,14 +320,31 @@ public class TileMap extends MapActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // this.requestWindowFeature(Window.FEATURE_NO_TITLE); + mSpinnerAdapter = ArrayAdapter.createFromResource(this, + R.array.view_sections, + android.R.layout.simple_spinner_dropdown_item); + ActionBar actionBar = getActionBar(); + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); + + actionBar.setListNavigationCallbacks(mSpinnerAdapter, this); + actionBar.setDisplayShowTitleEnabled(false); + + // getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + // getActionBar().setBackgroundDrawable( + // getResources().getDrawable(R.drawable.action_bar)); + // // getActionBar().setDisplayShowTitleEnabled(false); + // getActionBar().setIcon(R.drawable.bar_globe2); + // set up the layout views setContentView(R.layout.activity_advanced_map_viewer); - this.mapView = (MapView) findViewById(R.id.mapView); + + // getActionBar().setDisplayOptions(ActionBar.NAVIGATION_MODE_TABS); + + mMapView = (MapView) findViewById(R.id.mapView); configureMapView(); - this.snapToLocationView = (ToggleButton) findViewById(R.id.snapToLocationView); - this.snapToLocationView.setOnClickListener(new OnClickListener() { + mSnapToLocationView = (ToggleButton) findViewById(R.id.snapToLocationView); + mSnapToLocationView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (isSnapToLocationEnabled()) { @@ -307,15 +356,21 @@ public class TileMap extends MapActivity { }); // get the pointers to different system services - this.locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); - this.myLocationListener = new MyLocationListener(this); + mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + mMyLocationListener = new MyLocationListener(this); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); - this.wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "AMV"); + mWakeLock = powerManager + .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "AMV"); - if (savedInstanceState != null && savedInstanceState.getBoolean(BUNDLE_SHOW_MY_LOCATION)) { - enableShowMyLocation(savedInstanceState.getBoolean(BUNDLE_CENTER_AT_FIRST_FIX)); - if (savedInstanceState.getBoolean(BUNDLE_SNAP_TO_LOCATION)) { - enableSnapToLocation(false); + if (savedInstanceState != null) { + if (savedInstanceState.getBoolean(BUNDLE_SHOW_MY_LOCATION)) { + + enableShowMyLocation(savedInstanceState + .getBoolean(BUNDLE_CENTER_AT_FIRST_FIX)); + + if (savedInstanceState.getBoolean(BUNDLE_SNAP_TO_LOCATION)) { + enableSnapToLocation(false); + } } } } @@ -329,23 +384,30 @@ public class TileMap extends MapActivity { LayoutInflater factory = LayoutInflater.from(this); final View view = factory.inflate(R.layout.dialog_enter_coordinates, null); builder.setView(view); - builder.setPositiveButton(R.string.go_to_position, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // disable GPS follow mode if it is enabled - disableSnapToLocation(true); + builder.setPositiveButton(R.string.go_to_position, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // disable GPS follow mode if it is enabled + disableSnapToLocation(true); - // set the map center and zoom level - EditText latitudeView = (EditText) view.findViewById(R.id.latitude); - EditText longitudeView = (EditText) view.findViewById(R.id.longitude); - double latitude = Double.parseDouble(latitudeView.getText().toString()); - double longitude = Double.parseDouble(longitudeView.getText().toString()); - GeoPoint geoPoint = new GeoPoint(latitude, longitude); - TileMap.this.mapController.setCenter(geoPoint); - SeekBar zoomLevelView = (SeekBar) view.findViewById(R.id.zoomLevel); - TileMap.this.mapController.setZoom(zoomLevelView.getProgress()); - } - }); + // set the map center and zoom level + EditText latitudeView = (EditText) view + .findViewById(R.id.latitude); + EditText longitudeView = (EditText) view + .findViewById(R.id.longitude); + double latitude = Double.parseDouble(latitudeView.getText() + .toString()); + double longitude = Double.parseDouble(longitudeView.getText() + .toString()); + GeoPoint geoPoint = new GeoPoint(latitude, longitude); + TileMap.this.mMapController.setCenter(geoPoint); + SeekBar zoomLevelView = (SeekBar) view + .findViewById(R.id.zoomLevel); + TileMap.this.mMapController.setZoom(zoomLevelView + .getProgress()); + } + }); builder.setNegativeButton(R.string.cancel, null); return builder.create(); } else if (id == DIALOG_LOCATION_PROVIDER_DISABLED) { @@ -377,8 +439,8 @@ public class TileMap extends MapActivity { protected void onPause() { super.onPause(); // release the wake lock if necessary - if (this.wakeLock.isHeld()) { - this.wakeLock.release(); + if (mWakeLock.isHeld()) { + mWakeLock.release(); } } @@ -386,27 +448,28 @@ public class TileMap extends MapActivity { protected void onPrepareDialog(int id, final Dialog dialog) { if (id == DIALOG_ENTER_COORDINATES) { EditText editText = (EditText) dialog.findViewById(R.id.latitude); - GeoPoint mapCenter = this.mapView.getMapPosition().getMapCenter(); + GeoPoint mapCenter = mMapView.getMapPosition().getMapCenter(); editText.setText(Double.toString(mapCenter.getLatitude())); editText = (EditText) dialog.findViewById(R.id.longitude); editText.setText(Double.toString(mapCenter.getLongitude())); SeekBar zoomlevel = (SeekBar) dialog.findViewById(R.id.zoomLevel); - zoomlevel.setMax(this.mapView.getMapGenerator().getZoomLevelMax()); - zoomlevel.setProgress(this.mapView.getMapPosition().getZoomLevel()); + zoomlevel.setMax(mMapView.getMapGenerator().getZoomLevelMax()); + zoomlevel.setProgress(mMapView.getMapPosition().getZoomLevel()); final TextView textView = (TextView) dialog.findViewById(R.id.zoomlevelValue); textView.setText(String.valueOf(zoomlevel.getProgress())); zoomlevel.setOnSeekBarChangeListener(new SeekBarChangeListener(textView)); } else if (id == DIALOG_INFO_MAP_FILE) { - MapFileInfo mapFileInfo = this.mapView.getMapDatabase().getMapFileInfo(); + MapFileInfo mapFileInfo = mMapView.getMapDatabase().getMapFileInfo(); TextView textView = (TextView) dialog.findViewById(R.id.infoMapFileViewName); - textView.setText(this.mapView.getMapFile()); + textView.setText(mMapView.getMapFile()); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewSize); - textView.setText(FileUtils.formatFileSize(mapFileInfo.fileSize, getResources())); + textView.setText(FileUtils.formatFileSize(mapFileInfo.fileSize, + getResources())); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewVersion); textView.setText(String.valueOf(mapFileInfo.fileVersion)); @@ -424,7 +487,8 @@ public class TileMap extends MapActivity { textView = (TextView) dialog.findViewById(R.id.infoMapFileViewArea); BoundingBox boundingBox = mapFileInfo.boundingBox; - textView.setText(boundingBox.getMinLatitude() + ", " + boundingBox.getMinLongitude() + " - \n" + textView.setText(boundingBox.getMinLatitude() + ", " + + boundingBox.getMinLongitude() + " - \n" + boundingBox.getMaxLatitude() + ", " + boundingBox.getMaxLongitude()); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewStartPosition); @@ -432,7 +496,8 @@ public class TileMap extends MapActivity { if (startPosition == null) { textView.setText(null); } else { - textView.setText(startPosition.getLatitude() + ", " + startPosition.getLongitude()); + textView.setText(startPosition.getLatitude() + ", " + + startPosition.getLongitude()); } textView = (TextView) dialog.findViewById(R.id.infoMapFileViewStartZoomLevel); @@ -443,7 +508,8 @@ public class TileMap extends MapActivity { textView.setText(startZoomLevel.toString()); } - textView = (TextView) dialog.findViewById(R.id.infoMapFileViewLanguagePreference); + textView = (TextView) dialog + .findViewById(R.id.infoMapFileViewLanguagePreference); textView.setText(mapFileInfo.languagePreference); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewComment); @@ -460,13 +526,14 @@ public class TileMap extends MapActivity { protected void onResume() { super.onResume(); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + SharedPreferences preferences = PreferenceManager + .getDefaultSharedPreferences(this); - MapScaleBar mapScaleBar = this.mapView.getMapScaleBar(); - mapScaleBar.setShowMapScaleBar(preferences.getBoolean("showScaleBar", false)); - String scaleBarUnitDefault = getString(R.string.preferences_scale_bar_unit_default); - String scaleBarUnit = preferences.getString("scaleBarUnit", scaleBarUnitDefault); - mapScaleBar.setImperialUnits(scaleBarUnit.equals("imperial")); + // MapScaleBar mapScaleBar = mapView.getMapScaleBar(); + // mapScaleBar.setShowMapScaleBar(preferences.getBoolean("showScaleBar", false)); + // String scaleBarUnitDefault = getString(R.string.preferences_scale_bar_unit_default); + // String scaleBarUnit = preferences.getString("scaleBarUnit", scaleBarUnitDefault); + // mapScaleBar.setImperialUnits(scaleBarUnit.equals("imperial")); // if (preferences.contains("mapGenerator")) { // String name = preferences.getString("mapGenerator", MapGeneratorInternal.SW_RENDERER.name()); @@ -477,33 +544,41 @@ public class TileMap extends MapActivity { // mapGeneratorInternalNew = MapGeneratorInternal.SW_RENDERER; // } // - // if (mapGeneratorInternalNew != this.mapGeneratorInternal) { + // if (mapGeneratorInternalNew != mapGeneratorInternal) { // MapGenerator mapGenerator = MapGeneratorFactory.createMapGenerator(mapGeneratorInternalNew); - // this.mapView.setMapGenerator(mapGenerator); - // this.mapGeneratorInternal = mapGeneratorInternalNew; + // mapView.setMapGenerator(mapGenerator); + // mapGeneratorInternal = mapGeneratorInternalNew; // } // } + if (preferences.contains("mapDatabase")) { - String name = preferences.getString("mapDatabase", MapDatabaseInternal.MAP_READER.name()); + String name = preferences.getString("mapDatabase", + MapDatabaseInternal.POSTGIS_READER.name()); + MapDatabaseInternal mapDatabaseInternalNew; + try { mapDatabaseInternalNew = MapDatabaseInternal.valueOf(name); } catch (IllegalArgumentException e) { - mapDatabaseInternalNew = MapDatabaseInternal.MAP_READER; + mapDatabaseInternalNew = MapDatabaseInternal.POSTGIS_READER; } + Log.d("VectorTileMap", "set map database " + mapDatabaseInternalNew); - if (mapDatabaseInternalNew != this.mapDatabaseInternal) { - IMapDatabase mapDatabase = MapDatabaseFactory.createMapDatabase(mapDatabaseInternalNew); - this.mapView.setMapDatabase(mapDatabase); - this.mapDatabaseInternal = mapDatabaseInternalNew; + if (mapDatabaseInternalNew != mMapDatabaseInternal) { + IMapDatabase mapDatabase = MapDatabaseFactory + .createMapDatabase(mapDatabaseInternalNew); + mMapView.setMapDatabase(mapDatabase); + mMapDatabaseInternal = mapDatabaseInternalNew; } } + try { String textScaleDefault = getString(R.string.preferences_text_scale_default); - this.mapView.setTextScale(Float.parseFloat(preferences.getString("textScale", textScaleDefault))); + mMapView.setTextScale(Float.parseFloat(preferences.getString("textScale", + textScaleDefault))); } catch (NumberFormatException e) { - this.mapView.setTextScale(1); + mMapView.setTextScale(1); } if (preferences.getBoolean("fullscreen", false)) { @@ -515,18 +590,27 @@ public class TileMap extends MapActivity { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } - if (preferences.getBoolean("wakeLock", false) && !this.wakeLock.isHeld()) { - this.wakeLock.acquire(); + if (preferences.getBoolean("wakeLock", false) && !mWakeLock.isHeld()) { + mWakeLock.acquire(); } - boolean drawTileFrames = preferences.getBoolean("drawTileFrames", false); - boolean drawTileCoordinates = preferences.getBoolean("drawTileCoordinates", false); - boolean disablePolygons = preferences.getBoolean("disablePolygons", false); - DebugSettings debugSettings = new DebugSettings(drawTileCoordinates, drawTileFrames, disablePolygons); - this.mapView.setDebugSettings(debugSettings); + boolean drawTileFrames = + preferences.getBoolean("drawTileFrames", false); + boolean drawTileCoordinates = + preferences.getBoolean("drawTileCoordinates", false); + boolean disablePolygons = + preferences.getBoolean("disablePolygons", false); - if (!this.mapView.getMapGenerator().requiresInternetConnection() && this.mapView.getMapFile() == null) { - startMapFilePicker(); + DebugSettings debugSettings = new DebugSettings(drawTileCoordinates, + drawTileFrames, disablePolygons); + + mMapView.setDebugSettings(debugSettings); + + if (mMapDatabaseInternal == MapDatabaseInternal.MAP_READER) { + if (mMapView.getMapFile() == null) + startMapFilePicker(); + } else { + mMapView.setMapFile(null); } } @@ -534,8 +618,9 @@ public class TileMap extends MapActivity { protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, isShowMyLocationEnabled()); - outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX, this.myLocationListener.isCenterAtFirstFix()); - outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, this.snapToLocation); + outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX, + mMyLocationListener.isCenterAtFirstFix()); + outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, mSnapToLocation); } /** @@ -544,17 +629,17 @@ public class TileMap extends MapActivity { * @return ... */ private boolean disableShowMyLocation() { - if (this.showMyLocation) { - this.showMyLocation = false; + if (mShowMyLocation) { + mShowMyLocation = false; disableSnapToLocation(false); - this.locationManager.removeUpdates(this.myLocationListener); - // if (this.circleOverlay != null) { - // this.mapView.getOverlays().remove(this.circleOverlay); - // this.mapView.getOverlays().remove(this.itemizedOverlay); - // this.circleOverlay = null; - // this.itemizedOverlay = null; + mLocationManager.removeUpdates(mMyLocationListener); + // if (circleOverlay != null) { + // mapView.getOverlays().remove(circleOverlay); + // mapView.getOverlays().remove(itemizedOverlay); + // circleOverlay = null; + // itemizedOverlay = null; // } - this.snapToLocationView.setVisibility(View.GONE); + mSnapToLocationView.setVisibility(View.GONE); return true; } return false; @@ -567,10 +652,10 @@ public class TileMap extends MapActivity { * defines whether a toast message is displayed or not. */ void disableSnapToLocation(boolean showToast) { - if (this.snapToLocation) { - this.snapToLocation = false; - this.snapToLocationView.setChecked(false); - this.mapView.setClickable(true); + if (mSnapToLocation) { + mSnapToLocation = false; + mSnapToLocationView.setChecked(false); + mMapView.setClickable(true); if (showToast) { showToastOnUiThread(getString(R.string.snap_to_location_disabled)); } @@ -584,9 +669,9 @@ public class TileMap extends MapActivity { * defines whether a toast message is displayed or not. */ void enableSnapToLocation(boolean showToast) { - if (!this.snapToLocation) { - this.snapToLocation = true; - this.mapView.setClickable(false); + if (!mSnapToLocation) { + mSnapToLocation = true; + mMapView.setClickable(false); if (showToast) { showToastOnUiThread(getString(R.string.snap_to_location_enabled)); } @@ -599,7 +684,7 @@ public class TileMap extends MapActivity { * @return true if the "show my location" mode is enabled, false otherwise. */ boolean isShowMyLocationEnabled() { - return this.showMyLocation; + return mShowMyLocation; } /** @@ -608,7 +693,7 @@ public class TileMap extends MapActivity { * @return true if the "snap to location" mode is enabled, false otherwise. */ boolean isSnapToLocationEnabled() { - return this.snapToLocation; + return mSnapToLocation; } /** @@ -632,4 +717,10 @@ public class TileMap extends MapActivity { }); } } + + @Override + public boolean onNavigationItemSelected(int arg0, long arg1) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/org/mapsforge/tilemap/filepicker/FilePicker.java b/src/org/mapsforge/tilemap/filepicker/FilePicker.java index de81a213..8f8cbc87 100755 --- a/src/org/mapsforge/tilemap/filepicker/FilePicker.java +++ b/src/org/mapsforge/tilemap/filepicker/FilePicker.java @@ -19,6 +19,7 @@ import java.io.FileFilter; import java.util.Arrays; import java.util.Comparator; +import org.mapsforge.tilemap.R; import org.mapsforge.tilemap.filefilter.ValidFileFilter; import android.app.Activity; @@ -28,12 +29,9 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; -import android.preference.PreferenceManager; import android.view.View; -import android.view.WindowManager; import android.widget.AdapterView; import android.widget.GridView; -import org.mapsforge.tilemap.R; /** * A FilePicker displays the contents of directories. The user can navigate within the file system and select a single @@ -128,7 +126,8 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe this.currentDirectory = selectedFile; browseToCurrentDirectory(); } else if (fileSelectFilter == null || fileSelectFilter.accept(selectedFile)) { - setResult(RESULT_OK, new Intent().putExtra(SELECTED_FILE, selectedFile.getAbsolutePath())); + setResult(RESULT_OK, + new Intent().putExtra(SELECTED_FILE, selectedFile.getAbsolutePath())); finish(); } else { showDialog(DIALOG_FILE_INVALID); @@ -159,7 +158,8 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe if (this.currentDirectory.getParentFile() != null) { this.filesWithParentFolder = new File[this.files.length + 1]; this.filesWithParentFolder[0] = this.currentDirectory.getParentFile(); - System.arraycopy(this.files, 0, this.filesWithParentFolder, 1, this.files.length); + System.arraycopy(this.files, 0, this.filesWithParentFolder, 1, + this.files.length); this.files = this.filesWithParentFolder; this.filePickerIconAdapter.setFiles(this.files, true); } else { @@ -195,7 +195,8 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(getString(R.string.file_invalid)); stringBuilder.append("\n\n"); - stringBuilder.append(FilePicker.fileSelectFilter.getFileOpenResult().getErrorMessage()); + stringBuilder.append(FilePicker.fileSelectFilter.getFileOpenResult() + .getErrorMessage()); builder.setMessage(stringBuilder.toString()); builder.setPositiveButton(R.string.ok, null); @@ -225,18 +226,21 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe @Override protected void onResume() { super.onResume(); + getActionBar().hide(); // check if the full screen mode should be activated - if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fullscreen", false)) { - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - } else { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - } + // if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fullscreen", false)) { + // getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + // getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + // } else { + // getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + // getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + // } // restore the current directory - SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE); - this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY, DEFAULT_DIRECTORY)); + SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE, + MODE_PRIVATE); + this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY, + DEFAULT_DIRECTORY)); if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) { this.currentDirectory = new File(DEFAULT_DIRECTORY); } diff --git a/src/org/mapsforge/tilemap/preferences/EditPreferences.java b/src/org/mapsforge/tilemap/preferences/EditPreferences.java index 72d8febb..ae692609 100644 --- a/src/org/mapsforge/tilemap/preferences/EditPreferences.java +++ b/src/org/mapsforge/tilemap/preferences/EditPreferences.java @@ -14,11 +14,12 @@ */ package org.mapsforge.tilemap.preferences; +import org.mapsforge.tilemap.R; + import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.view.WindowManager; -import org.mapsforge.tilemap.R; /** * Activity to edit the application preferences. @@ -33,8 +34,11 @@ public class EditPreferences extends PreferenceActivity { @Override protected void onResume() { super.onResume(); + getActionBar().hide(); + // check if the full screen mode should be activated - if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fullscreen", false)) { + if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fullscreen", + false)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else {