clean structure
This commit is contained in:
parent
6c445aed91
commit
aec0b252c3
5 changed files with 61 additions and 14 deletions
|
@ -275,6 +275,18 @@ public class OsmandRegions {
|
|||
public RegionData getRegionData(String fullname) {
|
||||
return fullNamesToRegionData.get(fullname);
|
||||
}
|
||||
|
||||
public String getDownloadName(BinaryMapDataObject o) {
|
||||
return mapIndexFields.get(mapIndexFields.downloadNameType, o);
|
||||
}
|
||||
|
||||
public String getFullName(BinaryMapDataObject o) {
|
||||
return mapIndexFields.get(mapIndexFields.fullNameType, o);
|
||||
}
|
||||
|
||||
public List<RegionData> getAllRegionData() {
|
||||
return new ArrayList<OsmandRegions.RegionData>(fullNamesToRegionData.values());
|
||||
}
|
||||
|
||||
public void initRegionData() throws IOException {
|
||||
// final Collator clt = OsmAndCollator.primaryCollator();
|
||||
|
@ -533,6 +545,10 @@ public class OsmandRegions {
|
|||
protected LatLon regionCenter;
|
||||
|
||||
|
||||
public boolean isRegionMapDownload() {
|
||||
return regionMapDownload;
|
||||
}
|
||||
|
||||
public String getLocaleName() {
|
||||
if(!Algorithms.isEmpty(regionNameLocale)) {
|
||||
return regionNameLocale;
|
||||
|
@ -543,14 +559,33 @@ public class OsmandRegions {
|
|||
return regionName;
|
||||
}
|
||||
|
||||
public LatLon getCenter() {
|
||||
public String getRegionDownloadName() {
|
||||
return regionDownloadName;
|
||||
}
|
||||
|
||||
public String getRegionLeftHandDriving() {
|
||||
return regionLeftHandDriving;
|
||||
}
|
||||
|
||||
public String getRegionMetric() {
|
||||
return regionMetric;
|
||||
}
|
||||
|
||||
public String getRegionRoadSigns() {
|
||||
return regionRoadSigns;
|
||||
}
|
||||
|
||||
public LatLon getRegionCenter() {
|
||||
return regionCenter;
|
||||
}
|
||||
|
||||
public String getSearchText() {
|
||||
public String getRegionSearchText() {
|
||||
return regionSearchText;
|
||||
}
|
||||
|
||||
public String getRegionLang() {
|
||||
return regionLang;
|
||||
}
|
||||
|
||||
|
||||
///TODO investigate do we need it ???
|
||||
|
@ -570,5 +605,14 @@ public class OsmandRegions {
|
|||
public String getDownloadsId() {
|
||||
return downloadsId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map.Entry;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.map.OsmandRegions.RegionData;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.content.res.Resources;
|
||||
|
||||
|
@ -117,8 +118,7 @@ public class WorldRegion {
|
|||
}
|
||||
|
||||
public void loadWorldRegions(OsmandApplication app) {
|
||||
OsmandRegions osmandRegions = app.getRegions();
|
||||
Map<String, String> loadedItems = osmandRegions.getFullNamesToLowercaseCopy();
|
||||
List<RegionData> loadedItems = osmandRegions.getAllRegionData();
|
||||
if (loadedItems.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.widget.Toast;
|
|||
import net.osmand.IProgress;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.map.OsmandRegions.RegionData;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.DrivingRegion;
|
||||
|
@ -500,9 +501,10 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
|||
// TODO test set correctly (4 tests): when you download first Australia, Japan, Luxembourgh, US
|
||||
getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.set(false);
|
||||
DrivingRegion drg = null;
|
||||
boolean americanSigns = "american".equals(reg.getRoadSigns(getMyApplication().getRegions()));
|
||||
boolean leftHand = "yes".equals(reg.getLeftHandDriving(getMyApplication().getRegions()));
|
||||
MetricsConstants mc = "miles".equals(reg.getMetric(getMyApplication().getRegions())) ?
|
||||
RegionData rd = reg.getRegionData();
|
||||
boolean americanSigns = "american".equals(rd.getRegionRoadSigns());
|
||||
boolean leftHand = "yes".equals(rd.getRegionLeftHandDriving());
|
||||
MetricsConstants mc = "miles".equals(rd.getRegionMetric()) ?
|
||||
MetricsConstants.MILES_AND_FOOTS : MetricsConstants.KILOMETERS_AND_METERS;
|
||||
for (DrivingRegion r : DrivingRegion.values()) {
|
||||
if(r.americanSigns == americanSigns && r.leftHandDriving == leftHand &&
|
||||
|
@ -514,7 +516,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
|||
if (drg != null) {
|
||||
getMyApplication().getSettings().DRIVING_REGION.set(drg);
|
||||
}
|
||||
String lng = reg.getLang(getMyApplication().getRegions());
|
||||
String lng = rd.getRegionLang();
|
||||
if (lng != null) {
|
||||
String setTts = null;
|
||||
for (String s : OsmandSettings.TTS_AVAILABLE_VOICES) {
|
||||
|
|
|
@ -330,8 +330,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
|
||||
private void processGroup(DownloadResourceGroup group, List<Object> filter, List<List<String>> conds) {
|
||||
String name = null;
|
||||
if (group.getRegion() != null && group.getRegion().getSearchText() != null) {
|
||||
name = group.getRegion().getSearchText().toLowerCase();
|
||||
if (group.getRegion() != null && group.getRegion().getRegionData().getRegionSearchText() != null) {
|
||||
name = group.getRegion().getRegionData().getRegionSearchText().toLowerCase();
|
||||
}
|
||||
if (name == null) {
|
||||
name = group.getName(ctx).toLowerCase();
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.binary.BinaryMapDataObject;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.map.OsmandRegions.RegionData;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -248,10 +249,10 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
|||
continue;
|
||||
}
|
||||
String fullName = osmandRegions.getFullName(o);
|
||||
String downloadName = osmandRegions.getMapDownloadType(fullName);
|
||||
if (!Algorithms.isEmpty(downloadName)) {
|
||||
String name = osmandRegions.getLocaleName(downloadName, true); // Algorithms.capitalizeFirstLetterAndLowercase(o.getName());
|
||||
if (checkIfObjectDownloaded(downloadName)) {
|
||||
RegionData rd = osmandRegions.getRegionData(fullName);
|
||||
if (rd != null && rd.isRegionMapDownload()) {
|
||||
String name = rd.getLocaleName();
|
||||
if (checkIfObjectDownloaded(rd.getRegionDownloadName())) {
|
||||
return null;
|
||||
}
|
||||
if (!set.add(name)) {
|
||||
|
|
Loading…
Reference in a new issue