Skip to content

Commit

Permalink
Add #22 darker overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jun 20, 2016
1 parent f549215 commit 6598230
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void onClick(MaterialDialog dialog, DialogAction which) {
.setStyle(Style.HEADER_WITH_TITLE)
.setHeaderDrawable(R.drawable.header)
.withDialogAnimation(true)
.withDarkerOverlay(true)
.setTitle("An awesome library?")
.setDescription("Do you like this library? Check out my other Open Source libraries and apps!")
.setPositive("GitHub", new MaterialDialog.SingleButtonCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class MaterialStyledDialog {

private Style style; // setStyle()
private Duration duration; // withDialogAnimation()
private Boolean isIconAnimation, isDialogAnimation, isDialogDivider, isCancelable, scrollable; // withIconAnimation(), withDialogAnimation(), withDivider(), setCancelable(), setScrollable()
private boolean isIconAnimation, isDialogAnimation, isDialogDivider, isCancelable, isScrollable, isDarkerOverlay; // withIconAnimation(), withDialogAnimation(), withDivider(), setCancelable(), setScrollable(), withDarkerOverlay()
private Drawable headerDrawable, iconDrawable; // setHeaderDrawable(), setIconDrawable()
private Integer primaryColor, maxLines; // setHeaderColor(), setScrollable()
private CharSequence title, description; // setTitle(), setDescription()
Expand All @@ -52,10 +52,11 @@ public MaterialStyledDialog(Context context) {
this.isIconAnimation = true;
this.isDialogAnimation = false;
this.isDialogDivider = false;
this.isDarkerOverlay = false;
this.duration = Duration.NORMAL;
this.isCancelable = true;
this.primaryColor = UtilsLibrary.getPrimaryColor(context);
this.scrollable = false;
this.isScrollable = false;
this.maxLines = 5;
}

Expand Down Expand Up @@ -165,6 +166,17 @@ public MaterialStyledDialog withDivider(Boolean withDivider) {
return this;
}

/**
* Set if the header will display a gray/darker overlay. Default: false.
*
* @param withDarkerOverlay true to apply a darker overlay, false otherwise
* @return this
*/
public MaterialStyledDialog withDarkerOverlay(Boolean withDarkerOverlay) {
this.isDarkerOverlay = withDarkerOverlay;
return this;
}

/**
* Set an icon for the dialog header
* @param icon to show
Expand Down Expand Up @@ -313,24 +325,24 @@ public MaterialStyledDialog setCancelable(Boolean cancelable) {
}

/**
* Set if the description will be scrollable. Default: false.
* Set if the description will be isScrollable. Default: false.
*
* @param scrollable true to enable scrollable description, false otherwise
* @param scrollable true to enable isScrollable description, false otherwise
* @return this
*/
public MaterialStyledDialog setScrollable(Boolean scrollable) {
this.scrollable = scrollable;
this.isScrollable = scrollable;
return this;
}

/**
* Set if the description will be scrollable, with custom maximum lines. Default: false, 5.
* Set if the description will be isScrollable, with custom maximum lines. Default: false, 5.
*
* @param scrollable true to enable scrollable description, false otherwise
* @param scrollable true to enable isScrollable description, false otherwise
* @return this
*/
public MaterialStyledDialog setScrollable(Boolean scrollable, Integer maxLines) {
this.scrollable = scrollable;
this.isScrollable = scrollable;
this.maxLines = maxLines;
return this;
}
Expand Down Expand Up @@ -419,8 +431,8 @@ private View initStyle() {
// Set header color or drawable
if (headerDrawable != null) {
dialogHeader.setImageDrawable(headerDrawable);
if (style == Style.HEADER_WITH_TITLE) {
// Apply some darker to the header when STYLE_HEADER_TITLE is enabled
// Apply gray/darker overlay to the header if enabled
if (isDarkerOverlay) {
dialogHeader.setColorFilter(Color.rgb(123, 123, 123), PorterDuff.Mode.MULTIPLY);
}
}
Expand Down Expand Up @@ -453,8 +465,8 @@ private View initStyle() {
dialogDescription.setText(description);

// Set scrollable
dialogDescription.setVerticalScrollBarEnabled(scrollable);
if (scrollable) {
dialogDescription.setVerticalScrollBarEnabled(isScrollable);
if (isScrollable) {
dialogDescription.setMaxLines(maxLines);
dialogDescription.setMovementMethod(new ScrollingMovementMethod());
} else {
Expand Down

0 comments on commit 6598230

Please sign in to comment.