├── .gitignore ├── .gradle └── 2.2.1 │ └── taskArtifacts │ ├── cache.properties │ ├── cache.properties.lock │ ├── fileHashes.bin │ ├── fileSnapshots.bin │ ├── outputFileStates.bin │ └── taskArtifacts.bin ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── libraries │ ├── appcompat_v7_23_0_1.xml │ ├── nineoldandroids_2_4_0.xml │ ├── support_annotations_23_0_1.xml │ └── support_v4_23_0_1.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml ├── vcs.xml └── workspace.xml ├── ChangeSkin.iml ├── LICENSE ├── README.md ├── SkinChangeNow.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── libs │ └── nineoldandroids-2.4.0.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zhy │ │ └── skinchangenow │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── zhy │ │ └── skinchangenow │ │ ├── MainActivity.java │ │ ├── MenuLeftFragment.java │ │ ├── TestTagActivity.java │ │ └── sample │ │ └── MyApplication.java │ └── res │ ├── drawable-nodpi │ ├── left_menu_icon.png │ ├── left_menu_icon_green.png │ ├── left_menu_icon_red.png │ ├── main_bg.jpg │ ├── main_bg_green.jpg │ └── main_bg_red.jpg │ ├── layout │ ├── activity_main.xml │ ├── activity_test_tag.xml │ ├── fragment_left_menu.xml │ └── item.xml │ ├── menu │ ├── menu_main.xml │ └── menu_test_tag.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── changeskin ├── .gitignore ├── build.gradle ├── changeskin.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zhy │ │ └── changeskin │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── zhy │ │ └── changeskin │ │ ├── ResourceManager.java │ │ ├── SkinManager.java │ │ ├── attr │ │ ├── SkinAttr.java │ │ ├── SkinAttrSupport.java │ │ ├── SkinAttrType.java │ │ └── SkinView.java │ │ ├── callback │ │ ├── ISkinChangedListener.java │ │ └── ISkinChangingCallback.java │ │ ├── constant │ │ └── SkinConfig.java │ │ └── utils │ │ ├── L.java │ │ └── PrefUtils.java │ └── res │ └── values │ ├── ids.xml │ └── strings.xml ├── changeskin_sc.gif ├── gradle.properties ├── gradle ├── .gitignore └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── night_plugin.apk ├── npm-debug.log ├── plugin ├── .gitignore ├── build.gradle ├── plugin.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zhy │ │ └── plugin │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ └── res │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── values │ ├── strings.xml │ └── styles.xml ├── settings.gradle └── skin_plugin.apk /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # OS generated files 30 | .DS_Store 31 | .DS_Store? 32 | -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/cache.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 02 16:58:44 CST 2015 2 | -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/cache.properties.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/.gradle/2.2.1/taskArtifacts/cache.properties.lock -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/.gradle/2.2.1/taskArtifacts/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/fileSnapshots.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/outputFileStates.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/.gradle/2.2.1/taskArtifacts/outputFileStates.bin -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/taskArtifacts.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | ChangeSkin -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/appcompat_v7_23_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/nineoldandroids_2_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/support_annotations_23_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_v4_23_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ChangeSkin.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AndroidChangeSkin 2 | 一种完全无侵入的换肤方式,支持插件式和应用内,无需重启Activity. 3 | 4 | 与之前发布的ChangeSkin思路完全不同[https://github.com/hongyangAndroid/ChangeSkin](https://github.com/hongyangAndroid/ChangeSkin),主要因为ChangeSkin依赖V4,V7的版本,以及干涉系统构造View的过程,于是希望找到一个几乎没有侵入的方式来实现,于是产生了AndroidChangeSkin,两个项目各有特点,目前两个项目代码都保留,欢迎试用与反馈。 5 | 6 | 7 | ## 特点 8 | * 插件式换肤 9 | * 应用内换肤 10 | * 支持插件或者应用内多套皮肤 11 | * 支持动态生成addView 12 | * 无需重启Activity 13 | 14 | 15 | 16 | 17 | ## 效果图: 18 | 19 | 20 | 21 | ## 引入 22 | 23 | 下载changeskin,作为module依赖至主项目,例如: 24 | 25 | ```xml 26 | dependencies { 27 | compile project(':changeskin') 28 | } 29 | ``` 30 | 或者直接添加依赖: 31 | 32 | ```xml 33 | dependencies { 34 | compile 'com.zhy:changeskin:4.0.2' 35 | } 36 | ``` 37 | 38 | ## 运行 39 | 40 | Android Studio,import Project形式导入,将[skin_plugin.apk](skin_plugin.apk),放置到模拟器或者真机的sdcard根目录,然后运行项目。 41 | 42 | ## 使用 43 | 44 | * Application 45 | 46 | Application中去调用`SkinManager.getInstance().init(this);`,未来版本可能会去除该步骤。 47 | 48 | 49 | ```java 50 | public class MyApplication extends Application 51 | { 52 | @Override 53 | public void onCreate() 54 | { 55 | super.onCreate(); 56 | SkinManager.getInstance().init(this); 57 | } 58 | } 59 | 60 | ``` 61 | 62 | * Activity 63 | 64 | 在需要换肤的Activity的onCreate和onDestory中,分别: 65 | 66 | ```java 67 | 68 | @Override 69 | protected void onCreate(Bundle savedInstanceState) 70 | { 71 | SkinManager.getInstance().register(this); 72 | //... 73 | } 74 | 75 | @Override 76 | protected void onDestroy() 77 | { 78 | super.onDestroy(); 79 | SkinManager.getInstance().unregister(this); 80 | } 81 | ``` 82 | 83 | * 布局文件 84 | 85 | 布局文件中添加支持,主要依赖于tag属性: 86 | 87 | 例如: 88 | 89 | ```xml 90 | 96 | ``` 97 | 98 | tag属性分为3部分组成: 99 | 100 | * skin 101 | * 资源的名称,即插件包中资源的名称,需要与当前app内使用的资源名称一致。 102 | * 支持的属性,目前支持src,background,textColor,支持扩展。 103 | 104 | 3部分,必须以:分隔拼接。 105 | 106 | 对于一个View多个属性需要换肤的,`android:tag="skin:item_text_color:textColor|skin:icon:src"` 107 | 同样使用|进行分隔。 108 | 109 | 简言之:如果你哪个View需要换肤,就添加tag属性,tag值按照上述方式设置即可。 110 | 111 | 112 | * 换肤的API 113 | 114 | 插件式: 115 | 116 | ```java 117 | SkinManager.getInstance().changeSkin( 118 | mSkinPkgPath, 119 | "com.imooc.skin_plugin", 120 | new ISkinChangingCallback() 121 | { 122 | @Override 123 | public void onStart() 124 | { 125 | } 126 | 127 | @Override 128 | public void onError(Exception e) 129 | { 130 | Toast.makeText(MainActivity.this, "换肤失败", Toast.LENGTH_SHORT).show(); 131 | } 132 | 133 | @Override 134 | public void onComplete() 135 | { 136 | Toast.makeText(MainActivity.this, "换肤成功", Toast.LENGTH_SHORT).show(); 137 | } 138 | }); 139 | ``` 140 | 141 | 应用内: 142 | 143 | ```java 144 | SkinManager.getInstance().changeSkin(suffix); 145 | ``` 146 | 应用内多套皮肤以后缀就行区别,比如:main\_bg,皮肤资源可以为:main\_bg\_red,main\_bg\_green等。 147 | 148 | 换肤时,直接传入后缀,例如上面描述的red,green。 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /SkinChangeNow.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.zhy.skinchangenow" 9 | minSdkVersion 10 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 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(dir: 'libs', include: ['*.jar']) 24 | compile files('libs/nineoldandroids-2.4.0.jar') 25 | compile project(':changeskin') 26 | compile 'com.android.support:support-v4:23.0.1' 27 | compile 'com.android.support:appcompat-v7:23.0.1' 28 | } 29 | -------------------------------------------------------------------------------- /app/libs/nineoldandroids-2.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/libs/nineoldandroids-2.4.0.jar -------------------------------------------------------------------------------- /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 /Users/zhy/android/sdk/android-sdk-macosx/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/com/zhy/skinchangenow/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.zhy.skinchangenow; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase 10 | { 11 | public ApplicationTest() 12 | { 13 | super(Application.class); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/zhy/skinchangenow/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.zhy.skinchangenow; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.Environment; 6 | import android.support.v4.app.Fragment; 7 | import android.support.v4.app.FragmentManager; 8 | import android.support.v4.widget.DrawerLayout; 9 | import android.support.v4.widget.DrawerLayout.DrawerListener; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.view.LayoutInflater; 12 | import android.view.Menu; 13 | import android.view.MenuItem; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | import android.widget.ArrayAdapter; 17 | import android.widget.ListView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.nineoldandroids.view.ViewHelper; 22 | import com.zhy.changeskin.SkinManager; 23 | 24 | import java.io.File; 25 | import java.util.ArrayList; 26 | import java.util.Arrays; 27 | import java.util.List; 28 | 29 | /** 30 | * @author zhy 31 | */ 32 | public class MainActivity extends AppCompatActivity 33 | { 34 | 35 | private DrawerLayout mDrawerLayout; 36 | private ListView mListView; 37 | private String mSkinPkgPath = Environment.getExternalStorageDirectory() + File.separator + "skin_plugin.apk"; 38 | private List mDatas = new ArrayList(Arrays.asList("Activity", "Service", "Activity", "Service", 39 | "Activity", "Service", "Activity", "Service","Activity", "Service", "Activity", "Service", 40 | "Activity", "Service", "Activity", "Service","Activity", "Service", "Activity", "Service", 41 | "Activity", "Service", "Activity", "Service","Activity", "Service", "Activity", "Service", 42 | "Activity", "Service", "Activity", "Service","Activity", "Service", "Activity", "Service", 43 | "Activity", "Service", "Activity", "Service","Activity", "Service", "Activity", "Service", 44 | "Activity", "Service", "Activity", "Service")); 45 | private ArrayAdapter mAdapter ; 46 | 47 | @Override 48 | public void onCreate(Bundle savedInstanceState) 49 | { 50 | super.onCreate(savedInstanceState); 51 | SkinManager.getInstance().register(this); 52 | setContentView(R.layout.activity_main); 53 | initView(); 54 | initEvents(); 55 | 56 | } 57 | 58 | 59 | private void initEvents() 60 | { 61 | 62 | mListView = (ListView) findViewById(R.id.id_listview); 63 | mListView.setAdapter(mAdapter = new ArrayAdapter(this, -1, mDatas) 64 | { 65 | @Override 66 | public View getView(int position, View convertView, ViewGroup parent) 67 | { 68 | if (convertView == null) 69 | { 70 | convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.item, parent 71 | , false); 72 | 73 | } 74 | SkinManager.getInstance().injectSkin(convertView); 75 | TextView tv = (TextView) convertView.findViewById(R.id.id_tv_title); 76 | tv.setText(getItem(position)); 77 | return convertView; 78 | } 79 | }); 80 | 81 | 82 | mDrawerLayout.setDrawerListener(new DrawerListener() 83 | { 84 | @Override 85 | public void onDrawerStateChanged(int newState) 86 | { 87 | } 88 | 89 | @Override 90 | public void onDrawerSlide(View drawerView, float slideOffset) 91 | { 92 | View mContent = mDrawerLayout.getChildAt(0); 93 | View mMenu = drawerView; 94 | float scale = 1 - slideOffset; 95 | float rightScale = 0.8f + scale * 0.2f; 96 | 97 | if (drawerView.getTag().equals("LEFT")) 98 | { 99 | 100 | float leftScale = 1 - 0.3f * scale; 101 | 102 | ViewHelper.setScaleX(mMenu, leftScale); 103 | ViewHelper.setScaleY(mMenu, leftScale); 104 | ViewHelper.setAlpha(mMenu, 0.6f + 0.4f * (1 - scale)); 105 | ViewHelper.setTranslationX(mContent, 106 | mMenu.getMeasuredWidth() * (1 - scale)); 107 | ViewHelper.setPivotX(mContent, 0); 108 | ViewHelper.setPivotY(mContent, 109 | mContent.getMeasuredHeight() / 2); 110 | mContent.invalidate(); 111 | ViewHelper.setScaleX(mContent, rightScale); 112 | ViewHelper.setScaleY(mContent, rightScale); 113 | } 114 | } 115 | 116 | @Override 117 | public void onDrawerOpened(View drawerView) 118 | { 119 | } 120 | 121 | @Override 122 | public void onDrawerClosed(View drawerView) 123 | { 124 | } 125 | }); 126 | } 127 | 128 | private void initView() 129 | { 130 | mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawerLayout); 131 | 132 | FragmentManager fm = getSupportFragmentManager(); 133 | Fragment fragment = fm.findFragmentById(R.id.id_left_menu_container); 134 | if (fragment == null) 135 | { 136 | fm.beginTransaction().add(R.id.id_left_menu_container, new MenuLeftFragment()).commit(); 137 | } 138 | } 139 | 140 | @Override 141 | public boolean onCreateOptionsMenu(Menu menu) 142 | { 143 | getMenuInflater().inflate(R.menu.menu_main, menu); 144 | return true; 145 | } 146 | 147 | @Override 148 | public boolean onOptionsItemSelected(MenuItem item) 149 | { 150 | int id = item.getItemId(); 151 | 152 | switch (id) 153 | { 154 | case R.id.id_action_plugin_skinchange: 155 | com.zhy.changeskin.SkinManager.getInstance().changeSkin(mSkinPkgPath, "com.imooc.skin_plugin", new com.zhy.changeskin.callback.ISkinChangingCallback() 156 | { 157 | @Override 158 | public void onStart() 159 | { 160 | } 161 | 162 | @Override 163 | public void onError(Exception e) 164 | { 165 | Toast.makeText(MainActivity.this, "换肤失败:" + e.getMessage(), Toast.LENGTH_SHORT).show(); 166 | } 167 | 168 | @Override 169 | public void onComplete() 170 | { 171 | Toast.makeText(MainActivity.this, "换肤成功", Toast.LENGTH_SHORT).show(); 172 | } 173 | }); 174 | break; 175 | case R.id.id_action_remove_any_skin: 176 | com.zhy.changeskin.SkinManager.getInstance().removeAnySkin(); 177 | break; 178 | case R.id.id_action_notify_lv: 179 | 180 | for (int i = 0, n = mDatas.size(); i < n; i++) 181 | { 182 | mDatas.set(i, mDatas.get(i) + " changed"); 183 | } 184 | mAdapter.notifyDataSetChanged(); 185 | break; 186 | case R.id.id_action_dynamic: 187 | Intent intent = new Intent(this,TestTagActivity.class); 188 | startActivity(intent); 189 | break; 190 | 191 | } 192 | 193 | 194 | return super.onOptionsItemSelected(item); 195 | } 196 | 197 | @Override 198 | protected void onDestroy() 199 | { 200 | super.onDestroy(); 201 | SkinManager.getInstance().unregister(this); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /app/src/main/java/com/zhy/skinchangenow/MenuLeftFragment.java: -------------------------------------------------------------------------------- 1 | package com.zhy.skinchangenow; 2 | 3 | import android.os.Bundle; 4 | import android.os.Environment; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Toast; 10 | 11 | import com.zhy.changeskin.SkinManager; 12 | 13 | import java.io.File; 14 | 15 | public class MenuLeftFragment extends Fragment implements View.OnClickListener 16 | { 17 | private String mSkinPkgPath = Environment.getExternalStorageDirectory() + File.separator + "skin_plugin.apk"; 18 | private View mInnerChange01; 19 | private View mInnerChange02; 20 | 21 | @Override 22 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 23 | Bundle savedInstanceState) 24 | { 25 | return inflater.inflate(R.layout.fragment_left_menu, container, false); 26 | } 27 | 28 | @Override 29 | public void onViewCreated(View view, Bundle savedInstanceState) 30 | { 31 | super.onViewCreated(view, savedInstanceState); 32 | 33 | mInnerChange01 = view.findViewById(R.id.id_rl_innerchange01); 34 | mInnerChange01.setOnClickListener(this); 35 | 36 | mInnerChange02 = view.findViewById(R.id.id_rl_innerchange02); 37 | mInnerChange02.setOnClickListener(this); 38 | 39 | view.findViewById(R.id.id_restore).setOnClickListener(new View.OnClickListener() 40 | { 41 | @Override 42 | public void onClick(View v) 43 | { 44 | com.zhy.changeskin.SkinManager.getInstance().removeAnySkin(); 45 | } 46 | }); 47 | 48 | view.findViewById(R.id.id_changeskin).setOnClickListener(new View.OnClickListener() 49 | { 50 | @Override 51 | public void onClick(View v) 52 | { 53 | com.zhy.changeskin.SkinManager.getInstance().changeSkin(mSkinPkgPath, "com.imooc.skin_plugin", new com.zhy.changeskin.callback.ISkinChangingCallback() 54 | { 55 | @Override 56 | public void onStart() 57 | { 58 | } 59 | 60 | @Override 61 | public void onError(Exception e) 62 | { 63 | Toast.makeText(getActivity(), "换肤失败", Toast.LENGTH_SHORT).show(); 64 | } 65 | 66 | @Override 67 | public void onComplete() 68 | { 69 | Toast.makeText(getActivity(), "换肤成功", Toast.LENGTH_SHORT).show(); 70 | } 71 | }); 72 | } 73 | }); 74 | 75 | } 76 | 77 | /** 78 | * Called when a view has been clicked. 79 | * 80 | * @param v The view that was clicked. 81 | */ 82 | @Override 83 | public void onClick(View v) 84 | { 85 | switch (v.getId()) 86 | { 87 | case R.id.id_rl_innerchange01: 88 | SkinManager.getInstance().changeSkin("red"); 89 | break; 90 | case R.id.id_rl_innerchange02: 91 | SkinManager.getInstance().changeSkin("green"); 92 | break; 93 | } 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/com/zhy/skinchangenow/TestTagActivity.java: -------------------------------------------------------------------------------- 1 | package com.zhy.skinchangenow; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.zhy.changeskin.SkinManager; 12 | 13 | public class TestTagActivity extends AppCompatActivity 14 | { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) 18 | { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_test_tag); 21 | 22 | SkinManager.getInstance().register(this); 23 | } 24 | 25 | public void addNewView(View view) 26 | { 27 | //建议通过xml inflater 28 | TextView tv = new TextView(this); 29 | tv.setTag("skin:item_text_color:textColor"); 30 | tv.setTextColor(getResources().getColorStateList(R.color.item_text_color)); 31 | tv.setText("dymaic add!"); 32 | 33 | ((ViewGroup) findViewById(R.id.id_container)).addView(tv); 34 | SkinManager.getInstance().injectSkin(tv); 35 | 36 | } 37 | 38 | @Override 39 | protected void onDestroy() 40 | { 41 | super.onDestroy(); 42 | SkinManager.getInstance().unregister(this); 43 | } 44 | 45 | @Override 46 | public boolean onCreateOptionsMenu(Menu menu) 47 | { 48 | // Inflate the menu; this adds items to the action bar if it is present. 49 | getMenuInflater().inflate(R.menu.menu_test_tag, menu); 50 | return true; 51 | } 52 | 53 | @Override 54 | public boolean onOptionsItemSelected(MenuItem item) 55 | { 56 | // Handle action bar item clicks here. The action bar will 57 | // automatically handle clicks on the Home/Up button, so long 58 | // as you specify a parent activity in AndroidManifest.xml. 59 | int id = item.getItemId(); 60 | 61 | //noinspection SimplifiableIfStatement 62 | if (id == R.id.action_settings) 63 | { 64 | return true; 65 | } 66 | 67 | return super.onOptionsItemSelected(item); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/zhy/skinchangenow/sample/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.zhy.skinchangenow.sample; 2 | 3 | import android.app.Application; 4 | 5 | import com.zhy.changeskin.SkinManager; 6 | 7 | 8 | /** 9 | * Created by zhy on 15/9/22. 10 | */ 11 | public class MyApplication extends Application 12 | { 13 | @Override 14 | public void onCreate() 15 | { 16 | super.onCreate(); 17 | SkinManager.getInstance().init(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/left_menu_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/src/main/res/drawable-nodpi/left_menu_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/left_menu_icon_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/src/main/res/drawable-nodpi/left_menu_icon_green.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/left_menu_icon_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/src/main/res/drawable-nodpi/left_menu_icon_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/main_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/src/main/res/drawable-nodpi/main_bg.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/main_bg_green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/src/main/res/drawable-nodpi/main_bg_green.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/main_bg_red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hongyangAndroid/AndroidChangeSkin/002a464df30d3da95bb2ce147b500c50d6ca4487/app/src/main/res/drawable-nodpi/main_bg_red.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_test_tag.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 19 | 20 | 21 |