Skip to content

Commit 580c6f6

Browse files
committed
Merge pull request #67 from shark0017/master
Fix Bugs of Slider and Switch
2 parents 57fc470 + bcdf792 commit 580c6f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+227
-130
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.6

MaterialDesign/AndroidManifest.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
android:versionCode="1"
44
android:versionName="1.0" >
55

6-
<uses-sdk
7-
android:minSdkVersion="8"
8-
android:targetSdkVersion="19" />
6+
<uses-sdk android:minSdkVersion="8" />
97

10-
<application
11-
android:allowBackup="true"
12-
android:label="@string/app_name" >
13-
14-
</application>
8+
<application android:allowBackup="true" />
159

16-
</manifest>
10+
</manifest>

MaterialDesign/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-19
14+
target=android-8
1515
android.library=true

MaterialDesign/res/layout/text.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

MaterialDesign/res/values/attributes.xml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<resources>
3-
4-
<declare-styleable name="CustomAttributes">
5-
6-
<!-- Speed of ripple animation -->
7-
<attr name="rippleSpeed" format="float" />
8-
<!-- in float button indicate if must start with animation -->
9-
<attr name="rippleColor" format="color|reference" />
10-
<!-- indicate if the slider must show number indicator -->
11-
<attr name="showNumberIndicator" format="boolean" />
12-
<!-- in progress view indicate max value of progress -->
13-
<attr name="max" format="integer" />
14-
<!-- in progress view indicate min value of progress -->
15-
<attr name="min" format="integer" />
16-
<!-- in progress view indicate value of progress -->
17-
<attr name="value" format="integer" />
18-
<!-- in progress view indicate value of progress -->
19-
<attr name="progress" format="integer" />
20-
<attr name="ringWidth" format="dimension"/>
21-
<!-- in switche's view indicate state of view -->
22-
<attr name="checked" format="boolean" />
23-
<attr name="checkBoxSize" format="dimension" />
24-
<attr name="thumbSize" format="dimension" />
25-
<!-- in float button indicate icon resource -->
26-
<attr name="iconDrawable" format="integer" />
27-
<!-- in float button indicate icon resource -->
28-
<attr name="iconSize" format="dimension" />
29-
<!-- in float button indicate if must start with animation -->
30-
<attr name="animate" format="boolean" />
31-
<attr name="rippleBorderRadius" format="float" />
32-
<attr name="clickAfterRipple" format="boolean"/>
33-
</declare-styleable>
34-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<declare-styleable name="CustomAttributes">
4+
5+
<!-- Color of ripple animation -->
6+
<attr name="rippleColor" format="color|reference" />
7+
<!-- Speed of ripple animation -->
8+
<attr name="rippleSpeed" format="float" />
9+
<!-- indicate if the slider must show number indicator -->
10+
<attr name="showNumberIndicator" format="boolean" />
11+
<!-- in progress view indicate max value of progress -->
12+
<attr name="max" format="integer" />
13+
<!-- in progress view indicate min value of progress -->
14+
<attr name="min" format="integer" />
15+
<!-- in progress view indicate value of progress -->
16+
<attr name="value" format="integer" />
17+
<!-- in progress view indicate value of progress -->
18+
<attr name="progress" format="integer" />
19+
<attr name="ringWidth" format="dimension" />
20+
<!-- in switche's view indicate state of view -->
21+
<attr name="checked" format="boolean" />
22+
<attr name="checkBoxSize" format="dimension" />
23+
<attr name="thumbSize" format="dimension" />
24+
<!-- in float button indicate icon resource -->
25+
<attr name="iconDrawable" format="integer" />
26+
<!-- in button whitch contains drawable indicate icon resource -->
27+
<attr name="iconSize" format="dimension" />
28+
<!-- in float button indicate if must start with animation -->
29+
<attr name="animate" format="boolean" />
30+
<!-- set the border of the ripple frame -->
31+
<attr name="rippleBorderRadius" format="float" />
32+
<!-- if true, delays calls to OnClickListeners until ripple effect ends -->
33+
<attr name="clickAfterRipple" format="boolean" />
34+
</declare-styleable>
35+
3536
</resources>

MaterialDesign/res/values/strings.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

MaterialDesign/src/com/gc/materialdesign/utils/Utils.java

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

33
import android.content.res.Resources;
4+
import android.graphics.Rect;
45
import android.util.TypedValue;
56
import android.view.View;
67

@@ -31,12 +32,16 @@ public static float dipOrDpToFloat(String value) {
3132
}
3233

3334

35+
/**
36+
* 这里看似是得到控件相对的坐标,但是如果这个滑动条在可以上下滚动的布局中就会出现问题。
37+
* 因为这里的坐标都是死的,在上下滚动的view中父控件的top仍旧不变,但实际上是应该获得动态数值的。
38+
* @param myView
39+
* @return
40+
*/
3441
public static int getRelativeTop(View myView) {
35-
// if (myView.getParent() == myView.getRootView())
36-
if(myView.getId() == android.R.id.content)
37-
return myView.getTop();
38-
else
39-
return myView.getTop() + getRelativeTop((View) myView.getParent());
42+
Rect bounds = new Rect();
43+
myView.getGlobalVisibleRect(bounds);
44+
return bounds.top;
4045
}
4146

4247
public static int getRelativeLeft(View myView) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public Button(Context context, AttributeSet attrs) {
2121

2222
@Override
2323
protected void onInitDefaultValues() {
24-
backgroundColor = Color.parseColor("#1E88E5");// 默认的背景色,蓝色
24+
backgroundColor = Color.parseColor("#2196f3");// 默认的背景色,蓝色
2525
///beforeBackground = backgroundColor;// error
2626
}
2727

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected void onDraw(Canvas canvas) {
4646
x = -1;
4747
y = -1;
4848
radius = getHeight()/rippleSize;
49-
if (clickAfterRipple == true && onClickListener != null) {
49+
if (isEnabled() && clickAfterRipple == true && onClickListener != null) {
5050
onClickListener.onClick(this);
5151
}
5252
}
@@ -58,9 +58,9 @@ protected void onDraw(Canvas canvas) {
5858
public void setBackgroundColor(int color) {
5959
super.setBackgroundColor(color);
6060
if (!settedRippleColor) {
61+
// 如果之前没有设置过涟漪颜色,那么就用默认的
6162
rippleColor = Color.parseColor("#88DDDDDD");
6263
}
63-
//textButton.setTextColor(color);
6464
}
6565

6666

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ public Bitmap cropCircle(Bitmap bitmap) {
138138

139139
// GET AND SET
140140

141+
/* @Override
142+
public void setEnabled(boolean enabled) {
143+
// TODO 自动生成的方法存根
144+
super.setEnabled(enabled);
145+
icon.setEnabled(enabled);
146+
if (enabled) {
147+
getBackground().setAlpha(255);
148+
}else {
149+
getBackground().setAlpha(25);
150+
}
151+
}*/
152+
141153
public void isAnimate(boolean isAnimate) {
142154
if (isAnimate) {
143155
playAnimation();

0 commit comments

Comments
 (0)