Skip to content

Commit

Permalink
Use theme colors for tutorial
Browse files Browse the repository at this point in the history
Add support to provide tint color.
Color generation will be improved after using the latest
dynamic utils release.
  • Loading branch information
pranavpandey committed Apr 29, 2021
1 parent 9c3d890 commit 88da87a
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ public static void onPageScrollStateChanged(@Nullable ViewPager.OnPageChangeList
}

/**
* Call {@link Tutorial#getBackgroundColor()} method for the {@link Tutorial}.
* Call {@link Tutorial#getColor()} method for the {@link Tutorial}.
*
* @param tutorial The dynamic tutorial to be used.
* @param defaultColor The default color for the background.
Expand All @@ -1425,28 +1425,48 @@ public static void onPageScrollStateChanged(@Nullable ViewPager.OnPageChangeList
*
* @return The background color for the supplied tutorial.
*/
public static @ColorInt <T, V> int getBackgroundColor(@Nullable Tutorial<T, V> tutorial,
public static @ColorInt <T, V> int getColor(@Nullable Tutorial<T, V> tutorial,
@ColorInt int defaultColor) {
if (tutorial != null) {
return tutorial.getBackgroundColor();
return tutorial.getColor();
}

return defaultColor;
}

/**
* Call {@link Tutorial#onBackgroundColorChanged(int)} method for the
* Call {@link Tutorial#getTintColor()} method for the {@link Tutorial}.
*
* @param tutorial The dynamic tutorial to be used.
* @param defaultColor The default tint color.
* @param <T> The type of the tutorial.
* @param <V> The type of the tutorial fragment.
*
* @return The tint color for the supplied tutorial.
*/
public static @ColorInt <T, V> int getTintColor(@Nullable Tutorial<T, V> tutorial,
@ColorInt int defaultColor) {
if (tutorial != null) {
return tutorial.getTintColor();
}

return defaultColor;
}

/**
* Call {@link Tutorial#onColorChanged(int, int)} method for the
* {@link Tutorial}.
*
* @param tutorial The dynamic tutorial to be used.
* @param color The color of the background.
* @param tint The tint color used by the tutorial.
* @param <T> The type of the tutorial.
* @param <V> The type of the tutorial fragment.
*/
public static <T, V> void onBackgroundColorChanged(@Nullable Tutorial<T, V> tutorial,
@ColorInt int color) {
public static <T, V> void onColorChanged(@Nullable Tutorial<T, V> tutorial,
@ColorInt int color, @ColorInt int tint) {
if (tutorial != null) {
tutorial.onBackgroundColorChanged(color);
tutorial.onColorChanged(color, tint);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public void writeToParcel(Parcel dest, int flags) {

@Override
public @ColorInt int getStrokeColor() {
return DynamicTheme.getInstance().generateStrokeColor(getBackgroundColor());
return getTintBackgroundColor();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public DynamicMenuPopup(@NonNull View anchor,
onItemClickListener, Type.LIST);
}


/**
* Constructor to initialize an object of this class.
*
Expand Down

0 comments on commit 88da87a

Please sign in to comment.