Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-candidate' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Yanez Barreto committed Feb 8, 2017
2 parents 62d8db3 + c359c48 commit e11ecb7
Show file tree
Hide file tree
Showing 114 changed files with 1,312 additions and 535 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@ android:
- platform-tools #latest
- build-tools-25.0.0
- android-25
- extra-android-support
- extra-android-m2repository
- extra-google-google_play_services
- extra-google-m2repository
- addon-google_apis-google-25


before_install:
- echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null

licenses:
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

script:
- ./gradlew check jacocoTestReport
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 0.6.5

- Test improvements for Robolectric, styles are now supported
- First attempt at styling (for tests, not final version).
- Paddings are standardized now.
- Close button added.
- Sync to remote controller implemented. Still not fully ready or supported. Documentation incoming.



# 0.6.0

## Breaking changes
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Remixer](https://cdn.rawgit.com/material-foundation/material-remixer/master/docs/assets/lockup_remixer_icon_horizontal_dark_small.svg)

[![Build Status](https://travis-ci.org/material-foundation/material-remixer-android.svg?branch=develop)](https://travis-ci.org/material-foundation/material-remixer-android) [![codecov](https://codecov.io/gh/material-foundation/material-remixer-android/branch/develop/graph/badge.svg)](https://codecov.io/gh/material-foundation/material-remixer-android)
[![TravisCI Build Status](https://travis-ci.org/material-foundation/material-remixer-android.svg?branch=develop)](https://travis-ci.org/material-foundation/material-remixer-android) [![CircleCI Build Status](https://circleci.com/gh/material-foundation/material-remixer-android.svg?style=svg)](https://circleci.com/gh/material-foundation/material-remixer-android) [![codecov](https://codecov.io/gh/material-foundation/material-remixer-android/branch/develop/graph/badge.svg)](https://codecov.io/gh/material-foundation/material-remixer-android)

Remixer helps teams use and refine design specs by providing an abstraction for these values that is accessible and configurable from both inside and outside the app itself.

Expand Down Expand Up @@ -33,7 +33,7 @@ The project is defined as a gradle project with submodules.

__Disclaimer:__ Remixer still hasn't reached a stage that we consider is stable enough to commit to the current status of the API, it will be evolving quickly and we may commit breaking changes every once in a while. _That said_, we would love to have you try it out and tell us what you think is missing and what you'd like us to focus on.

You can read our [javadoc for the current release (0.6.0)](https://jitpack.io/com/github/material-foundation/material-remixer-android/remixer/0.6.0/javadoc/index.html) and the [javadoc for HEAD](https://jitpack.io/com/github/material-foundation/material-remixer-android/remixer/develop-SNAPSHOT/javadoc/index.html) generated by jitpack.
You can read our [javadoc for the current release (0.6.5)](https://jitpack.io/com/github/material-foundation/material-remixer-android/remixer/0.6.5/javadoc/index.html) and the [javadoc for HEAD](https://jitpack.io/com/github/material-foundation/material-remixer-android/remixer/develop-SNAPSHOT/javadoc/index.html) generated by jitpack.

### Set up dependencies

Expand Down Expand Up @@ -61,7 +61,7 @@ And in your modules, apply the `android-apt` plugin and add the remixer dependen
apply plugin: 'android-apt'
dependencies {
compile 'com.github.material-foundation.material-remixer-android:remixer:0.6.0'
compile 'com.github.material-foundation.material-remixer-android:remixer:0.6.5'
}
```

Expand Down Expand Up @@ -130,7 +130,7 @@ They support the following properties:

- `key` the key for this variable, you can use it to share the same value across activities, if not set it assumes the method name.
- `title` the displayable name of the variable, if not set assumes `key`
- `defaultValue` the initial value, if not set assumes 0 or `minValue` if 0 is out of range.
- `initialValue` the initial value, if not set assumes 0 or `minValue` if 0 is out of range.
- `minValue` the minimum value, if not set assumes 0
- `maxValue` the maximum value, if not set assumes 100
- `increment` the increment between two steps of the range, 1 by default.
Expand All @@ -139,7 +139,7 @@ They support the following properties:
A Range variable that goes from 15 to 70 and starts at 20 by default:
```java
@RangeVariableMethod(
minValue = 15, maxValue = 70, defaultValue = 20)
minValue = 15, maxValue = 70, initialValue = 20)
public void setFontSize(Integer fontSize) {
}
```
Expand All @@ -151,12 +151,12 @@ They support the following properties:

- `key` the key for this variable, you can use it to share the same value across activities, if not set it assumes the method name.
- `title` the displayable name of the variable, if not set assumes `key`
- `defaultValue` the initial value, if not set assumes `false`
- `initialValue` the initial value, if not set assumes `false`
- `layoutId` a layoutId to display this, must implement RemixerWidget. It assumes a sensible default if unset.

A Boolean variable that has true as a default value:
A Boolean variable that has true as its initial value:
```java
@BooleanVariableMethod(defaultValue = true, key = "someRemixerKey")
@BooleanVariableMethod(initialValue = true, key = "someRemixerKey")
public void setUseNewDialog(Boolean useNewDialog) {
}
```
Expand All @@ -168,15 +168,15 @@ They support the following properties:

- `key` the key for this variable, you can use it to share the same value across activities, if not set it assumes the method name.
- `title` the displayable name of the variable, if not set assumes `key`
- `defaultValue` the initial value, if not set assumes the first in the `possibleValues` list
- `possibleValues` the list of possible values.
- `initialValue` the initial value, if not set assumes the first in the `limitedToValues` list
- `limitedToValues` the list of values this variable is limited to take.
- `layoutId` a layoutId to display this, must implement RemixerWidget. It assumes a sensible default if unset.

A String List variable that sets fonts from a list and defaults to the first in the list:
```java
@StringListVariableMethod(
title = "Title font",
possibleValues = {"Roboto", "Roboto Mono", "Comic Sans MS"})
limitedToValues = {"Roboto", "Roboto Mono", "Comic Sans MS"})
public void setTitleFont(String fontName) {
}
```
Expand All @@ -185,7 +185,7 @@ public void setTitleFont(String fontName) {

- `key` the key for this variable, you can use it to share the same value across activities, if not set it assumes the method name.
- `title` the displayable name of the variable, if not set assumes `key`
- `defaultValue` the initial value, if not set assumes the empty string.
- `initialValue` the initial value, if not set assumes the empty string.
- `layoutId` a layoutId to display this, must implement RemixerWidget. It assumes a sensible default if unset.

A String variable that sets freeform example text:
Expand All @@ -195,19 +195,19 @@ public void setExampleText(String exampleText) {
}
```

##### Integer List Variable
##### Number List Variable

- `key` the key for this variable, you can use it to share the same value across activities, if not set it assumes the method name.
- `title` the displayable name of the variable, if not set assumes `key`
- `defaultValue` the initial value, if not set assumes the first in the `possibleValues` list
- `possibleValues` the list of possible values.
- `initialValue` the initial value, if not set assumes the first in the `limitedToValues` list
- `limitedToValues` the list of values this variable is limited to take.
- `layoutId` a layoutId to display this, must implement RemixerWidget. It assumes a sensible default if unset.

A variable that lets you pick colors from a list, this example uses a custom layout id to guarantee that it's treated as a Color:
```java
@IntegerListVariableMethod(
@NumberListVariableMethod(
title = "Title Color",
possibleValues = {Color.parseColor("#000000"), Color.parseColor("#DCDCDC")},
limitedToValues = {Color.parseColor("#000000"), Color.parseColor("#DCDCDC")},
layoutId = R.layout.color_list_variable_widget)
public void setTitleColor(Integer color) {
}
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.5.0'
}
Expand Down
14 changes: 14 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

test:
pre:
- echo y | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support
- echo y | android update sdk --no-ui --all --filter build-tools-25.0.0

override:
- ./gradlew lint build test check jacocoTestReport -PdisablePreDex;

post:
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- find . -type f -regex ".*/build/outputs/androidTest-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- bash <(curl -s https://codecov.io/bash)
8 changes: 4 additions & 4 deletions remixer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.remixer">

<application android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>
<application
android:label="@string/app_name"
android:supportsRtl="true"
>

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
class ItemListVariableMethodAnnotation<T> extends MethodAnnotation {

/**
* Suffix to add to the name of a list holding the possible values for this variable.
* Suffix to add to the name of a list holding the set of values this variable can take.
*/
private static final String LIST_SUFFIX = "_variable_list";

/**
* Statement format for String.format to add a value to the list of possible values.
* Statement format for String.format to add a value to the list of limited to values.
*/
private static final String ADD_ITEM_FORMAT = "$L.add(%s)";
/**
* Statement format for String.format to set the default value.
* Statement format for String.format to set the initial value.
*/
private static final String SET_DEFAULT_FORMAT = "$L.setDefaultValue(%s)";
private static final String SET_INITIAL_VALUE_FORMAT = "$L.setInitialValue(%s)";
/**
* Javapoet format escaping for float values
*/
Expand All @@ -64,13 +64,13 @@ class ItemListVariableMethodAnnotation<T> extends MethodAnnotation {
/**
* Statement to create an object through a no-parameter constructor.
*
* <p>This is used to create the list of possible values ({@code ArrayList&lt;T&gt; list =
* <p>This is used to create the list of limited to values ({@code ArrayList&lt;T&gt; list =
* new ArrayList&lt;T&gt;()}.
*/
private static final String CREATE_NEW_OBJECT = "$T $L = new $T()";

private final T defaultValue;
private T[] possibleValues;
private final T initialValue;
private T[] limitedToValues;

static ItemListVariableMethodAnnotation<String> forStringListVariableMethod(
TypeElement sourceClass,
Expand All @@ -86,8 +86,8 @@ static ItemListVariableMethodAnnotation<String> forStringListVariableMethod(
annotation.key(),
annotation.title(),
annotation.layoutId(),
annotation.possibleValues(),
annotation.defaultValue(),
annotation.limitedToValues(),
annotation.initialValue(),
"");
}

Expand All @@ -96,9 +96,9 @@ static ItemListVariableMethodAnnotation<Integer> forColorListVariableMethod(
ExecutableElement sourceMethod,
ColorListVariableMethod annotation)
throws RemixerAnnotationException {
Integer[] possibleValues = new Integer[annotation.possibleValues().length];
for (int i = 0; i < annotation.possibleValues().length; i++) {
possibleValues[i] = annotation.possibleValues()[i];
Integer[] limitedToValues = new Integer[annotation.limitedToValues().length];
for (int i = 0; i < annotation.limitedToValues().length; i++) {
limitedToValues[i] = annotation.limitedToValues()[i];
}
return new ItemListVariableMethodAnnotation<>(
sourceClass,
Expand All @@ -109,8 +109,8 @@ static ItemListVariableMethodAnnotation<Integer> forColorListVariableMethod(
annotation.key(),
annotation.title(),
annotation.layoutId(),
possibleValues,
annotation.defaultValue(),
limitedToValues,
annotation.initialValue(),
0);
}

Expand All @@ -119,9 +119,9 @@ static ItemListVariableMethodAnnotation<Float> forNumberListVariableMethod(
ExecutableElement sourceMethod,
NumberListVariableMethod annotation)
throws RemixerAnnotationException {
Float[] possibleValues = new Float[annotation.possibleValues().length];
for (int i = 0; i < annotation.possibleValues().length; i++) {
possibleValues[i] = annotation.possibleValues()[i];
Float[] limitedToValues = new Float[annotation.limitedToValues().length];
for (int i = 0; i < annotation.limitedToValues().length; i++) {
limitedToValues[i] = annotation.limitedToValues()[i];
}
return new ItemListVariableMethodAnnotation<>(
sourceClass,
Expand All @@ -132,8 +132,8 @@ static ItemListVariableMethodAnnotation<Float> forNumberListVariableMethod(
annotation.key(),
annotation.title(),
annotation.layoutId(),
possibleValues,
annotation.defaultValue(),
limitedToValues,
annotation.initialValue(),
0f);
}

Expand All @@ -142,10 +142,11 @@ static ItemListVariableMethodAnnotation<Float> forNumberListVariableMethod(
* annotations are met.
*
* <p>If the default is unset and the zero value (0 for numbers, empty string for Strings) is not
* amongst the possible values then it falls back to the first value in the list.
* amongst the values this variable is limited to then it falls back to the first value in the
* list.
*
* @throws RemixerAnnotationException if the constraints are not met:
* - The list of possible values is empty.
* - The list of limited to values is empty.
* - The default is explicitly set to an unknown value.
*/
private ItemListVariableMethodAnnotation(
Expand All @@ -156,34 +157,35 @@ private ItemListVariableMethodAnnotation(
String key,
String title,
int layoutId,
T[] possibleValues,
T defaultValue,
T[] limitedToValues,
T initialValue,
T zeroValue)
throws RemixerAnnotationException {
super(sourceClass, sourceMethod, dataType, builderTypeName, key, title, layoutId);
this.possibleValues = possibleValues;
if (possibleValues.length == 0) {
throw new RemixerAnnotationException(sourceMethod, "List of possible values cannot be empty");
this.limitedToValues = limitedToValues;
if (limitedToValues.length == 0) {
throw new RemixerAnnotationException(
sourceMethod, "List of limited to values cannot be empty");
}
boolean containsDefault = false;
for (T s : possibleValues) {
if (s.equals(defaultValue)) {
for (T s : limitedToValues) {
if (s.equals(initialValue)) {
containsDefault = true;
break;
}
}
if (!containsDefault) {
if (defaultValue.equals(zeroValue)) {
// If no default value was set (empty) and the list of possible values doesn't contain the
if (initialValue.equals(zeroValue)) {
// If no initial value was set (empty) and the list of limited to values doesn't contain the
// zero-value (empty string in case of string, 0 in case of numbers) then assume the first
// value in the list to be the default value.
this.defaultValue = possibleValues[0];
// value in the list to be the initial value.
this.initialValue = limitedToValues[0];
} else {
throw new RemixerAnnotationException(sourceMethod,
"Default value explicitly set to unknown value");
"Initial value explicitly set to unknown value");
}
} else {
this.defaultValue = defaultValue;
this.initialValue = initialValue;
}
}

Expand All @@ -192,18 +194,18 @@ public void addSpecificSetupStatements(MethodSpec.Builder methodBuilder) {
String listName = key + LIST_SUFFIX;
TypeName listType =
ParameterizedTypeName.get(ClassName.get(ArrayList.class),
ClassName.get(dataType.getValueClass()));
ClassName.get(dataType.getRuntimeType()));
methodBuilder.addStatement(CREATE_NEW_OBJECT, listType, listName, listType);
String addValueStatement =
String.format(Locale.getDefault(), ADD_ITEM_FORMAT, getJavaPoetEscaping());
for (T value : possibleValues) {
for (T value : limitedToValues) {
methodBuilder.addStatement(addValueStatement, listName, value);
}
methodBuilder.addStatement("$L.setPossibleValues($L)", remixerItemName, listName);
methodBuilder.addStatement("$L.setLimitedToValues($L)", remixerItemName, listName);

String setDefaultValueStatement =
String.format(Locale.getDefault(), SET_DEFAULT_FORMAT, getJavaPoetEscaping());
methodBuilder.addStatement(setDefaultValueStatement, remixerItemName, defaultValue);
String setInitialValueStatement =
String.format(Locale.getDefault(), SET_INITIAL_VALUE_FORMAT, getJavaPoetEscaping());
methodBuilder.addStatement(setInitialValueStatement, remixerItemName, initialValue);
}

private String getJavaPoetEscaping() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,6 @@ protected MethodSpec getCallbackMethodSpec() {
* Returns the type to use to parametrize the Variable objects when generating code.
*/
private final TypeName getVariableType() {
return ClassName.get(dataType.getValueClass());
return ClassName.get(dataType.getRuntimeType());
}
}
Loading

0 comments on commit e11ecb7

Please sign in to comment.