-
Notifications
You must be signed in to change notification settings - Fork 593
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
float descriptionTextAlpha = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets just make this comment |
||
public TapTarget descriptionTextAlpha(float descriptionTextAlpha) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. < 0f and > 1f |
||
throw new IllegalArgumentException("Alpha is out of allowed bounds"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
this.descriptionTextAlpha = descriptionTextAlpha; | ||
return this; | ||
} | ||
|
||
/** Return the id associated with this tap target **/ | ||
public int id() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should now just be |
||
descriptionLayout.draw(c); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is unnecessary