Fix Replace button color, added new info methods to WorldRegion

This commit is contained in:
Alexey Kulish 2015-10-22 11:48:14 +03:00
parent 51ff44cea3
commit 2050622214
5 changed files with 88 additions and 5 deletions

View file

@ -47,6 +47,11 @@ public class OsmandRegions {
Map<String, String> fullNamesToLowercaseIndex = new HashMap<String, String>();
Map<String, String> fullNamesToParentFullNames = new HashMap<String, String>();
Map<String, String> fullNamesToDownloadNames = new HashMap<String, String>();
Map<String, String> fullNamesToLangs = new HashMap<String, String>();
Map<String, String> fullNamesToMetrics = new HashMap<String, String>();
Map<String, String> fullNamesToLeftHandDrivings = new HashMap<String, String>();
Map<String, String> fullNamesToRoadSigns = new HashMap<String, String>();
QuadTree<String> quadTree = null ;
public Map<String, String> getFullNamesToLowercaseCopy() {
@ -60,6 +65,10 @@ public class OsmandRegions {
Integer nameType = null;
Integer nameLocaleType = null;
String locale = "en";
Integer langType = null;
Integer metricType = null;
Integer leftHandDrivingType = null;
Integer roadSignsType = null;
public void prepareFile(String fileName) throws IOException {
@ -71,6 +80,38 @@ public class OsmandRegions {
return countriesByDownloadName.containsKey(name);
}
public String getLang(String fullName) {
return fullNamesToLangs.get(fullName);
}
public String getMetric(String fullName) {
return fullNamesToMetrics.get(fullName);
}
public String getLeftHandDriving(String fullName) {
return fullNamesToLeftHandDrivings.get(fullName);
}
public String getRoadSigns(String fullName) {
return fullNamesToRoadSigns.get(fullName);
}
private String getLang(BinaryMapDataObject o) {
return o.getNameByType(langType);
}
private String getMetric(BinaryMapDataObject o) {
return o.getNameByType(metricType);
}
private String getLeftHandDriving(BinaryMapDataObject o) {
return o.getNameByType(leftHandDrivingType);
}
private String getRoadSigns(BinaryMapDataObject o) {
return o.getNameByType(roadSignsType);
}
public String getDownloadName(BinaryMapDataObject o) {
if(downloadNameType == null) {
return null;
@ -367,6 +408,24 @@ public class OsmandRegions {
fullNamesToLocaleNames.put(fullName, locName);
fullNamesNoParentToLocaleNames.put(fullName, locName);
}
String lang = getLang(object);
if(!Algorithms.isEmpty(lang)){
fullNamesToLangs.put(fullName, lang);
}
String metric = getMetric(object);
if(!Algorithms.isEmpty(metric)){
fullNamesToMetrics.put(fullName, metric);
}
String leftHandDriving = getLeftHandDriving(object);
if(!Algorithms.isEmpty(leftHandDriving)){
fullNamesToLeftHandDrivings.put(fullName, leftHandDriving);
}
String roadSigns = getRoadSigns(object);
if(!Algorithms.isEmpty(roadSigns)){
fullNamesToRoadSigns.put(fullName, roadSigns);
}
MapIndex mi = object.getMapIndex();
TIntObjectIterator<String> it = object.getObjectNames().iterator();
StringBuilder ind = new StringBuilder();
@ -517,7 +576,12 @@ public class OsmandRegions {
nameLocaleType = object.getMapIndex().getRule("name:" + locale, null);
parentFullName = object.getMapIndex().getRule("region_parent_name", null);
fullNameType = object.getMapIndex().getRule("region_full_name", null);
langType = object.getMapIndex().getRule("lang", null);
metricType = object.getMapIndex().getRule("metric", null);
leftHandDrivingType = object.getMapIndex().getRule("left_hand_driving", null);
roadSignsType = object.getMapIndex().getRule("road_signs", null);
if (downloadNameType == null || nameType == null) {
throw new IllegalStateException();
}

View file

@ -68,10 +68,10 @@
android:id="@+id/button_replace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/color_transparent"
android:textColor="@color/color_dialog_buttons"
android:background="?android:selectableItemBackground"
android:textColor="?attr/contextMenuButtonColor"
android:text="@string/update_existing"
android:visibility="gone"/>
android:visibility="visible"/>
</LinearLayout>

View file

@ -42,6 +42,7 @@
<attr name="new_app_theme" format="reference"/>
<attr name="divider_color" format="reference" />
<attr name="contextMenuButtonColor" format="reference" />
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -113,6 +113,8 @@
<item name="toolbar_theme">@style/OsmandLightTheme.Toolbar</item>
<item name="new_app_theme">@style/OsmandLightTheme.NewAppTheme</item>
<item name="android:textColorSecondary">@color/icon_color</item>
<item name="contextMenuButtonColor">@color/map_widget_blue</item>
</style>
<style name="OsmandLightTheme.DarkActionbar">
@ -192,6 +194,8 @@
<item name="toolbar_theme">@style/OsmandDarkTheme</item>
<item name="new_app_theme">@style/OsmandDarkTheme</item>
<item name="android:textColorSecondary">@color/dash_search_icon_dark</item>
<item name="contextMenuButtonColor">@color/osmand_orange</item>
</style>

View file

@ -39,7 +39,21 @@ public class WorldRegion {
private List<WorldRegion> subregions;
private List<WorldRegion> flattenedSubregions;
public String getLang(OsmandRegions osmandRegions) {
return osmandRegions.getLang(regionId);
}
public String getMetric(OsmandRegions osmandRegions) {
return osmandRegions.getMetric(regionId);
}
public String getLeftHandDriving(OsmandRegions osmandRegions) {
return osmandRegions.getLeftHandDriving(regionId);
}
public String getRoadSigns(OsmandRegions osmandRegions) {
return osmandRegions.getRoadSigns(regionId);
}
public String getRegionId() {
return regionId;
@ -96,8 +110,8 @@ public class WorldRegion {
private WorldRegion init(String regionId, OsmandRegions osmandRegions, String name) {
this.regionId = regionId;
String downloadName = osmandRegions.getDownloadName(regionId);
this.searchText = osmandRegions.getDownloadNameIndexLowercase(downloadName);
if (downloadName != null) {
this.searchText = osmandRegions.getDownloadNameIndexLowercase(downloadName);
downloadsId = downloadName.toLowerCase();
} else {
downloadsId = regionId.toLowerCase();