diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..cd29f5bf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.idea
+.gradle
+build
+local.properties
diff --git a/build.gradle b/build.gradle
index 88583e9d..1d32375c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.14.1'
+ classpath 'com.android.tools.build:gradle:1.1.0'
}
}
diff --git a/library/build.gradle b/library/build.gradle
index 8e4eabc6..ae2b2e56 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -17,7 +17,7 @@ android {
}
dependencies {
- compile 'com.pnikosis:materialish-progress:1.0'
+ compile 'com.pnikosis:materialish-progress:1.5'
}
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
\ No newline at end of file
diff --git a/library/library.iml b/library/library.iml
new file mode 100644
index 00000000..b214a8d3
--- /dev/null
+++ b/library/library.iml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/assets/noasarck.otf b/library/src/main/assets/noasarck.otf
new file mode 100644
index 00000000..370a4ea1
Binary files /dev/null and b/library/src/main/assets/noasarck.otf differ
diff --git a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java
index 77be52dd..27e8ed0c 100644
--- a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java
+++ b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java
@@ -3,19 +3,20 @@
import android.app.Dialog;
import android.content.Context;
+import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
+import android.media.MediaPlayer;
import android.os.Build;
import android.os.Bundle;
+import android.util.TypedValue;
import android.view.View;
+import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.Transformation;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.TextView;
+import android.widget.*;
import com.pnikosis.materialishprogress.ProgressWheel;
@@ -38,10 +39,15 @@ public class SweetAlertDialog extends Dialog implements View.OnClickListener {
private boolean mShowContent;
private String mCancelText;
private String mConfirmText;
+ private int mTitleSize;
+ private int mContentSize;
+ private int mButtonsSize;
+ private Typeface mTf;
private int mAlertType;
private FrameLayout mErrorFrame;
private FrameLayout mSuccessFrame;
private FrameLayout mProgressFrame;
+ private LinearLayout mButtonContainer;
private SuccessTickView mSuccessTick;
private ImageView mErrorX;
private View mSuccessLeftMask;
@@ -55,6 +61,7 @@ public class SweetAlertDialog extends Dialog implements View.OnClickListener {
private OnSweetClickListener mCancelClickListener;
private OnSweetClickListener mConfirmClickListener;
private boolean mCloseFromCancel;
+ private MediaPlayer mp;
public static final int NORMAL_TYPE = 0;
public static final int ERROR_TYPE = 1;
@@ -62,6 +69,15 @@ public class SweetAlertDialog extends Dialog implements View.OnClickListener {
public static final int WARNING_TYPE = 3;
public static final int CUSTOM_IMAGE_TYPE = 4;
public static final int PROGRESS_TYPE = 5;
+ private int mButtonsPaddingLeft;
+ private int mButtonsPaddingTop;
+ private int mButtonsPaddingRight;
+ private int mButtonsPaddingBottom;
+ private int mButtonContainerMarginLeft;
+ private int mButtonContainerMarginTop;
+ private int mButtonContainerMarginRight;
+ private int mButtonContainerMarginBottom;
+ private int mButtonHeight;
public static interface OnSweetClickListener {
public void onClick (SweetAlertDialog sweetAlertDialog);
@@ -153,6 +169,7 @@ protected void onCreate(Bundle savedInstanceState) {
mWarningFrame = (FrameLayout)findViewById(R.id.warning_frame);
mConfirmButton = (Button)findViewById(R.id.confirm_button);
mCancelButton = (Button)findViewById(R.id.cancel_button);
+ mButtonContainer = (LinearLayout)findViewById(R.id.button_container);
mProgressHelper.setProgressWheel((ProgressWheel)findViewById(R.id.progressWheel));
mConfirmButton.setOnClickListener(this);
mCancelButton.setOnClickListener(this);
@@ -161,6 +178,14 @@ protected void onCreate(Bundle savedInstanceState) {
setContentText(mContentText);
setCancelText(mCancelText);
setConfirmText(mConfirmText);
+ setTitleTextSize(mTitleSize);
+ setContentTextSize(mContentSize);
+ setButtonsTextSize(mButtonsSize);
+ setButtonPadding(mButtonsPaddingLeft, mButtonsPaddingTop, mButtonsPaddingRight, mButtonsPaddingBottom);
+ setButtonContainerMargins(mButtonContainerMarginLeft, mButtonContainerMarginTop, mButtonContainerMarginRight,
+ mButtonContainerMarginBottom);
+ setButtonHeight(mButtonHeight);
+ setTypeface(mTf);
changeAlertType(mAlertType, true);
}
@@ -248,6 +273,121 @@ public SweetAlertDialog setTitleText (String text) {
return this;
}
+ public SweetAlertDialog setTitleTextSize(int sps){
+ mTitleSize = sps;
+ if (mTitleTextView != null && mTitleSize != 0) {
+ mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sps);
+ }
+
+
+ return this;
+ }
+
+ public SweetAlertDialog setContentTextSize(int sps){
+ mContentSize = sps;
+ if (mContentTextView != null && mContentSize != 0) {
+ mContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sps);
+ }
+
+ return this;
+ }
+
+ /**
+ * Sets the margins for the button container on the bottom.
+ * @param left The left in pixels
+ * @param top The top in pixels
+ * @param right The right in pixels
+ * @param bottom The bottom in pixels
+ * @return
+ */
+ public SweetAlertDialog setButtonContainerMargins(int left, int top, int right, int bottom) {
+ mButtonContainerMarginLeft = left;
+ mButtonContainerMarginTop = top;
+ mButtonContainerMarginRight = right;
+ mButtonContainerMarginBottom = bottom;
+
+ if (mButtonContainer != null) {
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mButtonContainer.getLayoutParams();
+ params.setMargins(mButtonContainerMarginLeft, mButtonContainerMarginTop, mButtonContainerMarginRight, mButtonContainerMarginBottom);
+ mButtonContainer.setLayoutParams(params);
+ }
+ return this;
+ }
+
+ /**
+ * Sets the padding for both the cancel and confirm buttons.
+ * @param left
+ * @param top
+ * @param right
+ * @param bottom
+ * @return
+ */
+ public SweetAlertDialog setButtonPadding(int left, int top, int right, int bottom) {
+ mButtonsPaddingLeft = left;
+ mButtonsPaddingTop = top;
+ mButtonsPaddingRight = right;
+ mButtonsPaddingBottom = bottom;
+
+ if (mCancelButton != null) {
+ mCancelButton.setPadding(mButtonsPaddingLeft, mButtonsPaddingTop, mButtonsPaddingRight, mButtonsPaddingBottom);
+ }
+
+ if (mConfirmButton != null) {
+ mConfirmButton.setPadding(mButtonsPaddingLeft, mButtonsPaddingTop, mButtonsPaddingRight, mButtonsPaddingBottom);
+ }
+
+ return this;
+ }
+
+ public SweetAlertDialog setButtonHeight(int pixels) {
+ mButtonHeight = pixels;
+ if (mCancelButton != null && mButtonHeight != 0) {
+ ViewGroup.LayoutParams layoutParams = mCancelButton.getLayoutParams();
+ layoutParams.height = pixels;
+ mCancelButton.setLayoutParams(layoutParams);
+ }
+
+ if (mConfirmButton != null && mButtonHeight != 0) {
+ ViewGroup.LayoutParams layoutParams = mConfirmButton.getLayoutParams();
+ layoutParams.height = pixels;
+ mConfirmButton.setLayoutParams(layoutParams);
+ }
+
+ return this;
+ }
+
+ public SweetAlertDialog setButtonsTextSize(int sps){
+ mButtonsSize = sps;
+ if (mCancelButton != null && mButtonsSize != 0) {
+ mCancelButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, sps);
+ }
+
+ if (mConfirmButton != null && mButtonsSize != 0) {
+ mConfirmButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, sps);
+ }
+
+ return this;
+ }
+
+ public SweetAlertDialog setTypeface(Typeface tf){
+ mTf = tf;
+ if (mTitleTextView != null && mTf != null) {
+ mTitleTextView.setTypeface(tf);
+ }
+ if (mContentTextView != null && mTf != null) {
+ mContentTextView.setTypeface(tf);
+ }
+
+ if (mCancelButton != null && mTf != null) {
+ mCancelButton.setTypeface(tf);
+ }
+
+ if (mConfirmButton != null && mTf != null) {
+ mConfirmButton.setTypeface(tf);
+ }
+ return this;
+ }
+
public SweetAlertDialog setCustomImage (Drawable drawable) {
mCustomImgDrawable = drawable;
if (mCustomImage != null && mCustomImgDrawable != null) {
@@ -333,6 +473,13 @@ public SweetAlertDialog setConfirmClickListener (OnSweetClickListener listener)
return this;
}
+ public SweetAlertDialog setMediaPlayer(MediaPlayer mp){
+ this.mp = mp;
+
+ return this;
+ }
+
+
protected void onStart() {
mDialogView.startAnimation(mModalInAnim);
playAnimation();
@@ -361,6 +508,11 @@ private void dismissWithAnimation(boolean fromCancel) {
@Override
public void onClick(View v) {
+
+ if(mp != null){
+ mp.start();
+ }
+
if (v.getId() == R.id.cancel_button) {
if (mCancelClickListener != null) {
mCancelClickListener.onClick(SweetAlertDialog.this);
diff --git a/library/src/main/res/drawable/blue_button_background.xml b/library/src/main/res/drawable/blue_button_background.xml
index 0e597b42..5c650288 100644
--- a/library/src/main/res/drawable/blue_button_background.xml
+++ b/library/src/main/res/drawable/blue_button_background.xml
@@ -3,13 +3,13 @@
-
-
+
-
-
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/dialog_background.xml b/library/src/main/res/drawable/dialog_background.xml
index 4c4a5e72..ad69716c 100644
--- a/library/src/main/res/drawable/dialog_background.xml
+++ b/library/src/main/res/drawable/dialog_background.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/error_center_x.xml b/library/src/main/res/drawable/error_center_x.xml
index e8b989bc..b6e0f5f1 100644
--- a/library/src/main/res/drawable/error_center_x.xml
+++ b/library/src/main/res/drawable/error_center_x.xml
@@ -4,7 +4,7 @@
-
+
@@ -14,7 +14,7 @@
-
+
diff --git a/library/src/main/res/drawable/gray_button_background.xml b/library/src/main/res/drawable/gray_button_background.xml
index 04e807d0..39769afc 100644
--- a/library/src/main/res/drawable/gray_button_background.xml
+++ b/library/src/main/res/drawable/gray_button_background.xml
@@ -3,13 +3,13 @@
-
-
+
-
-
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/red_button_background.xml b/library/src/main/res/drawable/red_button_background.xml
index a0ef0823..09836ec2 100644
--- a/library/src/main/res/drawable/red_button_background.xml
+++ b/library/src/main/res/drawable/red_button_background.xml
@@ -3,13 +3,13 @@
-
-
+
-
-
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/warning_sigh.xml b/library/src/main/res/drawable/warning_sigh.xml
index 19022091..3169fadf 100644
--- a/library/src/main/res/drawable/warning_sigh.xml
+++ b/library/src/main/res/drawable/warning_sigh.xml
@@ -3,7 +3,7 @@
-
-
+
diff --git a/library/src/main/res/layout/alert_dialog.xml b/library/src/main/res/layout/alert_dialog.xml
index 7972157f..ddfebb78 100644
--- a/library/src/main/res/layout/alert_dialog.xml
+++ b/library/src/main/res/layout/alert_dialog.xml
@@ -113,7 +113,7 @@
android:id="@+id/progressWheel"
android:layout_width="80dp"
android:layout_height="80dp"
- wheel:progressIndeterminate="true"
+ wheel:matProg_progressIndeterminate="true"
android:layout_gravity="center" />
@@ -136,13 +136,14 @@
android:textAlignment="center"
android:gravity="center"
android:textColor="#797979"
- android:visibility="gone" />
+ android:visibility="gone" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"/>
+ android:id="@+id/button_container"
+ android:gravity="center" android:layout_marginBottom="18dp">
\ No newline at end of file
diff --git a/sample/proguard-android.txt b/sample/proguard-android.txt
index 944c7800..93154813 100644
--- a/sample/proguard-android.txt
+++ b/sample/proguard-android.txt
@@ -1,3 +1,5 @@
- -keep class cn.pedant.SweetAlert.Rotate3dAnimation {
+-keep class cn.pedant.SweetAlert.Rotate3dAnimation {
public (...);
- }
\ No newline at end of file
+ }
+
+-dontwarn android.support.v4.**
\ No newline at end of file
diff --git a/sample/sample.iml b/sample/sample.iml
new file mode 100644
index 00000000..325406bf
--- /dev/null
+++ b/sample/sample.iml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/java/cn/pedant/SweetAlert/sample/SampleActivity.java b/sample/src/main/java/cn/pedant/SweetAlert/sample/SampleActivity.java
index ea7f2cd6..f4c7a699 100644
--- a/sample/src/main/java/cn/pedant/SweetAlert/sample/SampleActivity.java
+++ b/sample/src/main/java/cn/pedant/SweetAlert/sample/SampleActivity.java
@@ -1,6 +1,7 @@
package cn.pedant.SweetAlert.sample;
import android.app.Activity;
+import android.graphics.Typeface;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
@@ -9,158 +10,189 @@
public class SampleActivity extends Activity implements View.OnClickListener {
- private int i = -1;
+ private int i = -1;
+ private Typeface tf;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.sample_activity);
- findViewById(R.id.basic_test).setOnClickListener(this);
- findViewById(R.id.under_text_test).setOnClickListener(this);
- findViewById(R.id.error_text_test).setOnClickListener(this);
- findViewById(R.id.success_text_test).setOnClickListener(this);
- findViewById(R.id.warning_confirm_test).setOnClickListener(this);
- findViewById(R.id.warning_cancel_test).setOnClickListener(this);
- findViewById(R.id.custom_img_test).setOnClickListener(this);
- findViewById(R.id.progress_dialog).setOnClickListener(this);
- }
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.sample_activity);
+ findViewById(R.id.basic_test).setOnClickListener(this);
+ findViewById(R.id.under_text_test).setOnClickListener(this);
+ findViewById(R.id.error_text_test).setOnClickListener(this);
+ findViewById(R.id.success_text_test).setOnClickListener(this);
+ findViewById(R.id.warning_confirm_test).setOnClickListener(this);
+ findViewById(R.id.warning_cancel_test).setOnClickListener(this);
+ findViewById(R.id.custom_img_test).setOnClickListener(this);
+ findViewById(R.id.progress_dialog).setOnClickListener(this);
+ findViewById(R.id.custom_margin_test).setOnClickListener(this);
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.basic_test:
- // default title "Here's a message!"
- SweetAlertDialog sd = new SweetAlertDialog(this);
- sd.setCancelable(true);
- sd.setCanceledOnTouchOutside(true);
- sd.show();
- break;
- case R.id.under_text_test:
- new SweetAlertDialog(this)
- .setContentText("It's pretty, isn't it?")
- .show();
- break;
- case R.id.error_text_test:
- new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
- .setTitleText("Oops...")
- .setContentText("Something went wrong!")
- .show();
- break;
- case R.id.success_text_test:
- new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
- .setTitleText("Good job!")
- .setContentText("You clicked the button!")
- .show();
- break;
- case R.id.warning_confirm_test:
- new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
- .setTitleText("Are you sure?")
- .setContentText("Won't be able to recover this file!")
- .setConfirmText("Yes,delete it!")
- .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
- @Override
- public void onClick(SweetAlertDialog sDialog) {
- // reuse previous dialog instance
- sDialog.setTitleText("Deleted!")
- .setContentText("Your imaginary file has been deleted!")
- .setConfirmText("OK")
- .setConfirmClickListener(null)
- .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
- }
- })
- .show();
- break;
- case R.id.warning_cancel_test:
- new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
- .setTitleText("Are you sure?")
- .setContentText("Won't be able to recover this file!")
- .setCancelText("No,cancel plx!")
- .setConfirmText("Yes,delete it!")
- .showCancelButton(true)
- .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
- @Override
- public void onClick(SweetAlertDialog sDialog) {
- // reuse previous dialog instance, keep widget user state, reset them if you need
- sDialog.setTitleText("Cancelled!")
- .setContentText("Your imaginary file is safe :)")
- .setConfirmText("OK")
- .showCancelButton(false)
- .setCancelClickListener(null)
- .setConfirmClickListener(null)
- .changeAlertType(SweetAlertDialog.ERROR_TYPE);
+ tf = Typeface.createFromAsset(this.getAssets(), "noasarck.otf");
+ }
- // or you can new a SweetAlertDialog to show
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.basic_test:
+ // default title "Here's a message!"
+ SweetAlertDialog sd = new SweetAlertDialog(this);
+ sd.setCancelable(true);
+ sd.setCanceledOnTouchOutside(true);
+ sd.show();
+ break;
+ case R.id.under_text_test:
+ new SweetAlertDialog(this)
+ .setContentText("It's pretty, isn't it?")
+ .show();
+ break;
+ case R.id.error_text_test:
+ new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
+ .setTitleText("Oops...")
+ .setContentText("Something went wrong!")
+ .show();
+ break;
+ case R.id.success_text_test:
+ new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
+ .setTitleText("Good job!")
+ .setContentText("You clicked the button!")
+ .show();
+ break;
+ case R.id.warning_confirm_test:
+ new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
+ .setTitleText("Are you sure?")
+ .setContentText("Won't be able to recover this file!")
+ .setConfirmText("Yes,delete it!")
+ .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
+ @Override
+ public void onClick(SweetAlertDialog sDialog) {
+ // reuse previous dialog instance
+ sDialog.setTitleText("Deleted!")
+ .setContentText("Your imaginary file has been deleted!")
+ .setConfirmText("OK")
+ .setConfirmClickListener(null)
+ .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
+ }
+ })
+ .show();
+ break;
+ case R.id.warning_cancel_test:
+ SweetAlertDialog s = new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE);
+ s.setTitleText("Are you sure?");
+ s.setContentText("Won't be able to recover this file!");
+ s.setCancelText("No,cancel plx!");
+ s.setConfirmText("Yes,delete it!");
+ s.setTitleTextSize(30);
+ s.setContentTextSize(20);
+ s.setButtonsTextSize(20);
+ s.setButtonContainerMargins(10, 20, 10, 10);
+ s.setTypeface(tf);
+ s.showCancelButton(true);
+ s.setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
+ @Override
+ public void onClick(SweetAlertDialog sDialog) {
+ // reuse previous dialog instance, keep widget user state, reset them if you need
+ sDialog.setTitleText("Cancelled!")
+ .setContentText("Your imaginary file is safe :)")
+ .setConfirmText("OK")
+ .showCancelButton(false)
+ .setCancelClickListener(null)
+ .setConfirmClickListener(null)
+ .changeAlertType(SweetAlertDialog.ERROR_TYPE);
+
+ // or you can new a SweetAlertDialog to show
/* sDialog.dismiss();
new SweetAlertDialog(SampleActivity.this, SweetAlertDialog.ERROR_TYPE)
.setTitleText("Cancelled!")
.setContentText("Your imaginary file is safe :)")
.setConfirmText("OK")
.show();*/
- }
- })
- .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
- @Override
- public void onClick(SweetAlertDialog sDialog) {
- sDialog.setTitleText("Deleted!")
- .setContentText("Your imaginary file has been deleted!")
- .setConfirmText("OK")
- .showCancelButton(false)
- .setCancelClickListener(null)
- .setConfirmClickListener(null)
- .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
- }
- })
- .show();
+ }
+ })
+ .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
+ @Override
+ public void onClick(SweetAlertDialog sDialog) {
+ sDialog.setTitleText("Deleted!")
+ .setContentText("Your imaginary file has been deleted!")
+ .setConfirmText("OK")
+ .showCancelButton(false)
+ .setCancelClickListener(null)
+ .setConfirmClickListener(null)
+ .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
+ }
+ });
+ s.show();
+ break;
+ case R.id.custom_img_test:
+ new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)
+ .setTitleText("Sweet!")
+ .setContentText("Here's a custom image.")
+ .setCustomImage(R.drawable.custom_img)
+ .show();
+ break;
+ case R.id.progress_dialog:
+ final SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE)
+ .setTitleText("Loading");
+ pDialog.show();
+ pDialog.setCancelable(false);
+ new CountDownTimer(800 * 7, 800) {
+ public void onTick(long millisUntilFinished) {
+ // you can change the progress bar color by ProgressHelper every 800 millis
+ i++;
+ switch (i) {
+ case 0:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.blue_btn_bg_color));
break;
- case R.id.custom_img_test:
- new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)
- .setTitleText("Sweet!")
- .setContentText("Here's a custom image.")
- .setCustomImage(R.drawable.custom_img)
- .show();
+ case 1:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_50));
break;
- case R.id.progress_dialog:
- final SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE)
- .setTitleText("Loading");
- pDialog.show();
- pDialog.setCancelable(false);
- new CountDownTimer(800 * 7, 800) {
- public void onTick(long millisUntilFinished) {
- // you can change the progress bar color by ProgressHelper every 800 millis
- i++;
- switch (i){
- case 0:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.blue_btn_bg_color));
- break;
- case 1:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_50));
- break;
- case 2:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
- break;
- case 3:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_20));
- break;
- case 4:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_blue_grey_80));
- break;
- case 5:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.warning_stroke_color));
- break;
- case 6:
- pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
- break;
- }
- }
-
- public void onFinish() {
- i = -1;
- pDialog.setTitleText("Success!")
- .setConfirmText("OK")
- .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
- }
- }.start();
+ case 2:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
+ break;
+ case 3:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_20));
+ break;
+ case 4:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_blue_grey_80));
+ break;
+ case 5:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.warning_stroke_color));
+ break;
+ case 6:
+ pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
break;
- }
+ }
+ }
+
+ public void onFinish() {
+ i = -1;
+ pDialog.setTitleText("Success!")
+ .setConfirmText("OK")
+ .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
+ }
+ }.start();
+ break;
+ case R.id.custom_margin_test:
+
+ int bottomMargin = getResources().getDimensionPixelSize(R.dimen.dialog_bottom_margin_size);
+ int topMargin = getResources().getDimensionPixelSize(R.dimen.dialog_top_margin_size);
+ int topBottomPadding = getResources().getDimensionPixelSize(R.dimen.dialog_top_bottom_padding_size);
+ int leftRightPadding = getResources().getDimensionPixelSize(R.dimen.dialog_left_right_padding_size);
+ int buttonHeight = getResources().getDimensionPixelSize(R.dimen.dialog_height_size);
+ int dialogButtonSize = 16; //unfortunately can't put this in dimens since it's in sp
+
+ SweetAlertDialog marginExample = new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE);
+ marginExample.setTitleText("Are you sure?");
+ marginExample.setContentText("Won't be able to recover this file!");
+ marginExample.setCancelText("No,cancel plx!");
+ marginExample.setConfirmText("Yes,delete it!");
+ marginExample.setButtonContainerMargins(0, topMargin, 0,
+ bottomMargin);
+ marginExample.setButtonPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
+ marginExample.setButtonHeight(buttonHeight);
+ marginExample.setButtonsTextSize(dialogButtonSize);
+ marginExample.show();
+ break;
+
}
+ }
}
diff --git a/sample/src/main/res/layout/sample_activity.xml b/sample/src/main/res/layout/sample_activity.xml
index bc3fe382..3f34e62b 100644
--- a/sample/src/main/res/layout/sample_activity.xml
+++ b/sample/src/main/res/layout/sample_activity.xml
@@ -177,6 +177,25 @@
android:layout_margin="10dp"
android:text="Try me!"/>
+
+
+
diff --git a/sample/src/main/res/values/dimens.xml b/sample/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..1f3cd1e3
--- /dev/null
+++ b/sample/src/main/res/values/dimens.xml
@@ -0,0 +1,8 @@
+
+
+ 12dp
+ 20dp
+ 18dp
+ 40dp
+ 0dp
+
\ No newline at end of file
diff --git a/sweet-alert-dialog.iml b/sweet-alert-dialog.iml
new file mode 100644
index 00000000..291996bd
--- /dev/null
+++ b/sweet-alert-dialog.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file