From befc9283c3854742700c09bc7ed61866a0c03a67 Mon Sep 17 00:00:00 2001 From: diegomura Date: Sat, 18 Apr 2015 16:19:03 -0300 Subject: [PATCH 01/11] SetTitleTextSize, SetContentTextSize, SetButtonsTextSize and SetTypeface methods added. Also sample modified to see these changes --- .idea/libraries/appcompat_v7_21_0_0.xml | 10 ++ .idea/libraries/materialish_progress_1_0.xml | 10 ++ .../libraries/support_annotations_21_0_0.xml | 11 ++ .idea/libraries/support_v4_21_0_0.xml | 11 ++ build.gradle | 2 +- library/library.iml | 95 ++++++++++++++++++ library/src/main/assets/noasarck.otf | Bin 0 -> 19900 bytes .../pedant/SweetAlert/SweetAlertDialog.java | 61 +++++++++++ sample/sample.iml | 92 +++++++++++++++++ .../SweetAlert/sample/SampleActivity.java | 26 +++-- sweet-alert-dialog.iml | 19 ++++ 11 files changed, 327 insertions(+), 10 deletions(-) create mode 100644 .idea/libraries/appcompat_v7_21_0_0.xml create mode 100644 .idea/libraries/materialish_progress_1_0.xml create mode 100644 .idea/libraries/support_annotations_21_0_0.xml create mode 100644 .idea/libraries/support_v4_21_0_0.xml create mode 100644 library/library.iml create mode 100644 library/src/main/assets/noasarck.otf create mode 100644 sample/sample.iml create mode 100644 sweet-alert-dialog.iml diff --git a/.idea/libraries/appcompat_v7_21_0_0.xml b/.idea/libraries/appcompat_v7_21_0_0.xml new file mode 100644 index 00000000..abb09ad1 --- /dev/null +++ b/.idea/libraries/appcompat_v7_21_0_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/materialish_progress_1_0.xml b/.idea/libraries/materialish_progress_1_0.xml new file mode 100644 index 00000000..b3cc078e --- /dev/null +++ b/.idea/libraries/materialish_progress_1_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_annotations_21_0_0.xml b/.idea/libraries/support_annotations_21_0_0.xml new file mode 100644 index 00000000..2b7b4353 --- /dev/null +++ b/.idea/libraries/support_annotations_21_0_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_21_0_0.xml b/.idea/libraries/support_v4_21_0_0.xml new file mode 100644 index 00000000..28b0ec79 --- /dev/null +++ b/.idea/libraries/support_v4_21_0_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file 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/library.iml b/library/library.iml new file mode 100644 index 00000000..3df36a14 --- /dev/null +++ b/library/library.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/src/main/assets/noasarck.otf b/library/src/main/assets/noasarck.otf new file mode 100644 index 0000000000000000000000000000000000000000..370a4ea195d474660577bc306779ee19c2680a20 GIT binary patch literal 19900 zcmdUXe|%KcweQ~N%#S1l$Ye74N#IO|B#MzAGZ`X5At(xgC2=ls!&^VE!rx9Yf-6im2!Pby)E_Wskf!pBDG2}@+=Q6_4@kB_4z__a=&Zsb7s!u z2ezO0-XCw0Gv~+bz4qE`uU~tueYTK7h_T{+p^No%m)6h29iB9tz&T^y+-t9+JKUeb zSN6Qci$S+sOY^qSu-E(eGX+~2-pZS(q{EPD9^ zA-vm#&{wW%-mrdP04<4zU*h+SRjv1|y!M`+#X@A^{>oE#v@|E=vTNVKZv=1p9e6N$ zujU85YTQq}W9`O{C*JG*5clr@-l5jE70n-9^41jq^(mgcySBMwz4)JEF0LC<-dNYX zw#EPbDxVPZ_6woCzrJn5#^)E+>=I%D@X@Z}zM+3#AIQ7$wy{_KyBL*$YC;^({oryw z=NDHEtg*U$`+P(XpP~h>P{()JY7(b?bpvbqHv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qr{8d}MB)h)&|g6sp{-^O_w_GHnp&kMEDEX02RqPu1B literal 0 HcmV?d00001 diff --git a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java index 77be52dd..77cf1ee3 100644 --- a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java +++ b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java @@ -3,9 +3,11 @@ import android.app.Dialog; import android.content.Context; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; +import android.util.TypedValue; import android.view.View; import android.view.WindowManager; import android.view.animation.AlphaAnimation; @@ -38,6 +40,10 @@ 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; @@ -161,6 +167,10 @@ protected void onCreate(Bundle savedInstanceState) { setContentText(mContentText); setCancelText(mCancelText); setConfirmText(mConfirmText); + setTitleTextSize(mTitleSize); + setContentTextSize(mContentSize); + setButtonsTextSize(mButtonsSize); + setTypeface(mTf); changeAlertType(mAlertType, true); } @@ -248,6 +258,57 @@ 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; + } + + 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) { diff --git a/sample/sample.iml b/sample/sample.iml new file mode 100644 index 00000000..5e41e17f --- /dev/null +++ b/sample/sample.iml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..86148288 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; @@ -10,6 +11,7 @@ public class SampleActivity extends Activity implements View.OnClickListener { private int i = -1; + private Typeface tf; @Override public void onCreate(Bundle savedInstanceState) { @@ -23,6 +25,8 @@ public void onCreate(Bundle savedInstanceState) { findViewById(R.id.warning_cancel_test).setOnClickListener(this); findViewById(R.id.custom_img_test).setOnClickListener(this); findViewById(R.id.progress_dialog).setOnClickListener(this); + + tf = Typeface.createFromAsset(this.getAssets(), "noasarck.otf"); } @Override @@ -71,13 +75,17 @@ public void onClick(SweetAlertDialog sDialog) { .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() { + 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.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 @@ -109,8 +117,8 @@ public void onClick(SweetAlertDialog sDialog) { .setConfirmClickListener(null) .changeAlertType(SweetAlertDialog.SUCCESS_TYPE); } - }) - .show(); + }); + s.show(); break; case R.id.custom_img_test: new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE) diff --git a/sweet-alert-dialog.iml b/sweet-alert-dialog.iml new file mode 100644 index 00000000..00bc43cf --- /dev/null +++ b/sweet-alert-dialog.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + From ff130a4c4b31640f61c369a81da4433e21fe0eb1 Mon Sep 17 00:00:00 2001 From: diegomura Date: Thu, 23 Apr 2015 23:27:23 -0300 Subject: [PATCH 02/11] setMediaPlayer method added to add a click sount to the dialog. --- .../cn/pedant/SweetAlert/SweetAlertDialog.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java index 77cf1ee3..4c6c3f06 100644 --- a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java +++ b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java @@ -5,6 +5,7 @@ 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; @@ -61,6 +62,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; @@ -394,6 +396,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(); @@ -422,6 +431,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); From 6c39ce03a7eac190ba0247653bae6473b411ef53 Mon Sep 17 00:00:00 2001 From: Tommy Chan Date: Fri, 1 May 2015 11:37:51 -0700 Subject: [PATCH 03/11] Added the set margins on the button container --- .gitignore | 4 ++++ .idea/libraries/appcompat_v7_21_0_0.xml | 2 +- .../libraries/support_annotations_21_0_0.xml | 4 ++-- .idea/libraries/support_v4_21_0_0.xml | 2 +- library/library.iml | 8 +++---- .../pedant/SweetAlert/SweetAlertDialog.java | 24 +++++++++++++++---- library/src/main/res/layout/alert_dialog.xml | 7 +++--- sample/sample.iml | 8 +++---- .../SweetAlert/sample/SampleActivity.java | 1 + sweet-alert-dialog.iml | 8 +++---- 10 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 .gitignore 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/.idea/libraries/appcompat_v7_21_0_0.xml b/.idea/libraries/appcompat_v7_21_0_0.xml index abb09ad1..5671bb46 100644 --- a/.idea/libraries/appcompat_v7_21_0_0.xml +++ b/.idea/libraries/appcompat_v7_21_0_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/support_annotations_21_0_0.xml b/.idea/libraries/support_annotations_21_0_0.xml index 2b7b4353..5084c9fe 100644 --- a/.idea/libraries/support_annotations_21_0_0.xml +++ b/.idea/libraries/support_annotations_21_0_0.xml @@ -1,11 +1,11 @@ - + - + \ No newline at end of file diff --git a/.idea/libraries/support_v4_21_0_0.xml b/.idea/libraries/support_v4_21_0_0.xml index 28b0ec79..601196ad 100644 --- a/.idea/libraries/support_v4_21_0_0.xml +++ b/.idea/libraries/support_v4_21_0_0.xml @@ -2,8 +2,8 @@ - + diff --git a/library/library.iml b/library/library.iml index 3df36a14..b46865d6 100644 --- a/library/library.iml +++ b/library/library.iml @@ -1,5 +1,5 @@ - + @@ -12,8 +12,9 @@ - - + \ No newline at end of file diff --git a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java index 4c6c3f06..c84e3f1e 100644 --- a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java +++ b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java @@ -15,10 +15,7 @@ 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; @@ -49,6 +46,7 @@ public class SweetAlertDialog extends Dialog implements View.OnClickListener { private FrameLayout mErrorFrame; private FrameLayout mSuccessFrame; private FrameLayout mProgressFrame; + private LinearLayout mButtonContainer; private SuccessTickView mSuccessTick; private ImageView mErrorX; private View mSuccessLeftMask; @@ -161,6 +159,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); @@ -279,6 +278,23 @@ public SweetAlertDialog setContentTextSize(int 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) { + if (mButtonContainer != null) { + LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mButtonContainer.getLayoutParams(); + params.setMargins(left, top, right, bottom); + mButtonContainer.setLayoutParams(params); + } + return this; + } + public SweetAlertDialog setButtonsTextSize(int sps){ mButtonsSize = sps; if (mCancelButton != null && mButtonsSize != 0) { diff --git a/library/src/main/res/layout/alert_dialog.xml b/library/src/main/res/layout/alert_dialog.xml index 7972157f..c0a64c97 100644 --- a/library/src/main/res/layout/alert_dialog.xml +++ b/library/src/main/res/layout/alert_dialog.xml @@ -136,13 +136,14 @@ android:textAlignment="center" android:gravity="center" android:textColor="#797979" - android:visibility="gone" /> + android:visibility="gone"/> + android:id="@+id/button_container" + android:gravity="center" android:layout_marginBottom="18dp">