diff --git a/DataExtractionOSM/src/com/osmand/OsmandSettings.java b/DataExtractionOSM/src/com/osmand/OsmandSettings.java new file mode 100644 index 0000000000..a980e40894 --- /dev/null +++ b/DataExtractionOSM/src/com/osmand/OsmandSettings.java @@ -0,0 +1,13 @@ +package com.osmand; + +import com.osmand.map.ITileSource; + +public class OsmandSettings { + + public static boolean useInternetToDownloadTiles = DefaultLauncherConstants.loadMissingImages; + + public static boolean showGPSLocationOnMap = DefaultLauncherConstants.showGPSCoordinates; + + public static ITileSource tileSource = DefaultLauncherConstants.MAP_defaultTileSource; + +} diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java index 32a93bc902..e3d3d112fe 100644 --- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java @@ -10,5 +10,13 @@ public class ToDoConstants { public int CONFIG_COMMONS_LOGGING_IN_ANDROID = 1; + + public int SAVE_SETTINGS_IN_ANDROID_BETWEEN_SESSION = 2; + + public int IMPLEMENT_ON_STOP_RESUME_ACTIVITY = 3; + + // OsmandMapTileView.java have problem with class loading (LogFactory, MapTileDownloader) - + // it is not editable in editor + public int MAKE_MAP_PANEL_EDITABLE_IN_EDITOR = 4; } diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index f537dcda7f..19e916df4f 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -4,7 +4,7 @@ android:versionCode="1" android:versionName="1.0"> - @@ -12,7 +12,7 @@ - + diff --git a/OsmAnd/res/layout/main.xml b/OsmAnd/res/layout/main.xml index 3e5fc1b964..f676e7ed9b 100644 --- a/OsmAnd/res/layout/main.xml +++ b/OsmAnd/res/layout/main.xml @@ -3,8 +3,8 @@ android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - - + + diff --git a/OsmAnd/res/layout/settings.xml b/OsmAnd/res/layout/settings.xml deleted file mode 100644 index 65371559de..0000000000 --- a/OsmAnd/res/layout/settings.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 8664ba99af..9ea9a568b0 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1,5 +1,11 @@ + Choose the source of tiles + Map tile source + Map source + Use internet + Show location + Map preferences Settings Show gps coordinates on map Use internet to download missing tiles diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml new file mode 100644 index 0000000000..b88947b341 --- /dev/null +++ b/OsmAnd/res/xml/settings_pref.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/OsmAnd/src/com/osmand/SettingsActivity.java b/OsmAnd/src/com/osmand/SettingsActivity.java deleted file mode 100644 index 64565eafc0..0000000000 --- a/OsmAnd/src/com/osmand/SettingsActivity.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.osmand; - -import android.app.Activity; -import android.os.Bundle; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.CheckBox; - -public class SettingsActivity extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.settings); - - final CheckBox useInternet = (CheckBox)findViewById(R.id.use_internet_to_download_tile); - useInternet.setOnClickListener(new OnClickListener(){ - @Override - public void onClick(View v) { - DefaultLauncherConstants.loadMissingImages = useInternet.isChecked(); - } - - }); - useInternet.setChecked(DefaultLauncherConstants.loadMissingImages); - - final CheckBox showGPSText = (CheckBox)findViewById(R.id.show_gps_coordinates_text); - showGPSText.setOnClickListener(new OnClickListener(){ - @Override - public void onClick(View v) { - DefaultLauncherConstants.showGPSCoordinates = showGPSText.isChecked(); - } - - }); - showGPSText.setChecked(DefaultLauncherConstants.showGPSCoordinates); - } - -} diff --git a/OsmAnd/src/com/osmand/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java similarity index 94% rename from OsmAnd/src/com/osmand/MapActivity.java rename to OsmAnd/src/com/osmand/activities/MapActivity.java index 7389e7344a..6e68fe7609 100644 --- a/OsmAnd/src/com/osmand/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -1,4 +1,4 @@ -package com.osmand; +package com.osmand.activities; import java.io.File; @@ -16,7 +16,12 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.ZoomControls; +import com.osmand.IMapLocationListener; +import com.osmand.OsmandSettings; +import com.osmand.R; import com.osmand.osm.MapUtils; +import com.osmand.views.OsmandMapTileView; +import com.osmand.views.PointOfView; public class MapActivity extends Activity implements LocationListener, IMapLocationListener { /** Called when the activity is first created. */ @@ -143,6 +148,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat } } + @Override protected void onPause() { // TODO switch off gps @@ -153,6 +159,9 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat protected void onResume() { // TODO switch on gps super.onResume(); + if(mapView.getMap() != OsmandSettings.tileSource){ + mapView.setMap(OsmandSettings.tileSource); + } } diff --git a/OsmAnd/src/com/osmand/activities/SettingsActivity.java b/OsmAnd/src/com/osmand/activities/SettingsActivity.java new file mode 100644 index 0000000000..3f05861a76 --- /dev/null +++ b/OsmAnd/src/com/osmand/activities/SettingsActivity.java @@ -0,0 +1,76 @@ +package com.osmand.activities; + +import java.util.List; + +import com.osmand.DefaultLauncherConstants; +import com.osmand.R; +import com.osmand.R.xml; +import com.osmand.map.TileSourceManager; +import com.osmand.map.TileSourceManager.TileSourceTemplate; + +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceScreen; +import android.preference.Preference.OnPreferenceChangeListener; + +public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener { + private static final String use_internet_to_download_tiles = "use_internet_to_download_tiles"; + private static final String show_gps_location_text = "show_gps_location_text"; + private static final String map_tile_sources = "map_tile_sources"; + private CheckBoxPreference showGpsLocation; + private CheckBoxPreference useInternetToDownloadTiles; + private ListPreference tileSourcePreference; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.settings_pref); + PreferenceScreen screen = getPreferenceScreen(); + showGpsLocation =(CheckBoxPreference) screen.findPreference(show_gps_location_text); + showGpsLocation.setOnPreferenceChangeListener(this); + useInternetToDownloadTiles =(CheckBoxPreference) screen.findPreference(use_internet_to_download_tiles); + useInternetToDownloadTiles.setOnPreferenceChangeListener(this); + + tileSourcePreference =(ListPreference) screen.findPreference(map_tile_sources); + tileSourcePreference.setOnPreferenceChangeListener(this); + + + } + + @Override + protected void onResume() { + super.onResume(); + useInternetToDownloadTiles.setChecked(DefaultLauncherConstants.loadMissingImages); + showGpsLocation.setChecked(DefaultLauncherConstants.showGPSCoordinates); + List list = TileSourceManager.getKnownSourceTemplates(); + String[] entries = new String[list.size()]; + for(int i=0; i