Small improvements
This commit is contained in:
parent
bcc1f0a532
commit
0a96d65468
3 changed files with 67 additions and 15 deletions
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
|
<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">
|
<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"
|
<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"/>
|
android:gravity="center_vertical" android:focusable="false" android:visibility="gone"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView android:id="@+id/category_name" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
|
<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>
|
</LinearLayout>
|
||||||
|
|
|
@ -12,10 +12,12 @@ import java.util.Map.Entry;
|
||||||
import net.osmand.Algoritms;
|
import net.osmand.Algoritms;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.OsmAndFormatter;
|
import net.osmand.OsmAndFormatter;
|
||||||
import net.osmand.data.AmenityType;
|
import net.osmand.data.AmenityType;
|
||||||
import net.osmand.map.ITileSource;
|
import net.osmand.map.ITileSource;
|
||||||
|
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
import net.osmand.plus.PoiFilter;
|
import net.osmand.plus.PoiFilter;
|
||||||
|
@ -518,10 +520,29 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
updateMapSource(mapView, null);
|
updateMapSource(mapView, null);
|
||||||
} else if (layerKey.equals(layerInstallMore)) {
|
} else if (layerKey.equals(layerInstallMore)) {
|
||||||
SettingsActivity.installMapLayers(activity, new DialogInterface.OnClickListener() {
|
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||||
|
TileSourceTemplate template = null;
|
||||||
|
int count = 0;
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public boolean publish(TileSourceTemplate object) {
|
||||||
openLayerSelectionDialog(mapView);
|
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 {
|
} else {
|
||||||
|
@ -555,10 +576,29 @@ public class MapActivityLayers {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == items.length - 1){
|
if (which == items.length - 1){
|
||||||
SettingsActivity.installMapLayers(activity, new DialogInterface.OnClickListener() {
|
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||||
|
TileSourceTemplate template = null;
|
||||||
|
int count = 0;
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public boolean publish(TileSourceTemplate object) {
|
||||||
openLayerSelectionDialog(mapView);
|
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 {
|
} else {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.map.TileSourceManager;
|
import net.osmand.map.TileSourceManager;
|
||||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
import net.osmand.plus.NavigationService;
|
import net.osmand.plus.NavigationService;
|
||||||
|
@ -529,10 +530,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
} else if (preference == tileSourcePreference || preference == overlayPreference
|
} else if (preference == tileSourcePreference || preference == overlayPreference
|
||||||
|| preference == underlayPreference) {
|
|| preference == underlayPreference) {
|
||||||
if(MORE_VALUE.equals(newValue)){
|
if(MORE_VALUE.equals(newValue)){
|
||||||
SettingsActivity.installMapLayers(this, new DialogInterface.OnClickListener() {
|
SettingsActivity.installMapLayers(this, new ResultMatcher<TileSourceTemplate>() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public boolean isCancelled() { return false;}
|
||||||
updateTileSourceSummary();
|
|
||||||
|
@Override
|
||||||
|
public boolean publish(TileSourceTemplate object) {
|
||||||
|
if(object == null){
|
||||||
|
updateTileSourceSummary();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if(preference == tileSourcePreference){
|
} else if(preference == tileSourcePreference){
|
||||||
|
@ -677,7 +684,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
return false;
|
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 OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
||||||
final Map<String, String> entriesMap = settings.getTileSourceEntries();
|
final Map<String, String> entriesMap = settings.getTileSourceEntries();
|
||||||
if(!settings.isInternetConnectionAvailable(true)){
|
if(!settings.isInternetConnectionAvailable(true)){
|
||||||
|
@ -717,10 +724,15 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(TileSourceTemplate ts : toInstall){
|
for(TileSourceTemplate ts : toInstall){
|
||||||
settings.installTileSource(ts);
|
if(settings.installTileSource(ts)){
|
||||||
|
if(result != null){
|
||||||
|
result.publish(ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(onClickListener != null){
|
// at the end publish null to show end of process
|
||||||
onClickListener.onClick(dialog, which);
|
if (!toInstall.isEmpty() && result != null) {
|
||||||
|
result.publish(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue