Skip to content

Commit 469c3e9

Browse files
committed
Merge pull request navasmdc#98 from navasmdc/develop
Add ProgressDialog widget and fix bugs
2 parents c8f18bf + 4c12fbe commit 469c3e9

File tree

9 files changed

+193
-13
lines changed

9 files changed

+193
-13
lines changed

MaterialDesign/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ android {
2525
defaultConfig {
2626
minSdkVersion 8
2727
targetSdkVersion 21
28-
versionCode 3
29-
versionName '1.1.1'
28+
versionCode 5
29+
versionName '1.3'
3030
}
3131
}
3232

@@ -35,8 +35,8 @@ ext.issueUrl = 'https://github.com/navasmdc/MaterialDesignLibrary/issues'
3535
ext.gitUrl = 'https://github.com/navasmdc/MaterialDesignLibrary.git'
3636

3737
bintray {
38-
user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "navasmdc"
39-
key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : "c27d6095b4b3880b5eacf18a5eed3a4ed582e5f3"
38+
user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : ""
39+
key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : ""
4040

4141
configurations = ["archives"]
4242
pkg {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/dialog_rootView"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#55000000"
7+
android:padding="32dp" >
8+
9+
<RelativeLayout
10+
android:id="@+id/contentDialog"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:layout_centerInParent="true"
14+
android:background="@drawable/dialog_background"
15+
android:padding="24dp" >
16+
17+
<com.gc.materialdesign.views.ProgressBarCircularIndeterminate
18+
android:id="@+id/progressBarCircularIndetermininate"
19+
android:layout_width="32dp"
20+
android:layout_height="32dp"
21+
android:layout_centerVertical="true"
22+
android:background="#1E88E5" />
23+
24+
<TextView
25+
android:id="@+id/title"
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:layout_centerVertical="true"
29+
android:layout_toRightOf="@+id/progressBarCircularIndetermininate"
30+
android:layout_marginLeft="8dp"
31+
android:text="Title"
32+
android:textAppearance="?android:attr/textAppearanceLarge"
33+
android:textColor="#000" />
34+
</RelativeLayout>
35+
36+
</RelativeLayout>

MaterialDesign/src/com/gc/materialdesign/views/Button.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ public abstract class Button extends CustomView {
2424
int minWidth;
2525
int minHeight;
2626
int background;
27-
float rippleSpeed = 10f;
27+
float rippleSpeed = 12f;
2828
int rippleSize = 3;
2929
Integer rippleColor;
3030
OnClickListener onClickListener;
31+
boolean clickAfterRipple = true;
3132
int backgroundColor = Color.parseColor("#1E88E5");
3233

3334
public Button(Context context, AttributeSet attrs) {
3435
super(context, attrs);
3536
setDefaultProperties();
37+
clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"animate", true);
3638
setAttributes(attrs);
3739
beforeBackground = backgroundColor;
3840
if(rippleColor==null)
@@ -80,6 +82,9 @@ public boolean onTouchEvent(MotionEvent event) {
8082
if ((event.getX() <= getWidth() && event.getX() >= 0)
8183
&& (event.getY() <= getHeight() && event.getY() >= 0)) {
8284
radius++;
85+
if(!clickAfterRipple && onClickListener != null){
86+
onClickListener.onClick(this);
87+
}
8388
} else {
8489
isLastTouch = false;
8590
x = -1;
@@ -125,7 +130,7 @@ public Bitmap makeCircle() {
125130
x = -1;
126131
y = -1;
127132
radius = getHeight() / rippleSize;
128-
if (onClickListener != null)
133+
if (onClickListener != null&& clickAfterRipple)
129134
onClickListener.onClick(this);
130135
}
131136
return output;

MaterialDesign/src/com/gc/materialdesign/views/ButtonFlat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected void onDraw(Canvas canvas) {
7979
x = -1;
8080
y = -1;
8181
radius = getHeight()/rippleSize;
82-
if(onClickListener != null)
82+
if(onClickListener != null&& clickAfterRipple)
8383
onClickListener.onClick(this);
8484
}
8585
invalidate();

MaterialDesign/src/com/gc/materialdesign/views/ButtonIcon.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ButtonIcon extends ButtonFloat {
1616
public ButtonIcon(Context context, AttributeSet attrs) {
1717
super(context, attrs);
1818
setBackground(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
19-
rippleSpeed = Utils.dpToPx(2, getResources());
19+
rippleSpeed = Utils.dpToPx(6, getResources());
2020
rippleSize = Utils.dpToPx(5, getResources());
2121
}
2222

@@ -43,7 +43,7 @@ protected void onDraw(Canvas canvas) {
4343
x = -1;
4444
y = -1;
4545
radius = getHeight()/rippleSize;
46-
if(onClickListener != null)
46+
if(onClickListener != null && clickAfterRipple)
4747
onClickListener.onClick(this);
4848
}
4949
invalidate();

MaterialDesign/src/com/gc/materialdesign/widgets/Dialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void setOnCancelButtonClickListener(
165165
View.OnClickListener onCancelButtonClickListener) {
166166
this.onCancelButtonClickListener = onCancelButtonClickListener;
167167
if(buttonCancel != null)
168-
buttonCancel.setOnClickListener(onAcceptButtonClickListener);
168+
buttonCancel.setOnClickListener(onCancelButtonClickListener);
169169
}
170170

171171
@Override
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package com.gc.materialdesign.widgets;
2+
3+
import android.content.Context;
4+
import android.os.Bundle;
5+
import android.view.MotionEvent;
6+
import android.view.View;
7+
import android.view.View.OnTouchListener;
8+
import android.view.Window;
9+
import android.view.animation.Animation;
10+
import android.view.animation.Animation.AnimationListener;
11+
import android.view.animation.AnimationUtils;
12+
import android.widget.RelativeLayout;
13+
import android.widget.TextView;
14+
15+
import com.gc.materialdesign.R;
16+
import com.gc.materialdesign.views.ButtonFlat;
17+
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
18+
19+
public class ProgressDialog extends android.app.Dialog{
20+
21+
Context context;
22+
View view;
23+
View backView;
24+
String title;
25+
TextView titleTextView;
26+
27+
int progressColor = -1;
28+
29+
public ProgressDialog(Context context,String title) {
30+
super(context, android.R.style.Theme_Translucent);
31+
this.title = title;
32+
this.context = context;
33+
}
34+
35+
public ProgressDialog(Context context,String title, int progressColor) {
36+
super(context, android.R.style.Theme_Translucent);
37+
this.title = title;
38+
this.progressColor = progressColor;
39+
this.context = context;
40+
}
41+
42+
@Override
43+
protected void onCreate(Bundle savedInstanceState) {
44+
requestWindowFeature(Window.FEATURE_NO_TITLE);
45+
super.onCreate(savedInstanceState);
46+
setContentView(R.layout.progress_dialog);
47+
48+
view = (RelativeLayout)findViewById(R.id.contentDialog);
49+
backView = (RelativeLayout)findViewById(R.id.dialog_rootView);
50+
backView.setOnTouchListener(new OnTouchListener() {
51+
52+
@Override
53+
public boolean onTouch(View v, MotionEvent event) {
54+
if (event.getX() < view.getLeft()
55+
|| event.getX() >view.getRight()
56+
|| event.getY() > view.getBottom()
57+
|| event.getY() < view.getTop()) {
58+
dismiss();
59+
}
60+
return false;
61+
}
62+
});
63+
64+
this.titleTextView = (TextView) findViewById(R.id.title);
65+
setTitle(title);
66+
if(progressColor != -1){
67+
ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate);
68+
progressBarCircularIndeterminate.setBackgroundColor(progressColor);
69+
}
70+
71+
72+
}
73+
74+
@Override
75+
public void show() {
76+
// TODO 自动生成的方法存根
77+
super.show();
78+
// set dialog enter animations
79+
view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination));
80+
backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin));
81+
}
82+
83+
// GETERS & SETTERS
84+
85+
public String getTitle() {
86+
return title;
87+
}
88+
89+
public void setTitle(String title) {
90+
this.title = title;
91+
if(title == null)
92+
titleTextView.setVisibility(View.GONE);
93+
else{
94+
titleTextView.setVisibility(View.VISIBLE);
95+
titleTextView.setText(title);
96+
}
97+
}
98+
99+
public TextView getTitleTextView() {
100+
return titleTextView;
101+
}
102+
103+
public void setTitleTextView(TextView titleTextView) {
104+
this.titleTextView = titleTextView;
105+
}
106+
107+
@Override
108+
public void dismiss() {
109+
Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
110+
anim.setAnimationListener(new AnimationListener() {
111+
112+
@Override
113+
public void onAnimationStart(Animation animation) {
114+
}
115+
116+
@Override
117+
public void onAnimationRepeat(Animation animation) {
118+
}
119+
120+
@Override
121+
public void onAnimationEnd(Animation animation) {
122+
view.post(new Runnable() {
123+
@Override
124+
public void run() {
125+
ProgressDialog.super.dismiss();
126+
}
127+
});
128+
129+
}
130+
});
131+
Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);
132+
133+
view.startAnimation(anim);
134+
backView.startAnimation(backAnim);
135+
}
136+
137+
138+
139+
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ allprojects {
1919
}
2020

2121
group = "com.github.navasmdc"
22-
version = "1.1.1"
22+
version = "1.3"
2323
}
2424

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
1919

20-
VERSION_NAME=1.1.1
21-
VERSION_CODE=3
20+
VERSION_NAME=1.3
21+
VERSION_CODE=5
2222

2323
GROUP=com.github.navasmdc
2424

0 commit comments

Comments
 (0)