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

Dialog background color #58

Merged
merged 1 commit into from
Mar 2, 2023
Merged
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
2 changes: 2 additions & 0 deletions SJDialog/BasicDialogDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ dialog.setLeftButtonBackgroundResource(drawable);
//Set right button background resource
dialog.setRightButtonBackgroundResource(drawable);

//Set dialog color
dialog.setDialogBackgroundColor(color);
//Set dialog background resource
dialog.setDialogBackgroundResource(drawable);

Expand Down
2 changes: 2 additions & 0 deletions SJDialog/CustomViewDialogDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ customViewDialog.setLeftButtonBackgroundResource(drawable);
//Set right button background resource
customViewDialog.setRightButtonBackgroundResource(drawable);

//Set dialog color
customViewDialog.setDialogBackgroundColor(color);
//Set dialog background resource
customViewDialog.setDialogBackgroundResource(drawable);

Expand Down
2 changes: 2 additions & 0 deletions SJDialog/ListDialogDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ listDialog.setLeftButtonBackgroundResource(drawable);
//Set right button background resource
listDialog.setRightButtonBackgroundResource(drawable);

//Set dialog color
listDialog.setDialogBackgroundColor(color);
//Set dialog background resource
listDialog.setDialogBackgroundResource(drawable);

Expand Down
4 changes: 3 additions & 1 deletion SJDialog/MessageDialogDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ messageDialog.setButtonTextColor(color);

//Set button background resource
messageDialog.setButtonBackgroundResource(drawable);


//Set dialog color
messageDialog.setDialogBackgroundColor(color);
//Set dialog background resource
messageDialog.setDialogBackgroundResource(drawable);

Expand Down
4 changes: 2 additions & 2 deletions SJDialog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {

defaultConfig {
minSdk 23
versionCode 19
versionName "1.6 (dev 5)"
versionCode 20
versionName "1.6 (dev 5.1)"

buildConfigField 'int', 'VERSION_CODE', "${versionCode}"
buildConfigField 'String', 'VERSION_NAME', "\"${versionName}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ public BasicDialog setRightButtonColor(@ButtonColor String color){
return this;
}

/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}

@Override
public BasicDialog setDialogBackgroundResource(@DrawableRes int drawable){
super.setDialogBackgroundResource(drawable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ public CustomViewDialog setRightButtonColor(@ButtonColor String color){
return this;
}

/**{@inheritDoc}
* @since 1.6*/
@Override
public CustomViewDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}

@Override
public CustomViewDialog setDialogBackgroundResource(@DrawableRes int drawable){
super.setDialogBackgroundResource(drawable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ public ListDialog setRightButtonColor(@ButtonColor String color) {
return this;
}

/**{@inheritDoc}
* @since 1.6*/
@Override
public ListDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}

@Override
public ListDialog setDialogBackgroundResource(@DrawableRes int drawable) {
super.setDialogBackgroundResource(drawable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ public MessageDialog setButtonColor(@ButtonColor String color){
return this;
}

/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}

@Override
public MessageDialog setDialogBackgroundResource(@DrawableRes int drawable){
super.setDialogBackgroundResource(drawable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public abstract class SJDialog {

public Dialog dialog;
protected Button button1, button2;
private LinearLayout background;
private int maxDialogWidth = 600;
Context context;

Expand Down Expand Up @@ -81,6 +82,7 @@ protected SJDialog Builder(Context context, @LayoutRes int layoutResID, @StyleRe
dialog.getWindow().getAttributes().gravity = Gravity.BOTTOM;
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.getWindow().getAttributes().windowAnimations = R.style.SJDialogAnimation;
background = dialog.findViewById(R.id.dialogBackground);
setButtons();
if (theme != defaultTheme || useAppTheme) {
usesDefaultTheme = false;
Expand Down Expand Up @@ -336,14 +338,25 @@ protected SJDialog setRightButtonColor(@ButtonColor String color) {
return this;
}


/**
* Change dialog color
* @param color {@link ColorInt}
* @return current class
* @since 1.6
*/
protected SJDialog setDialogBackgroundColor(@ColorInt int color){
background.getBackground().mutate().setTint(color);
return this;
}

/**
* Set background resource for dialog.
*
* @param drawable resource id
* @return current class
*/
protected SJDialog setDialogBackgroundResource(@DrawableRes int drawable) {
LinearLayout background = dialog.findViewById(R.id.dialogBackground);
background.setBackgroundResource(drawable);
return this;
}
Expand Down