Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to change, textSize, textAppearance and textColor #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.animation.ValueAnimator;
import android.content.Context;
import android.os.Build;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -460,19 +461,68 @@ protected ViewGroup createPagerIconElement(int iconDrawableRes, boolean isActive
}

/**
* @param PaperOnboardingPage new content page to show
* @param page new content page to show
* @return configured view with new content texts
*/
protected ViewGroup createContentTextView(PaperOnboardingPage PaperOnboardingPage) {
protected ViewGroup createContentTextView(PaperOnboardingPage page) {
LayoutInflater vi = LayoutInflater.from(mAppContext);
ViewGroup contentTextView = (ViewGroup) vi.inflate(R.layout.onboarding_text_content_layout, mContentTextContainer, false);
TextView contentTitle = (TextView) contentTextView.getChildAt(0);
contentTitle.setText(PaperOnboardingPage.getTitleText());
setTitleText(contentTitle, page);

TextView contentText = (TextView) contentTextView.getChildAt(1);
contentText.setText(PaperOnboardingPage.getDescriptionText());
setContentText(contentText, page);
return contentTextView;
}

/**
* Apply changes on title-text
* @param contentTitle the title-text reference
* @param page the changes source
*/
private void setTitleText(TextView contentTitle, PaperOnboardingPage page) {
contentTitle.setText(page.getTitleText());
if (page.getTitleTextSize() > 0)
contentTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, page.getTitleTextSize());

if (page.getTitleTextStyle() != 0)
setTextAppearance(contentTitle, page.getTitleTextStyle());

if (page.getTextColor() != 0)
contentTitle.setTextColor(page.getTextColor());
}

/**
* Apply changes on content-text
* @param contentText the content-text reference
* @param page the changes source
*/
private void setContentText(TextView contentText, PaperOnboardingPage page) {
contentText.setText(page.getDescriptionText());

if (page.getDescTextSize() > 0)
contentText.setTextSize(TypedValue.COMPLEX_UNIT_SP, page.getDescTextSize());

if (page.getDescTextStyle() != 0)
setTextAppearance(contentText, page.getDescTextStyle());

if (page.getTextColor() != 0)
contentText.setTextColor(page.getTextColor());
}

/**
* Set text-appearance for a text-view
* @param textView the TextView to change
* @param style the Style to set
*/
private void setTextAppearance(TextView textView, int style) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
textView.setTextAppearance(style);
} else {
textView.setTextAppearance(textView.getContext(), style);
}
}

/**
* @param PaperOnboardingPage new content page to show
* @return configured view with new content image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,108 @@ public class PaperOnboardingPage implements Serializable {
private int bgColor;
private int contentIconRes;
private int bottomBarIconRes;
private int textColor = 0;
private int titleTextSize = 0;
private int descTextSize = 0;
private int titleTextStyle = 0;
private int descTextStyle = 0;

public static class Builder {
private String titleText;
private String descriptionText;
private int bgColor;
private int contentIconRes;
private int bottomBarIconRes;
private int textColor = 0;
private int titleTextSize = 0;
private int descTextSize = 0;
private int titleTextStyle = 0;
private int descTextStyle = 0;


public Builder(String titleText, String descriptionText) {
this.titleText = titleText;
this.descriptionText = descriptionText;
}

public Builder backgroundColor(int bgColor) {
this.bgColor = bgColor;
return this;
}

public Builder contentIconResource(int contentIconRes) {
this.contentIconRes = contentIconRes;
return this;
}

public Builder bottomBarIconResource(int bottomBarIconRes) {
this.bottomBarIconRes = bottomBarIconRes;
return this;
}

public Builder textColor(int textColor) {
this.textColor = textColor;
return this;
}

public Builder titleTextSize(int titleTextSize) {
this.titleTextSize = titleTextSize;
return this;
}

public Builder descTextSize(int descTextSize) {
this.descTextSize = descTextSize;
return this;
}

public Builder titleTexStyle(int textStyle) {
this.titleTextStyle = textStyle;
return this;
}

public Builder descTextStyle(int textStyle) {
this.descTextStyle = textStyle;
return this;
}

public PaperOnboardingPage build() {
return new PaperOnboardingPage(this);
}

public PaperOnboardingPage() {
}

public PaperOnboardingPage(String titleText, String descriptionText, int bgColor, int contentIconRes, int bottomBarIconRes) {
this.bgColor = bgColor;
this.contentIconRes = contentIconRes;
this.bottomBarIconRes = bottomBarIconRes;
this.descriptionText = descriptionText;
this.titleText = titleText;
private PaperOnboardingPage(Builder builder) {
this.titleText = builder.titleText;
this.descriptionText = builder.descriptionText;
this.bgColor = builder.bgColor;
this.contentIconRes = builder.contentIconRes;
this.bottomBarIconRes = builder.bottomBarIconRes;
this.textColor = builder.textColor;
this.titleTextSize = builder.titleTextSize;
this.descTextSize = builder.descTextSize;
this.titleTextStyle = builder.titleTextStyle;
this.descTextStyle = builder.descTextStyle;
}


public int getDescTextStyle() {
return descTextStyle;
}

public int getDescTextSize() {
return descTextSize;
}

public int getTextColor() {
return textColor;
}

public int getTitleTextSize() {
return titleTextSize;
}

public int getTitleTextStyle() {
return titleTextStyle;
}

public String getTitleText() {
Expand Down