├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── net │ │ └── liang │ │ └── customuiapplication │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── better │ │ │ └── customuiapplication │ │ │ └── MainActivity.java │ └── res │ │ ├── color │ │ ├── green.xml │ │ └── red.xml │ │ ├── drawable │ │ └── m_button_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── net │ └── liang │ └── customuiapplication │ └── ExampleUnitTest.java ├── build.gradle ├── customui ├── .gitignore ├── README.md ├── bintrayUpload.gradle ├── build.gradle ├── proguard-rules.pro ├── project.properties └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── better │ │ └── customui │ │ ├── utils │ │ └── NetworkUtils.java │ │ └── widget │ │ ├── ImageProgress.java │ │ ├── NetworkStateView.java │ │ ├── ShapeButton.java │ │ └── ShapeEditText.java │ └── res │ ├── layout │ └── view_network_state.xml │ ├── mipmap │ └── base_img_plaint.png │ └── values │ └── attrs.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── readme ├── Readme_ImageProgress.md └── Readme_ShapeButton.md └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | bintray.properties 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://img.shields.io/badge/moven%20center-1.2.6-brightgreen.svg?style=flat)](https://bintray.com/betterliang/Android/customui) 2 | ![](https://img.shields.io/badge/minSdk-15-blue.svg) 3 | [![](https://img.shields.io/github/stars/lianghuiyong/CustomUI.svg)](https://github.com/lianghuiyong/CustomUI/stargazers) 4 | [![](https://img.shields.io/github/forks/lianghuiyong/CustomUI.svg)](https://github.com/lianghuiyong/CustomUI/network) 5 | 6 | # Gradle 7 | ```gradle 8 | compile 'com.better.android:customui:x.y.z' 9 | ``` 10 | 11 | # Color-Style 12 | ```xml 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ``` 24 | 25 | # 说明 26 | ``` 27 | app:stroke :细线宽度(不设置时,背景色会铺满按钮) 28 | app:radius :拐角半径 29 | app:buttonColor: 按钮颜色(支持Color style 30 | ``` 31 | 32 | # 示例 33 | ShapeButton | Explain | Sample 34 | --- | --- | --- 35 | Enable |
| app:radius="1.5dp"
app:stroke="0.2dp"
app:buttonColor="@color/green" 36 | Disable |
| android:enabled="false"
app:radius="1.5dp"
app:stroke="0.2dp"
app:buttonColor="@color/green" 37 | Enable |
| app:radius="1.5dp"
app:buttonColor="@color/green" 38 | Disable |
| android:enabled="false"
app:radius="1.5dp"
app:buttonColor="@color/green" 39 | 40 | ShapeEditText | Explain | Sample 41 | --- | --- | --- 42 | Enable |
| app:radius="1.5dp"
app:stroke="0.2dp"
app:buttonColor="@color/green" 43 | Disable |
| android:enabled="false"
app:radius="1.5dp"
app:stroke="0.2dp"
app:buttonColor="@color/green" -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | defaultConfig { 7 | applicationId "net.liang.customuiapplication" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':customui') 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 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 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/net/liang/customuiapplication/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package net.liang.customuiapplication; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("net.liang.customuiapplication", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/better/customuiapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.better.customuiapplication; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_main); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/color/green.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/color/red.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/m_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 26 | 27 | 30 | 31 | 34 | 35 | 47 | 48 | 60 | 61 | 62 | 65 | 66 | 76 | 77 | 87 | 88 | 89 | 92 | 103 | 104 | 116 | 117 | 118 | 121 | 130 | 131 | 141 | 142 | 143 | 146 | 156 | 157 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #00000000 8 | #000000 9 | #ffffff 10 | 11 | #10000000 12 | #20000000 13 | #30000000 14 | #40000000 15 | #50000000 16 | #60000000 17 | #70000000 18 | #80000000 19 | #90000000 20 | #a0000000 21 | #b0000000 22 | #c0000000 23 | #d0000000 24 | #e0000000 25 | #f0000000 26 | 27 | #10ffffff 28 | #20ffffff 29 | #30ffffff 30 | #40ffffff 31 | #50ffffff 32 | #60ffffff 33 | #70ffffff 34 | #80ffffff 35 | #90ffffff 36 | #a0ffffff 37 | #b0ffffff 38 | #c0ffffff 39 | #d0ffffff 40 | #e0ffffff 41 | #f0ffffff 42 | 43 | 44 | #fde0dc 45 | #f9bdbb 46 | #f69988 47 | #f36c60 48 | #e84e40 49 | #e51c23 50 | #dd191d 51 | #d01716 52 | #c41411 53 | #b0120a 54 | #ff7997 55 | #ff5177 56 | #ff2d6f 57 | #e00032 58 | 59 | 60 | #fce4ec 61 | #f8bbd0 62 | #f48fb1 63 | #f06292 64 | #ec407a 65 | #e91e63 66 | #d81b60 67 | #c2185b 68 | #ad1457 69 | #880e4f 70 | #ff80ab 71 | #ff4081 72 | #f50057 73 | #c51162 74 | 75 | 76 | #f3e5f5 77 | #e1bee7 78 | #ce93d8 79 | #ba68c8 80 | #ab47bc 81 | #9c27b0 82 | #8e24aa 83 | #7b1fa2 84 | #6a1b9a 85 | #4a148c 86 | #ea80fc 87 | #e040fb 88 | #d500f9 89 | #aa00ff 90 | 91 | 92 | #ede7f6 93 | #d1c4e9 94 | #b39ddb 95 | #9575cd 96 | #7e57c2 97 | #673ab7 98 | #5e35b1 99 | #512da8 100 | #4527a0 101 | #311b92 102 | #b388ff 103 | #7c4dff 104 | #651fff 105 | #6200ea 106 | 107 | 108 | #e8eaf6 109 | #c5cae9 110 | #9fa8da 111 | #7986cb 112 | #5c6bc0 113 | #3f51b5 114 | #3949ab 115 | #303f9f 116 | #283593 117 | #1a237e 118 | #8c9eff 119 | #536dfe 120 | #3d5afe 121 | #304ffe 122 | 123 | 124 | #e7e9fd 125 | #d0d9ff 126 | #afbfff 127 | #91a7ff 128 | #738ffe 129 | #5677fc 130 | #4e6cef 131 | #455ede 132 | #3b50ce 133 | #2a36b1 134 | #a6baff 135 | #6889ff 136 | #4d73ff 137 | #4d69ff 138 | 139 | 140 | #e1f5fe 141 | #b3e5fc 142 | #81d4fa 143 | #4fc3f7 144 | #29b6f6 145 | #03a9f4 146 | #039be5 147 | #0288d1 148 | #0277bd 149 | #01579b 150 | #80d8ff 151 | #40c4ff 152 | #00b0ff 153 | #0091ea 154 | 155 | 156 | #e0f7fa 157 | #b2ebf2 158 | #80deea 159 | #4dd0e1 160 | #26c6da 161 | #00bcd4 162 | #00acc1 163 | #0097a7 164 | #00838f 165 | #006064 166 | #84ffff 167 | #18ffff 168 | #00e5ff 169 | #00b8d4 170 | 171 | 172 | #e0f2f1 173 | #b2dfdb 174 | #80cbc4 175 | #4db6ac 176 | #26a69a 177 | #009688 178 | #00897b 179 | #00796b 180 | #00695c 181 | #004d40 182 | #a7ffeb 183 | #64ffda 184 | #1de9b6 185 | #00bfa5 186 | 187 | 188 | #d0f8ce 189 | #a3e9a4 190 | #72d572 191 | #42bd41 192 | #2baf2b 193 | #259b24 194 | #0a8f08 195 | #0a7e07 196 | #056f00 197 | #0d5302 198 | #a2f78d 199 | #5af158 200 | #14e715 201 | #12c700 202 | 203 | 204 | #f1f8e9 205 | #dcedc8 206 | #c5e1a5 207 | #aed581 208 | #9ccc65 209 | #8bc34a 210 | #7cb342 211 | #689f38 212 | #558b2f 213 | #33691e 214 | #ccff90 215 | #b2ff59 216 | #76ff03 217 | #64dd17 218 | 219 | 220 | #f9fbe7 221 | #f0f4c3 222 | #e6ee9c 223 | #dce775 224 | #d4e157 225 | #cddc39 226 | #c0ca33 227 | #afb42b 228 | #9e9d24 229 | #827717 230 | #f4ff81 231 | #eeff41 232 | #c6ff00 233 | #aeea00 234 | 235 | 236 | #fffde7 237 | #fff9c4 238 | #fff59d 239 | #fff176 240 | #ffee58 241 | #ffeb3b 242 | #fdd835 243 | #fbc02d 244 | #f9a825 245 | #f57f17 246 | #ffff8d 247 | #ffff00 248 | #ffea00 249 | #ffd600 250 | 251 | 252 | #fff8e1 253 | #ffecb3 254 | #ffe082 255 | #ffd54f 256 | #ffca28 257 | #ffc107 258 | #ffb300 259 | #ffa000 260 | #ff8f00 261 | #ff6f00 262 | #ffe57f 263 | #ffd740 264 | #ffc400 265 | #ffab00 266 | 267 | 268 | #fff3e0 269 | #ffe0b2 270 | #ffcc80 271 | #ffb74d 272 | #ffa726 273 | #ff9800 274 | #fb8c00 275 | #f57c00 276 | #ef6c00 277 | #e65100 278 | #ffd180 279 | #ffab40 280 | #ff9100 281 | #ff6d00 282 | 283 | 284 | #fbe9e7 285 | #ffccbc 286 | #ffab91 287 | #ff8a65 288 | #ff7043 289 | #ff5722 290 | #f4511e 291 | #e64a19 292 | #d84315 293 | #bf360c 294 | #ff9e80 295 | #ff6e40 296 | #ff3d00 297 | #dd2c00 298 | 299 | 300 | #efebe9 301 | #d7ccc8 302 | #bcaaa4 303 | #a1887f 304 | #8d6e63 305 | #795548 306 | #6d4c41 307 | #5d4037 308 | #4e342e 309 | #3e2723 310 | 311 | 312 | #fafafa 313 | #f5f5f5 314 | #eeeeee 315 | #e0e0e0 316 | #bdbdbd 317 | #9e9e9e 318 | #757575 319 | #616161 320 | #424242 321 | #212121 322 | 323 | 324 | #eceff1 325 | #cfd8dc 326 | #b0bec5 327 | #90a4ae 328 | #78909c 329 | #607d8b 330 | #546e7a 331 | #455a64 332 | #37474f 333 | #263238 334 | 335 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 4sp 7 | 6sp 8 | 8sp 9 | 10sp 10 | 12sp 11 | 14sp 12 | 16sp 13 | 18sp 14 | 20sp 15 | 22sp 16 | 24sp 17 | 28sp 18 | 32sp 19 | 34sp 20 | 38sp 21 | 44sp 22 | 56sp 23 | 112sp 24 | 25 | 2dp 26 | 4dp 27 | 6dp 28 | 8dp 29 | 10dp 30 | 12dp 31 | 14dp 32 | 16dp 33 | 20dp 34 | 24dp 35 | 28dp 36 | 32dp 37 | 36dp 38 | 40dp 39 | 44dp 40 | 48dp 41 | 52dp 42 | 56dp 43 | 60dp 44 | 64dp 45 | 68dp 46 | 72dp 47 | 76dp 48 | 80dp 49 | 84dp 50 | 88dp 51 | 92dp 52 | 96dp 53 | 100dp 54 | 116dp 55 | 128dp 56 | 156dp 57 | 172dp 58 | 224dp 59 | 256dp 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CustomUIApplication 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/net/liang/customuiapplication/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package net.liang.customuiapplication; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /customui/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /customui/README.md: -------------------------------------------------------------------------------- 1 | #bintray.properties 2 | 3 | ``` 4 | #配置bintray账号相关信息 5 | #bintray用户名,不是登陆邮箱,是个人中心右上角显示的名字 6 | bintray.user=************* 7 | #bintray的ApiKey 8 | bintray.apiKey=************* 9 | #bintray的Organization Id 10 | bintray.organizationId=********* 11 | 12 | 13 | #配置开发者信息 14 | #昵称 15 | developer.id=************* 16 | #姓名 17 | developer.name=************* 18 | #邮箱 19 | developer.email=*************@email.com 20 | ``` 21 | -------------------------------------------------------------------------------- /customui/bintrayUpload.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.dcendents.android-maven' 2 | apply plugin: 'com.jfrog.bintray' 3 | 4 | //加载属性文件 5 | Properties properties = new Properties() 6 | File localPropertiesFile = project.file("bintray.properties"); 7 | if (localPropertiesFile.exists()) { 8 | properties.load(localPropertiesFile.newDataInputStream()) 9 | } 10 | File projectPropertiesFile = project.file("project.properties"); 11 | if (projectPropertiesFile.exists()) { 12 | properties.load(projectPropertiesFile.newDataInputStream()) 13 | } 14 | 15 | //读取属性 16 | def projectRepositoryName = properties.getProperty("project.repositoryName") 17 | def projectName = properties.getProperty("project.name") 18 | def projectGroupId = properties.getProperty("project.groupId") 19 | def projectArtifactId = properties.getProperty("project.artifactId") 20 | def projectVersionName = android.defaultConfig.versionName 21 | def projectPackaging = properties.getProperty("project.packaging") 22 | def projectSiteUrl = properties.getProperty("project.siteUrl") 23 | def projectGitUrl = properties.getProperty("project.gitUrl") 24 | 25 | def developerId = properties.getProperty("developer.id") 26 | def developerName = properties.getProperty("developer.name") 27 | def developerEmail = properties.getProperty("developer.email") 28 | 29 | def bintrayUser = properties.getProperty("bintray.user") 30 | def bintrayApikey = properties.getProperty("bintray.apiKey") 31 | def bintrayOrganizationId = properties.getProperty("bintray.organizationId"); 32 | 33 | def javadocName = properties.getProperty("javadoc.name") 34 | 35 | /* 36 | *这句代码一定要加否则会出现如下错误 37 | * Could not upload to 'https://api.bintray.com/content/coolcode/maven/LibUiBase/1.0.0/CommonLibrary/LibUiBase/1.0.0/LibUiBase-1.0.0.pom': HTTP/1.1 400 Bad Request [ 38 | message:Unable to upload files: Maven group, artifact or version defined in the pom file do not match the file path 'CommonLibrary/LibUiBase/1.0.0/LibUiBase-1.0.0.p 39 | om'] 40 | * */ 41 | group = projectGroupId 42 | 43 | // 配置生成POM.xml文件的参数 44 | install { 45 | repositories.mavenInstaller { 46 | pom { 47 | project { 48 | name projectName 49 | groupId projectGroupId 50 | artifactId projectArtifactId 51 | version projectVersionName 52 | packaging projectPackaging 53 | url projectSiteUrl 54 | licenses { 55 | license { 56 | name 'The Apache Software License, Version 2.0' 57 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 58 | } 59 | } 60 | developers { 61 | developer { 62 | id developerId 63 | name developerName 64 | email developerEmail 65 | } 66 | } 67 | scm { 68 | connection projectGitUrl 69 | developerConnection projectGitUrl 70 | url projectSiteUrl 71 | } 72 | } 73 | } 74 | } 75 | } 76 | 77 | tasks.withType(Javadoc) { 78 | options.addStringOption('Xdoclint:none', '-quiet') 79 | options.addStringOption('encoding', 'UTF-8') 80 | options.addStringOption('charSet', 'UTF-8') 81 | } 82 | 83 | // This generates sources.jar 84 | task sourcesJar(type: Jar) { 85 | from android.sourceSets.main.java.srcDirs 86 | classifier = 'sources' 87 | } 88 | 89 | //This generates javadocJar.jar 90 | task javadoc(type: Javadoc) { 91 | source = android.sourceSets.main.java.srcDirs 92 | classpath += configurations.compile 93 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 94 | } 95 | 96 | task javadocJar(type: Jar, dependsOn: javadoc) { 97 | classifier = 'javadoc' 98 | from javadoc.destinationDir 99 | } 100 | 101 | 102 | artifacts { 103 | archives javadocJar 104 | archives sourcesJar 105 | } 106 | 107 | //javadoc的配置 108 | javadoc { 109 | options { 110 | encoding "UTF-8" 111 | charSet 'UTF-8' 112 | author true 113 | version projectVersionName 114 | links "http://docs.oracle.com/javase/7/docs/api" 115 | title javadocName 116 | } 117 | } 118 | 119 | /* 120 | *userOrg为bintray账号信息里面的Organization Id 121 | *repo为你创建的仓库名称 122 | * 如果上述两个字段写错了,则会出现下面类似的错误 123 | *Could not create package 'huangxuanheng/maven/fragmentstack': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found] 124 | * 125 | * 126 | * */ 127 | bintray { 128 | user = bintrayUser 129 | key = bintrayApikey 130 | configurations = ['archives'] 131 | pkg { 132 | userOrg = bintrayOrganizationId 133 | repo = projectRepositoryName 134 | name = projectName 135 | websiteUrl = projectSiteUrl 136 | vcsUrl = projectGitUrl 137 | licenses = ["Apache-2.0"] 138 | publish = true 139 | } 140 | } -------------------------------------------------------------------------------- /customui/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' 11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 12 | } 13 | } 14 | 15 | android { 16 | compileSdkVersion 25 17 | buildToolsVersion "25.0.2" 18 | 19 | defaultConfig { 20 | minSdkVersion 15 21 | targetSdkVersion 25 22 | versionCode 1 23 | versionName "1.5.0" 24 | 25 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 26 | 27 | } 28 | buildTypes { 29 | release { 30 | minifyEnabled false 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | } 33 | } 34 | } 35 | 36 | dependencies { 37 | compile fileTree(dir: 'libs', include: ['*.jar']) 38 | compile 'com.android.support:appcompat-v7:25.2.0' 39 | } 40 | 41 | apply from: "bintrayUpload.gradle" -------------------------------------------------------------------------------- /customui/proguard-rules.pro: -------------------------------------------------------------------------------- 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 | #} 18 | -------------------------------------------------------------------------------- /customui/project.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/customui/project.properties -------------------------------------------------------------------------------- /customui/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /customui/src/main/java/com/better/customui/utils/NetworkUtils.java: -------------------------------------------------------------------------------- 1 | package com.better.customui.utils; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.ConnectivityManager; 6 | import android.net.NetworkInfo; 7 | import android.telephony.TelephonyManager; 8 | 9 | import java.net.InetAddress; 10 | import java.net.UnknownHostException; 11 | import java.util.concurrent.Callable; 12 | import java.util.concurrent.ExecutionException; 13 | import java.util.concurrent.ExecutorService; 14 | import java.util.concurrent.Executors; 15 | import java.util.concurrent.Future; 16 | 17 | /** 18 | *
 19 |  *     author: Blankj
 20 |  *     blog  : http://blankj.com
 21 |  *     time  : 2016/8/2
 22 |  *     desc  : 网络相关工具类
 23 |  * 
