Skip to content

Commit

Permalink
Update Stylesheets (#465)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sarahsnow1 authored Oct 3, 2017
1 parent 5a841de commit aeddc24
Show file tree
Hide file tree
Showing 37 changed files with 844 additions and 106 deletions.
15 changes: 6 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[submodule "core/src/main/assets/styles/bubble-wrap"]
path = core/src/main/assets/styles/bubble-wrap
url = https://github.com/tangrams/bubble-wrap.git
[submodule "core/src/main/assets/styles/cinnabar-more-labels"]
path = core/src/main/assets/styles/cinnabar-more-labels
url = https://github.com/tangrams/cinnabar-style-more-labels.git
[submodule "core/src/main/assets/styles/walkabout-style-more-labels"]
path = core/src/main/assets/styles/walkabout-style-more-labels
url = https://github.com/tangrams/walkabout-style-more-labels.git
[submodule "core/src/main/assets/styles/zinc-style-more-labels"]
path = core/src/main/assets/styles/zinc-style-more-labels
url = https://github.com/tangrams/zinc-style-more-labels.git
[submodule "samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style"]
path = samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style
url = https://github.com/tangrams/tron-style.git
[submodule "core/src/main/assets/styles/refill-style"]
path = core/src/main/assets/styles/refill-style
url = https://github.com/tangrams/refill-style
[submodule "core/src/main/assets/styles/cinnabar-style"]
path = core/src/main/assets/styles/cinnabar-style
url = https://github.com/tangrams/cinnabar-style.git
[submodule "core/src/main/assets/styles/walkabout-style"]
path = core/src/main/assets/styles/walkabout-style
url = https://github.com/tangrams/walkabout-style.git
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ group = GROUP
version = VERSION_NAME
project.archivesBaseName = POM_ARTIFACT_ID

ext.tangram_version = "0.8.0"
ext.tangram_version = "0.8.1"

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

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

task submodules {
def folder = new File( 'core/src/main/assets/styles/walkabout-style-more-labels/walkabout-style-more-labels.yaml' )
def folder = new File( 'core/src/main/assets/styles/walkabout-style/walkabout-style.yaml' )
if(!folder.exists()) {
throw new GradleException("Submodules aren't present, please run:\n`git submodule init`, " +
"\n`git submodule update`\nfrom your root directory")
Expand Down
1 change: 0 additions & 1 deletion core/src/main/assets/styles/cinnabar-more-labels
Submodule cinnabar-more-labels deleted from 4b1ba0
1 change: 1 addition & 0 deletions core/src/main/assets/styles/cinnabar-style
Submodule cinnabar-style added at 079418
1 change: 1 addition & 0 deletions core/src/main/assets/styles/walkabout-style
Submodule walkabout-style added at 291d90
1 change: 0 additions & 1 deletion core/src/main/assets/styles/walkabout-style-more-labels
Submodule walkabout-style-more-labels deleted from 66bbe1
1 change: 0 additions & 1 deletion core/src/main/assets/styles/zinc-style-more-labels
Submodule zinc-style-more-labels deleted from ab5203
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mapzen.android.graphics.model.ThemeColor;
import com.mapzen.android.graphics.model.ThemedMapStyle;

import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;

/**
* Handles creating fully qualified import yaml for a given {@link ThemedMapStyle} so that
* it can be applied by {@link MapzenMap}.
Expand All @@ -17,26 +19,45 @@ class ImportYamlGenerator {
*/
String getImportYaml(ThemedMapStyle themedMapStyle, int labelLevel, int detailLevel,
ThemeColor color) {
String labelFileName = new StringBuilder()
.append("label-")
.append(labelLevel)
.append(".yaml")
.toString();
String detailFileName = new StringBuilder()
.append("detail-")
.append(detailLevel)
.append(".yaml")
.toString();
String colorFileName = new StringBuilder()
.append("color-")
.append(color.toString())
.append(".yaml")
.toString();
return "{ import: [ "
+ themedMapStyle.getBaseStyleFilename() + ", "
+ themedMapStyle.getThemesPath() + labelFileName + ", "
+ themedMapStyle.getThemesPath() + detailFileName + ", "
+ themedMapStyle.getThemesPath() + colorFileName
+ " ] }";
StringBuilder importBuilder = new StringBuilder()
.append("{ import: [ ")
.append(themedMapStyle.getBaseStyleFilename())
.append(", ");

if (labelLevel != NONE) {
importBuilder.append(themedMapStyle.getThemesPath());
importBuilder.append("label-");
importBuilder.append(labelLevel);
importBuilder.append(".yaml");
}

if (labelLevel != NONE && (detailLevel != NONE || colorExists(color))) {
importBuilder.append(", ");
}

if (detailLevel != NONE) {
importBuilder.append(themedMapStyle.getThemesPath());
importBuilder.append("detail-");
importBuilder.append(detailLevel);
importBuilder.append(".yaml");
}

if (detailLevel != NONE && colorExists(color)) {
importBuilder.append(", ");
}

if (colorExists(color)) {
importBuilder.append(themedMapStyle.getThemesPath());
importBuilder.append("color-");
importBuilder.append(color.toString());
importBuilder.append(".yaml");
}

importBuilder.append(" ] }");
return importBuilder.toString();
}

private boolean colorExists(ThemeColor color) {
return color != null && color != ThemeColor.NONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ private void loadMap(final MapView mapView, MapStyle mapStyle, boolean styleExpl
mapStyle = restoredMapStyle;
}
mapStateManager.setMapStyle(mapStyle);
if (mapStyle instanceof ThemedMapStyle) {
ThemedMapStyle themedStyle = (ThemedMapStyle) mapStyle;
mapStateManager.setLabelLevel(themedStyle.getDefaultLabelLevel());
mapStateManager.setLod(themedStyle.getDefaultLod());
mapStateManager.setThemeColor(themedStyle.getDefaultColor());
}
loadMap(mapView, mapStyle, callback);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.mapzen.android.graphics.model.ThemeColor;
import com.mapzen.tangram.LngLat;

import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;

/**
* Manages parameters around {@link MapzenMap}'s state so that it can be restore upon orientation
* change.
Expand All @@ -15,8 +17,8 @@ class MapStateManager {
private boolean persistMapState = true;
private LngLat position = new LngLat(0, 0);
private MapStyle mapStyle = new BubbleWrapStyle();
private int labelLevel = 0;
private int lod = 0;
private int labelLevel = NONE;
private int lod = NONE;
private ThemeColor themeColor = null;
private float zoom = 0;
private float rotation = 0;
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/com/mapzen/android/graphics/MapzenMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

import static
com.mapzen.android.graphics.internal.EaseTypeConverter.EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE;
import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;

/**
* This is the main class of the Mapzen Android API and is the entry point for all methods related
Expand Down Expand Up @@ -1203,6 +1204,9 @@ private ThemedMapStyle getThemedMapStyle() {
* @return
*/
private boolean isValidLabelLevel(int labelLevel) {
if (labelLevel == NONE) {
return true;
}
return labelLevel >= 0 && labelLevel < getThemedMapStyle().getLabelCount();
}

Expand All @@ -1214,6 +1218,9 @@ private boolean isValidLabelLevel(int labelLevel) {
* @return
*/
private boolean isValidLod(int lod) {
if (lod == NONE) {
return true;
}
return lod >= 0 && lod < getThemedMapStyle().getLodCount();
}

Expand All @@ -1225,6 +1232,9 @@ private boolean isValidLod(int lod) {
* @return
*/
private boolean isValidColor(ThemeColor color) {
if (color == ThemeColor.NONE) {
return true;
}
return getThemedMapStyle().getColors().contains(color);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
package com.mapzen.android.graphics.model;

import java.util.Set;

/**
* BubbleWrap default map style.
*/
public class BubbleWrapStyle extends MapStyle {
public class BubbleWrapStyle extends ThemedMapStyle {

/**
* Creates a new instance.
*/
public BubbleWrapStyle() {
super("styles/bubble-wrap/bubble-wrap-style-more-labels.yaml");
super("styles/bubble-wrap/bubble-wrap-style.yaml");
}

@Override public String getBaseStyleFilename() {
return "bubble-wrap-style.yaml";
}

@Override public String getStyleRootPath() {
return "styles/bubble-wrap/";
}

@Override public String getThemesPath() {
return "themes/";
}

@Override public int getDefaultLod() {
return NONE;
}

@Override public int getLodCount() {
return NONE;
}

@Override public int getDefaultLabelLevel() {
return 5;
}

@Override public int getLabelCount() {
return 12;
}

@Override public ThemeColor getDefaultColor() {
return ThemeColor.NONE;
}

@Override public Set<ThemeColor> getColors() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@
package com.mapzen.android.graphics.model;

import java.util.HashSet;
import java.util.Set;

import static com.mapzen.android.graphics.model.ThemeColor.CINNABAR;

/**
* Cinnabar default map style.
*/
public class CinnabarStyle extends MapStyle {
public class CinnabarStyle extends ThemedMapStyle {

private final Set<ThemeColor> supportedColors = new HashSet<ThemeColor>() { {
add(CINNABAR);
} };

/**
* Creates a new instance.
*/
public CinnabarStyle() {
super("styles/cinnabar-more-labels/cinnabar-style-more-labels.yaml");
super("styles/cinnabar-style/cinnabar-style.yaml");
}

@Override public String getBaseStyleFilename() {
return "cinnabar-style.yaml";
}

@Override public String getStyleRootPath() {
return "styles/cinnabar-style/";
}

@Override public String getThemesPath() {
return "themes/";
}

@Override public int getDefaultLod() {
return NONE;
}

@Override public int getLodCount() {
return NONE;
}

@Override public int getDefaultLabelLevel() {
return 5;
}

@Override public int getLabelCount() {
return 12;
}

@Override public ThemeColor getDefaultColor() {
return CINNABAR;
}

@Override public Set<ThemeColor> getColors() {
return supportedColors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.mapzen.android.graphics.model.ThemeColor.PINKYELLOW;
import static com.mapzen.android.graphics.model.ThemeColor.PURPLEGREEN;
import static com.mapzen.android.graphics.model.ThemeColor.SEPIA;
import static com.mapzen.android.graphics.model.ThemeColor.ZINC;

/**
* Refill default map style.
Expand All @@ -36,6 +37,7 @@ public class RefillStyle extends ThemedMapStyle {
add(PINKYELLOW);
add(PURPLEGREEN);
add(SEPIA);
add(ZINC);
} };

/**
Expand All @@ -58,7 +60,7 @@ public RefillStyle() {
}

@Override public int getDefaultLod() {
return 5;
return 10;
}

@Override public int getLodCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Available color themes for {@link RefillStyle}.
*/
public enum ThemeColor {
NONE(null),
BLACK("black"),
BLUE("blue"),
BLUEGRAY("blue-gray"),
Expand All @@ -16,7 +17,9 @@ public enum ThemeColor {
PINK("pink"),
PINKYELLOW("pink-yellow"),
PURPLEGREEN("purple-green"),
SEPIA("sepia");
SEPIA("sepia"),
CINNABAR("cinnabar"),
ZINC("zinc");

private final String color;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
public abstract class ThemedMapStyle extends MapStyle {

public static final int NONE = -1;

/**
* Constructor.
* @param baseSceneFile
Expand Down
Loading

0 comments on commit aeddc24

Please sign in to comment.