theme changes and making PostGIS the default backend

This commit is contained in:
Hannes Janetzek
2012-06-25 02:32:21 +02:00
parent 8b630eebc9
commit d13f1b43ad
28 changed files with 521 additions and 283 deletions

View File

@@ -15,8 +15,10 @@
android:targetSdkVersion="15" /> android:targetSdkVersion="15" />
<application <application
android:icon="@drawable/globe" android:icon="@drawable/globe2"
android:label="@string/application_name" > android:label="@string/application_name"
android:theme="@style/Theme.TileMap" >
<activity android:name="org.mapsforge.tilemap.TileMap" > <activity android:name="org.mapsforge.tilemap.TileMap" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@@ -10,64 +10,69 @@ package org.mapsforge.tilemap;
public final class R { public final class R {
public static final class array { public static final class array {
public static final int preferences_map_database_keys=0x7f050000; 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_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_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 attr {
} }
public static final class drawable { public static final class drawable {
public static final int btn_snap_normal=0x7f020000; public static final int action_bar=0x7f020000;
public static final int btn_snap_pressed=0x7f020001; public static final int bar_globe=0x7f020001;
public static final int btn_snap_selected=0x7f020002; public static final int bar_globe2=0x7f020002;
public static final int file_picker_back=0x7f020003; public static final int btn_snap_normal=0x7f020003;
public static final int file_picker_file=0x7f020004; public static final int btn_snap_pressed=0x7f020004;
public static final int file_picker_folder=0x7f020005; public static final int btn_snap_selected=0x7f020005;
public static final int globe=0x7f020006; public static final int file_picker_back=0x7f020006;
public static final int ic_menu_archive=0x7f020007; public static final int file_picker_file=0x7f020007;
public static final int ic_menu_camera=0x7f020008; public static final int file_picker_folder=0x7f020008;
public static final int ic_menu_info_details=0x7f020009; public static final int globe=0x7f020009;
public static final int ic_menu_mapmode=0x7f02000a; public static final int globe2=0x7f02000a;
public static final int ic_menu_mylocation=0x7f02000b; public static final int ic_menu_archive=0x7f02000b;
public static final int ic_menu_preferences=0x7f02000c; public static final int ic_menu_camera=0x7f02000c;
public static final int my_location=0x7f02000d; public static final int ic_menu_info_details=0x7f02000d;
public static final int snap_to_position=0x7f02000e; 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 class id {
public static final int filePickerView=0x7f080003; public static final int filePickerView=0x7f090003;
public static final int infoMapFileViewArea=0x7f08000d; public static final int infoMapFileViewArea=0x7f09000d;
public static final int infoMapFileViewComment=0x7f080011; public static final int infoMapFileViewComment=0x7f090011;
public static final int infoMapFileViewCreatedBy=0x7f080012; public static final int infoMapFileViewCreatedBy=0x7f090012;
public static final int infoMapFileViewDate=0x7f08000c; public static final int infoMapFileViewDate=0x7f09000c;
public static final int infoMapFileViewDebug=0x7f08000b; public static final int infoMapFileViewDebug=0x7f09000b;
public static final int infoMapFileViewLanguagePreference=0x7f080010; public static final int infoMapFileViewLanguagePreference=0x7f090010;
public static final int infoMapFileViewName=0x7f080008; public static final int infoMapFileViewName=0x7f090008;
public static final int infoMapFileViewSize=0x7f080009; public static final int infoMapFileViewSize=0x7f090009;
public static final int infoMapFileViewStartPosition=0x7f08000e; public static final int infoMapFileViewStartPosition=0x7f09000e;
public static final int infoMapFileViewStartZoomLevel=0x7f08000f; public static final int infoMapFileViewStartZoomLevel=0x7f09000f;
public static final int infoMapFileViewVersion=0x7f08000a; public static final int infoMapFileViewVersion=0x7f09000a;
public static final int latitude=0x7f080004; public static final int latitude=0x7f090004;
public static final int longitude=0x7f080005; public static final int longitude=0x7f090005;
public static final int mainView=0x7f080000; public static final int mainView=0x7f090000;
public static final int mapView=0x7f080001; public static final int mapView=0x7f090001;
public static final int menu_info=0x7f080013; public static final int menu_mapfile=0x7f09001e;
public static final int menu_info_map_file=0x7f080014; public static final int menu_options=0x7f090019;
public static final int menu_mapfile=0x7f08001f; public static final int menu_position=0x7f090013;
public static final int menu_position=0x7f080015; public static final int menu_position_enter_coordinates=0x7f090017;
public static final int menu_position_enter_coordinates=0x7f080019; public static final int menu_position_last_known=0x7f090016;
public static final int menu_position_last_known=0x7f080018; public static final int menu_position_map_center=0x7f090018;
public static final int menu_position_map_center=0x7f08001a; public static final int menu_position_my_location_disable=0x7f090015;
public static final int menu_position_my_location_disable=0x7f080017; public static final int menu_position_my_location_enable=0x7f090014;
public static final int menu_position_my_location_enable=0x7f080016; public static final int menu_preferences=0x7f09001a;
public static final int menu_preferences=0x7f08001b; public static final int menu_render_theme=0x7f09001b;
public static final int menu_render_theme=0x7f08001c; public static final int menu_render_theme_osmarender=0x7f09001c;
public static final int menu_render_theme_osmarender=0x7f08001d; public static final int menu_render_theme_select_file=0x7f09001d;
public static final int menu_render_theme_select_file=0x7f08001e; public static final int snapToLocationView=0x7f090002;
public static final int snapToLocationView=0x7f080002; public static final int zoomLevel=0x7f090006;
public static final int zoomLevel=0x7f080006; public static final int zoomlevelValue=0x7f090007;
public static final int zoomlevelValue=0x7f080007;
} }
public static final class layout { public static final class layout {
public static final int activity_advanced_map_viewer=0x7f030000; 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 int dialog_info_map_file=0x7f030003;
} }
public static final class menu { 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 class string {
public static final int application_name=0x7f060003; 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_language_preference=0x7f060016;
public static final int info_map_file_name=0x7f060017; 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_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_position=0x7f060019;
public static final int info_map_file_start_zoom_level=0x7f06001a; public static final int info_map_file_start_zoom_level=0x7f06001a;
public static final int info_map_file_version=0x7f06001b; 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_about=0x7f060020;
public static final int menu_info_map_file=0x7f06001f; public static final int menu_info_map_file=0x7f06001f;
public static final int menu_mapfile=0x7f060021; 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=0x7f060022;
public static final int menu_position_enter_coordinates=0x7f060023; public static final int menu_position_enter_coordinates=0x7f060023;
public static final int menu_position_last_known=0x7f060024; 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_coordinates_desc=0x7f060047;
public static final int preferences_show_tile_frames=0x7f060048; 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_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_show_water_tiles_desc=0x7f06004b;
public static final int preferences_text_scale=0x7f06004c; public static final int preferences_text_scale=0x7f06004c;
public static final int preferences_text_scale_default=0x7f060002; 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 unit_symbol_meter=0x7f060053;
public static final int zoomLevel=0x7f060054; public static final int zoomLevel=0x7f060054;
} }
public static final class style {
public static final int MyActionBar=0x7f070000;
/**
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
<item name="android:listChoiceIndicatorMultiple">@drawable/ad_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">@drawable/ad_btn_radio_holo_light</item>
*/
public static final int Theme_TileMap=0x7f070001;
}
public static final class xml { public static final class xml {
public static final int preferences=0x7f040000; public static final int preferences=0x7f040000;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
res/drawable-mdpi/ic_menu_archive.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
res/drawable-mdpi/ic_menu_mylocation.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#BB000000" />
</shape>

BIN
res/drawable/globe2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -2,7 +2,9 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
>
<org.mapsforge.android.MapView <org.mapsforge.android.MapView
android:id="@+id/mapView" android:id="@+id/mapView"

View File

@@ -1,25 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_info" android:title="@string/menu_info" android:icon="@drawable/ic_menu_info_details" android:showAsAction="never">
<menu> <item
<item android:id="@+id/menu_info_map_file" android:title="@string/menu_info_map_file" /> android:id="@+id/menu_position"
</menu> android:icon="@drawable/ic_menu_mylocation"
</item> android:showAsAction="always"
<item android:id="@+id/menu_position" android:title="@string/menu_position" android:icon="@drawable/ic_menu_mylocation" android:showAsAction="always"> android:title="@string/menu_position">
<menu> <menu>
<item android:id="@+id/menu_position_my_location_enable" android:title="@string/menu_position_my_location_enable" /> <item
<item android:id="@+id/menu_position_my_location_disable" android:title="@string/menu_position_my_location_disable" /> android:id="@+id/menu_position_my_location_enable"
<item android:id="@+id/menu_position_last_known" android:title="@string/menu_position_last_known" /> android:title="@string/menu_position_my_location_enable"/>
<item android:id="@+id/menu_position_enter_coordinates" android:title="@string/menu_position_enter_coordinates" /> <item
<item android:id="@+id/menu_position_map_center" android:title="@string/menu_position_map_file_center" /> android:id="@+id/menu_position_my_location_disable"
</menu> android:title="@string/menu_position_my_location_disable"/>
</item> <item
<item android:id="@+id/menu_preferences" android:title="@string/menu_preferences" android:icon="@drawable/ic_menu_preferences" android:showAsAction="never"/> android:id="@+id/menu_position_last_known"
<item android:id="@+id/menu_render_theme" android:title="@string/menu_render_theme" android:icon="@drawable/ic_menu_mapmode" android:showAsAction="ifRoom"> android:title="@string/menu_position_last_known"/>
<menu> <item
<item android:id="@+id/menu_render_theme_osmarender" android:title="@string/menu_render_theme_osmarender" /> android:id="@+id/menu_position_enter_coordinates"
<item android:id="@+id/menu_render_theme_select_file" android:title="@string/menu_render_theme_select_file" /> android:title="@string/menu_position_enter_coordinates"/>
</menu> <item
</item> android:id="@+id/menu_position_map_center"
<item android:id="@+id/menu_mapfile" android:title="@string/menu_mapfile" android:icon="@drawable/ic_menu_archive" android:showAsAction="always"/> android:title="@string/menu_position_map_file_center"/>
</menu>
</item>
<item
android:id="@+id/menu_options"
android:icon="@drawable/ic_menu_options"
android:showAsAction="always"
android:title="@string/menu_options">
<menu>
<!-- android:icon="@drawable/ic_menu_preferences" -->
<item
android:id="@+id/menu_preferences"
android:showAsAction="never"
android:title="@string/menu_preferences"/>
<!-- android:icon="@drawable/ic_menu_mapmode" -->
<item
android:id="@+id/menu_render_theme"
android:showAsAction="never"
android:title="@string/menu_render_theme">
<menu>
<item
android:id="@+id/menu_render_theme_osmarender"
android:title="@string/menu_render_theme_osmarender"/>
<item
android:id="@+id/menu_render_theme_select_file"
android:title="@string/menu_render_theme_select_file"/>
</menu>
</item>
<!-- android:icon="@drawable/ic_menu_archive" -->
<item
android:id="@+id/menu_mapfile"
android:showAsAction="never"
android:title="@string/menu_mapfile"/>
<!-- <item
android:id="@+id/menu_info_map_file"
android:title="@string/menu_info_map_file"/> -->
</menu>
</item>
</menu> </menu>

View File

@@ -18,7 +18,7 @@
<item>riesig</item> <item>riesig</item>
</string-array> </string-array>
<string name="application_name">VectorTileMap</string> <string name="application_name">OpenScienceMap</string>
<string name="cancel">Abbrechen</string> <string name="cancel">Abbrechen</string>
<string name="error">Fehler</string> <string name="error">Fehler</string>
<string name="error_last_location_unknown">Die letzte Position ist unbekannt</string> <string name="error_last_location_unknown">Die letzte Position ist unbekannt</string>

View File

@@ -13,7 +13,7 @@
<item>hyvin suuri</item> <item>hyvin suuri</item>
</string-array> </string-array>
<string name="application_name">VectorTileMap</string> <string name="application_name">OpenScienceMap</string>
<string name="cancel">Peruuta</string> <string name="cancel">Peruuta</string>
<string name="error">Virhe</string> <string name="error">Virhe</string>
<string name="error_last_location_unknown">Viimeinen sijainti ei ole tiedossa</string> <string name="error_last_location_unknown">Viimeinen sijainti ei ole tiedossa</string>

View File

@@ -13,7 +13,7 @@
<item>enorme</item> <item>enorme</item>
</string-array> </string-array>
<string name="application_name">VectorTileMap</string> <string name="application_name">OpenScienceMap</string>
<string name="cancel">Annulla</string> <string name="cancel">Annulla</string>
<string name="error">Errore</string> <string name="error">Errore</string>
<string name="error_last_location_unknown">L\'ultima posizione è sconosciuta</string> <string name="error_last_location_unknown">L\'ultima posizione è sconosciuta</string>

View File

@@ -4,7 +4,7 @@
<item>MAP_READER</item> <item>MAP_READER</item>
<item>POSTGIS_READER</item> <item>POSTGIS_READER</item>
</string-array> </string-array>
<string name="preferences_map_database_default">MAP_READER</string> <string name="preferences_map_database_default">POSTGIS_READER</string>
<string-array name="preferences_scale_bar_unit_keys"> <string-array name="preferences_scale_bar_unit_keys">
<item>imperial</item> <item>imperial</item>
@@ -20,4 +20,11 @@
<item>1.6</item> <item>1.6</item>
</string-array> </string-array>
<string name="preferences_text_scale_default">1.0</string> <string name="preferences_text_scale_default">1.0</string>
<string-array name="view_sections">
<item>Map</item>
<item>Routes</item>
<item>Overlays</item>
<item>etc</item>
</string-array>
</resources> </resources>

View File

@@ -18,7 +18,7 @@
<item>huge</item> <item>huge</item>
</string-array> </string-array>
<string name="application_name">VectorTileMap</string> <string name="application_name">OpenScienceMap</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="error">Error</string> <string name="error">Error</string>
<string name="error_last_location_unknown">The last location is unknown</string> <string name="error_last_location_unknown">The last location is unknown</string>
@@ -100,4 +100,5 @@
<string name="unit_symbol_kilometer">&#160;km</string> <string name="unit_symbol_kilometer">&#160;km</string>
<string name="unit_symbol_meter">&#160;m</string> <string name="unit_symbol_meter">&#160;m</string>
<string name="zoomLevel">Zoom level</string> <string name="zoomLevel">Zoom level</string>
<string name="menu_options">Options</string>
</resources> </resources>

27
res/values/styles.xml Normal file
View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@drawable/action_bar</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<style name="Theme.TileMap" parent="android:style/Theme.Holo">
<!-- <item name="android:windowNoTitle">true</item> -->
<item name="android:displayOptions"></item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- <item name="android:selectableItemBackgroun">@drawable/ad_selectable_background</item> -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!--
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
<item name="android:listChoiceIndicatorMultiple">@drawable/ad_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">@drawable/ad_btn_radio_holo_light</item>
-->
</style>
</resources>

View File

@@ -40,7 +40,8 @@ public abstract class MapActivity extends Activity {
private static final String PREFERENCES_FILE = "MapActivity"; private static final String PREFERENCES_FILE = "MapActivity";
private static boolean containsMapViewPosition(SharedPreferences sharedPreferences) { 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); && sharedPreferences.contains(KEY_ZOOM_LEVEL);
} }
@@ -59,10 +60,14 @@ public abstract class MapActivity extends Activity {
} }
private void restoreMapView(MapView mapView) { private void restoreMapView(MapView mapView) {
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE,
MODE_PRIVATE);
if (containsMapViewPosition(sharedPreferences)) { if (containsMapViewPosition(sharedPreferences)) {
MapGenerator mapGenerator = mapView.getMapGenerator(); 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 // get and set the map file
mapView.setMapFile(sharedPreferences.getString(KEY_MAP_FILE, null)); 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); 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 // save the map file
editor.putString(KEY_MAP_FILE, mMapView.getMapFile()); editor.putString(KEY_MAP_FILE, mMapView.getMapFile());
} }

View File

@@ -25,6 +25,7 @@ import org.mapsforge.android.mapgenerator.MapDatabaseFactory;
import org.mapsforge.android.mapgenerator.MapDatabaseInternal; import org.mapsforge.android.mapgenerator.MapDatabaseInternal;
import org.mapsforge.android.mapgenerator.MapGenerator; import org.mapsforge.android.mapgenerator.MapGenerator;
import org.mapsforge.android.mapgenerator.MapGeneratorFactory; import org.mapsforge.android.mapgenerator.MapGeneratorFactory;
import org.mapsforge.android.mapgenerator.MapGeneratorInternal;
import org.mapsforge.android.mapgenerator.MapWorker; import org.mapsforge.android.mapgenerator.MapWorker;
import org.mapsforge.android.rendertheme.ExternalRenderTheme; import org.mapsforge.android.rendertheme.ExternalRenderTheme;
import org.mapsforge.android.rendertheme.InternalRenderTheme; 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} . * if the context object is not an instance of {@link MapActivity} .
*/ */
public MapView(Context context) { 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} . * if the context object is not an instance of {@link MapActivity} .
*/ */
public MapView(Context context, AttributeSet attributeSet) { 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} . * if the context object is not an instance of {@link MapActivity} .
*/ */
public MapView(Context context, MapGenerator mapGenerator) { 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); super(context, attributeSet);
@@ -128,6 +135,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");
} }
setWillNotDraw(true); setWillNotDraw(true);
setWillNotCacheDrawing(true); setWillNotCacheDrawing(true);
@@ -139,8 +147,9 @@ public class MapView extends GLSurfaceView {
mMapController = new MapController(this); mMapController = new MapController(this);
// mMapDatabase = MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.POSTGIS_READER); // mMapDatabase = MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.POSTGIS_READER);
mMapDatabase = MapDatabaseFactory mMapDatabase = mapDatabase;
.createMapDatabase(MapDatabaseInternal.MAP_READER); // MapDatabaseFactory
// .createMapDatabase(MapDatabaseInternal.MAP_READER);
mMapViewPosition = new MapViewPosition(this); mMapViewPosition = new MapViewPosition(this);
mMapScaleBar = new MapScaleBar(this); mMapScaleBar = new MapScaleBar(this);
@@ -354,14 +363,21 @@ public class MapView extends GLSurfaceView {
* if the current MapGenerator mode works with an Internet connection. * if the current MapGenerator mode works with an Internet connection.
*/ */
public boolean setMapFile(String mapFile) { public boolean setMapFile(String mapFile) {
FileOpenResult fileOpenResult = null;
if (mMapGenerator.requiresInternetConnection()) { if (mMapGenerator.requiresInternetConnection()) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
Log.d(TAG, "set mapfile " + mapFile); Log.d(TAG, "set mapfile " + mapFile);
if (mapFile == null) { // if (mapFile == null) {
// no map file specified // if (mMapDatabase instanceof org.mapsforge.database.postgis.MapDatabase) {
return false; // fileOpenResult = mMapDatabase.openFile(null);
} else if (mapFile.equals(mMapFile)) { // } else {
// // no map file specified
// return false;
// }
// } else
if (mapFile != null && mapFile.equals(mMapFile)) {
// same map file as before // same map file as before
return false; return false;
} }
@@ -378,8 +394,13 @@ public class MapView extends GLSurfaceView {
mMapWorker.proceed(); mMapWorker.proceed();
mMapDatabase.closeFile(); 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; mMapFile = mapFile;
GeoPoint startPoint = mMapGenerator.getStartPoint(); GeoPoint startPoint = mMapGenerator.getStartPoint();
@@ -454,19 +475,24 @@ public class MapView extends GLSurfaceView {
if (mapDatabase == null) { if (mapDatabase == null) {
throw new IllegalArgumentException("MapDatabase must not be null"); throw new IllegalArgumentException("MapDatabase must not be null");
} }
// mMapWorker.pause();
// mMapWorker.awaitPausing();
if (!mMapWorker.isPausing()) {
mMapWorker.pause();
mMapWorker.awaitPausing();
}
mJobQueue.clear();
mMapDatabase = mapDatabase; mMapDatabase = mapDatabase;
mMapGenerator.setMapDatabase(mMapDatabase); mMapGenerator.setMapDatabase(mMapDatabase);
Log.d(TAG, "setMapDatabaseInternal " + mapDatabase.getClass()); Log.d(TAG, "setMapDatabaseInternal " + mapDatabase.getClass());
// mMapWorker.proceed();
String mapFile = mMapFile; String mapFile = mMapFile;
mMapFile = null; mMapFile = null;
setMapFile(mapFile); setMapFile(mapFile);
mMapWorker.proceed();
// mMapWorker.setMapDatabase(mMapDatabase); // mMapWorker.setMapDatabase(mMapDatabase);
} }
@@ -559,28 +585,28 @@ public class MapView extends GLSurfaceView {
return true; return true;
} }
@Override // @Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { // protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom); // super.onLayout(changed, left, top, right, bottom);
// mMapZoomControls.onLayout(changed, left, top, right, bottom); // // mMapZoomControls.onLayout(changed, left, top, right, bottom);
} // }
@Override // @Override
protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// find out how big the zoom controls should be // // find out how big the zoom controls should be
mMapZoomControls.measure( // mMapZoomControls.measure(
MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), // MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec),
MeasureSpec.AT_MOST), // MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), // MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec),
MeasureSpec.AT_MOST)); // MeasureSpec.AT_MOST));
//
// make sure that MapView is big enough to display the zoom controls // // make sure that MapView is big enough to display the zoom controls
setMeasuredDimension( // setMeasuredDimension(
Math.max(MeasureSpec.getSize(widthMeasureSpec), // Math.max(MeasureSpec.getSize(widthMeasureSpec),
mMapZoomControls.getMeasuredWidth()), // mMapZoomControls.getMeasuredWidth()),
Math.max(MeasureSpec.getSize(heightMeasureSpec), // Math.max(MeasureSpec.getSize(heightMeasureSpec),
mMapZoomControls.getMeasuredHeight())); // mMapZoomControls.getMeasuredHeight()));
} // }
@Override @Override
protected synchronized void onSizeChanged(int width, int height, int oldWidth, protected synchronized void onSizeChanged(int width, int height, int oldWidth,

View File

@@ -8,7 +8,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.MapController;
import org.mapsforge.android.MapScaleBar;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.mapgenerator.MapDatabaseFactory; import org.mapsforge.android.mapgenerator.MapDatabaseFactory;
import org.mapsforge.android.mapgenerator.MapDatabaseInternal; 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.filepicker.FilePicker;
import org.mapsforge.tilemap.preferences.EditPreferences; import org.mapsforge.tilemap.preferences.EditPreferences;
import android.app.ActionBar;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
@@ -46,8 +46,10 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.SpinnerAdapter;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ToggleButton; 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 * location. A simple file browser for selecting the map file is also included. Some preferences can be adjusted via the
* {@link EditPreferences} activity. * {@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_CENTER_AT_FIRST_FIX = "centerAtFirstFix";
private static final String BUNDLE_SHOW_MY_LOCATION = "showMyLocation"; private static final String BUNDLE_SHOW_MY_LOCATION = "showMyLocation";
private static final String BUNDLE_SNAP_TO_LOCATION = "snapToLocation"; private static final String BUNDLE_SNAP_TO_LOCATION = "snapToLocation";
private static final int DIALOG_ENTER_COORDINATES = 0; private static final int DIALOG_ENTER_COORDINATES = 0;
private static final int DIALOG_INFO_MAP_FILE = 1; private static final int DIALOG_INFO_MAP_FILE = 1;
private static final int DIALOG_LOCATION_PROVIDER_DISABLED = 2; 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_MAP =
private static final FileFilter FILE_FILTER_EXTENSION_XML = new FilterByFileExtension(".xml"); 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_MAP_FILE = 0;
private static final int SELECT_RENDER_THEME_FILE = 1; private static final int SELECT_RENDER_THEME_FILE = 1;
private LocationManager locationManager; private LocationManager mLocationManager;
private MapDatabaseInternal mapDatabaseInternal; private MapDatabaseInternal mMapDatabaseInternal;
private MyLocationListener myLocationListener; private MyLocationListener mMyLocationListener;
private boolean showMyLocation; private boolean mShowMyLocation;
private boolean snapToLocation; private boolean mSnapToLocation;
private ToggleButton snapToLocationView; private ToggleButton mSnapToLocationView;
private WakeLock wakeLock; private WakeLock mWakeLock;
MapController mapController; MapController mMapController;
MapView mapView; MapView mMapView;
private Menu mMenu = null; private Menu mMenu = null;
SpinnerAdapter mSpinnerAdapter;
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu); getMenuInflater().inflate(R.menu.options_menu, menu);
mMenu = menu; mMenu = menu;
return true; return true;
} }
@@ -89,31 +96,37 @@ public class TileMap extends MapActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.menu_info:
return true;
case R.id.menu_info_map_file: // case R.id.menu_info_map_file:
showDialog(DIALOG_INFO_MAP_FILE); // showDialog(DIALOG_INFO_MAP_FILE);
return true; // return true;
case R.id.menu_position: case R.id.menu_position:
return true; return true;
case R.id.menu_position_my_location_enable: case R.id.menu_position_my_location_enable:
if (enableShowMyLocation(true)) { if (enableShowMyLocation(true)) {
mMenu.findItem(R.id.menu_position_my_location_enable).setVisible(false); mMenu.findItem(R.id.menu_position_my_location_enable)
mMenu.findItem(R.id.menu_position_my_location_enable).setEnabled(false); .setVisible(false);
mMenu.findItem(R.id.menu_position_my_location_disable).setVisible(true); mMenu.findItem(R.id.menu_position_my_location_enable)
mMenu.findItem(R.id.menu_position_my_location_disable).setEnabled(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()) { if (disableShowMyLocation()) {
mMenu.findItem(R.id.menu_position_my_location_enable).setVisible(true); mMenu.findItem(R.id.menu_position_my_location_enable)
mMenu.findItem(R.id.menu_position_my_location_enable).setEnabled(true); .setVisible(true);
mMenu.findItem(R.id.menu_position_my_location_disable).setVisible(false); mMenu.findItem(R.id.menu_position_my_location_enable)
mMenu.findItem(R.id.menu_position_my_location_disable).setEnabled(false); .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;
@@ -128,7 +141,8 @@ 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); disableSnapToLocation(true);
this.mapController.setCenter(this.mapView.getMapDatabase().getMapFileInfo().mapCenter); mMapController.setCenter(mMapView.getMapDatabase()
.getMapFileInfo().mapCenter);
return true; return true;
case R.id.menu_preferences: case R.id.menu_preferences:
@@ -138,8 +152,11 @@ public class TileMap extends MapActivity {
case R.id.menu_render_theme: case R.id.menu_render_theme:
return true; return true;
case R.id.menu_options:
return true;
case R.id.menu_render_theme_osmarender: case R.id.menu_render_theme_osmarender:
this.mapView.setRenderTheme(InternalRenderTheme.OSMARENDER); mMapView.setRenderTheme(InternalRenderTheme.OSMARENDER);
return true; return true;
case R.id.menu_render_theme_select_file: case R.id.menu_render_theme_select_file:
@@ -157,13 +174,13 @@ public class TileMap extends MapActivity {
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
MapGenerator mapGenerator = this.mapView.getMapGenerator(); MapGenerator mapGenerator = mMapView.getMapGenerator();
if (mapGenerator.requiresInternetConnection()) { // if (mapGenerator.requiresInternetConnection()) {
menu.findItem(R.id.menu_info_map_file).setEnabled(false); // menu.findItem(R.id.menu_info_map_file).setEnabled(false);
} else { // } else {
menu.findItem(R.id.menu_info_map_file).setEnabled(true); // menu.findItem(R.id.menu_info_map_file).setEnabled(true);
} // }
if (isShowMyLocationEnabled()) { if (isShowMyLocationEnabled()) {
menu.findItem(R.id.menu_position_my_location_enable).setVisible(false); menu.findItem(R.id.menu_position_my_location_enable).setVisible(false);
@@ -201,32 +218,33 @@ public class TileMap extends MapActivity {
@Override @Override
public boolean onTrackballEvent(MotionEvent event) { public boolean onTrackballEvent(MotionEvent event) {
// forward the event to the MapView // forward the event to the MapView
return this.mapView.onTrackballEvent(event); return mMapView.onTrackballEvent(event);
} }
private void configureMapView() { private void configureMapView() {
// configure the MapView and activate the zoomLevel buttons // configure the MapView and activate the zoomLevel buttons
this.mapView.setClickable(true); mMapView.setClickable(true);
this.mapView.setBuiltInZoomControls(true); mMapView.setBuiltInZoomControls(true);
this.mapView.setFocusable(true); mMapView.setFocusable(true);
this.mapController = this.mapView.getController(); mMapController = mMapView.getController();
} }
private boolean enableShowMyLocation(boolean centerAtFirstFix) { private boolean enableShowMyLocation(boolean centerAtFirstFix) {
if (!this.showMyLocation) { if (!mShowMyLocation) {
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAccuracy(Criteria.ACCURACY_FINE);
String bestProvider = this.locationManager.getBestProvider(criteria, true); String bestProvider = mLocationManager.getBestProvider(criteria, true);
if (bestProvider == null) { if (bestProvider == null) {
showDialog(DIALOG_LOCATION_PROVIDER_DISABLED); showDialog(DIALOG_LOCATION_PROVIDER_DISABLED);
return false; return false;
} }
this.showMyLocation = true; mShowMyLocation = true;
this.myLocationListener.setCenterAtFirstFix(centerAtFirstFix); mMyLocationListener.setCenterAtFirstFix(centerAtFirstFix);
this.locationManager.requestLocationUpdates(bestProvider, 1000, 0, this.myLocationListener); mLocationManager.requestLocationUpdates(bestProvider, 1000, 0,
this.snapToLocationView.setVisibility(View.VISIBLE); mMyLocationListener);
mSnapToLocationView.setVisibility(View.VISIBLE);
return true; return true;
} }
return false; return false;
@@ -235,16 +253,20 @@ public class TileMap extends MapActivity {
private void gotoLastKnownPosition() { private void gotoLastKnownPosition() {
Location currentLocation; Location currentLocation;
Location bestLocation = null; Location bestLocation = null;
for (String provider : this.locationManager.getProviders(true)) { for (String provider : mLocationManager.getProviders(true)) {
currentLocation = this.locationManager.getLastKnownLocation(provider); currentLocation = mLocationManager.getLastKnownLocation(provider);
if (bestLocation == null || currentLocation.getAccuracy() < bestLocation.getAccuracy()) { if (currentLocation == null)
continue;
if (bestLocation == null
|| currentLocation.getAccuracy() < bestLocation.getAccuracy()) {
bestLocation = currentLocation; bestLocation = currentLocation;
} }
} }
if (bestLocation != null) { if (bestLocation != null) {
GeoPoint point = new GeoPoint(bestLocation.getLatitude(), bestLocation.getLongitude()); GeoPoint point = new GeoPoint(bestLocation.getLatitude(),
this.mapController.setCenter(point); bestLocation.getLongitude());
mMapController.setCenter(point);
} else { } else {
showToastOnUiThread(getString(R.string.error_last_location_unknown)); showToastOnUiThread(getString(R.string.error_last_location_unknown));
} }
@@ -259,25 +281,35 @@ public class TileMap extends MapActivity {
private void startRenderThemePicker() { private void startRenderThemePicker() {
FilePicker.setFileDisplayFilter(FILE_FILTER_EXTENSION_XML); FilePicker.setFileDisplayFilter(FILE_FILTER_EXTENSION_XML);
FilePicker.setFileSelectFilter(new ValidRenderTheme()); 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 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == SELECT_MAP_FILE) { if (requestCode == SELECT_MAP_FILE) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
disableSnapToLocation(true); 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() } else if (resultCode == RESULT_CANCELED) {
&& this.mapView.getMapFile() == null) { startActivity(new Intent(this, EditPreferences.class));
finish(); // && !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) { && intent.getStringExtra(FilePicker.SELECTED_FILE) != null) {
try { try {
this.mapView.setRenderTheme(intent.getStringExtra(FilePicker.SELECTED_FILE)); mMapView.setRenderTheme(intent
.getStringExtra(FilePicker.SELECTED_FILE));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
showToastOnUiThread(e.getLocalizedMessage()); showToastOnUiThread(e.getLocalizedMessage());
} }
@@ -288,14 +320,31 @@ public class TileMap extends MapActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 // set up the layout views
setContentView(R.layout.activity_advanced_map_viewer); 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(); configureMapView();
this.snapToLocationView = (ToggleButton) findViewById(R.id.snapToLocationView); mSnapToLocationView = (ToggleButton) findViewById(R.id.snapToLocationView);
this.snapToLocationView.setOnClickListener(new OnClickListener() { mSnapToLocationView.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (isSnapToLocationEnabled()) { if (isSnapToLocationEnabled()) {
@@ -307,15 +356,21 @@ public class TileMap extends MapActivity {
}); });
// get the pointers to different system services // get the pointers to different system services
this.locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
this.myLocationListener = new MyLocationListener(this); mMyLocationListener = new MyLocationListener(this);
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); 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)) { if (savedInstanceState != null) {
enableShowMyLocation(savedInstanceState.getBoolean(BUNDLE_CENTER_AT_FIRST_FIX)); if (savedInstanceState.getBoolean(BUNDLE_SHOW_MY_LOCATION)) {
if (savedInstanceState.getBoolean(BUNDLE_SNAP_TO_LOCATION)) {
enableSnapToLocation(false); 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); 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, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.go_to_position,
@Override new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
// disable GPS follow mode if it is enabled public void onClick(DialogInterface dialog, int which) {
disableSnapToLocation(true); // disable GPS follow mode if it is enabled
disableSnapToLocation(true);
// set the map center and zoom level // set the map center and zoom level
EditText latitudeView = (EditText) view.findViewById(R.id.latitude); EditText latitudeView = (EditText) view
EditText longitudeView = (EditText) view.findViewById(R.id.longitude); .findViewById(R.id.latitude);
double latitude = Double.parseDouble(latitudeView.getText().toString()); EditText longitudeView = (EditText) view
double longitude = Double.parseDouble(longitudeView.getText().toString()); .findViewById(R.id.longitude);
GeoPoint geoPoint = new GeoPoint(latitude, longitude); double latitude = Double.parseDouble(latitudeView.getText()
TileMap.this.mapController.setCenter(geoPoint); .toString());
SeekBar zoomLevelView = (SeekBar) view.findViewById(R.id.zoomLevel); double longitude = Double.parseDouble(longitudeView.getText()
TileMap.this.mapController.setZoom(zoomLevelView.getProgress()); .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); builder.setNegativeButton(R.string.cancel, null);
return builder.create(); return builder.create();
} else if (id == DIALOG_LOCATION_PROVIDER_DISABLED) { } else if (id == DIALOG_LOCATION_PROVIDER_DISABLED) {
@@ -377,8 +439,8 @@ public class TileMap extends MapActivity {
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
// release the wake lock if necessary // release the wake lock if necessary
if (this.wakeLock.isHeld()) { if (mWakeLock.isHeld()) {
this.wakeLock.release(); mWakeLock.release();
} }
} }
@@ -386,27 +448,28 @@ public class TileMap extends MapActivity {
protected void onPrepareDialog(int id, final Dialog dialog) { protected void onPrepareDialog(int id, final Dialog dialog) {
if (id == DIALOG_ENTER_COORDINATES) { if (id == DIALOG_ENTER_COORDINATES) {
EditText editText = (EditText) dialog.findViewById(R.id.latitude); 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.setText(Double.toString(mapCenter.getLatitude()));
editText = (EditText) dialog.findViewById(R.id.longitude); editText = (EditText) dialog.findViewById(R.id.longitude);
editText.setText(Double.toString(mapCenter.getLongitude())); editText.setText(Double.toString(mapCenter.getLongitude()));
SeekBar zoomlevel = (SeekBar) dialog.findViewById(R.id.zoomLevel); SeekBar zoomlevel = (SeekBar) dialog.findViewById(R.id.zoomLevel);
zoomlevel.setMax(this.mapView.getMapGenerator().getZoomLevelMax()); zoomlevel.setMax(mMapView.getMapGenerator().getZoomLevelMax());
zoomlevel.setProgress(this.mapView.getMapPosition().getZoomLevel()); zoomlevel.setProgress(mMapView.getMapPosition().getZoomLevel());
final TextView textView = (TextView) dialog.findViewById(R.id.zoomlevelValue); final TextView textView = (TextView) dialog.findViewById(R.id.zoomlevelValue);
textView.setText(String.valueOf(zoomlevel.getProgress())); textView.setText(String.valueOf(zoomlevel.getProgress()));
zoomlevel.setOnSeekBarChangeListener(new SeekBarChangeListener(textView)); zoomlevel.setOnSeekBarChangeListener(new SeekBarChangeListener(textView));
} else if (id == DIALOG_INFO_MAP_FILE) { } 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 textView = (TextView) dialog.findViewById(R.id.infoMapFileViewName);
textView.setText(this.mapView.getMapFile()); textView.setText(mMapView.getMapFile());
textView = (TextView) dialog.findViewById(R.id.infoMapFileViewSize); 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 = (TextView) dialog.findViewById(R.id.infoMapFileViewVersion);
textView.setText(String.valueOf(mapFileInfo.fileVersion)); textView.setText(String.valueOf(mapFileInfo.fileVersion));
@@ -424,7 +487,8 @@ public class TileMap extends MapActivity {
textView = (TextView) dialog.findViewById(R.id.infoMapFileViewArea); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewArea);
BoundingBox boundingBox = mapFileInfo.boundingBox; BoundingBox boundingBox = mapFileInfo.boundingBox;
textView.setText(boundingBox.getMinLatitude() + ", " + boundingBox.getMinLongitude() + " - \n" textView.setText(boundingBox.getMinLatitude() + ", "
+ boundingBox.getMinLongitude() + " - \n"
+ boundingBox.getMaxLatitude() + ", " + boundingBox.getMaxLongitude()); + boundingBox.getMaxLatitude() + ", " + boundingBox.getMaxLongitude());
textView = (TextView) dialog.findViewById(R.id.infoMapFileViewStartPosition); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewStartPosition);
@@ -432,7 +496,8 @@ public class TileMap extends MapActivity {
if (startPosition == null) { if (startPosition == null) {
textView.setText(null); textView.setText(null);
} else { } else {
textView.setText(startPosition.getLatitude() + ", " + startPosition.getLongitude()); textView.setText(startPosition.getLatitude() + ", "
+ startPosition.getLongitude());
} }
textView = (TextView) dialog.findViewById(R.id.infoMapFileViewStartZoomLevel); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewStartZoomLevel);
@@ -443,7 +508,8 @@ public class TileMap extends MapActivity {
textView.setText(startZoomLevel.toString()); textView.setText(startZoomLevel.toString());
} }
textView = (TextView) dialog.findViewById(R.id.infoMapFileViewLanguagePreference); textView = (TextView) dialog
.findViewById(R.id.infoMapFileViewLanguagePreference);
textView.setText(mapFileInfo.languagePreference); textView.setText(mapFileInfo.languagePreference);
textView = (TextView) dialog.findViewById(R.id.infoMapFileViewComment); textView = (TextView) dialog.findViewById(R.id.infoMapFileViewComment);
@@ -460,13 +526,14 @@ public class TileMap extends MapActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(this);
MapScaleBar mapScaleBar = this.mapView.getMapScaleBar(); // MapScaleBar mapScaleBar = mapView.getMapScaleBar();
mapScaleBar.setShowMapScaleBar(preferences.getBoolean("showScaleBar", false)); // mapScaleBar.setShowMapScaleBar(preferences.getBoolean("showScaleBar", false));
String scaleBarUnitDefault = getString(R.string.preferences_scale_bar_unit_default); // String scaleBarUnitDefault = getString(R.string.preferences_scale_bar_unit_default);
String scaleBarUnit = preferences.getString("scaleBarUnit", scaleBarUnitDefault); // String scaleBarUnit = preferences.getString("scaleBarUnit", scaleBarUnitDefault);
mapScaleBar.setImperialUnits(scaleBarUnit.equals("imperial")); // mapScaleBar.setImperialUnits(scaleBarUnit.equals("imperial"));
// if (preferences.contains("mapGenerator")) { // if (preferences.contains("mapGenerator")) {
// String name = preferences.getString("mapGenerator", MapGeneratorInternal.SW_RENDERER.name()); // String name = preferences.getString("mapGenerator", MapGeneratorInternal.SW_RENDERER.name());
@@ -477,33 +544,41 @@ public class TileMap extends MapActivity {
// mapGeneratorInternalNew = MapGeneratorInternal.SW_RENDERER; // mapGeneratorInternalNew = MapGeneratorInternal.SW_RENDERER;
// } // }
// //
// if (mapGeneratorInternalNew != this.mapGeneratorInternal) { // if (mapGeneratorInternalNew != mapGeneratorInternal) {
// MapGenerator mapGenerator = MapGeneratorFactory.createMapGenerator(mapGeneratorInternalNew); // MapGenerator mapGenerator = MapGeneratorFactory.createMapGenerator(mapGeneratorInternalNew);
// this.mapView.setMapGenerator(mapGenerator); // mapView.setMapGenerator(mapGenerator);
// this.mapGeneratorInternal = mapGeneratorInternalNew; // mapGeneratorInternal = mapGeneratorInternalNew;
// } // }
// } // }
if (preferences.contains("mapDatabase")) { if (preferences.contains("mapDatabase")) {
String name = preferences.getString("mapDatabase", MapDatabaseInternal.MAP_READER.name()); String name = preferences.getString("mapDatabase",
MapDatabaseInternal.POSTGIS_READER.name());
MapDatabaseInternal mapDatabaseInternalNew; MapDatabaseInternal mapDatabaseInternalNew;
try { try {
mapDatabaseInternalNew = MapDatabaseInternal.valueOf(name); mapDatabaseInternalNew = MapDatabaseInternal.valueOf(name);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
mapDatabaseInternalNew = MapDatabaseInternal.MAP_READER; mapDatabaseInternalNew = MapDatabaseInternal.POSTGIS_READER;
} }
Log.d("VectorTileMap", "set map database " + mapDatabaseInternalNew); Log.d("VectorTileMap", "set map database " + mapDatabaseInternalNew);
if (mapDatabaseInternalNew != this.mapDatabaseInternal) { if (mapDatabaseInternalNew != mMapDatabaseInternal) {
IMapDatabase mapDatabase = MapDatabaseFactory.createMapDatabase(mapDatabaseInternalNew); IMapDatabase mapDatabase = MapDatabaseFactory
this.mapView.setMapDatabase(mapDatabase); .createMapDatabase(mapDatabaseInternalNew);
this.mapDatabaseInternal = mapDatabaseInternalNew; mMapView.setMapDatabase(mapDatabase);
mMapDatabaseInternal = mapDatabaseInternalNew;
} }
} }
try { try {
String textScaleDefault = getString(R.string.preferences_text_scale_default); 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) { } catch (NumberFormatException e) {
this.mapView.setTextScale(1); mMapView.setTextScale(1);
} }
if (preferences.getBoolean("fullscreen", false)) { if (preferences.getBoolean("fullscreen", false)) {
@@ -515,18 +590,27 @@ 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("wakeLock", false) && !this.wakeLock.isHeld()) { if (preferences.getBoolean("wakeLock", false) && !mWakeLock.isHeld()) {
this.wakeLock.acquire(); mWakeLock.acquire();
} }
boolean drawTileFrames = preferences.getBoolean("drawTileFrames", false); boolean drawTileFrames =
boolean drawTileCoordinates = preferences.getBoolean("drawTileCoordinates", false); preferences.getBoolean("drawTileFrames", false);
boolean disablePolygons = preferences.getBoolean("disablePolygons", false); boolean drawTileCoordinates =
DebugSettings debugSettings = new DebugSettings(drawTileCoordinates, drawTileFrames, disablePolygons); preferences.getBoolean("drawTileCoordinates", false);
this.mapView.setDebugSettings(debugSettings); boolean disablePolygons =
preferences.getBoolean("disablePolygons", false);
if (!this.mapView.getMapGenerator().requiresInternetConnection() && this.mapView.getMapFile() == null) { DebugSettings debugSettings = new DebugSettings(drawTileCoordinates,
startMapFilePicker(); 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) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, isShowMyLocationEnabled()); outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, isShowMyLocationEnabled());
outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX, this.myLocationListener.isCenterAtFirstFix()); outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX,
outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, this.snapToLocation); mMyLocationListener.isCenterAtFirstFix());
outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, mSnapToLocation);
} }
/** /**
@@ -544,17 +629,17 @@ public class TileMap extends MapActivity {
* @return ... * @return ...
*/ */
private boolean disableShowMyLocation() { private boolean disableShowMyLocation() {
if (this.showMyLocation) { if (mShowMyLocation) {
this.showMyLocation = false; mShowMyLocation = false;
disableSnapToLocation(false); disableSnapToLocation(false);
this.locationManager.removeUpdates(this.myLocationListener); mLocationManager.removeUpdates(mMyLocationListener);
// if (this.circleOverlay != null) { // if (circleOverlay != null) {
// this.mapView.getOverlays().remove(this.circleOverlay); // mapView.getOverlays().remove(circleOverlay);
// this.mapView.getOverlays().remove(this.itemizedOverlay); // mapView.getOverlays().remove(itemizedOverlay);
// this.circleOverlay = null; // circleOverlay = null;
// this.itemizedOverlay = null; // itemizedOverlay = null;
// } // }
this.snapToLocationView.setVisibility(View.GONE); mSnapToLocationView.setVisibility(View.GONE);
return true; return true;
} }
return false; return false;
@@ -567,10 +652,10 @@ public class TileMap extends MapActivity {
* defines whether a toast message is displayed or not. * defines whether a toast message is displayed or not.
*/ */
void disableSnapToLocation(boolean showToast) { void disableSnapToLocation(boolean showToast) {
if (this.snapToLocation) { if (mSnapToLocation) {
this.snapToLocation = false; mSnapToLocation = false;
this.snapToLocationView.setChecked(false); mSnapToLocationView.setChecked(false);
this.mapView.setClickable(true); mMapView.setClickable(true);
if (showToast) { if (showToast) {
showToastOnUiThread(getString(R.string.snap_to_location_disabled)); 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. * defines whether a toast message is displayed or not.
*/ */
void enableSnapToLocation(boolean showToast) { void enableSnapToLocation(boolean showToast) {
if (!this.snapToLocation) { if (!mSnapToLocation) {
this.snapToLocation = true; mSnapToLocation = true;
this.mapView.setClickable(false); mMapView.setClickable(false);
if (showToast) { if (showToast) {
showToastOnUiThread(getString(R.string.snap_to_location_enabled)); 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. * @return true if the "show my location" mode is enabled, false otherwise.
*/ */
boolean isShowMyLocationEnabled() { 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. * @return true if the "snap to location" mode is enabled, false otherwise.
*/ */
boolean isSnapToLocationEnabled() { 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;
}
} }

View File

@@ -19,6 +19,7 @@ import java.io.FileFilter;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import org.mapsforge.tilemap.R;
import org.mapsforge.tilemap.filefilter.ValidFileFilter; import org.mapsforge.tilemap.filefilter.ValidFileFilter;
import android.app.Activity; import android.app.Activity;
@@ -28,12 +29,9 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.GridView; 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 * 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; this.currentDirectory = selectedFile;
browseToCurrentDirectory(); browseToCurrentDirectory();
} else if (fileSelectFilter == null || fileSelectFilter.accept(selectedFile)) { } 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(); finish();
} else { } else {
showDialog(DIALOG_FILE_INVALID); showDialog(DIALOG_FILE_INVALID);
@@ -159,7 +158,8 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
if (this.currentDirectory.getParentFile() != null) { if (this.currentDirectory.getParentFile() != null) {
this.filesWithParentFolder = new File[this.files.length + 1]; this.filesWithParentFolder = new File[this.files.length + 1];
this.filesWithParentFolder[0] = this.currentDirectory.getParentFile(); 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.files = this.filesWithParentFolder;
this.filePickerIconAdapter.setFiles(this.files, true); this.filePickerIconAdapter.setFiles(this.files, true);
} else { } else {
@@ -195,7 +195,8 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(getString(R.string.file_invalid)); stringBuilder.append(getString(R.string.file_invalid));
stringBuilder.append("\n\n"); stringBuilder.append("\n\n");
stringBuilder.append(FilePicker.fileSelectFilter.getFileOpenResult().getErrorMessage()); stringBuilder.append(FilePicker.fileSelectFilter.getFileOpenResult()
.getErrorMessage());
builder.setMessage(stringBuilder.toString()); builder.setMessage(stringBuilder.toString());
builder.setPositiveButton(R.string.ok, null); builder.setPositiveButton(R.string.ok, null);
@@ -225,18 +226,21 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
getActionBar().hide();
// check if the full screen mode should be activated // 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().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); // getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else { // } else {
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);
} // }
// restore the current directory // restore the current directory
SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE); SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE,
this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY, DEFAULT_DIRECTORY)); MODE_PRIVATE);
this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY,
DEFAULT_DIRECTORY));
if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) { if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) {
this.currentDirectory = new File(DEFAULT_DIRECTORY); this.currentDirectory = new File(DEFAULT_DIRECTORY);
} }

View File

@@ -14,11 +14,12 @@
*/ */
package org.mapsforge.tilemap.preferences; package org.mapsforge.tilemap.preferences;
import org.mapsforge.tilemap.R;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.view.WindowManager; import android.view.WindowManager;
import org.mapsforge.tilemap.R;
/** /**
* Activity to edit the application preferences. * Activity to edit the application preferences.
@@ -33,8 +34,11 @@ public class EditPreferences extends PreferenceActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
getActionBar().hide();
// check if the full screen mode should be activated // 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().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else { } else {