From 688ddb61aee60429479e42a320d78eb035fb6595 Mon Sep 17 00:00:00 2001 From: Kohei Yamashita Date: Tue, 2 May 2017 15:45:32 +0900 Subject: [PATCH 1/5] Update gradle and build tools version --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 88583e9d..047b9e4a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,13 +3,13 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.14.1' + classpath 'com.android.tools.build:gradle:2.3.1' } } ext { compileSdkVersion = 21 - buildToolsVersion = "19.1.0" + buildToolsVersion = "25.0.2" } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8a6b0613..90de923d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Dec 02 17:43:17 CET 2014 +#Tue May 02 15:42:42 JST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip From bc7ec3192559eccfde98f75f6cad3997d01e88e9 Mon Sep 17 00:00:00 2001 From: Kohei Yamashita Date: Tue, 2 May 2017 16:20:19 +0900 Subject: [PATCH 2/5] Add edit text dialog --- .../pedant/SweetAlert/SweetAlertDialog.java | 37 +++++++++++++++++++ library/src/main/res/layout/alert_dialog.xml | 20 ++++++++++ .../SweetAlert/sample/SampleActivity.java | 22 ++++++++++- .../src/main/res/layout/sample_activity.xml | 19 ++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java index 77be52dd..bd2853ef 100644 --- a/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java +++ b/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java @@ -13,6 +13,7 @@ import android.view.animation.AnimationSet; import android.view.animation.Transformation; import android.widget.Button; +import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -55,6 +56,10 @@ public class SweetAlertDialog extends Dialog implements View.OnClickListener { private OnSweetClickListener mCancelClickListener; private OnSweetClickListener mConfirmClickListener; private boolean mCloseFromCancel; + private FrameLayout mEditTextFrame; + private EditText mEditText; + private Button mEditTextConfirmButton; + private OnEditTextSweetClickListener mEditTextConfirmClickListener; public static final int NORMAL_TYPE = 0; public static final int ERROR_TYPE = 1; @@ -62,11 +67,16 @@ 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; + public static final int EDIT_TEXT_TYPE = 6; public static interface OnSweetClickListener { public void onClick (SweetAlertDialog sweetAlertDialog); } + public static interface OnEditTextSweetClickListener { + public void onClick (SweetAlertDialog sweetAlertDialog, String inputText); + } + public SweetAlertDialog(Context context) { this(context, NORMAL_TYPE); } @@ -156,6 +166,10 @@ protected void onCreate(Bundle savedInstanceState) { mProgressHelper.setProgressWheel((ProgressWheel)findViewById(R.id.progressWheel)); mConfirmButton.setOnClickListener(this); mCancelButton.setOnClickListener(this); + mEditTextFrame = (FrameLayout)findViewById(R.id.edit_text_frame); + mEditText = (EditText)findViewById(R.id.editText); + mEditTextConfirmButton = (Button)findViewById(R.id.edit_text_confirm_button); + mEditTextConfirmButton.setOnClickListener(this); setTitleText(mTitleText); setContentText(mContentText); @@ -172,6 +186,8 @@ private void restore () { mWarningFrame.setVisibility(View.GONE); mProgressFrame.setVisibility(View.GONE); mConfirmButton.setVisibility(View.VISIBLE); + mEditTextFrame.setVisibility(View.GONE); + mEditTextConfirmButton.setVisibility(View.GONE); mConfirmButton.setBackgroundResource(R.drawable.blue_button_background); mErrorFrame.clearAnimation(); @@ -220,6 +236,12 @@ private void changeAlertType(int alertType, boolean fromCreate) { mProgressFrame.setVisibility(View.VISIBLE); mConfirmButton.setVisibility(View.GONE); break; + case EDIT_TEXT_TYPE: + mEditTextFrame.setVisibility(View.VISIBLE); + mConfirmButton.setVisibility(View.GONE); + mEditTextConfirmButton.setVisibility(View.VISIBLE); + mEditText.requestFocus(); + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } if (!fromCreate) { playAnimation(); @@ -320,6 +342,9 @@ public SweetAlertDialog setConfirmText (String text) { if (mConfirmButton != null && mConfirmText != null) { mConfirmButton.setText(mConfirmText); } + if (mEditTextConfirmButton != null && mConfirmText != null) { + mEditTextConfirmButton.setText(mConfirmText); + } return this; } @@ -333,6 +358,11 @@ public SweetAlertDialog setConfirmClickListener (OnSweetClickListener listener) return this; } + public SweetAlertDialog setEditTextConfirmClickListener (OnEditTextSweetClickListener listener) { + mEditTextConfirmClickListener = listener; + return this; + } + protected void onStart() { mDialogView.startAnimation(mModalInAnim); playAnimation(); @@ -356,6 +386,7 @@ public void dismissWithAnimation() { private void dismissWithAnimation(boolean fromCancel) { mCloseFromCancel = fromCancel; mConfirmButton.startAnimation(mOverlayOutAnim); + mEditTextConfirmButton.startAnimation(mOverlayOutAnim); mDialogView.startAnimation(mModalOutAnim); } @@ -373,6 +404,12 @@ public void onClick(View v) { } else { dismissWithAnimation(); } + } else if (v.getId() == R.id.edit_text_confirm_button) { + if (mEditTextConfirmClickListener != null) { + mEditTextConfirmClickListener.onClick(SweetAlertDialog.this, mEditText.getText().toString()); + } else { + dismissWithAnimation(); + } } } diff --git a/library/src/main/res/layout/alert_dialog.xml b/library/src/main/res/layout/alert_dialog.xml index 7972157f..a17ae5fe 100644 --- a/library/src/main/res/layout/alert_dialog.xml +++ b/library/src/main/res/layout/alert_dialog.xml @@ -138,6 +138,20 @@ android:textColor="#797979" android:visibility="gone" /> + + + + + +