Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentuso committed Apr 25, 2017
2 parents adde5e9 + 8dc49b3 commit 3ee2d59
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
GROUP=com.stephentuso
VERSION_NAME=1.3.1
VERSION_CODE=23
VERSION_NAME=1.4.1
VERSION_CODE=24

LIBRARY_PACKAGING=aar
LIBRARY_NAME=welcome
Expand Down
41 changes: 40 additions & 1 deletion library/src/main/java/com/stephentuso/welcome/BasicPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class BasicPage extends WelcomePage<BasicPage> {
private String headerTypefacePath = null;
private String descriptionTypefacePath = null;
private int headerColor = WelcomeUtils.NO_COLOR_SET;
private int descriptionColor = WelcomeUtils.NO_COLOR_SET;

/**
* A page with a large image, header, and description
Expand Down Expand Up @@ -100,6 +101,32 @@ public BasicPage headerColorResource(Context context, @ColorRes int colorRes) {
return this;
}

/**
* Set the color of the header
*
* @param color Color int
*
* @return This BasicPage object to allow method calls to be chained
*/
public BasicPage descriptionColor(@ColorInt int color) {
this.descriptionColor = color;
return this;
}

/**
* Set the color of the description from a color resource id
*
* @param context Context used to resolve color
*
* @param colorRes Resource id of color to set
*
* @return This BasicPage object to allow method calls to be chained
*/
public BasicPage descriptionColorResource(Context context, @ColorRes int colorRes) {
this.descriptionColor = ContextCompat.getColor(context, colorRes);
return this;
}

/* Package local getters for testing */

/* package */ int getDrawableResId() {
Expand Down Expand Up @@ -130,6 +157,10 @@ public BasicPage headerColorResource(Context context, @ColorRes int colorRes) {
return headerColor;
}

/* package */ int getDescriptionColor() {
return descriptionColor;
}

@Override
public void setup(WelcomeConfiguration config) {
super.setup(config);
Expand All @@ -146,7 +177,15 @@ public void setup(WelcomeConfiguration config) {

@Override
public Fragment fragment() {
return WelcomeBasicFragment.newInstance(drawableResId, title, description, showParallax, headerTypefacePath, descriptionTypefacePath, headerColor);
// TODO: So many arguments...refactor?
return WelcomeBasicFragment.newInstance(drawableResId,
title,
description,
showParallax,
headerTypefacePath,
descriptionTypefacePath,
headerColor,
descriptionColor);
}

}
44 changes: 41 additions & 3 deletions library/src/main/java/com/stephentuso/welcome/ParallaxPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ParallaxPage extends WelcomePage<ParallaxPage> {
private String headerTypefacePath = null;
private String descriptionTyefacePath = null;
private int headerColor = WelcomeUtils.NO_COLOR_SET;
private int descriptionColor = WelcomeUtils.NO_COLOR_SET;

/**
* A page with a title and description that applies a parallax effect to the supplied layout.
Expand Down Expand Up @@ -158,6 +159,32 @@ public ParallaxPage headerColorResource(Context context, @ColorRes int colorRes)
return this;
}

/**
* Set the color of the header
*
* @param color Color int
*
* @return This ParallaxPage object to allow method calls to be chained
*/
public ParallaxPage descriptionColor(@ColorInt int color) {
this.descriptionColor = color;
return this;
}

/**
* Set the color of the description from a color resource id
*
* @param context Context used to resolve color
*
* @param colorRes Resource id of color to set
*
* @return This ParallaxPage object to allow method calls to be chained
*/
public ParallaxPage descriptionColorResource(Context context, @ColorRes int colorRes) {
this.descriptionColor = ContextCompat.getColor(context, colorRes);
return this;
}

/* Package local getters for testing */

/* package */ int getLayoutResId() {
Expand Down Expand Up @@ -196,6 +223,10 @@ public ParallaxPage headerColorResource(Context context, @ColorRes int colorRes)
return headerColor;
}

/* package */ int getDescriptionColor() {
return descriptionColor;
}

@Override
public void setup(WelcomeConfiguration config) {
super.setup(config);
Expand All @@ -211,8 +242,15 @@ public void setup(WelcomeConfiguration config) {

@Override
public Fragment fragment() {
return WelcomeParallaxFragment.newInstance(layoutResId, title, description,
firstParallaxFactor, lastParallaxFactor, parallaxRecursive,
headerTypefacePath, descriptionTyefacePath, headerColor);
return WelcomeParallaxFragment.newInstance(layoutResId,
title,
description,
firstParallaxFactor,
lastParallaxFactor,
parallaxRecursive,
headerTypefacePath,
descriptionTyefacePath,
headerColor,
descriptionColor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class WelcomeBasicFragment extends Fragment implements WelcomePage.OnChan
public static final String KEY_HEADER_TYPEFACE_PATH = "header_typeface";
public static final String KEY_DESCRIPTION_TYPEFACE_PATH = "description_typeface";
public static final String KEY_HEADER_COLOR = "header_color";
public static final String KEY_DESCRIPTION_COLOR = "description_color";

private ImageView imageView = null;
private TextView titleView = null;
Expand All @@ -37,7 +38,8 @@ public static WelcomeBasicFragment newInstance(@DrawableRes int drawableId,
boolean showParallaxAnim,
String headerTypefacePath,
String descriptionTypefacePath,
@ColorInt int headerColor)
@ColorInt int headerColor,
@ColorInt int descriptionColor)
{
Bundle args = new Bundle();
args.putInt(KEY_DRAWABLE_ID, drawableId);
Expand All @@ -47,6 +49,7 @@ public static WelcomeBasicFragment newInstance(@DrawableRes int drawableId,
args.putString(KEY_HEADER_TYPEFACE_PATH, headerTypefacePath);
args.putString(KEY_DESCRIPTION_TYPEFACE_PATH, descriptionTypefacePath);
args.putInt(KEY_HEADER_COLOR, headerColor);
args.putInt(KEY_DESCRIPTION_COLOR, descriptionColor);
WelcomeBasicFragment fragment = new WelcomeBasicFragment();
fragment.setArguments(args);
return fragment;
Expand Down Expand Up @@ -80,6 +83,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (headerColor != WelcomeUtils.NO_COLOR_SET)
titleView.setTextColor(headerColor);

int descriptionColor = args.getInt(KEY_DESCRIPTION_COLOR, WelcomeUtils.NO_COLOR_SET);
if (descriptionColor != WelcomeUtils.NO_COLOR_SET)
descriptionView.setTextColor(descriptionColor);

WelcomeUtils.setTypeface(titleView, args.getString(KEY_HEADER_TYPEFACE_PATH), getActivity());
WelcomeUtils.setTypeface(descriptionView, args.getString(KEY_DESCRIPTION_TYPEFACE_PATH), getActivity());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class WelcomeParallaxFragment extends Fragment implements WelcomePage.OnC
public static final String KEY_HEADER_TYPEFACE_PATH = "header_typeface";
public static final String KEY_DESCRIPTION_TYPEFACE_PATH = "description_typeface";
public static final String KEY_HEADER_COLOR = "header_color";
public static final String KEY_DESCRIPTION_COLOR = "description_color";

private FrameLayout frameLayout = null;
private TextView titleView = null;
Expand All @@ -44,7 +45,8 @@ public static WelcomeParallaxFragment newInstance(@LayoutRes int layoutId,
boolean parallaxRecursive,
String headerTypefacePath,
String descriptionTypefacePath,
@ColorInt int headerColor)
@ColorInt int headerColor,
@ColorInt int descriptionColor)
{
Bundle args = new Bundle();
args.putInt(KEY_LAYOUT_ID, layoutId);
Expand All @@ -56,6 +58,7 @@ public static WelcomeParallaxFragment newInstance(@LayoutRes int layoutId,
args.putString(KEY_HEADER_TYPEFACE_PATH, headerTypefacePath);
args.putString(KEY_DESCRIPTION_TYPEFACE_PATH, descriptionTypefacePath);
args.putInt(KEY_HEADER_COLOR, headerColor);
args.putInt(KEY_DESCRIPTION_COLOR, descriptionColor);
WelcomeParallaxFragment fragment = new WelcomeParallaxFragment();
fragment.setArguments(args);
return fragment;
Expand Down Expand Up @@ -91,6 +94,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (headerColor != WelcomeUtils.NO_COLOR_SET)
titleView.setTextColor(headerColor);

int descriptionColor = args.getInt(KEY_DESCRIPTION_COLOR, WelcomeUtils.NO_COLOR_SET);
if (descriptionColor != WelcomeUtils.NO_COLOR_SET)
descriptionView.setTextColor(descriptionColor);

WelcomeUtils.setTypeface(titleView, args.getString(KEY_HEADER_TYPEFACE_PATH), getActivity());
WelcomeUtils.setTypeface(descriptionView, args.getString(KEY_DESCRIPTION_TYPEFACE_PATH), getActivity());

Expand Down
10 changes: 10 additions & 0 deletions library/src/test/java/com/stephentuso/welcome/PagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public void basicPage() {
page.headerColorResource(context, R.color.wel_default_background_color);
assertEquals(DEFAULT_COLOR, page.getHeaderColor());

page.descriptionColor(Color.BLUE);
assertEquals(Color.BLUE, page.getDescriptionColor());
page.descriptionColorResource(context, R.color.wel_default_background_color);
assertEquals(DEFAULT_COLOR, page.getDescriptionColor());

page.setup(builder.build());
assertEquals("header_typeface", page.getHeaderTypefacePath());
assertEquals("description_typeface", page.getDescriptionTypefacePath());
Expand Down Expand Up @@ -161,6 +166,11 @@ public void parallaxPage() {
page.headerColorResource(context, R.color.wel_default_background_color);
assertEquals(DEFAULT_COLOR, page.getHeaderColor());

page.descriptionColor(Color.BLUE);
assertEquals(Color.BLUE, page.getDescriptionColor());
page.descriptionColorResource(context, R.color.wel_default_background_color);
assertEquals(DEFAULT_COLOR, page.getDescriptionColor());

page.setup(builder.build());
assertEquals("header_typeface", page.getHeaderTypefacePath());
assertEquals("description_typeface", page.getDescriptionTyefacePath());
Expand Down

0 comments on commit 3ee2d59

Please sign in to comment.