Skip to content

Commit

Permalink
added new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MarsadMaqsood committed Sep 17, 2021
1 parent 09860a7 commit 8306341
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
13 changes: 9 additions & 4 deletions app/src/main/java/com/marsad/stylishdialogs/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ protected void onCreate(Bundle savedInstanceState) {

findViewById(R.id.titleWTextDialog)
.setOnClickListener(v ->
new StylishAlertDialog(this, StylishAlertDialog.PROGRESS)
.setTitleText("Hey, This is title")
.setContentText("Content text")
.show()
new StylishAlertDialog(this, StylishAlertDialog.NORMAL)
.setTitleText("Hey, This is title")
.setContentText("Content text")
// .setCancellable(false)
.setCancelledOnTouchOutside(false)
.setConfirmButton("Dismiss", StylishAlertDialog::dismissWithAnimation)
.show()


);

findViewById(R.id.successMsgDialog)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class StylishAlertDialog extends Dialog implements View.OnClickListener {
public final static int BUTTON_CANCEL = DialogInterface.BUTTON_NEGATIVE;
public static boolean DARK_STYLE = false;
private final float defStrokeWidth;
boolean mCancelable = true;
boolean mCanceledOnTouchOutside = true;
private View mDialogView;
private AnimationSet mModalInAnim;
private AnimationSet mModalOutAnim;
Expand Down Expand Up @@ -92,15 +94,12 @@ public class StylishAlertDialog extends Dialog implements View.OnClickListener {
private int contentTextSize = 0;
private float strokeWidth = 0;


public StylishAlertDialog(Context context) {
this(context, NORMAL);
}

public StylishAlertDialog(Context context, int alertType) {
super(context, DARK_STYLE ? R.style.alert_dialog_dark : R.style.alert_dialog_light);
setCancelable(true);
setCanceledOnTouchOutside(true); //TODO was false

defStrokeWidth = getContext().getResources().getDimension(R.dimen.buttons_stroke_width);
strokeWidth = defStrokeWidth;
Expand Down Expand Up @@ -220,6 +219,10 @@ protected void onCreate(Bundle savedInstanceState) {
setNeutralButtonBackgroundColor(mNeutralButtonBackgroundColor);
setNeutralButtonTextColor(mNeutralButtonTextColor);
changeAlertType(mAlertType, true);
//todo:
setCancelable(mCancelable);
if (getCancellable())
setCanceledOnTouchOutside(mCanceledOnTouchOutside);

}

Expand Down Expand Up @@ -315,6 +318,29 @@ public void changeAlertType(int alertType) {
changeAlertType(alertType, false);
}

public boolean getCancellable() {
return mCancelable;
}

public StylishAlertDialog setCancellable(boolean cancelable) {
mCancelable = cancelable;
return this;
}

public boolean getCancelledOnTouchOutside() {
return mCanceledOnTouchOutside;
}

public StylishAlertDialog setCancelledOnTouchOutside(boolean cancelledOnTouchOutside) {
mCanceledOnTouchOutside = cancelledOnTouchOutside;
return this;
}

@Override
public void setCancelable(boolean flag) {
super.setCancelable(flag);
}

public String getTitleText() {
return mTitleText;
}
Expand Down

0 comments on commit 8306341

Please sign in to comment.