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

Issue #212: Add possibility to configure alpha of description text. #213

Merged
merged 2 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -82,6 +82,8 @@ public class TapTarget {
boolean cancelable = true;
boolean tintTarget = true;
boolean transparentTarget = false;
// This variable is used for configuring alpha of description text.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is unnecessary

float descriptionTextAlpha = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be initialized to 0.54f


/**
* Return a tap target for the overflow button from the given toolbar
Expand Down Expand Up @@ -414,6 +416,17 @@ public TapTarget targetRadius(int targetRadius) {
return this;
}

/**
* @param descriptionTextAlpha is used to define alpha of description text, should be [0..255].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The range is [0, 1]

* @return TapTarget object with defined alpha for description text.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets just make this comment /** Specify the alpha value [0.0, 1.0] of the description text **/

public TapTarget descriptionTextAlpha(float descriptionTextAlpha) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this function to line 325

if (descriptionTextAlpha < 0 || descriptionTextAlpha > 255) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< 0f and > 1f

throw new IllegalArgumentException("Alpha is out of allowed bounds");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw new IllegalArgumentException("Given an invalid alpha value: " + alpha);

}
this.descriptionTextAlpha = descriptionTextAlpha;
return this;
}

/** Return the id associated with this tap target **/
public int id() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,11 @@ protected void onDraw(Canvas c) {

if (descriptionLayout != null && titleLayout != null) {
c.translate(0, titleLayout.getHeight() + TEXT_SPACING);
descriptionPaint.setAlpha((int) (0.54f * textAlpha));
if (target.descriptionTextAlpha != 0) {
descriptionPaint.setAlpha((int) target.descriptionTextAlpha);
} else {
descriptionPaint.setAlpha((int) (0.54f * textAlpha));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now just be descriptionPaint.setAlpha((int) (target.descriptionTextAlpha * textAlpha));

descriptionLayout.draw(c);
}
}
Expand Down