Skip to content

Commit aeddc24

Browse files
authored
Update Stylesheets (#465)
* migrate all styles to use themed repos * fix tests and temporarily comment out two * tmp deploy sdk for this branch * update style switcher example * deploy samples temporarily * disable location in sample on destroy * tangram 0.8.1 * refill default lod 10 * autoselect theme defaults when style switched * yaml generator cleanup * update zinc lod default * update test * https for submodules * fix MapInitializerTests * add test coverage for themes * rm tmp circle branch deployment * deprecate zinc style * rm log
1 parent 5a841de commit aeddc24

37 files changed

+844
-106
lines changed

.gitmodules

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
[submodule "core/src/main/assets/styles/bubble-wrap"]
22
path = core/src/main/assets/styles/bubble-wrap
33
url = https://github.com/tangrams/bubble-wrap.git
4-
[submodule "core/src/main/assets/styles/cinnabar-more-labels"]
5-
path = core/src/main/assets/styles/cinnabar-more-labels
6-
url = https://github.com/tangrams/cinnabar-style-more-labels.git
7-
[submodule "core/src/main/assets/styles/walkabout-style-more-labels"]
8-
path = core/src/main/assets/styles/walkabout-style-more-labels
9-
url = https://github.com/tangrams/walkabout-style-more-labels.git
10-
[submodule "core/src/main/assets/styles/zinc-style-more-labels"]
11-
path = core/src/main/assets/styles/zinc-style-more-labels
12-
url = https://github.com/tangrams/zinc-style-more-labels.git
134
[submodule "samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style"]
145
path = samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style
156
url = https://github.com/tangrams/tron-style.git
167
[submodule "core/src/main/assets/styles/refill-style"]
178
path = core/src/main/assets/styles/refill-style
189
url = https://github.com/tangrams/refill-style
10+
[submodule "core/src/main/assets/styles/cinnabar-style"]
11+
path = core/src/main/assets/styles/cinnabar-style
12+
url = https://github.com/tangrams/cinnabar-style.git
13+
[submodule "core/src/main/assets/styles/walkabout-style"]
14+
path = core/src/main/assets/styles/walkabout-style
15+
url = https://github.com/tangrams/walkabout-style.git

core/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ group = GROUP
1919
version = VERSION_NAME
2020
project.archivesBaseName = POM_ARTIFACT_ID
2121

22-
ext.tangram_version = "0.8.0"
22+
ext.tangram_version = "0.8.1"
2323

2424
def SDK_VERSION = hasProperty('version') ? '"' + version + '"' : "null";
2525

@@ -64,7 +64,7 @@ task checkstyle(type: Checkstyle) {
6464
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
6565

6666
task submodules {
67-
def folder = new File( 'core/src/main/assets/styles/walkabout-style-more-labels/walkabout-style-more-labels.yaml' )
67+
def folder = new File( 'core/src/main/assets/styles/walkabout-style/walkabout-style.yaml' )
6868
if(!folder.exists()) {
6969
throw new GradleException("Submodules aren't present, please run:\n`git submodule init`, " +
7070
"\n`git submodule update`\nfrom your root directory")
This file was deleted.
Submodule cinnabar-style added at 079418b
Submodule walkabout-style added at 291d90a
This file was deleted.
This file was deleted.

core/src/main/java/com/mapzen/android/graphics/ImportYamlGenerator.java

+42-21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.mapzen.android.graphics.model.ThemeColor;
44
import com.mapzen.android.graphics.model.ThemedMapStyle;
55

6+
import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;
7+
68
/**
79
* Handles creating fully qualified import yaml for a given {@link ThemedMapStyle} so that
810
* it can be applied by {@link MapzenMap}.
@@ -17,26 +19,45 @@ class ImportYamlGenerator {
1719
*/
1820
String getImportYaml(ThemedMapStyle themedMapStyle, int labelLevel, int detailLevel,
1921
ThemeColor color) {
20-
String labelFileName = new StringBuilder()
21-
.append("label-")
22-
.append(labelLevel)
23-
.append(".yaml")
24-
.toString();
25-
String detailFileName = new StringBuilder()
26-
.append("detail-")
27-
.append(detailLevel)
28-
.append(".yaml")
29-
.toString();
30-
String colorFileName = new StringBuilder()
31-
.append("color-")
32-
.append(color.toString())
33-
.append(".yaml")
34-
.toString();
35-
return "{ import: [ "
36-
+ themedMapStyle.getBaseStyleFilename() + ", "
37-
+ themedMapStyle.getThemesPath() + labelFileName + ", "
38-
+ themedMapStyle.getThemesPath() + detailFileName + ", "
39-
+ themedMapStyle.getThemesPath() + colorFileName
40-
+ " ] }";
22+
StringBuilder importBuilder = new StringBuilder()
23+
.append("{ import: [ ")
24+
.append(themedMapStyle.getBaseStyleFilename())
25+
.append(", ");
26+
27+
if (labelLevel != NONE) {
28+
importBuilder.append(themedMapStyle.getThemesPath());
29+
importBuilder.append("label-");
30+
importBuilder.append(labelLevel);
31+
importBuilder.append(".yaml");
32+
}
33+
34+
if (labelLevel != NONE && (detailLevel != NONE || colorExists(color))) {
35+
importBuilder.append(", ");
36+
}
37+
38+
if (detailLevel != NONE) {
39+
importBuilder.append(themedMapStyle.getThemesPath());
40+
importBuilder.append("detail-");
41+
importBuilder.append(detailLevel);
42+
importBuilder.append(".yaml");
43+
}
44+
45+
if (detailLevel != NONE && colorExists(color)) {
46+
importBuilder.append(", ");
47+
}
48+
49+
if (colorExists(color)) {
50+
importBuilder.append(themedMapStyle.getThemesPath());
51+
importBuilder.append("color-");
52+
importBuilder.append(color.toString());
53+
importBuilder.append(".yaml");
54+
}
55+
56+
importBuilder.append(" ] }");
57+
return importBuilder.toString();
58+
}
59+
60+
private boolean colorExists(ThemeColor color) {
61+
return color != null && color != ThemeColor.NONE;
4162
}
4263
}

core/src/main/java/com/mapzen/android/graphics/MapInitializer.java

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ private void loadMap(final MapView mapView, MapStyle mapStyle, boolean styleExpl
9090
mapStyle = restoredMapStyle;
9191
}
9292
mapStateManager.setMapStyle(mapStyle);
93+
if (mapStyle instanceof ThemedMapStyle) {
94+
ThemedMapStyle themedStyle = (ThemedMapStyle) mapStyle;
95+
mapStateManager.setLabelLevel(themedStyle.getDefaultLabelLevel());
96+
mapStateManager.setLod(themedStyle.getDefaultLod());
97+
mapStateManager.setThemeColor(themedStyle.getDefaultColor());
98+
}
9399
loadMap(mapView, mapStyle, callback);
94100
}
95101

core/src/main/java/com/mapzen/android/graphics/MapStateManager.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.mapzen.android.graphics.model.ThemeColor;
77
import com.mapzen.tangram.LngLat;
88

9+
import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;
10+
911
/**
1012
* Manages parameters around {@link MapzenMap}'s state so that it can be restore upon orientation
1113
* change.
@@ -15,8 +17,8 @@ class MapStateManager {
1517
private boolean persistMapState = true;
1618
private LngLat position = new LngLat(0, 0);
1719
private MapStyle mapStyle = new BubbleWrapStyle();
18-
private int labelLevel = 0;
19-
private int lod = 0;
20+
private int labelLevel = NONE;
21+
private int lod = NONE;
2022
private ThemeColor themeColor = null;
2123
private float zoom = 0;
2224
private float rotation = 0;

core/src/main/java/com/mapzen/android/graphics/MapzenMap.java

+10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import static
4242
com.mapzen.android.graphics.internal.EaseTypeConverter.EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE;
43+
import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;
4344

4445
/**
4546
* This is the main class of the Mapzen Android API and is the entry point for all methods related
@@ -1203,6 +1204,9 @@ private ThemedMapStyle getThemedMapStyle() {
12031204
* @return
12041205
*/
12051206
private boolean isValidLabelLevel(int labelLevel) {
1207+
if (labelLevel == NONE) {
1208+
return true;
1209+
}
12061210
return labelLevel >= 0 && labelLevel < getThemedMapStyle().getLabelCount();
12071211
}
12081212

@@ -1214,6 +1218,9 @@ private boolean isValidLabelLevel(int labelLevel) {
12141218
* @return
12151219
*/
12161220
private boolean isValidLod(int lod) {
1221+
if (lod == NONE) {
1222+
return true;
1223+
}
12171224
return lod >= 0 && lod < getThemedMapStyle().getLodCount();
12181225
}
12191226

@@ -1225,6 +1232,9 @@ private boolean isValidLod(int lod) {
12251232
* @return
12261233
*/
12271234
private boolean isValidColor(ThemeColor color) {
1235+
if (color == ThemeColor.NONE) {
1236+
return true;
1237+
}
12281238
return getThemedMapStyle().getColors().contains(color);
12291239
}
12301240

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
11
package com.mapzen.android.graphics.model;
22

3+
import java.util.Set;
4+
35
/**
46
* BubbleWrap default map style.
57
*/
6-
public class BubbleWrapStyle extends MapStyle {
8+
public class BubbleWrapStyle extends ThemedMapStyle {
79

810
/**
911
* Creates a new instance.
1012
*/
1113
public BubbleWrapStyle() {
12-
super("styles/bubble-wrap/bubble-wrap-style-more-labels.yaml");
14+
super("styles/bubble-wrap/bubble-wrap-style.yaml");
15+
}
16+
17+
@Override public String getBaseStyleFilename() {
18+
return "bubble-wrap-style.yaml";
19+
}
20+
21+
@Override public String getStyleRootPath() {
22+
return "styles/bubble-wrap/";
23+
}
24+
25+
@Override public String getThemesPath() {
26+
return "themes/";
27+
}
28+
29+
@Override public int getDefaultLod() {
30+
return NONE;
31+
}
32+
33+
@Override public int getLodCount() {
34+
return NONE;
35+
}
36+
37+
@Override public int getDefaultLabelLevel() {
38+
return 5;
39+
}
40+
41+
@Override public int getLabelCount() {
42+
return 12;
43+
}
44+
45+
@Override public ThemeColor getDefaultColor() {
46+
return ThemeColor.NONE;
47+
}
48+
49+
@Override public Set<ThemeColor> getColors() {
50+
return null;
1351
}
1452
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
package com.mapzen.android.graphics.model;
22

3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
import static com.mapzen.android.graphics.model.ThemeColor.CINNABAR;
7+
38
/**
49
* Cinnabar default map style.
510
*/
6-
public class CinnabarStyle extends MapStyle {
11+
public class CinnabarStyle extends ThemedMapStyle {
12+
13+
private final Set<ThemeColor> supportedColors = new HashSet<ThemeColor>() { {
14+
add(CINNABAR);
15+
} };
716

817
/**
918
* Creates a new instance.
1019
*/
1120
public CinnabarStyle() {
12-
super("styles/cinnabar-more-labels/cinnabar-style-more-labels.yaml");
21+
super("styles/cinnabar-style/cinnabar-style.yaml");
22+
}
23+
24+
@Override public String getBaseStyleFilename() {
25+
return "cinnabar-style.yaml";
26+
}
27+
28+
@Override public String getStyleRootPath() {
29+
return "styles/cinnabar-style/";
30+
}
31+
32+
@Override public String getThemesPath() {
33+
return "themes/";
34+
}
35+
36+
@Override public int getDefaultLod() {
37+
return NONE;
38+
}
39+
40+
@Override public int getLodCount() {
41+
return NONE;
42+
}
43+
44+
@Override public int getDefaultLabelLevel() {
45+
return 5;
46+
}
47+
48+
@Override public int getLabelCount() {
49+
return 12;
50+
}
51+
52+
@Override public ThemeColor getDefaultColor() {
53+
return CINNABAR;
54+
}
55+
56+
@Override public Set<ThemeColor> getColors() {
57+
return supportedColors;
1358
}
1459
}

core/src/main/java/com/mapzen/android/graphics/model/RefillStyle.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import static com.mapzen.android.graphics.model.ThemeColor.PINKYELLOW;
1717
import static com.mapzen.android.graphics.model.ThemeColor.PURPLEGREEN;
1818
import static com.mapzen.android.graphics.model.ThemeColor.SEPIA;
19+
import static com.mapzen.android.graphics.model.ThemeColor.ZINC;
1920

2021
/**
2122
* Refill default map style.
@@ -36,6 +37,7 @@ public class RefillStyle extends ThemedMapStyle {
3637
add(PINKYELLOW);
3738
add(PURPLEGREEN);
3839
add(SEPIA);
40+
add(ZINC);
3941
} };
4042

4143
/**
@@ -58,7 +60,7 @@ public RefillStyle() {
5860
}
5961

6062
@Override public int getDefaultLod() {
61-
return 5;
63+
return 10;
6264
}
6365

6466
@Override public int getLodCount() {

core/src/main/java/com/mapzen/android/graphics/model/ThemeColor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Available color themes for {@link RefillStyle}.
55
*/
66
public enum ThemeColor {
7+
NONE(null),
78
BLACK("black"),
89
BLUE("blue"),
910
BLUEGRAY("blue-gray"),
@@ -16,7 +17,9 @@ public enum ThemeColor {
1617
PINK("pink"),
1718
PINKYELLOW("pink-yellow"),
1819
PURPLEGREEN("purple-green"),
19-
SEPIA("sepia");
20+
SEPIA("sepia"),
21+
CINNABAR("cinnabar"),
22+
ZINC("zinc");
2023

2124
private final String color;
2225

core/src/main/java/com/mapzen/android/graphics/model/ThemedMapStyle.java

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
public abstract class ThemedMapStyle extends MapStyle {
99

10+
public static final int NONE = -1;
11+
1012
/**
1113
* Constructor.
1214
* @param baseSceneFile

0 commit comments

Comments
 (0)