24 | */ 25 | public class NetworkUtils { 26 | 27 | private NetworkUtils() { 28 | throw new UnsupportedOperationException("u can't instantiate me..."); 29 | } 30 | 31 | public static final int NETWORK_WIFI = 1; // wifi network 32 | public static final int NETWORK_4G = 4; // "4G" networks 33 | public static final int NETWORK_3G = 3; // "3G" networks 34 | public static final int NETWORK_2G = 2; // "2G" networks 35 | public static final int NETWORK_UNKNOWN = 5; // unknown network 36 | public static final int NETWORK_NO = -1; // no network 37 | 38 | private static final int NETWORK_TYPE_GSM = 16; 39 | private static final int NETWORK_TYPE_TD_SCDMA = 17; 40 | private static final int NETWORK_TYPE_IWLAN = 18; 41 | 42 | private static final String CMCC_ISP = "46000";//中国移动 43 | private static final String CMCC2_ISP = "46002";//中国移动 44 | private static final String CU_ISP = "46001";//中国联通 45 | private static final String CT_ISP = "46003";//中国电信 46 | 47 | /** 48 | * 打开网络设置界面 49 | *

3.0以下打开设置界面

50 | * 51 | * @param context 上下文 52 | */ 53 | public static void openWirelessSettings(Context context) { 54 | if (android.os.Build.VERSION.SDK_INT > 10) { 55 | context.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS)); 56 | } else { 57 | context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS)); 58 | } 59 | } 60 | 61 | /** 62 | * 获取活动网络信息 63 | * 64 | * @param context 上下文 65 | * @return NetworkInfo 66 | */ 67 | private static NetworkInfo getActiveNetworkInfo(Context context) { 68 | ConnectivityManager cm = (ConnectivityManager) context 69 | .getSystemService(Context.CONNECTIVITY_SERVICE); 70 | return cm.getActiveNetworkInfo(); 71 | } 72 | 73 | /** 74 | * 判断网络是否可用 75 | *

需添加权限 {@code }

76 | * 77 | * @param context 上下文 78 | * @return {@code true}: 可用
{@code false}: 不可用 79 | */ 80 | public static boolean isAvailable(Context context) { 81 | NetworkInfo info = getActiveNetworkInfo(context); 82 | return info != null && info.isAvailable(); 83 | } 84 | 85 | /** 86 | * 判断网络是否连接 87 | *

需添加权限 {@code }

88 | * 89 | * @param context 上下文 90 | * @return {@code true}: 是
{@code false}: 否 91 | */ 92 | public static boolean isConnected(Context context) { 93 | NetworkInfo info = getActiveNetworkInfo(context); 94 | return info != null && info.isConnected(); 95 | } 96 | 97 | /** 98 | * 判断网络是否是4G 99 | *

需添加权限 {@code }

100 | * 101 | * @param context 上下文 102 | * @return {@code true}: 是
{@code false}: 否 103 | */ 104 | public static boolean is4G(Context context) { 105 | NetworkInfo info = getActiveNetworkInfo(context); 106 | return info != null && info.isAvailable() && info.getSubtype() == TelephonyManager.NETWORK_TYPE_LTE; 107 | } 108 | 109 | /** 110 | * 判断wifi是否连接状态 111 | *

需添加权限 {@code }

112 | * 113 | * @param context 上下文 114 | * @return {@code true}: 连接
{@code false}: 未连接 115 | */ 116 | public static boolean isWifiConnected(Context context) { 117 | ConnectivityManager cm = (ConnectivityManager) context 118 | .getSystemService(Context.CONNECTIVITY_SERVICE); 119 | return cm != null && cm.getActiveNetworkInfo() != null 120 | && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI; 121 | } 122 | 123 | /** 124 | * 获取移动网络运营商名称 125 | *

中国移动、如中国联通、中国电信

126 | * 127 | * @param context 上下文 128 | * @return 移动网络运营商名称 129 | */ 130 | public static String getNetworkOperatorName(Context context) { 131 | TelephonyManager tm = (TelephonyManager) context 132 | .getSystemService(Context.TELEPHONY_SERVICE); 133 | String np = tm != null ? tm.getNetworkOperatorName() : null; 134 | String teleCompany = "unknown"; 135 | if (np != null) { 136 | if (np.equals(CMCC_ISP) || np.equals(CMCC2_ISP)) { 137 | teleCompany = "中国移动"; 138 | } else if (np.startsWith(CU_ISP)) { 139 | teleCompany = "中国联通"; 140 | } else if (np.startsWith(CT_ISP)) { 141 | teleCompany = "中国电信"; 142 | } 143 | } 144 | return teleCompany; 145 | } 146 | 147 | /** 148 | * 获取移动终端类型 149 | * 150 | * @param context 上下文 151 | * @return 手机制式 152 | * 158 | */ 159 | public static int getPhoneType(Context context) { 160 | TelephonyManager tm = (TelephonyManager) context 161 | .getSystemService(Context.TELEPHONY_SERVICE); 162 | return tm != null ? tm.getPhoneType() : -1; 163 | } 164 | 165 | 166 | /** 167 | * 获取当前的网络类型(WIFI,2G,3G,4G) 168 | *

需添加权限 {@code }

169 | * 170 | * @param context 上下文 171 | * @return 网络类型 172 | * 180 | */ 181 | public static int getNetWorkType(Context context) { 182 | int netType = NETWORK_NO; 183 | NetworkInfo info = getActiveNetworkInfo(context); 184 | if (info != null && info.isAvailable()) { 185 | 186 | if (info.getType() == ConnectivityManager.TYPE_WIFI) { 187 | netType = NETWORK_WIFI; 188 | } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { 189 | switch (info.getSubtype()) { 190 | 191 | case NETWORK_TYPE_GSM: 192 | case TelephonyManager.NETWORK_TYPE_GPRS: 193 | case TelephonyManager.NETWORK_TYPE_CDMA: 194 | case TelephonyManager.NETWORK_TYPE_EDGE: 195 | case TelephonyManager.NETWORK_TYPE_1xRTT: 196 | case TelephonyManager.NETWORK_TYPE_IDEN: 197 | netType = NETWORK_2G; 198 | break; 199 | 200 | case NETWORK_TYPE_TD_SCDMA: 201 | case TelephonyManager.NETWORK_TYPE_EVDO_A: 202 | case TelephonyManager.NETWORK_TYPE_UMTS: 203 | case TelephonyManager.NETWORK_TYPE_EVDO_0: 204 | case TelephonyManager.NETWORK_TYPE_HSDPA: 205 | case TelephonyManager.NETWORK_TYPE_HSUPA: 206 | case TelephonyManager.NETWORK_TYPE_HSPA: 207 | case TelephonyManager.NETWORK_TYPE_EVDO_B: 208 | case TelephonyManager.NETWORK_TYPE_EHRPD: 209 | case TelephonyManager.NETWORK_TYPE_HSPAP: 210 | netType = NETWORK_3G; 211 | break; 212 | 213 | case NETWORK_TYPE_IWLAN: 214 | case TelephonyManager.NETWORK_TYPE_LTE: 215 | netType = NETWORK_4G; 216 | break; 217 | default: 218 | 219 | String subtypeName = info.getSubtypeName(); 220 | if (subtypeName.equalsIgnoreCase("TD-SCDMA") 221 | || subtypeName.equalsIgnoreCase("WCDMA") 222 | || subtypeName.equalsIgnoreCase("CDMA2000")) { 223 | netType = NETWORK_3G; 224 | } else { 225 | netType = NETWORK_UNKNOWN; 226 | } 227 | break; 228 | } 229 | } else { 230 | netType = NETWORK_UNKNOWN; 231 | } 232 | } 233 | return netType; 234 | } 235 | 236 | /** 237 | * 获取当前的网络类型(WIFI,2G,3G,4G) 238 | *

依赖上面的方法

239 | * 240 | * @param context 上下文 241 | * @return 网络类型名称 242 | * 250 | */ 251 | public static String getNetWorkTypeName(Context context) { 252 | switch (getNetWorkType(context)) { 253 | case NETWORK_WIFI: 254 | return "NETWORK_WIFI"; 255 | case NETWORK_4G: 256 | return "NETWORK_4G"; 257 | case NETWORK_3G: 258 | return "NETWORK_3G"; 259 | case NETWORK_2G: 260 | return "NETWORK_2G"; 261 | case NETWORK_NO: 262 | return "NETWORK_NO"; 263 | default: 264 | return "NETWORK_UNKNOWN"; 265 | } 266 | } 267 | 268 | /** 269 | * 根据域名获取ip地址 270 | * 271 | * @param domain 域名 272 | * @return ip地址 273 | */ 274 | public static String getIpAddress(final String domain) { 275 | try { 276 | ExecutorService exec = Executors.newCachedThreadPool(); 277 | Future fs = exec.submit(new Callable() { 278 | @Override 279 | public String call() throws Exception { 280 | InetAddress inetAddress; 281 | try { 282 | inetAddress = InetAddress.getByName(domain); 283 | return inetAddress.getHostAddress(); 284 | } catch (UnknownHostException e) { 285 | e.printStackTrace(); 286 | return null; 287 | } 288 | } 289 | }); 290 | return fs.get(); 291 | } catch (InterruptedException | ExecutionException e) { 292 | e.printStackTrace(); 293 | return null; 294 | } 295 | } 296 | } -------------------------------------------------------------------------------- /customui/src/main/java/com/better/customui/widget/ImageProgress.java: -------------------------------------------------------------------------------- 1 | package com.better.customui.widget; 2 | 3 | 4 | import android.annotation.SuppressLint; 5 | import android.content.Context; 6 | import android.content.res.ColorStateList; 7 | import android.content.res.TypedArray; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.graphics.Rect; 12 | import android.util.AttributeSet; 13 | import android.view.View; 14 | 15 | import com.better.customui.R; 16 | 17 | public class ImageProgress extends View { 18 | 19 | private Paint mPaint;//画笔 20 | 21 | Context context; 22 | 23 | int mCenterX; 24 | int mCenterY; 25 | 26 | /** 27 | * 进度值。 28 | */ 29 | int progress = 0; 30 | 31 | /** 32 | * 进度字体的大小。 33 | */ 34 | private float textSize; 35 | 36 | public ImageProgress(Context context) { 37 | this(context, null); 38 | } 39 | 40 | public ImageProgress(Context context, AttributeSet attrs) { 41 | this(context, attrs, 0); 42 | } 43 | 44 | public ImageProgress(Context context, AttributeSet attrs, int defStyleAttr) { 45 | super(context, attrs, defStyleAttr); 46 | this.context = context; 47 | mPaint = new Paint(); 48 | 49 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ImageProgress); 50 | textSize = typedArray.getDimension(R.styleable.ImageProgress_text_size, 15); 51 | } 52 | 53 | @SuppressLint("DrawAllocation") 54 | @Override 55 | protected void onDraw(Canvas canvas) { 56 | super.onDraw(canvas); 57 | mPaint.setAntiAlias(true); //消除锯齿 58 | mPaint.setStyle(Paint.Style.FILL); 59 | 60 | mPaint.setColor(Color.parseColor("#70000000"));//半透明 61 | canvas.drawRect(0, 0, getWidth(), getHeight() - getHeight() * progress / 100, mPaint); 62 | 63 | mPaint.setColor(Color.parseColor("#00000000"));//全透明 64 | canvas.drawRect(0, getHeight() - getHeight() * progress / 100, getWidth(), getHeight(), mPaint); 65 | 66 | mPaint.setTextSize(textSize); 67 | mPaint.setColor(Color.parseColor("#FFFFFF")); 68 | mPaint.setStrokeWidth(2); 69 | 70 | canvas.translate(mCenterX, mCenterY); 71 | mPaint.setTextAlign(Paint.Align.CENTER); 72 | drawTextByCenter(progress + "%", 0, 0, canvas, mPaint); 73 | } 74 | 75 | @Override 76 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 77 | super.onSizeChanged(w, h, oldw, oldh); 78 | mCenterX = w / 2; 79 | mCenterY = h / 2; 80 | } 81 | 82 | /** 83 | * 居中绘制文本 84 | * 85 | * @param text 86 | * @param canvas 87 | * @param paint 88 | */ 89 | public void drawTextByCenter(String text, float x, float y, Canvas canvas, Paint paint) { 90 | Paint tempPaint = new Paint(paint); // 创建一个临时画笔,防止影响原来画笔的状态 91 | tempPaint.setTextAlign(Paint.Align.CENTER); // 设置文本对齐方式为居中 92 | 93 | // 通过y计算出baseline的位置 94 | float baseline = y - (tempPaint.descent() + tempPaint.ascent()) / 2; 95 | 96 | canvas.drawText(text, x, baseline, tempPaint); //绘制文本 97 | } 98 | 99 | /** 100 | * 进度 101 | * 102 | * @param progress 103 | */ 104 | public void setProgress(int progress) { 105 | this.progress = progress; 106 | postInvalidate(); 107 | } 108 | } 109 | 110 | -------------------------------------------------------------------------------- /customui/src/main/java/com/better/customui/widget/NetworkStateView.java: -------------------------------------------------------------------------------- 1 | package com.better.customui.widget; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.IntentFilter; 7 | import android.net.ConnectivityManager; 8 | import android.support.annotation.AttrRes; 9 | import android.support.annotation.NonNull; 10 | import android.support.annotation.Nullable; 11 | import android.util.AttributeSet; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.widget.FrameLayout; 15 | 16 | import com.better.customui.R; 17 | import com.better.customui.utils.NetworkUtils; 18 | 19 | /** 20 | * Created by yuzhihua on 2017/7/10. 21 | */ 22 | 23 | public class NetworkStateView extends FrameLayout { 24 | 25 | private View view; 26 | private Context context; 27 | private NetWorkStateReceiver mReceiver; 28 | 29 | public NetworkStateView(@NonNull Context context) { 30 | super(context); 31 | init(context); 32 | } 33 | 34 | public NetworkStateView(@NonNull Context context, @Nullable AttributeSet attrs) { 35 | super(context, attrs); 36 | init(context); 37 | } 38 | 39 | public NetworkStateView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { 40 | super(context, attrs, defStyleAttr); 41 | init(context); 42 | } 43 | 44 | private void init(Context context) { 45 | this.context = context; 46 | view = LayoutInflater.from(context).inflate(R.layout.view_network_state, this); 47 | 48 | if (view.isInEditMode()) { 49 | return; 50 | } 51 | 52 | startNetReceiver(context); 53 | } 54 | 55 | //动态启动网络监听广播 56 | private void startNetReceiver(Context context){ 57 | IntentFilter mFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); 58 | mReceiver = new NetWorkStateReceiver(); 59 | context.registerReceiver(mReceiver, mFilter); 60 | } 61 | 62 | @Override 63 | protected void onDetachedFromWindow() { 64 | super.onDetachedFromWindow(); 65 | if (mReceiver != null){ 66 | context.unregisterReceiver(mReceiver); 67 | } 68 | } 69 | 70 | /** 71 | * Created by Liang on 2017/4/5. 72 | */ 73 | public class NetWorkStateReceiver extends BroadcastReceiver { 74 | 75 | @Override 76 | public void onReceive(Context context, Intent intent) { 77 | 78 | if (NetworkUtils.isConnected(context)) { 79 | showView(false); 80 | } else { 81 | showView(true); 82 | } 83 | } 84 | 85 | private void showView(boolean isShow) { 86 | if (view != null) { 87 | setVisibility(isShow ? VISIBLE : GONE); 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /customui/src/main/java/com/better/customui/widget/ShapeButton.java: -------------------------------------------------------------------------------- 1 | package com.better.customui.widget; 2 | 3 | import android.content.Context; 4 | import android.content.res.ColorStateList; 5 | import android.content.res.TypedArray; 6 | import android.graphics.Color; 7 | import android.graphics.drawable.GradientDrawable; 8 | import android.graphics.drawable.StateListDrawable; 9 | import android.os.Build; 10 | import android.util.AttributeSet; 11 | import android.view.Gravity; 12 | 13 | import com.better.customui.R; 14 | 15 | /** 16 | * Created by lenovo on 2017/2/28. 17 | */ 18 | 19 | public class ShapeButton extends android.support.v7.widget.AppCompatButton { 20 | 21 | private float radius; 22 | private float stroke; 23 | private ColorStateList colors; 24 | 25 | public ShapeButton(Context context, AttributeSet attrs) { 26 | super(context, attrs); 27 | init(context, attrs); 28 | } 29 | 30 | public ShapeButton(Context context, AttributeSet attrs, int defStyleAttr) { 31 | super(context, attrs, defStyleAttr); 32 | init(context, attrs); 33 | } 34 | 35 | void init(Context context, AttributeSet attrs) { 36 | setClickable(true); 37 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeButton); 38 | radius = typedArray.getDimension(R.styleable.ShapeButton_radius, 0); 39 | stroke = typedArray.getDimension(R.styleable.ShapeButton_stroke, 0); 40 | colors = typedArray.getColorStateList(R.styleable.ShapeButton_buttonColor); 41 | 42 | StateListDrawable selector = getSelector(); 43 | 44 | if (Build.VERSION.SDK_INT < 16) { 45 | setBackgroundDrawable(selector); 46 | } else { 47 | setBackground(selector); 48 | } 49 | setGravity(Gravity.CENTER); 50 | } 51 | 52 | public GradientDrawable getDrawable(int state) { 53 | GradientDrawable gradientDrawable = new GradientDrawable(); 54 | gradientDrawable.setShape(GradientDrawable.RECTANGLE); 55 | 56 | int color_pressed = colors.getColorForState(new int[]{android.R.attr.state_pressed}, 0); 57 | int color_disable = colors.getColorForState(new int[]{-android.R.attr.state_enabled}, 0); 58 | int color_normal = colors.getColorForState(new int[]{android.R.attr.state_enabled}, 0); 59 | 60 | switch (state) { 61 | case android.R.attr.state_pressed: 62 | gradientDrawable.setColor(stroke == 0 ? color_pressed : Color.parseColor("#0C000000"));//设置颜色 63 | gradientDrawable.setStroke(dp2px(stroke), color_pressed);//描边 64 | break; 65 | 66 | case -android.R.attr.state_enabled: 67 | gradientDrawable.setColor(stroke == 0 ? color_disable : Color.parseColor("#06000000"));//设置颜色 68 | gradientDrawable.setStroke(dp2px(stroke), color_disable);//描边 69 | break; 70 | 71 | case android.R.attr.state_enabled: 72 | gradientDrawable.setColor(stroke == 0 ? color_normal : Color.parseColor("#00000000"));//设置颜色 73 | gradientDrawable.setStroke(dp2px(stroke), color_normal);//描边 74 | break; 75 | } 76 | gradientDrawable.setCornerRadius(dp2px(radius));//设置圆角的半径 77 | return gradientDrawable; 78 | } 79 | 80 | public StateListDrawable getSelector() { 81 | 82 | StateListDrawable stateListDrawable = new StateListDrawable(); 83 | 84 | //注意该处的顺序,只要有一个状态与之相配,背景就会被换掉 85 | //所以不要把大范围放在前面了,如果sd.addState(new[]{},normal)放在第一个的话,就没有什么效果了 86 | stateListDrawable.addState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled}, getDrawable(android.R.attr.state_pressed)); 87 | stateListDrawable.addState(new int[]{-android.R.attr.state_enabled}, getDrawable(-android.R.attr.state_enabled)); 88 | stateListDrawable.addState(new int[]{}, getDrawable(android.R.attr.state_enabled)); 89 | 90 | return stateListDrawable; 91 | } 92 | 93 | /** 94 | * dp转px 95 | * 96 | * @param dpValue dp值 97 | * @return px值 98 | */ 99 | public int dp2px(float dpValue) { 100 | final float scale = getResources().getDisplayMetrics().density; 101 | return (int) (dpValue * scale + 0.5f); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /customui/src/main/java/com/better/customui/widget/ShapeEditText.java: -------------------------------------------------------------------------------- 1 | package com.better.customui.widget; 2 | 3 | import android.content.Context; 4 | import android.content.res.ColorStateList; 5 | import android.content.res.TypedArray; 6 | import android.graphics.Color; 7 | import android.graphics.drawable.GradientDrawable; 8 | import android.graphics.drawable.StateListDrawable; 9 | import android.os.Build; 10 | import android.util.AttributeSet; 11 | import android.view.Gravity; 12 | 13 | import com.better.customui.R; 14 | 15 | /** 16 | * Created by lenovo on 2017/2/28. 17 | */ 18 | 19 | public class ShapeEditText extends android.support.v7.widget.AppCompatEditText { 20 | 21 | private float radius; 22 | private float stroke; 23 | private ColorStateList colors; 24 | 25 | public ShapeEditText(Context context, AttributeSet attrs) { 26 | super(context, attrs); 27 | init(context, attrs); 28 | } 29 | 30 | public ShapeEditText(Context context, AttributeSet attrs, int defStyleAttr) { 31 | super(context, attrs, defStyleAttr); 32 | init(context, attrs); 33 | } 34 | 35 | void init(Context context, AttributeSet attrs) { 36 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeButton); 37 | radius = typedArray.getDimension(R.styleable.ShapeButton_radius, 0); 38 | stroke = typedArray.getDimension(R.styleable.ShapeButton_stroke, 0); 39 | colors = typedArray.getColorStateList(R.styleable.ShapeButton_buttonColor); 40 | 41 | StateListDrawable selector = getSelector(); 42 | 43 | if (Build.VERSION.SDK_INT < 16) { 44 | setBackgroundDrawable(selector); 45 | } else { 46 | setBackground(selector); 47 | } 48 | } 49 | 50 | public GradientDrawable getDrawable(int state) { 51 | GradientDrawable gradientDrawable = new GradientDrawable(); 52 | gradientDrawable.setShape(GradientDrawable.RECTANGLE); 53 | 54 | int color_pressed = colors.getColorForState(new int[]{android.R.attr.state_pressed}, 0); 55 | int color_disable = colors.getColorForState(new int[]{-android.R.attr.state_enabled}, 0); 56 | int color_normal = colors.getColorForState(new int[]{android.R.attr.state_enabled}, 0); 57 | 58 | switch (state) { 59 | case android.R.attr.state_pressed: 60 | gradientDrawable.setColor(stroke == 0 ? color_pressed : Color.parseColor("#0C000000"));//设置颜色 61 | gradientDrawable.setStroke(dp2px(stroke), color_pressed);//描边 62 | break; 63 | 64 | case -android.R.attr.state_enabled: 65 | gradientDrawable.setColor(stroke == 0 ? color_disable : Color.parseColor("#06000000"));//设置颜色 66 | gradientDrawable.setStroke(dp2px(stroke), color_disable);//描边 67 | break; 68 | 69 | case android.R.attr.state_enabled: 70 | gradientDrawable.setColor(stroke == 0 ? color_normal : Color.parseColor("#00000000"));//设置颜色 71 | gradientDrawable.setStroke(dp2px(stroke), color_normal);//描边 72 | break; 73 | } 74 | gradientDrawable.setCornerRadius(dp2px(radius));//设置圆角的半径 75 | return gradientDrawable; 76 | } 77 | 78 | public StateListDrawable getSelector() { 79 | 80 | StateListDrawable stateListDrawable = new StateListDrawable(); 81 | 82 | //注意该处的顺序,只要有一个状态与之相配,背景就会被换掉 83 | //所以不要把大范围放在前面了,如果sd.addState(new[]{},normal)放在第一个的话,就没有什么效果了 84 | stateListDrawable.addState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled}, getDrawable(android.R.attr.state_pressed)); 85 | stateListDrawable.addState(new int[]{-android.R.attr.state_enabled}, getDrawable(-android.R.attr.state_enabled)); 86 | stateListDrawable.addState(new int[]{}, getDrawable(android.R.attr.state_enabled)); 87 | 88 | return stateListDrawable; 89 | } 90 | 91 | /** 92 | * dp转px 93 | * 94 | * @param dpValue dp值 95 | * @return px值 96 | */ 97 | public int dp2px(float dpValue) { 98 | final float scale = getResources().getDisplayMetrics().density; 99 | return (int) (dpValue * scale + 0.5f); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /customui/src/main/res/layout/view_network_state.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 20 | 21 | -------------------------------------------------------------------------------- /customui/src/main/res/mipmap/base_img_plaint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/customui/src/main/res/mipmap/base_img_plaint.png -------------------------------------------------------------------------------- /customui/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianghuiyong/CustomUI/f5739e1f2123fad2b05ff61e0dfde947b9caf53b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun May 28 16:00:33 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /readme/Readme_ImageProgress.md: -------------------------------------------------------------------------------- 1 | # 仿QQ图片上传进度UI 2 | 3 | ##XML 4 | ``` 5 | 9 | ``` 10 | ##设置进度 11 | ``` 12 | imageProgress.setProgress(progress); 13 | ``` -------------------------------------------------------------------------------- /readme/Readme_ShapeButton.md: -------------------------------------------------------------------------------- 1 | # 做按钮,用shape画样式,NO,简单点 2 | 3 | [![](https://img.shields.io/badge/moven%20center-1.1.0-brightgreen.svg?style=flat)](https://bintray.com/betterliang/Android/customui) 4 | ![](https://img.shields.io/badge/minSdk-15-blue.svg) 5 | [![](https://img.shields.io/github/stars/lianghuiyong/CustomUI.svg)](https://github.com/lianghuiyong/CustomUI/stargazers) 6 | [![](https://img.shields.io/github/forks/lianghuiyong/CustomUI.svg)](https://github.com/lianghuiyong/CustomUI/network) 7 | 8 | ```gradle 9 | compile 'com.better.android:customui:x.y.z' 10 | ``` 11 | 12 | ## 可定制属性 13 | 14 | ``` 15 | app:stroke :细线宽度(不设置时,背景色会铺满按钮) 16 | app:radius :拐角半径 17 | app:buttonColor: 按钮颜色(支持Color style) 18 | ``` 19 | 20 | ```xml 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ``` 32 | ## 示例 33 | ```xml 34 | 37 | 38 | 49 | 50 | 59 | 60 | 70 | 71 | 72 | ``` 73 |
74 | 75 |
-------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':customui' 2 | --------------------------------------------------------------------------------