Skip to content

Commit 7fed932

Browse files
committed
refactor
1 parent 347f26e commit 7fed932

75 files changed

Lines changed: 2282 additions & 654 deletions

File tree

Some content is hidden

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

ColorPicker/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
/*.iml

ColorPicker/build.gradle

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion Integer.parseInt(System.properties['compileSdkVersion'].toString())
5+
buildToolsVersion System.properties['buildToolsVersion']
6+
7+
defaultConfig {
8+
minSdkVersion Integer.parseInt(System.properties['minSdkVersion'].toString())
9+
targetSdkVersion Integer.parseInt(System.properties['compileSdkVersion'].toString())
10+
versionCode Integer.parseInt(System.properties['versionCode'].toString())
11+
versionName System.properties['versionName']
12+
}
13+
14+
buildTypes {
15+
release {
16+
//是否zip优化
17+
zipAlignEnabled true
18+
//是否移除无用的resource
19+
shrinkResources true
20+
//是否混淆
21+
minifyEnabled false
22+
//混淆配置文件
23+
proguardFiles 'proguard-rules.pro'
24+
}
25+
}
26+
27+
lintOptions {
28+
//忽略lint错误
29+
abortOnError false
30+
}
31+
32+
packagingOptions {
33+
exclude 'META-INF/DEPENDENCIES.txt'
34+
exclude 'META-INF/LICENSE.txt'
35+
exclude 'META-INF/NOTICE.txt'
36+
exclude 'META-INF/NOTICE'
37+
exclude 'META-INF/LICENSE'
38+
exclude 'META-INF/DEPENDENCIES'
39+
exclude 'META-INF/notice.txt'
40+
exclude 'META-INF/license.txt'
41+
exclude 'META-INF/dependencies.txt'
42+
exclude 'META-INF/LGPL2.1'
43+
exclude 'META-INF/ASL2.0'
44+
}
45+
46+
}
47+
48+
dependencies {
49+
compile project(':Core')
50+
}

ColorPicker/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in D:\android-sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest package="cn.qqtheme.framework.picker.color" />

Picker/src/main/java/cn/qqtheme/framework/picker/ColorPicker.java renamed to ColorPicker/src/main/java/cn/qqtheme/framework/picker/ColorPicker.java

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import android.view.inputmethod.InputMethodManager;
1111
import android.widget.*;
1212

13-
import cn.qqtheme.framework.helper.Common;
13+
import cn.qqtheme.framework.picker.color.R;
1414
import cn.qqtheme.framework.popup.ConfirmPopup;
15+
import cn.qqtheme.framework.util.CompatUtils;
16+
import cn.qqtheme.framework.util.ConvertUtils;
1517
import cn.qqtheme.framework.view.ColorPanelView;
1618

1719
import java.util.Locale;
@@ -44,8 +46,8 @@ protected LinearLayout initContentView() {
4446
blackColorView = new ColorPanelView(activity);
4547
//noinspection ResourceType
4648
blackColorView.setId(BLACK_ID);
47-
blackColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, Common.toPx(activity, 30)));
48-
blackColorView.setPointerDrawable(Common.getDrawable(activity, R.drawable.color_picker_cursor_bottom));
49+
blackColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
50+
blackColorView.setPointerDrawable(CompatUtils.getDrawable(activity, R.drawable.color_picker_cursor_bottom));
4951
blackColorView.setLockPointerInBounds(false);
5052
blackColorView.setOnColorChangedListener(new ColorPanelView.OnColorChangedListener() {
5153
@Override
@@ -58,7 +60,7 @@ public void onColorChanged(ColorPanelView view, int color) {
5860
//noinspection ResourceType
5961
multiColorView.setId(MULTI_ID);
6062
multiColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
61-
multiColorView.setPointerDrawable(Common.getDrawable(activity, R.drawable.color_picker_cursor_top));
63+
multiColorView.setPointerDrawable(CompatUtils.getDrawable(activity, R.drawable.color_picker_cursor_top));
6264
multiColorView.setLockPointerInBounds(true);
6365
multiColorView.setOnColorChangedListener(new ColorPanelView.OnColorChangedListener() {
6466
@Override
@@ -70,7 +72,7 @@ public void onColorChanged(ColorPanelView view, int color) {
7072
LinearLayout previewLayout = new LinearLayout(activity);
7173
previewLayout.setOrientation(LinearLayout.HORIZONTAL);
7274
previewLayout.setGravity(Gravity.CENTER);
73-
previewLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, Common.toPx(activity, 30)));
75+
previewLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
7476
hexValView = new EditText(activity);
7577
hexValView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
7678
hexValView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
@@ -92,7 +94,7 @@ public void onColorChanged(ColorPanelView view, int color) {
9294

9395
@Override
9496
protected void setContentViewAfter(View contentView) {
95-
setHeight(screenHeight / 2);
97+
setHeight(screen.heightPixels / 2);
9698
multiColorView.setColor(initColor);//将触发onColorChanged,故必须先待其他控件初始化完成后才能调用
9799
multiColorView.setBrightnessGradientView(blackColorView);
98100
if (onColorPickListener != null) {
@@ -101,17 +103,12 @@ protected void setContentViewAfter(View contentView) {
101103
public void onConfirm() {
102104
onColorPickListener.onColorPicked(Color.parseColor("#" + hexValView.getText()));
103105
}
104-
105-
@Override
106-
public void onCancel() {
107-
onColorPickListener.onCancel();
108-
}
109106
});
110107
}
111108
}
112109

113110
private void updateCurrentColor(int color) {
114-
String hexColorString = Common.toColorString(color, false).toUpperCase(Locale.getDefault());
111+
String hexColorString = ConvertUtils.toColorString(color, false).toUpperCase(Locale.getDefault());
115112
hexValView.setText(hexColorString);
116113
hexValView.setTextColor(hexValDefaultColor);
117114
hexValView.setBackgroundColor(color);
@@ -157,18 +154,9 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
157154
return false;
158155
}
159156

160-
public static abstract class OnColorPickListener extends OnConfirmListener {
157+
public interface OnColorPickListener {
161158

162-
public abstract void onColorPicked(int pickedColor);
163-
164-
/**
165-
* Use {@link #onColorPicked(int)} instead
166-
*/
167-
@Deprecated
168-
@Override
169-
public void onConfirm() {
170-
throw new RuntimeException("Please use onColorPicked(int) instead");
171-
}
159+
void onColorPicked(int pickedColor);
172160

