diff --git a/MaterialDesign/build.gradle b/MaterialDesign/build.gradle index 2861056..d7795cf 100644 --- a/MaterialDesign/build.gradle +++ b/MaterialDesign/build.gradle @@ -25,8 +25,8 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 21 - versionCode 3 - versionName '1.1.1' + versionCode 5 + versionName '1.3' } } @@ -35,8 +35,8 @@ ext.issueUrl = 'https://github.com/navasmdc/MaterialDesignLibrary/issues' ext.gitUrl = 'https://github.com/navasmdc/MaterialDesignLibrary.git' bintray { - user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "navasmdc" - key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : "c27d6095b4b3880b5eacf18a5eed3a4ed582e5f3" + user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "" + key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : "" configurations = ["archives"] pkg { diff --git a/MaterialDesign/res/layout/progress_dialog.xml b/MaterialDesign/res/layout/progress_dialog.xml new file mode 100644 index 0000000..38e8b07 --- /dev/null +++ b/MaterialDesign/res/layout/progress_dialog.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MaterialDesign/src/com/gc/materialdesign/views/Button.java b/MaterialDesign/src/com/gc/materialdesign/views/Button.java index c4f7c48..9b4c64a 100644 --- a/MaterialDesign/src/com/gc/materialdesign/views/Button.java +++ b/MaterialDesign/src/com/gc/materialdesign/views/Button.java @@ -24,15 +24,17 @@ public abstract class Button extends CustomView { int minWidth; int minHeight; int background; - float rippleSpeed = 10f; + float rippleSpeed = 12f; int rippleSize = 3; Integer rippleColor; OnClickListener onClickListener; + boolean clickAfterRipple = true; int backgroundColor = Color.parseColor("#1E88E5"); public Button(Context context, AttributeSet attrs) { super(context, attrs); setDefaultProperties(); + clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"animate", true); setAttributes(attrs); beforeBackground = backgroundColor; if(rippleColor==null) @@ -80,6 +82,9 @@ public boolean onTouchEvent(MotionEvent event) { if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) { radius++; + if(!clickAfterRipple && onClickListener != null){ + onClickListener.onClick(this); + } } else { isLastTouch = false; x = -1; @@ -125,7 +130,7 @@ public Bitmap makeCircle() { x = -1; y = -1; radius = getHeight() / rippleSize; - if (onClickListener != null) + if (onClickListener != null&& clickAfterRipple) onClickListener.onClick(this); } return output; diff --git a/MaterialDesign/src/com/gc/materialdesign/views/ButtonFlat.java b/MaterialDesign/src/com/gc/materialdesign/views/ButtonFlat.java index 11dbd0a..b1664c9 100644 --- a/MaterialDesign/src/com/gc/materialdesign/views/ButtonFlat.java +++ b/MaterialDesign/src/com/gc/materialdesign/views/ButtonFlat.java @@ -79,7 +79,7 @@ protected void onDraw(Canvas canvas) { x = -1; y = -1; radius = getHeight()/rippleSize; - if(onClickListener != null) + if(onClickListener != null&& clickAfterRipple) onClickListener.onClick(this); } invalidate(); diff --git a/MaterialDesign/src/com/gc/materialdesign/views/ButtonIcon.java b/MaterialDesign/src/com/gc/materialdesign/views/ButtonIcon.java index 0637b2f..2c820bc 100644 --- a/MaterialDesign/src/com/gc/materialdesign/views/ButtonIcon.java +++ b/MaterialDesign/src/com/gc/materialdesign/views/ButtonIcon.java @@ -16,7 +16,7 @@ public class ButtonIcon extends ButtonFloat { public ButtonIcon(Context context, AttributeSet attrs) { super(context, attrs); setBackground(new ColorDrawable(getResources().getColor(android.R.color.transparent))); - rippleSpeed = Utils.dpToPx(2, getResources()); + rippleSpeed = Utils.dpToPx(6, getResources()); rippleSize = Utils.dpToPx(5, getResources()); } @@ -43,7 +43,7 @@ protected void onDraw(Canvas canvas) { x = -1; y = -1; radius = getHeight()/rippleSize; - if(onClickListener != null) + if(onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } invalidate(); diff --git a/MaterialDesign/src/com/gc/materialdesign/widgets/Dialog.java b/MaterialDesign/src/com/gc/materialdesign/widgets/Dialog.java index 2558393..b6c4f44 100644 --- a/MaterialDesign/src/com/gc/materialdesign/widgets/Dialog.java +++ b/MaterialDesign/src/com/gc/materialdesign/widgets/Dialog.java @@ -165,7 +165,7 @@ public void setOnCancelButtonClickListener( View.OnClickListener onCancelButtonClickListener) { this.onCancelButtonClickListener = onCancelButtonClickListener; if(buttonCancel != null) - buttonCancel.setOnClickListener(onAcceptButtonClickListener); + buttonCancel.setOnClickListener(onCancelButtonClickListener); } @Override diff --git a/MaterialDesign/src/com/gc/materialdesign/widgets/ProgressDialog.java b/MaterialDesign/src/com/gc/materialdesign/widgets/ProgressDialog.java new file mode 100644 index 0000000..e83a6b6 --- /dev/null +++ b/MaterialDesign/src/com/gc/materialdesign/widgets/ProgressDialog.java @@ -0,0 +1,139 @@ +package com.gc.materialdesign.widgets; + +import android.content.Context; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnTouchListener; +import android.view.Window; +import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.gc.materialdesign.R; +import com.gc.materialdesign.views.ButtonFlat; +import com.gc.materialdesign.views.ProgressBarCircularIndeterminate; + +public class ProgressDialog extends android.app.Dialog{ + + Context context; + View view; + View backView; + String title; + TextView titleTextView; + + int progressColor = -1; + + public ProgressDialog(Context context,String title) { + super(context, android.R.style.Theme_Translucent); + this.title = title; + this.context = context; + } + + public ProgressDialog(Context context,String title, int progressColor) { + super(context, android.R.style.Theme_Translucent); + this.title = title; + this.progressColor = progressColor; + this.context = context; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + super.onCreate(savedInstanceState); + setContentView(R.layout.progress_dialog); + + view = (RelativeLayout)findViewById(R.id.contentDialog); + backView = (RelativeLayout)findViewById(R.id.dialog_rootView); + backView.setOnTouchListener(new OnTouchListener() { + + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getX() < view.getLeft() + || event.getX() >view.getRight() + || event.getY() > view.getBottom() + || event.getY() < view.getTop()) { + dismiss(); + } + return false; + } + }); + + this.titleTextView = (TextView) findViewById(R.id.title); + setTitle(title); + if(progressColor != -1){ + ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate); + progressBarCircularIndeterminate.setBackgroundColor(progressColor); + } + + + } + + @Override + public void show() { + // TODO 自动生成的方法存根 + super.show(); + // set dialog enter animations + view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination)); + backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin)); + } + + // GETERS & SETTERS + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + if(title == null) + titleTextView.setVisibility(View.GONE); + else{ + titleTextView.setVisibility(View.VISIBLE); + titleTextView.setText(title); + } + } + + public TextView getTitleTextView() { + return titleTextView; + } + + public void setTitleTextView(TextView titleTextView) { + this.titleTextView = titleTextView; + } + + @Override + public void dismiss() { + Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); + anim.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationStart(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationEnd(Animation animation) { + view.post(new Runnable() { + @Override + public void run() { + ProgressDialog.super.dismiss(); + } + }); + + } + }); + Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); + + view.startAnimation(anim); + backView.startAnimation(backAnim); + } + + + +} diff --git a/build.gradle b/build.gradle index 722823f..735f036 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,6 @@ allprojects { } group = "com.github.navasmdc" - version = "1.1.1" + version = "1.3" } diff --git a/gradle.properties b/gradle.properties index ddca79d..2b7ccca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.1.1 -VERSION_CODE=3 +VERSION_NAME=1.3 +VERSION_CODE=5 GROUP=com.github.navasmdc