Small improvements

This commit is contained in:
Victor Shcherb 2011-10-01 10:53:36 +02:00
parent bcc1f0a532
commit 0a96d65468
3 changed files with 67 additions and 15 deletions

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:paddingLeft="40dp">
android:layout_height="wrap_content" android:paddingLeft="40dp" android:paddingTop="3dp">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<CheckBox android:id="@+id/check_item" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:focusable="false" android:visibility="gone"/>
</LinearLayout>
<TextView android:id="@+id/category_name" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="21sp"></TextView>
android:textSize="24sp"></TextView>
</LinearLayout>

View file

@ -12,10 +12,12 @@ import java.util.Map.Entry;
import net.osmand.Algoritms;
import net.osmand.CallbackWithObject;
import net.osmand.GPXUtilities;
import net.osmand.ResultMatcher;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.OsmAndFormatter;
import net.osmand.data.AmenityType;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.PoiFilter;
@ -518,10 +520,29 @@ public class MapActivityLayers {
}
updateMapSource(mapView, null);
} else if (layerKey.equals(layerInstallMore)) {
SettingsActivity.installMapLayers(activity, new DialogInterface.OnClickListener() {
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
TileSourceTemplate template = null;
int count = 0;
@Override
public void onClick(DialogInterface dialog, int which) {
openLayerSelectionDialog(mapView);
public boolean publish(TileSourceTemplate object) {
if(object == null){
if(count == 1){
settings.MAP_TILE_SOURCES.set(template.getName());
settings.MAP_VECTOR_DATA.set(false);
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
} else {
selectMapLayer(mapView);
}
} else {
count ++;
template = object;
}
return false;
}
@Override
public boolean isCancelled() {
return false;
}
});
} else {
@ -555,10 +576,29 @@ public class MapActivityLayers {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == items.length - 1){
SettingsActivity.installMapLayers(activity, new DialogInterface.OnClickListener() {
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
TileSourceTemplate template = null;
int count = 0;
@Override
public void onClick(DialogInterface dialog, int which) {
openLayerSelectionDialog(mapView);
public boolean publish(TileSourceTemplate object) {
if(object == null){
if(count == 1){
mapPref.set(template.getName());
mapControlsLayer.showAndHideTransparencyBar(transparencyPref, transparencyToChange);
updateMapSource(mapView, mapPref);
} else {
selectMapOverlayLayer(mapView, mapPref, transparencyPref, transparencyToChange);
}
} else {
count ++;
template = object;
}
return false;
}
@Override
public boolean isCancelled() {
return false;
}
});
} else {

View file

@ -10,6 +10,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.osmand.ResultMatcher;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.NavigationService;
@ -529,10 +530,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if (preference == tileSourcePreference || preference == overlayPreference
|| preference == underlayPreference) {
if(MORE_VALUE.equals(newValue)){
SettingsActivity.installMapLayers(this, new DialogInterface.OnClickListener() {
SettingsActivity.installMapLayers(this, new ResultMatcher<TileSourceTemplate>() {
@Override
public void onClick(DialogInterface dialog, int which) {
updateTileSourceSummary();
public boolean isCancelled() { return false;}
@Override
public boolean publish(TileSourceTemplate object) {
if(object == null){
updateTileSourceSummary();
}
return true;
}
});
} else if(preference == tileSourcePreference){
@ -677,7 +684,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
return false;
}
public static void installMapLayers(final Activity activity, final DialogInterface.OnClickListener onClickListener){
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result){
final OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
final Map<String, String> entriesMap = settings.getTileSourceEntries();
if(!settings.isInternetConnectionAvailable(true)){
@ -717,10 +724,15 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
}
}
for(TileSourceTemplate ts : toInstall){
settings.installTileSource(ts);
if(settings.installTileSource(ts)){
if(result != null){
result.publish(ts);
}
}
}
if(onClickListener != null){
onClickListener.onClick(dialog, which);
// at the end publish null to show end of process
if (!toInstall.isEmpty() && result != null) {
result.publish(null);
}
}
});