Skip to content

Commit 648ab88

Browse files
committed
Merge pull request navasmdc#113 from navasmdc/develop
Fix Bugs Fix bug in the ButtonIcon Fix bug with the animation of the views Fix bugs in the CheckBox and Switch Fix bug in the CancelButton in the Dialog, now the Dialog has got one button by default, if you want add cancelButton, you have to call addCancelButton() function.
2 parents 469c3e9 + 1d5cbfa commit 648ab88

File tree

11 files changed

+69
-28
lines changed

11 files changed

+69
-28
lines changed

MaterialDesign/build.gradle

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

@@ -35,7 +35,7 @@ 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 : ""
38+
user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "navasmdc"
3939
key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : ""
4040

4141
configurations = ["archives"]

MaterialDesign/res/layout/dialog.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,16 @@
5959
android:id="@+id/button_cancel"
6060
android:layout_width="wrap_content"
6161
android:layout_height="wrap_content"
62-
android:text="Cancel"
63-
android:textColor="#000" />
62+
android:text="Cancel"
63+
android:background="#000000"
64+
android:visibility="gone" />
6465

6566
<com.gc.materialdesign.views.ButtonFlat
6667
android:id="@+id/button_accept"
6768
android:layout_width="wrap_content"
6869
android:layout_height="wrap_content"
6970
android:text="Accept"
70-
android:textColor="#1E88E5" />
71+
android:background="#1E88E5" />
7172
</LinearLayout>
7273
</RelativeLayout>
7374

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ public ButtonFloat(Context context, AttributeSet attrs) {
5050
icon.setScaleType(ScaleType.CENTER_CROP);
5151
if(drawableIcon != null) {
5252
icon.setImageDrawable(drawableIcon);
53-
// try {
54-
// icon.setBackground(drawableIcon);
55-
// } catch (NoSuchMethodError e) {
56-
// icon.setBackgroundDrawable(drawableIcon);
57-
// }
5853
}
5954
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
6055
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ public class ButtonIcon extends ButtonFloat {
1515

1616
public ButtonIcon(Context context, AttributeSet attrs) {
1717
super(context, attrs);
18-
setBackground(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
19-
rippleSpeed = Utils.dpToPx(6, getResources());
18+
try {
19+
setBackground(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
20+
} catch (NoSuchMethodError e) {
21+
setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
22+
}
23+
rippleSpeed = Utils.dpToPx(2, getResources());
2024
rippleSize = Utils.dpToPx(5, getResources());
2125
}
2226

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void setBackgroundColor(int color) {
159159
}
160160

161161
public void setChecked(boolean check) {
162+
invalidate();
162163
this.check = check;
163164
setPressed(false);
164165
changeBackgroundColor(getResources().getColor(

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.gc.materialdesign.views;
22

33
import android.content.Context;
4+
import android.graphics.Canvas;
45
import android.graphics.Color;
56
import android.util.AttributeSet;
67
import android.widget.RelativeLayout;
@@ -30,4 +31,25 @@ public void setEnabled(boolean enabled) {
3031
setBackgroundColor(disabledBackgroundColor);
3132
invalidate();
3233
}
34+
35+
boolean animation = false;
36+
37+
@Override
38+
protected void onAnimationStart() {
39+
super.onAnimationStart();
40+
animation = true;
41+
}
42+
43+
@Override
44+
protected void onAnimationEnd() {
45+
super.onAnimationEnd();
46+
animation = false;
47+
}
48+
49+
@Override
50+
protected void onDraw(Canvas canvas) {
51+
super.onDraw(canvas);
52+
if(animation)
53+
invalidate();
54+
}
3355
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public void setBackgroundColor(int color) {
194194
}
195195

196196
public void setChecked(boolean check) {
197+
invalidate();
197198
this.check = check;
198199
ball.animateCheck();
199200
}

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,29 @@ public class Dialog extends android.app.Dialog{
2828
ButtonFlat buttonAccept;
2929
ButtonFlat buttonCancel;
3030

31+
String buttonCancelText;
32+
3133
View.OnClickListener onAcceptButtonClickListener;
3234
View.OnClickListener onCancelButtonClickListener;
3335

34-
36+
3537
public Dialog(Context context,String title, String message) {
3638
super(context, android.R.style.Theme_Translucent);
3739
this.context = context;// init Context
3840
this.message = message;
3941
this.title = title;
4042
}
4143

44+
public void addCancelButton(String buttonCancelText){
45+
this.buttonCancelText = buttonCancelText;
46+
}
47+
48+
public void addCancelButton(String buttonCancelText, View.OnClickListener onCancelButtonClickListener){
49+
this.buttonCancelText = buttonCancelText;
50+
this.onCancelButtonClickListener = onCancelButtonClickListener;
51+
}
52+
53+
4254
@Override
4355
protected void onCreate(Bundle savedInstanceState) {
4456
requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -76,16 +88,21 @@ public void onClick(View v) {
7688
onAcceptButtonClickListener.onClick(v);
7789
}
7890
});
79-
this.buttonCancel = (ButtonFlat) findViewById(R.id.button_cancel);
80-
buttonCancel.setOnClickListener(new View.OnClickListener() {
81-
82-
@Override
83-
public void onClick(View v) {
84-
dismiss();
85-
if(onCancelButtonClickListener != null)
86-
onCancelButtonClickListener.onClick(v);
87-
}
88-
});
91+
92+
if(buttonCancelText != null){
93+
this.buttonCancel = (ButtonFlat) findViewById(R.id.button_cancel);
94+
this.buttonCancel.setVisibility(View.VISIBLE);
95+
this.buttonCancel.setText(buttonCancelText);
96+
buttonCancel.setOnClickListener(new View.OnClickListener() {
97+
98+
@Override
99+
public void onClick(View v) {
100+
dismiss();
101+
if(onCancelButtonClickListener != null)
102+
onCancelButtonClickListener.onClick(v);
103+
}
104+
});
105+
}
89106
}
90107

91108
@Override

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
If you want use this library, you only have to download MaterialDesign project, import it into your workspace and add the project as a library in your android project settings.
3232

33-
If you prefer it, you can use the grade dependency, you have to add these lines in your buil.gradle file:
33+
If you prefer it, you can use the gradle dependency, you have to add these lines in your build.gradle file:
3434

3535
```xml
3636
repositories {

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.3"
22+
version = "1.4"
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.3
21-
VERSION_CODE=5
20+
VERSION_NAME=1.4
21+
VERSION_CODE=6
2222

2323
GROUP=com.github.navasmdc
2424

0 commit comments

Comments
 (0)