Skip to content

Commit

Permalink
Add map-related upgraders
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Jul 28, 2020
1 parent c4c4355 commit cf91272
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
Expand Up @@ -370,6 +370,8 @@ private static void upgradeComponentProperties(Map<String, JSONValue> componentP
srcCompVersion = upgradeRectangleProperties(componentProperties, srcCompVersion);
} else if (componentType.equals("FeatureCollection")) {
srcCompVersion = upgradeFeatureCollection(componentProperties, srcCompVersion);
} else if (componentType.equals("Navigation")) {
srcCompVersion = upgradeNavigationProperties(componentProperties, srcCompVersion);
} else if (componentType.equals("YandexTranslate")) {
srcCompVersion = upgradeYandexTranslateProperties(componentProperties, srcCompVersion);
}
Expand Down Expand Up @@ -1688,6 +1690,21 @@ private static int upgradeMapProperties(Map<String, JSONValue> componentProperti
// The ScaleUnits and ShowScale properties were added
srcCompVersion = 5;
}
if (srcCompVersion < 6) {
// Adds Units and MapType dropdowns.
srcCompVersion = 6;
}
return srcCompVersion;
}

private static int upgradeNavigationProperties(
Map<String, JSONValue> componentProperties,
int srcCompVersion
) {
if (srcCompVersion < 2) {
// - Adds TransportMethod dropdown.
srcCompVersion = 2;
}
return srcCompVersion;
}

Expand Down
19 changes: 18 additions & 1 deletion appinventor/blocklyeditor/src/versioning.js
Expand Up @@ -2046,7 +2046,14 @@ Blockly.Versioning.AllUpgradeMaps =

// AI2:
// - The ScaleUnits and ShowScale properties were added to Map
5: "noUpgrade"
5: "noUpgrade",

// AI2:
// - Adds Units and MapType dropdowns.
6: [Blockly.Versioning.makeSetterUseDropdown(
'Map', 'ScaleUnits', 'Units'),
Blockly.Versioning.makeSetterUseDropdown(
'Map', 'MapType', 'MapType')]

}, // End Map upgraders

Expand Down Expand Up @@ -2084,6 +2091,16 @@ Blockly.Versioning.AllUpgradeMaps =
2: "noUpgrade"
}, // End Rectangle upgraders

"Navigation": {
// This is an initial version. Placehoder for future upgrades.
1: "noUpgrade",

// Adds TransportMethod dropdown.
2: [Blockly.Versioning.makeSetterUseDropdown(
'Navigation', 'TransportationMethod', 'TransportMethod')]

}, // End Navigation upgraders.

"NearField": {

//This is initial version. Placeholder for future upgrades
Expand Down
Expand Up @@ -1015,7 +1015,9 @@ private YaVersion() {
// For MAP_COMPONENT_VERSION 5:
// - Added ShowScale property
// - Added ScaleUnits property
public static final int MAP_COMPONENT_VERSION = 5;
// For MAP_COMPONENT_VERSION 6:
// - Adds Units and MapType dropdowns.
public static final int MAP_COMPONENT_VERSION = 6;

// For MARKER_COMPONENT_VERSION 1:
// - Initial Marker implementation using OpenStreetMap
Expand All @@ -1027,7 +1029,9 @@ private YaVersion() {

// For NAVIGATION_COMPONENT_VERSION 1:
// - Initial Navigation implementation
public static final int NAVIGATION_COMPONENT_VERSION = 1;
// For NAVIGATION_COMPONENT_VERSION 2:
// - Adds TransportMethod dropdown.
public static final int NAVIGATION_COMPONENT_VERSION = 2;

// For NEARFIELD_COMPONENT_VERSION 1:
public static final int NEARFIELD_COMPONENT_VERSION = 1;
Expand Down

0 comments on commit cf91272

Please sign in to comment.