173161
}
174162

Picker/src/main/java/cn/qqtheme/framework/view/ColorPanelView.java renamed to ColorPicker/src/main/java/cn/qqtheme/framework/view/ColorPanelView.java

File renamed without changes.

Picker/src/main/res/drawable-hdpi/color_picker_cursor_bottom.png renamed to ColorPicker/src/main/res/drawable-hdpi/color_picker_cursor_bottom.png

File renamed without changes.

Picker/src/main/res/drawable-hdpi/color_picker_cursor_top.png renamed to ColorPicker/src/main/res/drawable-hdpi/color_picker_cursor_top.png

File renamed without changes.
File renamed without changes.

Core/build.gradle

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion Integer.parseInt(System.properties['compileSdkVersion'].toString())
5+
buildToolsVersion System.properties['buildToolsVersion']
6+
7+
defaultConfig {
8+
minSdkVersion Integer.parseInt(System.properties['minSdkVersion'].toString())
9+
targetSdkVersion Integer.parseInt(System.properties['compileSdkVersion'].toString())
10+
versionCode Integer.parseInt(System.properties['versionCode'].toString())
11+
versionName System.properties['versionName']
12+
}
13+
14+
buildTypes {
15+
release {
16+
//是否zip优化
17+
zipAlignEnabled true
18+
//是否移除无用的resource
19+
shrinkResources true
20+
//是否混淆
21+
minifyEnabled false
22+
//混淆配置文件
23+
proguardFiles 'proguard-rules.pro'
24+
}
25+
}
26+
27+
lintOptions {
28+
//忽略lint错误
29+
abortOnError false
30+
}
31+
32+
packagingOptions {
33+
exclude 'META-INF/DEPENDENCIES.txt'
34+
exclude 'META-INF/LICENSE.txt'
35+
exclude 'META-INF/NOTICE.txt'
36+
exclude 'META-INF/NOTICE'
37+
exclude 'META-INF/LICENSE'
38+
exclude 'META-INF/DEPENDENCIES'
39+
exclude 'META-INF/notice.txt'
40+
exclude 'META-INF/license.txt'
41+
exclude 'META-INF/dependencies.txt'
42+
exclude 'META-INF/LGPL2.1'
43+
exclude 'META-INF/ASL2.0'
44+
}
45+
46+
}
47+
48+
dependencies {
49+
compile 'com.android.support:support-v4:'+System.properties['androidSupportVersion']
50+
compile 'com.android.support:support-annotations:'+System.properties['androidSupportVersion']
51+
}

0 commit comments

Comments
 (0)