├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── canyinghao │ │ └── candialog │ │ └── demo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── canyinghao │ │ │ └── candialog │ │ │ └── demo │ │ │ ├── App.java │ │ │ ├── ButtonActivity.java │ │ │ ├── CustomAppDialog.java │ │ │ ├── CustomDialog.java │ │ │ ├── MainActivity.java │ │ │ └── ProgressActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_other.xml │ │ ├── content_main.xml │ │ ├── custom_layout.xml │ │ └── dialog_custom.xml │ │ ├── menu │ │ └── menu_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 │ └── com │ └── canyinghao │ └── candialog │ └── demo │ └── ExampleUnitTest.java ├── build.gradle ├── candialog ├── .gitignore ├── bintray.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── canyinghao │ │ └── candialog │ │ ├── BaseAppCompatDialog.java │ │ ├── BaseBottomSheetDialog.java │ │ ├── CanAppCompatDialog.java │ │ ├── CanBaseDialog.java │ │ ├── CanBottomSheetDialog.java │ │ ├── CanDialog.java │ │ ├── CanDialogInterface.java │ │ ├── CanManagerDialog.java │ │ ├── InputUtils.java │ │ ├── MorphButton.java │ │ ├── TileAnimation.java │ │ ├── manager │ │ ├── DialogActivityAgent.java │ │ ├── DialogManager.java │ │ └── DialogManagerInterface.java │ │ └── vector │ │ ├── AnimatedVectorDrawable.java │ │ ├── DrawableCompat.java │ │ ├── Outline.java │ │ ├── PathAnimatorInflater.java │ │ ├── PathParser.java │ │ ├── ResourcesCompat.java │ │ ├── Tintable.java │ │ └── VectorDrawable.java │ └── res │ ├── anim │ ├── eye2eyeclose.xml │ ├── eyeclose2eye.xml │ ├── info2danger.xml │ ├── info2success.xml │ └── info2warning.xml │ ├── drawable │ ├── svg_animated_eye2eyeclose.xml │ ├── svg_animated_eyeclose2eye.xml │ ├── svg_animated_info2danger.xml │ ├── svg_animated_info2success.xml │ └── svg_animated_info2warning.xml │ ├── layout │ ├── dialog_edit.xml │ ├── dialog_item.xml │ ├── dialog_layout.xml │ ├── dialog_list.xml │ ├── dialog_multichoice.xml │ ├── dialog_progress.xml │ └── dialog_singchoice.xml │ ├── values-v21 │ └── dimens.xml │ ├── values │ ├── attr.xml │ ├── dimens.xml │ └── strings.xml │ └── xml │ ├── svg_danger.xml │ ├── svg_eye.xml │ ├── svg_eyeclose.xml │ ├── svg_info.xml │ ├── svg_success.xml │ └── svg_warning.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pic └── CanDialog.gif └── settings.gradle /.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 | # Eclipse project files 30 | .classpath 31 | .project 32 | .settings/ 33 | 34 | # Intellij project files 35 | *.iml 36 | *.ipr 37 | *.iws 38 | .idea/ 39 | 40 | # Mac system files 41 | .DS_Store 42 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CanDialog 2 | 仿照系统Dialog所写,继承于FrameLayout,添加一些动画,一些显示类型。 3 | 4 | ![](./pic/CanDialog.gif) 5 | 6 | 7 | ## 添加依赖 8 | ``` 9 | compile 'com.github.canyinghao:CanDialog:5.0.2' 10 | ``` 11 | 12 | ## 使用方式 13 | **1. 使用方法** 14 | CanDialog是一个继承FrameLayout,将view添加到getWindow().getDecorView()里面,仿照系统AlertDialog写成的。使用方式与AlertDialog大同小异。增加了两种动画效果,增加了一个输入框的布局和一个加载中的布局,还加了一些svg动画。Button点击后是否可取消,可以直接传参确定。button点击事件中能够返回单选、多选、输入框的结果。 15 | ``` 16 | 17 | @OnClick({R.id.fab, R.id.button1, R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6}) 18 | public void click(View v) { 19 | switch (v.getId()) { 20 | 21 | case R.id.fab: 22 | 23 | 24 | new CanDialog.Builder(this) 25 | .setIconType(CanDialog.ICON_WARNING) 26 | .setTitle("Dialog Title") 27 | .setMessage("Dialog Message") 28 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 29 | .setNegativeButton("cancel", true, null) 30 | .setPositiveButton("sure", true, null) 31 | .show(); 32 | 33 | 34 | break; 35 | 36 | case R.id.button1: 37 | 38 | new CanDialog.Builder(this) 39 | .setTitle("Dialog Title") 40 | .setMessage("Dialog Message") 41 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.TOP_RIGHT) 42 | .show(); 43 | break; 44 | case R.id.button2: 45 | 46 | new CanDialog.Builder(this) 47 | .setTitle("Dialog Title") 48 | 49 | .setItems(new String[]{"item0", "item1", "item2"}, new CanDialogInterface.OnClickListener() { 50 | @Override 51 | public void onClick(CanDialog dialog, int position, CharSequence text, boolean[] checkitems) { 52 | App.showToast(text.toString()); 53 | dialog.dismiss(); 54 | } 55 | }) 56 | .setCancelable(true) 57 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.TOP_LEFT) 58 | .show(); 59 | 60 | 61 | break; 62 | case R.id.button3: 63 | 64 | new CanDialog.Builder(this) 65 | .setTitle("Dialog Title") 66 | .setSingleChoiceItems(new String[]{"item0", "item1", "item2"}, 1, new CanDialogInterface.OnClickListener() { 67 | @Override 68 | public void onClick(CanDialog dialog, int position, CharSequence text, boolean[] checkitems) { 69 | 70 | App.showToast(text.toString()); 71 | 72 | } 73 | }) 74 | .setNegativeButton("cancel", true, null) 75 | .setPositiveButton("sure", true, new CanDialogInterface.OnClickListener() { 76 | @Override 77 | public void onClick(CanDialog dialog, int checkItem, CharSequence text, boolean[] checkItems) { 78 | App.showToast("select " + checkItem); 79 | 80 | } 81 | }) 82 | .setTileAnimator() 83 | .setCancelable(true) 84 | .show(); 85 | 86 | break; 87 | case R.id.button4: 88 | 89 | 90 | new CanDialog.Builder(this) 91 | .setTitle("Dialog Title") 92 | .setMultiChoiceItems(new String[]{"item0", "item1", "item2"}, new boolean[]{false, false, false}, new CanDialogInterface.OnMultiChoiceClickListener() { 93 | @Override 94 | public void onClick(CanDialog dialog, int position, boolean flag) { 95 | 96 | App.showToast("item" + position + flag); 97 | 98 | 99 | } 100 | }) 101 | .setNegativeButton("cancel", true, null) 102 | .setPositiveButton("sure", true, new CanDialogInterface.OnClickListener() { 103 | @Override 104 | public void onClick(CanDialog dialog, int checkItem, CharSequence text, boolean[] checkItems) { 105 | 106 | 107 | String msg = ""; 108 | for (boolean check : checkItems) { 109 | msg += check + " "; 110 | } 111 | App.showToast(msg); 112 | } 113 | }) 114 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_LEFT) 115 | .setCancelable(false) 116 | .show(); 117 | 118 | 119 | break; 120 | 121 | case R.id.button5: 122 | 123 | 124 | new CanDialog.Builder(this) 125 | .setIconType(CanDialog.ICON_INFO) 126 | .setTitle("Dialog Title") 127 | .setEditDialog("input pwd", true, 8, 0) 128 | .setNegativeButton("cancel", true, null) 129 | .setPositiveButton("sure", false, new CanDialogInterface.OnClickListener() { 130 | @Override 131 | public void onClick(CanDialog dialog, int position, CharSequence text, boolean[] checkitems) { 132 | 133 | 134 | dialog.setAnimationMessage(CanDialog.ANIM_INFO_SUCCESS, "Password is " + text.toString()); 135 | dialog.setPositiveButton("sure", true, null); 136 | 137 | 138 | } 139 | }) 140 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 141 | .setCancelable(true) 142 | .show(); 143 | 144 | break; 145 | 146 | 147 | case R.id.button6: 148 | 149 | 150 | startActivity(new Intent(MainActivity.this, ProgressActivity.class)); 151 | 152 | break; 153 | 154 | 155 | } 156 | 157 | 158 | } 159 | 160 | ``` 161 | **2. 注意事项** 162 | 可以兼容到9+。 163 | 使用的其它库: 164 | 165 | compile 'com.android.support:design:24.2.0' 166 | compile 'com.android.support:appcompat-v7:24.2.0' 167 | compile 'com.android.support:cardview-v7:24.2.0' 168 | compile 'com.canyinghao:cananimation:1.0.3' 169 | compile 'com.canyinghao:caneffect:1.0.3' 170 | compile 'com.nineoldandroids:library:2.4.0' 171 | 172 | **3.更新日志** 173 | 174 | - 更新1.0.5 175 | - 更新依赖库 176 | - 使其兼容到9+ 177 | - 更新1.0.4 178 | - Android studio升到2.0以后,出错问题。 179 | 180 | ### 开发者 181 | 182 | ![](https://avatars3.githubusercontent.com/u/12572840?v=3&s=460) 183 | 184 | canyinghao: 185 | 186 | 187 | 188 | [新浪微博](http://weibo.com/u/5670978460) 189 | 190 | [google+](https://plus.google.com/u/0/109542533436298291853) 191 | 192 | ### License 193 | 194 | Copyright 2016 canyinghao 195 | 196 | Licensed under the Apache License, Version 2.0 (the "License"); 197 | you may not use this file except in compliance with the License. 198 | You may obtain a copy of the License at 199 | 200 | http://www.apache.org/licenses/LICENSE-2.0 201 | 202 | Unless required by applicable law or agreed to in writing, software 203 | distributed under the License is distributed on an "AS IS" BASIS, 204 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 205 | See the License for the specific language governing permissions and 206 | limitations under the License. 207 | 208 | 209 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | android { 3 | compileSdkVersion 28 4 | buildToolsVersion "28.0.3" 5 | 6 | defaultConfig { 7 | applicationId "com.canyinghao.candialog.demo" 8 | minSdkVersion 14 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | 24 | 25 | 26 | implementation 'androidx.appcompat:appcompat:1.1.0' 27 | implementation 'com.google.android.material:material:1.1.0' 28 | implementation 'androidx.cardview:cardview:1.0.0' 29 | implementation 'androidx.annotation:annotation:1.1.0' 30 | implementation 'com.github.canyinghao:CanEffect:5.0.1' 31 | implementation 'com.github.canyinghao:CanAnimation:5.0.1' 32 | 33 | implementation project(':candialog') 34 | } 35 | -------------------------------------------------------------------------------- /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/canyinghao/Documents/program/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/canyinghao/candialog/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/canyinghao/candialog/demo/App.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | import android.widget.Toast; 6 | 7 | import java.io.File; 8 | import java.io.FileNotFoundException; 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | import java.io.PrintWriter; 12 | import java.io.StringWriter; 13 | 14 | 15 | public class App extends Application implements 16 | Thread.UncaughtExceptionHandler { 17 | 18 | private static App app; 19 | 20 | 21 | 22 | 23 | @Override 24 | public void onCreate() { 25 | super.onCreate(); 26 | 27 | app = this; 28 | 29 | 30 | Thread.setDefaultUncaughtExceptionHandler(this); 31 | 32 | } 33 | 34 | /** 35 | * 全局唯一的Application 36 | * 37 | * @return 38 | */ 39 | public static App getInstance() { 40 | if (app == null) { 41 | app = new App(); 42 | } 43 | return app; 44 | 45 | } 46 | 47 | 48 | 49 | public static void showToast(String msg){ 50 | 51 | Toast.makeText(getInstance(), msg, Toast.LENGTH_SHORT).show(); 52 | } 53 | 54 | 55 | /** 56 | * 处理应用崩溃 57 | * 58 | * @param thread 59 | * @param ex 60 | */ 61 | @Override 62 | public void uncaughtException(Thread thread, Throwable ex) { 63 | 64 | 65 | String eStr = getCrashReport(ex); 66 | 67 | 68 | // PgyCrashManager.reportCaughtException(this, new Exception(eStr)); 69 | 70 | Log.e("CanDialog", eStr); 71 | try { 72 | 73 | File saveFile = new File(getExternalCacheDir(),"failLog.txt"); 74 | FileOutputStream f = new FileOutputStream(saveFile); 75 | f.write(eStr.getBytes()); 76 | f.close(); 77 | } catch (FileNotFoundException e1) { 78 | e1.printStackTrace(); 79 | } catch (IOException e1) { 80 | e1.printStackTrace(); 81 | } 82 | 83 | 84 | try { 85 | Thread.sleep(1000); 86 | } catch (InterruptedException e) { 87 | e.printStackTrace(); 88 | } 89 | 90 | System.exit(0); 91 | 92 | } 93 | 94 | /** 95 | * 得到应用崩溃信息 96 | * 97 | * @param ex 98 | * @return 99 | */ 100 | private String getCrashReport(Throwable ex) { 101 | StringWriter sw = new StringWriter(); 102 | PrintWriter pw = new PrintWriter(sw); 103 | ex.printStackTrace(pw); 104 | String expcetionStr = sw.toString(); 105 | try { 106 | sw.close(); 107 | } catch (IOException e) { 108 | e.printStackTrace(); 109 | } 110 | pw.close(); 111 | return expcetionStr; 112 | } 113 | 114 | 115 | 116 | } 117 | -------------------------------------------------------------------------------- /app/src/main/java/com/canyinghao/candialog/demo/ButtonActivity.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.os.Bundle; 4 | import android.widget.Toast; 5 | 6 | import com.canyinghao.candialog.CanDialog; 7 | import com.canyinghao.candialog.CanDialogInterface; 8 | import com.canyinghao.candialog.CanManagerDialog; 9 | 10 | import androidx.appcompat.app.AppCompatActivity; 11 | 12 | /** 13 | * Created by canyinghao on 16/9/13. 14 | */ 15 | public class ButtonActivity extends AppCompatActivity { 16 | 17 | 18 | @Override 19 | public void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | 22 | setContentView(R.layout.activity_other); 23 | 24 | 25 | 26 | new CanDialog.Builder(this) 27 | .setSystemDialog(true) 28 | .setIconType(CanDialog.ICON_WARNING) 29 | .setTitle("System Title 1") 30 | .setMessage("Dialog Message") 31 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 32 | .setNegativeButton("cancel", true, null) 33 | .setPositiveButton("sure", true, null) 34 | .create() 35 | .showManager(); 36 | 37 | 38 | new CanDialog.Builder(this) 39 | .setIconType(CanDialog.ICON_WARNING) 40 | .setTitle("Dialog Title 2") 41 | .setMessage("Dialog Message") 42 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 43 | .setNegativeButton("cancel", true, null) 44 | .setPositiveButton("sure", true, null) 45 | .create() 46 | .showManager(); 47 | 48 | 49 | CanDialog dialog = new CanDialog.Builder(this) 50 | .setIconType(CanDialog.ICON_WARNING) 51 | .setTitle("Dialog Title 3") 52 | .setMessage("Dialog Message") 53 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 54 | .setNegativeButton("cancel", true, null) 55 | .setPositiveButton("sure", true, null) 56 | .create(); 57 | dialog.setOnDismissListener(new CanDialogInterface.OnDismissListener() { 58 | @Override 59 | public void onDismiss(CanManagerDialog dialog) { 60 | Toast.makeText(ButtonActivity.this,"test",Toast.LENGTH_SHORT).show(); 61 | } 62 | }); 63 | dialog.showManager(); 64 | 65 | 66 | 67 | 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/canyinghao/candialog/demo/CustomAppDialog.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | 6 | import com.canyinghao.candialog.CanAppCompatDialog; 7 | 8 | 9 | 10 | /** 11 | * Created by jianyang on 2019/7/17. 12 | */ 13 | 14 | public class CustomAppDialog extends CanAppCompatDialog { 15 | public CustomAppDialog(Context context) { 16 | super(context); 17 | init(); 18 | } 19 | 20 | public CustomAppDialog(Context context, int theme) { 21 | super(context, theme); 22 | init(); 23 | } 24 | 25 | protected CustomAppDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { 26 | super(context, cancelable, cancelListener); 27 | init(); 28 | } 29 | 30 | 31 | private void init(){ 32 | setContentView(R.layout.dialog_custom); 33 | findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() { 34 | @Override 35 | public void onClick(View view) { 36 | App.showToast("CustomAppDialog"); 37 | } 38 | }); 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/canyinghao/candialog/demo/CustomDialog.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.app.Activity; 4 | 5 | import android.view.View; 6 | import android.widget.Button; 7 | 8 | import com.canyinghao.candialog.CanBaseDialog; 9 | 10 | 11 | 12 | /** 13 | * Created by canyinghao on 2017/7/7. 14 | */ 15 | 16 | public class CustomDialog extends CanBaseDialog { 17 | 18 | 19 | public CustomDialog( Activity context) { 20 | super(context); 21 | } 22 | 23 | @Override 24 | protected void onCrate() { 25 | setContentView(R.layout.dialog_custom); 26 | 27 | 28 | findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() { 29 | @Override 30 | public void onClick(View view) { 31 | App.showToast("CustomAppDialog"); 32 | } 33 | }); 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/canyinghao/candialog/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Color; 5 | import android.os.Bundle; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.Toast; 11 | 12 | import com.canyinghao.candialog.CanBaseDialog; 13 | import com.canyinghao.candialog.CanDialog; 14 | import com.canyinghao.candialog.CanDialogInterface; 15 | import com.canyinghao.candialog.CanManagerDialog; 16 | import com.canyinghao.candialog.manager.DialogActivityAgent; 17 | import com.canyinghao.candialog.manager.DialogManager; 18 | import com.google.android.material.floatingactionbutton.FloatingActionButton; 19 | 20 | import androidx.appcompat.app.AlertDialog; 21 | import androidx.appcompat.app.AppCompatActivity; 22 | import androidx.appcompat.widget.Toolbar; 23 | 24 | 25 | public class MainActivity extends AppCompatActivity { 26 | 27 | 28 | Toolbar toolbar; 29 | 30 | Button button1; 31 | 32 | Button button2; 33 | 34 | Button button3; 35 | 36 | Button button4; 37 | 38 | FloatingActionButton fab; 39 | 40 | @Override 41 | protected void onCreate(Bundle savedInstanceState) { 42 | super.onCreate(savedInstanceState); 43 | setContentView(R.layout.activity_main); 44 | toolbar = findViewById(R.id.toolbar); 45 | button1 = findViewById(R.id.button1); 46 | button2 = findViewById(R.id.button2); 47 | button3 = findViewById(R.id.button3); 48 | button4 = findViewById(R.id.button4); 49 | fab = findViewById(R.id.fab); 50 | 51 | setSupportActionBar(toolbar); 52 | 53 | View.OnClickListener onClickListener = new View.OnClickListener() { 54 | @Override 55 | public void onClick(View view) { 56 | click( view); 57 | } 58 | }; 59 | 60 | button1.setOnClickListener(onClickListener); 61 | button2.setOnClickListener(onClickListener); 62 | button3.setOnClickListener(onClickListener); 63 | button4.setOnClickListener(onClickListener); 64 | fab.setOnClickListener(onClickListener); 65 | findViewById(R.id.button5).setOnClickListener(onClickListener); 66 | findViewById(R.id.button6).setOnClickListener(onClickListener); 67 | findViewById(R.id.button7).setOnClickListener(onClickListener); 68 | findViewById(R.id.button8).setOnClickListener(onClickListener); 69 | } 70 | 71 | 72 | 73 | public void click(View v) { 74 | switch (v.getId()) { 75 | 76 | case R.id.fab: 77 | 78 | 79 | new CanDialog.Builder(this) 80 | .setSystemDialog(true) 81 | .setIconType(CanDialog.ICON_WARNING) 82 | .setTitle("System Title 1") 83 | .setMessage("Dialog Message") 84 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 85 | .setNegativeButton("cancel", true, null) 86 | .setPositiveButton("sure", true, null) 87 | .create() 88 | .showManager(); 89 | 90 | 91 | new DialogActivityAgent(this,new Intent(this,ProgressActivity.class)).showManager(); 92 | 93 | 94 | new CanDialog.Builder(this) 95 | .setIconType(CanDialog.ICON_WARNING) 96 | .setTitle("Dialog Title 2") 97 | .setMessage("Dialog Message") 98 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 99 | .setNegativeButton("cancel", true, null) 100 | .setPositiveButton("sure", true, null) 101 | .create() 102 | .showManager(); 103 | 104 | new DialogActivityAgent(this,new Intent(this,ProgressActivity.class)).showManager(); 105 | 106 | CanDialog dialog = new CanDialog.Builder(this) 107 | .setIconType(CanDialog.ICON_WARNING) 108 | .setTitle("Dialog Title 3") 109 | .setMessage("Dialog Message") 110 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 111 | .setNegativeButton("cancel", true, null) 112 | .setPositiveButton("sure", true, null) 113 | .create(); 114 | dialog.setOnDismissListener(new CanDialogInterface.OnDismissListener() { 115 | @Override 116 | public void onDismiss(CanManagerDialog dialog) { 117 | Toast.makeText(MainActivity.this,"test",Toast.LENGTH_SHORT).show(); 118 | } 119 | }); 120 | dialog.showManager(); 121 | 122 | 123 | // startActivity(new Intent(MainActivity.this,MainActivity.class)); 124 | 125 | 126 | break; 127 | 128 | case R.id.button1: 129 | 130 | new CanDialog.Builder(this) 131 | .setTitle("Dialog Title") 132 | .setMessage("Dialog Message") 133 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.TOP_RIGHT) 134 | .show(); 135 | break; 136 | case R.id.button2: 137 | 138 | new CanDialog.Builder(this) 139 | .setTitle("Dialog Title") 140 | 141 | .setItems(new String[]{"item0", "item1", "item2"}, new CanDialogInterface.OnClickListener() { 142 | @Override 143 | public void onClick(CanBaseDialog dialog, int position, CharSequence text, boolean[] checkitems) { 144 | App.showToast(text.toString()); 145 | dialog.dismiss(); 146 | } 147 | }) 148 | .setCancelable(true) 149 | 150 | .setFullBackgroundColor(Color.TRANSPARENT) 151 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.TOP_LEFT) 152 | .show(); 153 | 154 | 155 | break; 156 | case R.id.button3: 157 | 158 | new CanDialog.Builder(this) 159 | .setTitle("Dialog Title") 160 | .setSingleChoiceItems(new String[]{"item0", "item1", "item2"}, 1, new CanDialogInterface.OnClickListener() { 161 | @Override 162 | public void onClick(CanBaseDialog dialog, int position, CharSequence text, boolean[] checkitems) { 163 | 164 | App.showToast(text.toString()); 165 | 166 | } 167 | }) 168 | .setNegativeButton("cancel", true, null) 169 | .setPositiveButton("sure", true, new CanDialogInterface.OnClickListener() { 170 | @Override 171 | public void onClick(CanBaseDialog dialog, int checkItem, CharSequence text, boolean[] checkItems) { 172 | App.showToast("select " + checkItem); 173 | 174 | } 175 | }) 176 | .setTileAnimator() 177 | .setCancelable(true) 178 | .show(); 179 | 180 | break; 181 | case R.id.button4: 182 | 183 | 184 | new CanDialog.Builder(this) 185 | .setTitle("Dialog Title") 186 | .setMultiChoiceItems(new String[]{"item0", "item1", "item2"}, new boolean[]{false, false, false}, new CanDialogInterface.OnMultiChoiceClickListener() { 187 | @Override 188 | public void onClick(CanBaseDialog dialog, int position, boolean flag) { 189 | 190 | App.showToast("item" + position + flag); 191 | 192 | 193 | } 194 | }) 195 | .setNegativeButton("cancel", true, null) 196 | .setPositiveButton("sure", true, new CanDialogInterface.OnClickListener() { 197 | @Override 198 | public void onClick(CanBaseDialog dialog, int checkItem, CharSequence text, boolean[] checkItems) { 199 | 200 | 201 | String msg = ""; 202 | for (boolean check : checkItems) { 203 | msg += check + " "; 204 | } 205 | App.showToast(msg); 206 | } 207 | }) 208 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_LEFT) 209 | .setCancelable(false) 210 | .show(); 211 | 212 | 213 | break; 214 | 215 | case R.id.button5: 216 | 217 | 218 | new CanDialog.Builder(this) 219 | .setIconType(CanDialog.ICON_INFO) 220 | .setTitle("Dialog Title") 221 | .setEditDialog("input pwd", true, 8, 0) 222 | .setNegativeButton("cancel", true, null) 223 | .setPositiveButton("sure", false, new CanDialogInterface.OnClickListener() { 224 | @Override 225 | public void onClick(CanBaseDialog dialog, int position, CharSequence text, boolean[] checkitems) { 226 | 227 | 228 | dialog.setAnimationMessage(CanDialog.ANIM_INFO_SUCCESS, "Password is " + text.toString()); 229 | dialog.setPositiveButton("sure", true, null); 230 | 231 | 232 | } 233 | }) 234 | .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 235 | .setCancelable(true) 236 | .show(); 237 | 238 | break; 239 | 240 | 241 | case R.id.button6: 242 | 243 | 244 | new CustomAppDialog(this).showManager(); 245 | new CustomDialog(this).setLeftRightMargin(0).setDialogHeight(500).setDialogWidth(500).showManager(); 246 | 247 | // View view = LayoutInflater.from(this).inflate(R.layout.custom_layout, null); 248 | // 249 | // TextView tv_name = (TextView) view.findViewById(R.id.tv_name); 250 | // final TextView et_name = (TextView) view.findViewById(R.id.et_name); 251 | // 252 | // CanDialog dialog= new CanDialog.Builder(this) 253 | // .setTitle("Dialog Title") 254 | // .setView(view) 255 | // .setIsInput() 256 | // .setNegativeButton("cancel", true, new CanDialogInterface.OnClickListener() { 257 | // @Override 258 | // public void onClick(CanBaseDialog dialog, int checkItem, CharSequence text, boolean[] checkItems) { 259 | // 260 | // InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 261 | // 262 | // imm.hideSoftInputFromWindow(et_name.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 263 | // } 264 | // }) 265 | // .setPositiveButton("sure", true, new CanDialogInterface.OnClickListener() { 266 | // @Override 267 | // public void onClick(CanBaseDialog dialog, int position, CharSequence text, boolean[] checkitems) { 268 | // 269 | // 270 | // Toast.makeText(getApplicationContext(), et_name.getText().toString(), Toast.LENGTH_SHORT).show(); 271 | // 272 | // 273 | // InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 274 | // 275 | // imm.hideSoftInputFromWindow(et_name.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 276 | // 277 | // 278 | // } 279 | // }) 280 | // .setCircularRevealAnimator(CanDialog.CircularRevealStatus.BOTTOM_RIGHT) 281 | // .setCancelable(true) 282 | // .show(); 283 | // 284 | // 285 | // 286 | // 287 | // 288 | // tv_name.setText("标题"); 289 | 290 | break; 291 | 292 | case R.id.button7: 293 | 294 | 295 | startActivity(new Intent(MainActivity.this, ProgressActivity.class)); 296 | 297 | break; 298 | 299 | case R.id.button8: 300 | 301 | 302 | startActivity(new Intent(MainActivity.this, ButtonActivity.class)); 303 | 304 | break; 305 | 306 | 307 | } 308 | 309 | 310 | } 311 | 312 | 313 | @Override 314 | public boolean onCreateOptionsMenu(Menu menu) { 315 | 316 | getMenuInflater().inflate(R.menu.menu_main, menu); 317 | return true; 318 | } 319 | 320 | @Override 321 | public boolean onOptionsItemSelected(MenuItem item) { 322 | 323 | int id = item.getItemId(); 324 | 325 | if (id == R.id.action_settings) { 326 | 327 | 328 | new AlertDialog.Builder(this) 329 | .setIcon(R.mipmap.ic_launcher) 330 | .setTitle("Dialog Title") 331 | .setMessage("Dialog Message") 332 | .setNegativeButton("cancel", null) 333 | .setPositiveButton("sure", null) 334 | .show(); 335 | 336 | 337 | return true; 338 | } 339 | 340 | return super.onOptionsItemSelected(item); 341 | } 342 | 343 | @Override 344 | protected void onDestroy() { 345 | super.onDestroy(); 346 | DialogManager.onDestroy(MainActivity.this); 347 | } 348 | } 349 | -------------------------------------------------------------------------------- /app/src/main/java/com/canyinghao/candialog/demo/ProgressActivity.java: -------------------------------------------------------------------------------- 1 | package com.canyinghao.candialog.demo; 2 | 3 | import android.os.Bundle; 4 | import android.view.KeyEvent; 5 | import android.view.View; 6 | 7 | import com.canyinghao.candialog.CanBaseDialog; 8 | import com.canyinghao.candialog.CanDialog; 9 | import com.canyinghao.candialog.CanDialogInterface; 10 | import com.canyinghao.candialog.manager.DialogManager; 11 | import com.google.android.material.floatingactionbutton.FloatingActionButton; 12 | 13 | import androidx.appcompat.app.AppCompatActivity; 14 | import androidx.appcompat.widget.Toolbar; 15 | 16 | 17 | /** 18 | * Created by canyinghao on 16/3/3. 19 | */ 20 | public class ProgressActivity extends AppCompatActivity { 21 | 22 | 23 | Toolbar toolbar; 24 | 25 | FloatingActionButton fab; 26 | 27 | 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_other); 33 | toolbar = findViewById(R.id.toolbar); 34 | fab = findViewById(R.id.fab); 35 | 36 | 37 | toolbar.setTitle("Progress"); 38 | 39 | final CanDialog dialog = new CanDialog.Builder(this) 40 | .setProgress("loading") 41 | .show(); 42 | dialog.setOnKeyListener(new CanDialogInterface.OnKeyListener() { 43 | @Override 44 | public boolean onKey(CanBaseDialog dialog, int code, KeyEvent event) { 45 | dialog.dismiss(); 46 | return false; 47 | } 48 | }); 49 | 50 | fab.setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View view) { 53 | App.showToast("fab"); 54 | } 55 | }); 56 | 57 | 58 | } 59 | 60 | 61 | 62 | 63 | @Override 64 | protected void onDestroy() { 65 | super.onDestroy(); 66 | DialogManager.activityDestroy(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_other.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | 34 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 22 | 23 |