├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ └── app-release.apk
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zlyandroid
│ │ └── upperdialog
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zlyandroid
│ │ │ └── upperdialog
│ │ │ ├── App.java
│ │ │ ├── BaseRecyclerViewAdapter.java
│ │ │ ├── DialogActivity.java
│ │ │ ├── LifeIndexAdapter.java
│ │ │ ├── MainActivity.java
│ │ │ ├── PopupActivity.java
│ │ │ ├── TitleView.java
│ │ │ ├── ToastActivity.java
│ │ │ └── utils
│ │ │ ├── DownloadUtils.java
│ │ │ ├── FileUtils.java
│ │ │ ├── PermissionUtils.java
│ │ │ ├── ToastUtils.java
│ │ │ └── dialog
│ │ │ ├── DownloadDialog.java
│ │ │ └── PermissionDialog.java
│ └── res
│ │ ├── drawable-v24
│ │ ├── ic_back.png
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── card_bg.xml
│ │ ├── ic_fail.png
│ │ ├── ic_fail.xml
│ │ ├── ic_index_sport.xml
│ │ ├── ic_launcher_background.xml
│ │ └── ic_success.xml
│ │ ├── layout
│ │ ├── activity_dialog.xml
│ │ ├── activity_main.xml
│ │ ├── activity_popup.xml
│ │ ├── activity_toast.xml
│ │ ├── basic_ui_dialog_download.xml
│ │ ├── basic_ui_dialog_permission.xml
│ │ ├── dialog_list.xml
│ │ ├── dialog_match_width.xml
│ │ ├── dialog_normal.xml
│ │ ├── item_life_index.xml
│ │ ├── layout_title_view.xml
│ │ ├── popup_match_width.xml
│ │ ├── popup_meun.xml
│ │ └── popup_normal.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── file_path.xml
│ └── test
│ └── java
│ └── com
│ └── zlyandroid
│ └── upperdialog
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot
├── Screenshot_20200506_110015_com.zlyandroid.upperdi.jpg
├── Screenshot_20200506_110022_com.zlyandroid.upperdi.jpg
├── Screenshot_20200506_110027_com.zlyandroid.upperdi.jpg
├── Screenshot_20200506_115746_com.zlyandroid.upperdi.jpg
├── Screenshot_20200506_115850_com.zlyandroid.upperdi.jpg
├── Screenshot_20200506_120027_com.zlyandroid.upperdi.jpg
└── Screenshot_20200506_120035_com.zlyandroid.upperdi.jpg
├── settings.gradle
└── upperdialoglib
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── zlylib
│ └── upperdialog
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── zlylib
│ │ └── upperdialog
│ │ ├── ListDialog.java
│ │ ├── LoadingDialog.java
│ │ ├── TipDialog.java
│ │ ├── Upper.java
│ │ ├── common
│ │ ├── Align.java
│ │ ├── AnimatorHelper.java
│ │ └── ViewDragHelper.java
│ │ ├── dialog
│ │ └── DialogLayer.java
│ │ ├── listener
│ │ ├── SimpleCallback.java
│ │ └── SimpleListener.java
│ │ ├── manager
│ │ ├── ActivityHolder.java
│ │ ├── DecorLayer.java
│ │ ├── DragCompat.java
│ │ ├── Layer.java
│ │ ├── ScrollCompat.java
│ │ ├── SoftInputHelper.java
│ │ └── ViewManager.java
│ │ ├── popup
│ │ └── PopupLayer.java
│ │ ├── pro
│ │ └── ActivityProvider.java
│ │ ├── toast
│ │ └── ToastLayer.java
│ │ ├── utils
│ │ ├── ResUtils.java
│ │ └── Utils.java
│ │ └── view
│ │ ├── BackgroundView.java
│ │ ├── ContainerLayout.java
│ │ ├── DragLayout.java
│ │ └── UpperActivity.java
└── res
│ ├── drawable
│ ├── basic_ui_dialog_download_progress_bg.xml
│ ├── basic_ui_dialog_loading_bg.xml
│ ├── bg_press_color_main_radius_max.xml
│ ├── bg_press_color_surface.xml
│ ├── bg_press_color_surface_radius_def.xml
│ ├── bg_press_color_surface_radius_max.xml
│ ├── bg_solid_round_color_accent_radius_def.xml
│ ├── bg_solid_round_color_background_radius_max.xml
│ ├── bg_solid_round_color_main_radius_max.xml
│ ├── bg_solid_round_color_surface_radius_def.xml
│ ├── bg_solid_round_color_surface_radius_max.xml
│ ├── bg_solid_round_color_surface_radius_top_def.xml
│ └── upper_toast_bg.xml
│ ├── layout
│ ├── anylayer_dialog_layer.xml
│ ├── anylayer_toast_layer.xml
│ ├── basic_ui_dialog_download.xml
│ ├── basic_ui_dialog_list.xml
│ ├── basic_ui_dialog_tip.xml
│ ├── basic_ui_rv_item_dialog_list.xml
│ └── loading_dialog.xml
│ ├── mipmap-xhdpi
│ ├── basic_ui_dialog_permission_calendar.png
│ ├── basic_ui_dialog_permission_camera.png
│ ├── basic_ui_dialog_permission_contacts.png
│ ├── basic_ui_dialog_permission_location.png
│ ├── basic_ui_dialog_permission_microphone.png
│ ├── basic_ui_dialog_permission_phone.png
│ ├── basic_ui_dialog_permission_sensors.png
│ ├── basic_ui_dialog_permission_sms.png
│ ├── basic_ui_dialog_permission_storage.png
│ ├── basic_ui_dialog_permission_unknow.png
│ ├── basic_ui_dialog_update.png
│ └── loading_bg.png
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── test
└── java
└── com
└── zlylib
└── upperdialog
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Android template
3 | # Built application files
4 | *.ap_
5 | *.aab
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 | gradle/
22 |
23 | # Local configuration file (sdk path, etc)
24 | local.properties
25 |
26 | # Proguard folder generated by Eclipse
27 | proguard/
28 |
29 | # Log Files
30 | *.log
31 |
32 | # Android Studio Navigation editor temp files
33 | .navigation/
34 |
35 | # Android Studio captures folder
36 | captures/
37 |
38 | # IntelliJ
39 | *.iml
40 | .idea/
41 | .idea/workspace.xml
42 | .idea/tasks.xml
43 | .idea/gradle.xml
44 | .idea/assetWizardSettings.xml
45 | .idea/dictionaries
46 | .idea/libraries
47 | # Android Studio 3 in .gitignore file.
48 | .idea/caches
49 | .idea/modules.xml
50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
51 | .idea/navEditor.xml
52 |
53 | # Keystore files
54 | # Uncomment the following lines if you do not want to check your keystore files in.
55 | #*.jks
56 | #*.keystore
57 |
58 | # External native build folder generated in Android Studio 2.2 and later
59 | .externalNativeBuild
60 |
61 | # Google Services (e.g. APIs or Firebase)
62 | # google-services.json
63 |
64 | # Freeline
65 | freeline.py
66 | freeline/
67 | freeline_project_description.json
68 |
69 | # fastlane
70 | fastlane/report.xml
71 | fastlane/Preview.html
72 | fastlane/screenshots
73 | fastlane/test_output
74 | fastlane/readme.md
75 |
76 | # Version control
77 | vcs.xml
78 |
79 | # lint
80 | lint/intermediates/
81 | lint/generated/
82 | lint/outputs/
83 | lint/tmp/
84 | # lint/reports/
85 |
86 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UpperDialog
2 |
3 | Android轻量级弹窗。
4 |
5 | 自定义Dialog弹窗,自定义大小和位置,进出场方式。链式调用,自由扩展。
6 |
7 |
8 | [GitHub主页](https://github.com/ZLYang110/UpperDialog)
9 |
10 | [简书](https://www.jianshu.com/p/8c7b2ebd892a)
11 |
12 | [Demo下载](https://github.com/ZLYang110/UpperDialog/raw/master/app/release/app-release.apk)
13 |
14 |
15 |
16 |
17 |
18 | # 简介
19 | - anylayer
20 | - 同时兼容support和androidx
21 | - 实现几种常用效果
22 | - LoadingDialog 加载
23 | - TipDialog 弹窗提示
24 | - ListDialog 底部列表弹出
25 | - Upper 自定义加载方式
26 | - 占用区域不会超过当前Activity避免导航栏遮挡
27 | - 支持自定义大小和显示位置
28 | - 支持自定义数据绑定
29 | - 支持自定义进出场动画
30 | - 支持自定义背景颜色/图片/高斯模糊
31 | - 支持在Activity的onCreate生命周期弹出
32 | - 支持从ApplicationContext中弹出
33 | - 支持拖拽关闭
34 | - 支持不拦截外部事件
35 | - Toast效果
36 | - 支持自定义图标和文字
37 | - 支持自定义显示时长
38 | - 支持自定义位置
39 | - 支持自定义背景资源和颜色
40 | - 支持自定义透明度
41 | - 支持自定义进出场动画
42 | - Popup效果
43 | - 拥有Dialog效果特性
44 | - 支持跟随目标View移动
45 |
46 |
47 |
48 |
49 |
50 |
51 | # 说明
52 |
53 | # 运行截图
54 |
55 |
56 |
57 | # 使用说明
58 |
59 | ## 集成
60 |
61 |  
62 |
63 | - ### 添加jitpack库
64 |
65 | ```java
66 | // build.gradle(Project:)
67 | allprojects {
68 | repositories {
69 | ...
70 | maven { url 'https://www.jitpack.io' }
71 | }
72 | }
73 | ```
74 |
75 | - ### 添加依赖
76 |
77 | ```groovy
78 | // build.gradle(Module:)
79 | dependencies {
80 |
81 | implementation 'com.github.ZLYang110:UpperDialog:1.3'
82 | }
83 | ```
84 |
85 | ### LoadingDialog
86 |
87 |
88 | ```java
89 |
90 | //初始化
91 | dialog = DialogUtils.createLoadingDialog(this, "请稍后...");
92 |
93 | //显示
94 | dialog.show();
95 |
96 | //关闭
97 | dialog.dismiss();
98 |
99 | ```
100 |
101 | ### TipDialog
102 |
103 |
104 | ```java
105 |
106 |
107 | TipDialog.with(getActivity())
108 | // .yesTextColor(R.color.colorAccent)
109 | //.setAdaption(false)
110 | //.setAdaptionSize(false,300) //设置弹窗限定宽度,只有为false,300才能生效 。默认是true
111 | .message("确定不给个star么?")
112 | .onYes(new SimpleCallback() {
113 | @Override
114 | public void onResult(Void data) {
115 |
116 | }
117 | })
118 | .show();
119 |
120 | ```
121 |
122 | ### ListDialog
123 |
124 |
125 | ```java
126 |
127 | /**
128 | * 正常弹出
129 | */
130 | List lisStr=new ArrayList<>();
131 | lisStr.add("选项1");
132 | lisStr.add("选项2");
133 | lisStr.add("选项3");
134 | lisStr.add("选项4");
135 |
136 | ListDialog.with(SettingActivity.this)
137 | .cancelable(true)
138 | // .yesTextColor(R.color.colorAccent)
139 | .noYseBtn() //不显示确定按钮 三个相互冲突,请设置一个
140 | //.noNoBtn() //不显示取消按钮
141 | //.noBtn() // 不显示按钮
142 | // .title("列表动画")
143 | .datas(lisStr)
144 | .currSelectPos(1)
145 | .listener(new ListDialog.OnItemSelectedListener() {
146 | @Override
147 | public void onSelect(String data, int pos) {
148 | Log.d("selectStr",lisStr.get(pos));
149 | }
150 | })
151 | .show();
152 |
153 | ```
154 |
155 |
156 |
157 | ### Upper
158 |
159 |
160 | ```java
161 |
162 | /**
163 | * 正常弹出
164 | */
165 | Upper.dialog(DialogActivity.this)
166 | .contentView(R.layout.dialog_normal)
167 | .backgroundDimDefault()
168 | .onClickToDismiss(R.id.fl_dialog_yes, R.id.fl_dialog_no)
169 | .show();
170 |
171 | /**
172 | * 显示上方
173 | */
174 | Upper.dialog(DialogActivity.this)
175 | .contentView(R.layout.dialog_match_width)
176 | .avoidStatusBar(true)
177 | .backgroundDimDefault()
178 | .gravity(Gravity.TOP)
179 | .dragDismiss(DragLayout.DragStyle.Top)
180 | .onClickToDismiss(R.id.fl_dialog_no)
181 | .show();
182 | /**
183 | * 显示下方
184 | */
185 | Upper.dialog(DialogActivity.this)
186 | .contentView(R.layout.dialog_list)
187 | .backgroundDimDefault()
188 | .gravity(Gravity.BOTTOM)
189 | .dragDismiss(DragLayout.DragStyle.Bottom)
190 | .onClickToDismiss(R.id.fl_dialog_no)
191 | .show();
192 |
193 |
194 |
195 | ```
196 |
197 |
198 | ### Toast
199 |
200 |
201 | ```java
202 |
203 | /**
204 | * 正常弹出
205 | */
206 | ToastUtils.show(ToastActivity.this,"轻量级浮层弹窗");
207 |
208 |
209 |
210 | /**
211 | * 自定义效果
212 | */
213 | Upper.toast(context)
214 | .duration(3000)
215 | .message(msg)
216 | .backgroundColorRes(R.color.default_title_background_color)
217 | .gravity(gravity)
218 | .animator(new Layer.AnimatorCreator() {
219 | @Override
220 | public Animator createInAnimator(View target) {
221 | return AnimatorHelper.createZoomAlphaInAnim(target);
222 | }
223 |
224 | @Override
225 | public Animator createOutAnimator(View target) {
226 | return AnimatorHelper.createZoomAlphaOutAnim(target);
227 | }
228 | })
229 | .show();
230 |
231 |
232 | ```
233 |
234 | 说明
235 |
236 | 安装APK 下面配置很关键
237 | ```java
238 |
239 |
240 | ......
241 |
242 |
247 |
250 |
251 | ```
252 | 如果报错如下
253 |
254 | ```java
255 |
256 | java.io.IOException: Permission denied
257 |
258 | ```
259 | 查看是否有网络权限然后在AndroidManifest.xml中application添加
260 |
261 |
262 | ```java
263 |
264 | android:requestLegacyExternalStorage="true"
265 |
266 | ```
267 |
268 |
269 |
270 | # 更新日志
271 |
272 | 1.4.1
273 | ----
274 |
275 | - 优化代码
276 | - ListDialog 按钮颜色可自定义
277 | - TipDialog 按钮颜色可自定义
278 |
279 | 1.4
280 | ----
281 |
282 | - 优化代码
283 | - ListDialog 按钮显示可自定义
284 |
285 |
286 | 1.3
287 | ----
288 |
289 | - 弹窗是否自适应
290 | * true 根据屏幕大小自适应
291 | * false 固定弹窗大小 (可以给宽高值)
292 |
293 | 1.2
294 | ----
295 | - 添加popup弹窗
296 |
297 | 1.1
298 | ----
299 | - 添加Toast弹窗
300 |
301 | 1.0
302 | ----
303 | - dialog轻量级封装库
304 |
305 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.3"
6 | defaultConfig {
7 | applicationId "com.zlyandroid.upperdialog"
8 | minSdkVersion 19
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 |
22 | compileOptions {
23 |
24 | sourceCompatibility JavaVersion.VERSION_1_8
25 | targetCompatibility JavaVersion.VERSION_1_8
26 | }
27 |
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 | implementation 'androidx.appcompat:appcompat:1.0.2'
33 | implementation 'androidx.cardview:cardview:1.0.0'
34 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
35 |
36 | implementation project(':upperdialoglib')
37 |
38 | //butterknife
39 | implementation 'com.jakewharton:butterknife:10.0.0' // this
40 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
41 |
42 | //recyclerview
43 | implementation 'androidx.recyclerview:recyclerview:1.1.0'// this
44 |
45 | //权限申请
46 | implementation 'com.github.ZLYang110:MyPermission:1.0'
47 |
48 | implementation 'com.github.ZLYang110:MultiStateViewLib:1.0'
49 | }
50 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/zlyandroid/upperdialog/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.zlyandroid.upperdialog", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
37 |
41 |
42 |
45 |
50 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/App.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.app.Application;
4 | import android.os.Handler;
5 |
6 | /**
7 | * @author CuiZhen
8 | * @date 2019/3/10
9 | * QQ: 302833254
10 | * E-mail: goweii@163.com
11 | * GitHub: https://github.com/goweii
12 | */
13 | public class App extends Application {
14 |
15 | public static Handler sHandler = new Handler();
16 |
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/BaseRecyclerViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.widget.AdapterView;
4 |
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | /**
8 | */
9 | public abstract class BaseRecyclerViewAdapter extends RecyclerView.Adapter{
10 |
11 | protected AdapterView.OnItemClickListener onItemClickListener;
12 |
13 | public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
14 |
15 | this.onItemClickListener = onItemClickListener;
16 | }
17 |
18 | protected void onItemHolderClick(RecyclerView.ViewHolder itemHolder) {
19 | if (onItemClickListener != null) {
20 | onItemClickListener.onItemClick(null, itemHolder.itemView,
21 | itemHolder.getAdapterPosition(), itemHolder.getItemId());
22 | } else {
23 | throw new IllegalStateException("Please call setOnItemClickListener method set the click event listeners");
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/LifeIndexAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import androidx.recyclerview.widget.RecyclerView;
12 |
13 |
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 |
19 |
20 | /**
21 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com)
22 | * 2016/12/13
23 | */
24 | public class LifeIndexAdapter extends BaseRecyclerViewAdapter {
25 |
26 | private Context context;
27 | private List indexList;
28 |
29 | public LifeIndexAdapter(Context context, List indexList) {
30 | this.context = context;
31 | this.indexList = indexList;
32 | }
33 |
34 | @Override
35 | public LifeIndexAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
36 | View itemView = LayoutInflater.from(parent.getContext())
37 | .inflate(R.layout.item_life_index, parent, false);
38 | return new ViewHolder(itemView, this);
39 | }
40 |
41 | @Override
42 | public void onBindViewHolder(LifeIndexAdapter.ViewHolder holder, int position) {
43 | String index = indexList.get(position);
44 | holder.indexIconImageView.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_index_sport));
45 | holder.indexLevelTextView.setText(index);
46 | }
47 |
48 | @Override
49 | public int getItemCount() {
50 | return indexList == null ? 0 : indexList.size();
51 | }
52 |
53 | static class ViewHolder extends RecyclerView.ViewHolder {
54 |
55 | @BindView(R.id.index_icon_image_view)
56 | ImageView indexIconImageView;
57 | @BindView(R.id.index_level_text_view)
58 | TextView indexLevelTextView;
59 | @BindView(R.id.index_name_text_view)
60 | TextView indexNameTextView;
61 |
62 | ViewHolder(View itemView,final LifeIndexAdapter adapter) {
63 | super(itemView);
64 | ButterKnife.bind(this, itemView);
65 | itemView.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View v) {
68 | adapter.onItemHolderClick(LifeIndexAdapter.ViewHolder.this);
69 | }
70 | });
71 | }
72 | }
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/PopupActivity.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.view.Gravity;
8 | import android.view.View;
9 | import android.view.animation.DecelerateInterpolator;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.appcompat.app.AppCompatActivity;
13 |
14 | import com.zlylib.upperdialog.Upper;
15 | import com.zlylib.upperdialog.common.Align;
16 | import com.zlylib.upperdialog.common.AnimatorHelper;
17 | import com.zlylib.upperdialog.dialog.DialogLayer;
18 | import com.zlylib.upperdialog.manager.Layer;
19 | import com.zlylib.upperdialog.view.DragLayout;
20 | import com.zlylib.upperdialog.view.UpperActivity;
21 |
22 | import butterknife.ButterKnife;
23 | import butterknife.OnClick;
24 | import butterknife.Unbinder;
25 |
26 | public class PopupActivity extends AppCompatActivity implements View.OnClickListener {
27 |
28 |
29 | private DialogLayer upper_show_target_right = null;
30 | private DialogLayer upper_show_target_bottom = null;
31 | private DialogLayer upper_show_target_full = null;
32 | private DialogLayer upper_show_menu = null;
33 |
34 | private Unbinder unbinder;
35 |
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_popup);
41 | unbinder = ButterKnife.bind(this);
42 |
43 | }
44 |
45 |
46 |
47 | @Override
48 | protected void onDestroy() {
49 | super.onDestroy();
50 | unbinder.unbind();
51 | }
52 |
53 | @OnClick({
54 | R.id.tv_show_menu,
55 | R.id.tv_show_target_right,
56 | R.id.tv_show_target_top,
57 | R.id.tv_show_target_bottom,
58 | R.id.tv_show_target_left,
59 |
60 | })
61 |
62 |
63 | @Override
64 | public void onClick(View v) {
65 | switch (v.getId()) {
66 | case R.id.tv_show_menu:
67 | if (upper_show_menu == null) {
68 | upper_show_menu = Upper.popup(findViewById(R.id.tv_show_menu))
69 | .align(Align.Direction.VERTICAL, Align.Horizontal.ALIGN_RIGHT, Align.Vertical.BELOW, true)
70 | .offsetYdp(15)
71 | .outsideTouchedToDismiss(true)
72 | .outsideInterceptTouchEvent(false)
73 | .contentView(R.layout.popup_meun)
74 | .contentAnimator(new DialogLayer.AnimatorCreator() {
75 | @Override
76 | public Animator createInAnimator(View content) {
77 | return AnimatorHelper.createDelayedZoomInAnim(content, 1F, 0F);
78 | }
79 |
80 | @Override
81 | public Animator createOutAnimator(View content) {
82 | return AnimatorHelper.createDelayedZoomOutAnim(content, 1F, 0F);
83 | }
84 | });
85 | }
86 | if (upper_show_menu.isShow()) {
87 | upper_show_menu.dismiss();
88 | } else {
89 | upper_show_menu.show();
90 | }
91 | break;
92 | case R.id.tv_show_target_right:
93 | if (upper_show_target_right == null) {
94 | upper_show_target_right = Upper.popup(findViewById(R.id.tv_show_target_right))
95 | .direction(Align.Direction.HORIZONTAL)
96 | .horizontal(Align.Horizontal.TO_RIGHT)
97 | .vertical(Align.Vertical.CENTER)
98 | .inside(true)
99 | .outsideInterceptTouchEvent(false)
100 | .contentView(R.layout.popup_normal)
101 | .contentAnimator(new DialogLayer.AnimatorCreator() {
102 | @Override
103 | public Animator createInAnimator(View content) {
104 | return AnimatorHelper.createLeftInAnim(content);
105 | }
106 |
107 | @Override
108 | public Animator createOutAnimator(View content) {
109 | return AnimatorHelper.createLeftOutAnim(content);
110 | }
111 | });
112 | }
113 | if (upper_show_target_right.isShow()) {
114 | upper_show_target_right.dismiss();
115 | } else {
116 | upper_show_target_right.show();
117 | }
118 | break;
119 | case R.id.tv_show_target_top:
120 | Upper.popup(findViewById(R.id.tv_show_target_top))
121 | .align(Align.Direction.VERTICAL, Align.Horizontal.CENTER, Align.Vertical.ABOVE, true)
122 | .contentView(R.layout.popup_match_width)
123 | .backgroundDimDefault()
124 | .gravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL)
125 | .contentAnimator(new DialogLayer.AnimatorCreator() {
126 | @Override
127 | public Animator createInAnimator(View content) {
128 | return AnimatorHelper.createBottomInAnim(content);
129 | }
130 |
131 | @Override
132 | public Animator createOutAnimator(View content) {
133 | return AnimatorHelper.createBottomOutAnim(content);
134 | }
135 | })
136 | .show();
137 | break;
138 | case R.id.tv_show_target_bottom:
139 | if (upper_show_target_bottom == null) {
140 | upper_show_target_bottom = Upper.popup(findViewById(R.id.tv_show_target_bottom))
141 | .align(Align.Direction.VERTICAL, Align.Horizontal.CENTER, Align.Vertical.BELOW, true)
142 | .outsideInterceptTouchEvent(false)
143 | .backgroundDimDefault()
144 | .contentView(R.layout.popup_match_width)
145 | .contentAnimator(new DialogLayer.AnimatorCreator() {
146 | @Override
147 | public Animator createInAnimator(View content) {
148 | return AnimatorHelper.createTopInAnim(content);
149 | }
150 |
151 | @Override
152 | public Animator createOutAnimator(View content) {
153 | return AnimatorHelper.createTopOutAnim(content);
154 | }
155 | });
156 | }
157 | if (upper_show_target_bottom.isShow()) {
158 | upper_show_target_bottom.dismiss();
159 | } else {
160 | upper_show_target_bottom.show();
161 | }
162 | break;
163 | case R.id.tv_show_target_left://显示顶部
164 | Upper.popup(findViewById(R.id.tv_show_target_left))
165 | .align(Align.Direction.HORIZONTAL, Align.Horizontal.TO_LEFT, Align.Vertical.CENTER, true)
166 | .contentView(R.layout.popup_normal)
167 | .contentAnimator(new DialogLayer.AnimatorCreator() {
168 | @Override
169 | public Animator createInAnimator(View content) {
170 | return AnimatorHelper.createRightInAnim(content);
171 | }
172 |
173 | @Override
174 | public Animator createOutAnimator(View content) {
175 | return AnimatorHelper.createRightOutAnim(content);
176 | }
177 | })
178 | .show();
179 | break;
180 |
181 | }
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/TitleView.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.util.DisplayMetrics;
7 | import android.util.TypedValue;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.LinearLayout;
11 | import android.widget.TextView;
12 |
13 | import androidx.annotation.Nullable;
14 |
15 | /**
16 | * @author zhangliyang
17 | */
18 | public class TitleView extends LinearLayout {
19 |
20 | private int defaultTitleTextSize = 7;// 默认文字大小
21 | private int defaultTitleBackgroundColorId = R.color.default_title_background_color;// 默认背景颜色
22 | private int defaultTitleTextColorId = R.color.default_title_text_color;// 默认文字颜色
23 | private int defaultTitleLineColorId = R.color.default_title_line_color;// 默认底部线条颜色
24 |
25 | private String title;
26 | private int titleTextSize;
27 | private int titleTextColor;
28 | private int titleBackgroundColor;
29 | private int titleLineColor;
30 |
31 | public TitleView(Context context, @Nullable AttributeSet attrs) {
32 | super(context, attrs);
33 |
34 | initAttrs(context, attrs);
35 |
36 | initView();
37 | }
38 |
39 | private void initAttrs(Context context, @Nullable AttributeSet attrs) {
40 |
41 | DisplayMetrics dm = getResources().getDisplayMetrics();
42 | this.defaultTitleTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, defaultTitleTextSize, dm);
43 |
44 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TitleView);
45 | title = typedArray.getString(R.styleable.TitleView_titleViewText);
46 | titleTextSize = typedArray.getDimensionPixelSize(R.styleable.TitleView_titleViewTextSize, defaultTitleTextSize);
47 | titleTextColor = typedArray.getColor(R.styleable.TitleView_titleViewTextColor, getResources().getColor(defaultTitleTextColorId));
48 | titleBackgroundColor = typedArray.getColor(R.styleable.TitleView_titleViewBackground, getResources().getColor(defaultTitleBackgroundColorId));
49 | titleLineColor = typedArray.getColor(R.styleable.TitleView_titleViewLineColor, getResources().getColor(defaultTitleLineColorId));
50 | typedArray.recycle();
51 | }
52 |
53 | private void initView() {
54 |
55 | LayoutInflater.from(getContext()).inflate(R.layout.layout_title_view, this, true);
56 | this.setOrientation(VERTICAL);
57 | this.setBackgroundColor(titleBackgroundColor);
58 |
59 | TextView titleTextView = (TextView) findViewById(R.id.title_text_view);
60 | titleTextView.setText(title);
61 | // titleTextView.setTextSize(titleTextSize);
62 | titleTextView.setTextColor(titleTextColor);
63 |
64 | View view = findViewById(R.id.title_line_view);
65 | view.setBackgroundColor(titleLineColor);
66 | }
67 | }
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/ToastActivity.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.view.Gravity;
8 | import android.view.View;
9 | import android.view.animation.DecelerateInterpolator;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.appcompat.app.AppCompatActivity;
13 |
14 | import com.zlyandroid.upperdialog.utils.ToastUtils;
15 | import com.zlylib.upperdialog.Upper;
16 | import com.zlylib.upperdialog.common.AnimatorHelper;
17 | import com.zlylib.upperdialog.dialog.DialogLayer;
18 | import com.zlylib.upperdialog.manager.Layer;
19 | import com.zlylib.upperdialog.view.DragLayout;
20 | import com.zlylib.upperdialog.view.UpperActivity;
21 |
22 | import butterknife.ButterKnife;
23 | import butterknife.OnClick;
24 | import butterknife.Unbinder;
25 |
26 | public class ToastActivity extends AppCompatActivity implements View.OnClickListener {
27 |
28 |
29 | private Unbinder unbinder;
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_toast);
34 | unbinder = ButterKnife.bind(this);
35 |
36 | }
37 |
38 |
39 |
40 | @Override
41 | protected void onDestroy() {
42 | super.onDestroy();
43 | unbinder.unbind();
44 | }
45 |
46 | @OnClick({
47 | R.id.tv_show,
48 | R.id.tv_show_success,
49 | R.id.tv_show_fail,
50 | R.id.tv_show_normal,
51 |
52 |
53 | })
54 | @Override
55 | public void onClick(View v) {
56 | switch (v.getId()) {
57 | case R.id.tv_show:
58 | ToastUtils.show(ToastActivity.this,"轻量级浮层弹窗");
59 | break;
60 | case R.id.tv_show_success:
61 | ToastUtils.showSuccess(ToastActivity.this,"成功了");
62 | break;
63 | case R.id.tv_show_fail:
64 | ToastUtils.showFail(ToastActivity.this,"失败了");
65 | break;
66 | case R.id.tv_show_normal:
67 | ToastUtils.showNormal(ToastActivity.this,"测试");
68 | break;
69 |
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/utils/DownloadUtils.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog.utils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.AsyncTask;
7 | import android.os.Build;
8 | import android.os.Environment;
9 | import android.util.Log;
10 |
11 | import androidx.core.content.FileProvider;
12 |
13 | import com.zlylib.upperdialog.utils.Utils;
14 |
15 | import java.io.File;
16 | import java.io.FileOutputStream;
17 | import java.io.IOException;
18 | import java.io.InputStream;
19 | import java.net.HttpURLConnection;
20 | import java.net.MalformedURLException;
21 | import java.net.URL;
22 |
23 | /**
24 | * 版本更新下载apk
25 | *
26 | * @author zhangliyang
27 | * @date 18/5/17
28 | */
29 | public class DownloadUtils {
30 |
31 |
32 | private DownloadUtils(String url, DownloadListener listener) {
33 | new DownloadApk(listener).execute(url);
34 | }
35 |
36 | public static DownloadUtils download(String url, DownloadListener listener) {
37 | return new DownloadUtils(url, listener);
38 | }
39 |
40 | public static void installApk(Context context, String filePath) {
41 | if (filePath == null) {
42 | return;
43 | }
44 | File file = new File(filePath);
45 | installApk(context, file);
46 | }
47 |
48 | public static void installApk(Context context, File file) {
49 | if (file == null || !file.exists() || !file.isFile()) {
50 | return;
51 | }
52 | Intent intent = new Intent(Intent.ACTION_VIEW);
53 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
54 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
55 | Uri apkUri = FileProvider.getUriForFile(context, Utils.getAppContext().getPackageName() + ".fileprovider", file);
56 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
57 | intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
58 | } else {
59 | intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
60 | }
61 | context.startActivity(intent);
62 | }
63 |
64 | public interface DownloadListener {
65 | void onPreExecute();
66 |
67 | void onDownloadLength(int length);
68 |
69 | void onProgressUpdate(int progress);
70 |
71 | void onPostExecute(File apk);
72 | }
73 |
74 | /**
75 | * 通过路径去下载
76 | **/
77 | static class DownloadApk extends AsyncTask {
78 |
79 | private final DownloadListener downloadListener;
80 |
81 | DownloadApk(DownloadListener listener) {
82 | this.downloadListener = listener;
83 | }
84 |
85 | @Override
86 | protected File doInBackground(String... params) {
87 | File file = null;
88 | try {
89 | URL url = new URL(params[0]);
90 | try {
91 | final String fileName = Utils.getAppContext().getPackageName() + ".apk";
92 | String parentPath;
93 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
94 | parentPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
95 | } else {
96 | parentPath = Environment.getDownloadCacheDirectory().getAbsolutePath();
97 | }
98 | File tmpFile = new File(parentPath);
99 | if (!tmpFile.exists()) {
100 | tmpFile.mkdirs();
101 | }
102 | file = new File(parentPath, fileName);
103 | if (!file.exists()) {
104 | file.createNewFile();
105 | }
106 |
107 | HttpURLConnection conn = (HttpURLConnection) url.openConnection();
108 | conn.setRequestProperty("Accept-Encoding", "identity");
109 | int length = conn.getContentLength();
110 | downloadListener.onDownloadLength(length);
111 | InputStream is = conn.getInputStream();
112 | FileOutputStream fos = new FileOutputStream(file);
113 | byte[] buf = new byte[256];
114 | conn.connect();
115 | double count = 0;
116 | if (conn.getResponseCode() >= 400) {
117 | } else {
118 | double cou = 0;
119 | while (count <= 100) {
120 | if (is != null) {
121 | int numRead = is.read(buf);
122 | cou += numRead;
123 | int pro = (int) ((cou / length) * 100);
124 | if (numRead <= 0) {
125 | break;
126 | } else {
127 | publishProgress(pro);
128 | fos.write(buf, 0, numRead);
129 | }
130 | } else {
131 | break;
132 | }
133 | }
134 | }
135 | conn.disconnect();
136 | fos.close();
137 | is.close();
138 | } catch (IOException e) {
139 | e.printStackTrace();
140 | }
141 | } catch (MalformedURLException e) {
142 | e.printStackTrace();
143 | }
144 | return file;
145 | }
146 |
147 |
148 | @Override
149 | protected void onPostExecute(File file) {
150 | super.onPostExecute(file);
151 | downloadListener.onPostExecute(file);
152 | }
153 |
154 | @Override
155 | protected void onPreExecute() {
156 | super.onPreExecute();
157 | downloadListener.onPreExecute();
158 | }
159 |
160 | @Override
161 | protected void onProgressUpdate(Integer... values) {
162 | super.onProgressUpdate(values);
163 | downloadListener.onProgressUpdate(values[0]);
164 | }
165 |
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/utils/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog.utils;
2 |
3 | import android.os.Environment;
4 | import android.text.TextUtils;
5 |
6 | import java.io.File;
7 | import java.math.BigDecimal;
8 |
9 | /**
10 | * 描述:
11 | *
12 | * @author zhangliyang
13 | * @date 2018/12/23
14 | */
15 | public class FileUtils {
16 |
17 | public static boolean isSDCardAlive() {
18 | return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
19 | }
20 |
21 | public static void delete(File file, String except) {
22 | if (file == null) {
23 | return;
24 | }
25 | if (file.isDirectory()) {
26 | String[] children = file.list();
27 | for (String c : children) {
28 | File childFile = new File(file, c);
29 | if (!TextUtils.equals(childFile.getName(), except)) {
30 | delete(childFile);
31 | }
32 | }
33 | } else {
34 | if (!TextUtils.equals(file.getName(), except)) {
35 | file.delete();
36 | }
37 | }
38 | }
39 |
40 | public static boolean delete(File file) {
41 | if (file == null) {
42 | return false;
43 | }
44 | if (file.isDirectory()) {
45 | String[] children = file.list();
46 | for (String c : children) {
47 | boolean success = delete(new File(file, c));
48 | if (!success) {
49 | return false;
50 | }
51 | }
52 | }
53 | return file.delete();
54 | }
55 |
56 | public static long getSize(File file) {
57 | long size = 0;
58 | try {
59 | File[] fileList = file.listFiles();
60 | for (File f : fileList) {
61 | if (f.isDirectory()) {
62 | size = size + getSize(f);
63 | } else {
64 | size = size + f.length();
65 | }
66 | }
67 | } catch (Exception ignore) {
68 | }
69 | return size;
70 | }
71 |
72 | /**
73 | * 格式化单位
74 | */
75 | public static String formatSize(double size) {
76 | double kiloByte = size / 1024;
77 | if (kiloByte < 1) {
78 | return "0KB";
79 | }
80 | double megaByte = kiloByte / 1024;
81 | if (megaByte < 1) {
82 | BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
83 | return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB";
84 | }
85 | double gigaByte = megaByte / 1024;
86 | if (gigaByte < 1) {
87 | BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
88 | return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
89 | }
90 | double teraBytes = gigaByte / 1024;
91 | if (teraBytes < 1) {
92 | BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
93 | return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB";
94 | }
95 | BigDecimal result4 = new BigDecimal(teraBytes);
96 | return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB";
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/utils/ToastUtils.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog.utils;
2 |
3 |
4 | import android.animation.Animator;
5 | import android.content.Context;
6 | import android.graphics.Color;
7 | import android.view.Gravity;
8 | import android.view.View;
9 |
10 | import com.zlyandroid.upperdialog.R;
11 | import com.zlylib.upperdialog.Upper;
12 | import com.zlylib.upperdialog.common.AnimatorHelper;
13 | import com.zlylib.upperdialog.manager.Layer;
14 |
15 | import java.util.Random;
16 |
17 | /**
18 | * @author zhangliyang
19 | * GitHub: https://github.com/ZLYang110
20 | */
21 | public class ToastUtils {
22 |
23 | private static Random mRandom = new Random();
24 |
25 | /**
26 | * 提示
27 | * Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL :
28 | * Gravity.TOP | Gravity.CENTER_HORIZONTAL :
29 | * Gravity.LEFT | Gravity.CENTER_VERTICAL :
30 | * Gravity.RIGHT | Gravity.CENTER_VERTICAL
31 | * */
32 | public static void show(Context context, String msg) {
33 | show(context, msg, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
34 | }
35 |
36 | public static void show(Context context, String msg, int gravity) {
37 | Upper.toast(context)
38 | .duration(3000)
39 | .message(msg)
40 | // .marginBottom(450)
41 | .backgroundColorRes(R.color.default_title_background_color)
42 | .gravity(gravity)
43 | .animator(new Layer.AnimatorCreator() {
44 | @Override
45 | public Animator createInAnimator(View target) {
46 | return AnimatorHelper.createZoomAlphaInAnim(target);
47 | }
48 |
49 | @Override
50 | public Animator createOutAnimator(View target) {
51 | return AnimatorHelper.createZoomAlphaOutAnim(target);
52 | }
53 | })
54 | .show();
55 | }
56 | /**
57 | * 正确提示
58 | *
59 | * Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL :
60 | * Gravity.TOP | Gravity.CENTER_HORIZONTAL :
61 | * Gravity.LEFT | Gravity.CENTER_VERTICAL :
62 | * Gravity.RIGHT | Gravity.CENTER_VERTICAL
63 | * */
64 | public static void showSuccess(Context context, String msg) {
65 | showSuccess(context, msg, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
66 | }
67 |
68 | public static void showSuccess(Context context, String msg, int gravity) {
69 | Upper.toast(context)
70 | .duration(3000)
71 | .icon(R.drawable.ic_success)
72 | .message(msg)
73 | .backgroundColorRes(R.color.assist)
74 | .gravity(gravity)
75 | .animator(new Layer.AnimatorCreator() {
76 | @Override
77 | public Animator createInAnimator(View target) {
78 | return AnimatorHelper.createZoomAlphaInAnim(target);
79 | }
80 |
81 | @Override
82 | public Animator createOutAnimator(View target) {
83 | return AnimatorHelper.createZoomAlphaOutAnim(target);
84 | }
85 | })
86 | .show();
87 | }
88 |
89 |
90 | /**
91 | * 错误提示
92 | *
93 | * Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL :
94 | * Gravity.TOP | Gravity.CENTER_HORIZONTAL :
95 | * Gravity.LEFT | Gravity.CENTER_VERTICAL :
96 | * Gravity.RIGHT | Gravity.CENTER_VERTICAL
97 | * */
98 | public static void showFail(Context context, String msg) {
99 | showFail(context, msg, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
100 | }
101 |
102 | public static void showFail(Context context, String msg, int gravity) {
103 | Upper.toast(context)
104 | .duration(3000)
105 | .icon(R.drawable.ic_fail)
106 | .message(msg)
107 | .backgroundColorRes(R.color.rednrd)
108 | .gravity(gravity)
109 | .animator(new Layer.AnimatorCreator() {
110 | @Override
111 | public Animator createInAnimator(View target) {
112 | return AnimatorHelper.createZoomAlphaInAnim(target);
113 | }
114 |
115 | @Override
116 | public Animator createOutAnimator(View target) {
117 | return AnimatorHelper.createZoomAlphaOutAnim(target);
118 | }
119 | })
120 | .show();
121 | }
122 |
123 | /**
124 | * 可自定义
125 | * */
126 | public static void showNormal(Context context, String msg ) {
127 | boolean isSucc = mRandom.nextBoolean();
128 | Upper.toast()
129 | .duration(3000)
130 | .icon(isSucc ? R.drawable.ic_success : R.drawable.ic_fail)
131 | .message(isSucc ? " 成功了" : " 失败了")
132 | .alpha(mRandom.nextFloat())
133 | .backgroundColorInt(Color.argb(mRandom.nextInt(255), mRandom.nextInt(255), mRandom.nextInt(255), mRandom.nextInt(255)))
134 | .gravity(
135 | mRandom.nextBoolean() ?
136 | mRandom.nextBoolean() ?
137 | Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL :
138 | Gravity.TOP | Gravity.CENTER_HORIZONTAL :
139 | mRandom.nextBoolean() ?
140 | Gravity.LEFT | Gravity.CENTER_VERTICAL :
141 | Gravity.RIGHT | Gravity.CENTER_VERTICAL
142 | )
143 | .animator(new Layer.AnimatorCreator() {
144 | @Override
145 | public Animator createInAnimator(View target) {
146 | return AnimatorHelper.createZoomAlphaInAnim(target);
147 | }
148 |
149 | @Override
150 | public Animator createOutAnimator(View target) {
151 | return AnimatorHelper.createZoomAlphaOutAnim(target);
152 | }
153 | })
154 | .show();
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zlyandroid/upperdialog/utils/dialog/DownloadDialog.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog.utils.dialog;
2 |
3 | import android.app.Activity;
4 | import android.view.Gravity;
5 | import android.view.View;
6 | import android.widget.ProgressBar;
7 | import android.widget.TextView;
8 |
9 | import com.zlyandroid.upperdialog.R;
10 | import com.zlyandroid.upperdialog.utils.DownloadUtils;
11 | import com.zlyandroid.upperdialog.utils.FileUtils;
12 | import com.zlylib.upperdialog.Upper;
13 | import com.zlylib.upperdialog.manager.Layer;
14 | import com.zlylib.upperdialog.utils.ResUtils;
15 | import com.zlylib.upperdialog.utils.Utils;
16 |
17 | import java.io.File;
18 |
19 | /**
20 | * 版本更新弹窗
21 | *
22 | * @author zhangliyang
23 | * @date 2018/8/6-上午9:17
24 | */
25 | public class DownloadDialog {
26 |
27 | private final Activity mActivity;
28 | private Layer upperLayer = null;
29 | private final boolean isForce;
30 | private boolean isAutoInstall = true;
31 |
32 | private ProgressBar progressBar;
33 | private TextView tvProgress;
34 | private TextView tvApkSize;
35 | private TextView tvState;
36 | private File mApk;
37 |
38 | public static DownloadDialog with(Activity activity, boolean isForce, String url) {
39 | Utils.init(activity);
40 | return new DownloadDialog(activity, isForce, url);
41 | }
42 |
43 | private DownloadDialog(Activity activity, boolean isForce, String url) {
44 | Utils.init(activity);
45 | this.mActivity = activity;
46 | this.isForce = isForce;
47 | showDialog();
48 | startDownload(url);
49 | }
50 |
51 | public DownloadDialog setAutoInstall(boolean autoInstall) {
52 | isAutoInstall = autoInstall;
53 | return this;
54 | }
55 |
56 | private void startDownload(String url) {
57 | DownloadUtils.download(url, new DownloadUtils.DownloadListener() {
58 | @Override
59 | public void onPreExecute() {
60 | preDownload();
61 | }
62 |
63 | @Override
64 | public void onDownloadLength(final int length) {
65 | if (tvApkSize != null) {
66 | mActivity.runOnUiThread(new Runnable() {
67 | @Override
68 | public void run() {
69 | tvApkSize.setText(FileUtils.formatSize(length));
70 | }
71 | });
72 | }
73 | }
74 |
75 | @Override
76 | public void onProgressUpdate(int progress) {
77 | setProgress(progress);
78 | }
79 |
80 | @Override
81 | public void onPostExecute(File apk) {
82 | mApk = apk;
83 | if (isAutoInstall && tvState != null) {
84 | tvState.performClick();
85 | }
86 | }
87 |
88 |
89 | });
90 | }
91 |
92 | private void showDialog() {
93 | upperLayer = Upper.dialog(mActivity)
94 | .contentView( R.layout.basic_ui_dialog_download)
95 | .gravity(Gravity.CENTER)
96 | .backgroundDimDefault()
97 | .cancelableOnTouchOutside(false)
98 | .cancelableOnClickKeyBack(false)
99 | .bindData(new Layer.DataBinder() {
100 | @Override
101 | public void bindData(Layer layer) {
102 | progressBar = layer.getView( R.id.basic_ui_pb_dialog_download);
103 | tvProgress = layer.getView( R.id.basic_ui_tv_dialog_download_progress);
104 | tvApkSize = layer.getView( R.id.basic_ui_tv_dialog_download_apk_size);
105 | tvState = layer.getView( R.id.basic_ui_tv_dialog_download_state);
106 |
107 | }
108 | })
109 | .onClick(new Layer.OnClickListener() {
110 | @Override
111 | public void onClick(Layer layer, View v) {
112 | if (mApk == null) {
113 | return;
114 | }
115 | if (!isForce) {
116 | dismiss();
117 | }
118 | DownloadUtils.installApk(mActivity, mApk);
119 | }
120 | }, R.id.basic_ui_tv_dialog_download_state);
121 | upperLayer.show();
122 | }
123 |
124 | private void preDownload() {
125 | if (progressBar != null) {
126 | progressBar.setMax(100);
127 | progressBar.setProgress(0);
128 | }
129 | if (tvApkSize != null) {
130 | tvApkSize.setText("0B");
131 | }
132 | if (tvProgress != null) {
133 | tvProgress.setText("0");
134 | }
135 | if (tvState != null) {
136 | tvState.setText(com.zlylib.upperdialog.R.string.basic_ui_dialog_download_state_downloading);
137 | }
138 | }
139 |
140 | private void setProgress(int progress) {
141 | if (progressBar != null) {
142 | progressBar.setProgress(progress);
143 | }
144 | if (tvProgress != null) {
145 | tvProgress.setText("" + progress);
146 | }
147 | if (progress >= 100) {
148 | if (tvState != null) {
149 | tvState.setText(com.zlylib.upperdialog.R.string.basic_ui_dialog_download_state_install);
150 | tvState.setTextColor(ResUtils.getColor(mActivity, com.zlylib.upperdialog.R.color.text_main));
151 | }
152 | }
153 | }
154 |
155 | private void dismiss() {
156 | if (upperLayer != null) {
157 | upperLayer.dismiss();
158 | }
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/drawable-v24/ic_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/card_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_fail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/drawable/ic_fail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_fail.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_index_sport.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_success.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
25 |
29 |
34 |
42 |
43 |
44 |
45 |
46 |
47 |
56 |
60 |
65 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_popup.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
18 |
19 |
22 |
23 |
34 |
35 |
47 |
48 |
49 |
50 |
51 |
52 |
57 |
61 |
62 |
71 |
72 |
81 |
82 |
91 |
92 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
22 |
30 |
38 |
39 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/basic_ui_dialog_download.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
21 |
22 |
32 |
33 |
37 |
38 |
42 |
43 |
51 |
52 |
60 |
61 |
68 |
69 |
70 |
71 |
76 |
77 |
84 |
85 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/basic_ui_dialog_permission.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
34 |
35 |
47 |
48 |
61 |
62 |
77 |
78 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
30 |
31 |
36 |
37 |
41 |
42 |
43 |
51 |
52 |
60 |
61 |
69 |
70 |
78 |
79 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
99 |
100 |
105 |
106 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_match_width.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
37 |
38 |
43 |
44 |
49 |
50 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
38 |
39 |
44 |
45 |
52 |
53 |
61 |
62 |
63 |
64 |
71 |
72 |
79 |
80 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_life_index.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
26 |
27 |
36 |
37 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_title_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/popup_match_width.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/popup_meun.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
27 |
28 |
29 |
30 |
34 |
35 |
43 |
44 |
48 |
49 |
50 |
51 |
55 |
56 |
64 |
65 |
69 |
70 |
71 |
72 |
76 |
77 |
85 |
86 |
90 |
91 |
92 |
93 |
97 |
98 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/popup_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 | #33ffffff
8 | #B2FFFFFF
9 | #333333
10 | #E6E6E6
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UpperDialog
3 | Android轻量级弹窗
4 |
5 |
6 | 暂不授权
7 | 去授权
8 | 去设置
9 | 未知
10 | 日历
11 | 照相机
12 | 通讯录
13 | 定位
14 | 麦克风
15 | 手机
16 | 短信
17 | 传感器
18 | 存储空间
19 | 相关
20 | 我们需要获取%s权限以确保应用的正常运行,请点击去授权完成权限申请。
21 | 您已拒绝应用使用%s权限,这将影响功能的正常运行,请前往设置打开权限。
22 | 安装应用
23 | 我们将开始请求安装应用权限
24 | 悬浮窗
25 | 我们将开始请求悬浮窗权限
26 | 修改设置
27 | 我们将开始请求修改设置权限
28 | 访问通知
29 | 我们将开始请求访问通知权限
30 | 显示通知
31 | 我们将开始请求显示通知权限
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/file_path.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/com/zlyandroid/upperdialog/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.zlyandroid.upperdialog;
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() {
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 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | maven { url 'https://jitpack.io' }
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 01 17:01:42 GMT+08:00 2020
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-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_110015_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_110015_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_110022_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_110022_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_110027_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_110027_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_115746_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_115746_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_115850_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_115850_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_120027_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_120027_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/screenshot/Screenshot_20200506_120035_com.zlyandroid.upperdi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/screenshot/Screenshot_20200506_120035_com.zlyandroid.upperdi.jpg
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':upperdialoglib'
2 | rootProject.name='UpperDialog'
3 |
--------------------------------------------------------------------------------
/upperdialoglib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/upperdialoglib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.3"
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 19
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles 'consumer-rules.pro'
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 | implementation 'androidx.appcompat:appcompat:1.1.0'
30 | implementation 'androidx.cardview:cardview:1.0.0'
31 | implementation 'com.github.goweii:Blurred:1.3.0'
32 | //BRVAH:Powerful and flexible RecyclerAdapter
33 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50'
34 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
35 |
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/upperdialoglib/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/consumer-rules.pro
--------------------------------------------------------------------------------
/upperdialoglib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/upperdialoglib/src/androidTest/java/com/zlylib/upperdialog/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.zlylib.upperdialog.test", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/LoadingDialog.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.util.DisplayMetrics;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * @author zhangliyang
13 | * GitHub: https://https://github.com/ZLYang110
14 | */
15 | public class LoadingDialog {
16 | static Dialog loadingDialog;
17 | static TextView tipTextView;
18 | /**
19 | * 获取一个类似加载的对话框
20 | *
21 | * @param context 上下文
22 | * @param msg 文字说明
23 | * @return 对话框的对象
24 | */
25 | public static Dialog createLoadingDialog(Context context, String msg) {
26 | /*
27 | * 获得view填充器对象
28 | */
29 | LayoutInflater inflater = LayoutInflater.from(context);
30 | /*
31 | * 得到加载view
32 | */
33 | View v = inflater.inflate(R.layout.loading_dialog, null);
34 | tipTextView = v.findViewById(R.id.tipTextView);// 提示文字
35 | if (msg != null && !msg.equals("")) {
36 | tipTextView.setText(msg);// 设置加载信息
37 | }
38 |
39 | loadingDialog = new Dialog(context, R.style.loading_dialog);// 创建自定义样式dialog
40 | loadingDialog.setCancelable(true);// 可以用“返回键”取消
41 | loadingDialog.setCanceledOnTouchOutside(false);//
42 | loadingDialog.setContentView(v);// 设置布局
43 |
44 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
45 | int width = (int) (dm.widthPixels*0.3);
46 | int height = ViewGroup.LayoutParams.WRAP_CONTENT;
47 | loadingDialog.getWindow().setLayout(width ,height);
48 |
49 | return loadingDialog;
50 | }
51 |
52 | public static void setMsg(String msg){
53 | if (loadingDialog!=null&&loadingDialog.isShowing()){
54 | tipTextView.setText(msg);// 设置加载信息
55 | }
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/Upper.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog;
2 |
3 |
4 | import android.content.Context;
5 | import android.view.View;
6 |
7 | import com.zlylib.upperdialog.dialog.DialogLayer;
8 | import com.zlylib.upperdialog.manager.ActivityHolder;
9 | import com.zlylib.upperdialog.popup.PopupLayer;
10 | import com.zlylib.upperdialog.toast.ToastLayer;
11 | import com.zlylib.upperdialog.utils.Utils;
12 | import com.zlylib.upperdialog.view.UpperActivity;
13 |
14 | /**
15 | * @author zhangliyang
16 | * GitHub: https://github.com/ZLYang110
17 | */
18 | public class Upper {
19 |
20 |
21 | /**
22 | * 弹窗
23 | * */
24 | public static DialogLayer dialog(Context context) {
25 |
26 | return new DialogLayer(context);
27 | }
28 |
29 | public static void dialog(UpperActivity.OnLayerCreatedCallback callback) {
30 | UpperActivity.start(ActivityHolder.getApplication(), callback);
31 | }
32 | public static DialogLayer dialog() {
33 | return new DialogLayer(ActivityHolder.getCurrentActivity());
34 | }
35 |
36 | /**
37 | * toast
38 | * */
39 | public static ToastLayer toast() {
40 | return new ToastLayer(ActivityHolder.getCurrentActivity());
41 | }
42 |
43 | public static ToastLayer toast(Context context) {
44 | return new ToastLayer(context);
45 | }
46 |
47 | /**
48 | * popup
49 | * */
50 | public static PopupLayer popup(Context context) {
51 | return new PopupLayer(context);
52 | }
53 |
54 | public static PopupLayer popup(View targetView) {
55 | return new PopupLayer(targetView);
56 | }
57 | }
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/common/Align.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.common;
2 |
3 | /**
4 | * @author zhangliyang
5 | */
6 | public final class Align {
7 | /**
8 | * 主方向
9 | */
10 | public enum Direction {
11 | HORIZONTAL,
12 | VERTICAL
13 | }
14 |
15 | /**
16 | * 水平对齐方式
17 | */
18 | public enum Horizontal {
19 | CENTER,
20 | TO_LEFT,
21 | TO_RIGHT,
22 | ALIGN_LEFT,
23 | ALIGN_RIGHT,
24 | ALIGN_PARENT_LEFT,
25 | ALIGN_PARENT_RIGHT
26 | }
27 |
28 | /**
29 | * 垂直对齐方式
30 | */
31 | public enum Vertical {
32 | CENTER,
33 | ABOVE,
34 | BELOW,
35 | ALIGN_TOP,
36 | ALIGN_BOTTOM,
37 | ALIGN_PARENT_TOP,
38 | ALIGN_PARENT_BOTTOM
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/listener/SimpleCallback.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.listener;
2 |
3 | /**
4 | * @author zhangliyang
5 | */
6 | public interface SimpleCallback {
7 | void onResult(E data);
8 | }
9 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/listener/SimpleListener.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.listener;
2 |
3 | /**
4 | * @author zhangliyang
5 | * GitHub: https://github.com/ZLYang110
6 | */
7 | public interface SimpleListener {
8 | void onResult();
9 | }
10 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/manager/ActivityHolder.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.manager;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.os.Bundle;
6 | import android.text.TextUtils;
7 |
8 | import com.zlylib.upperdialog.utils.Utils;
9 |
10 | import java.util.LinkedList;
11 | import java.util.List;
12 |
13 | /**
14 | * @author zhangliyang
15 | * GitHub: https://github.com/ZLYang110
16 | */
17 | public final class ActivityHolder implements Application.ActivityLifecycleCallbacks {
18 |
19 | private static ActivityHolder INSTANCE = null;
20 |
21 | private final Application mApplication;
22 | private final List mActivityStack = new LinkedList<>();
23 |
24 | private ActivityHolder(Application application) {
25 | mApplication = Utils.requireNonNull(application, "application == null");
26 | application.registerActivityLifecycleCallbacks(this);
27 | }
28 |
29 | public static void init(Application application) {
30 | if (INSTANCE == null) {
31 | INSTANCE = new ActivityHolder(application);
32 | }
33 | }
34 |
35 | public static Application getApplication() {
36 | if (INSTANCE == null) {
37 | return null;
38 | }
39 | return INSTANCE.mApplication;
40 | }
41 |
42 | public static Activity getActivity(Class clazz) {
43 | Utils.requireNonNull(clazz, "clazz == null");
44 | if (INSTANCE == null) {
45 | return null;
46 | }
47 | if (INSTANCE.mActivityStack.isEmpty()) {
48 | return null;
49 | }
50 | final int size = INSTANCE.mActivityStack.size();
51 | for (int i = size - 1; i >= 0; i--) {
52 | Activity activity = INSTANCE.mActivityStack.get(i);
53 | if (TextUtils.equals(clazz.getName(), activity.getClass().getName())) {
54 | return activity;
55 | }
56 | }
57 | return null;
58 | }
59 |
60 | public static Activity getCurrentActivity() {
61 | if (INSTANCE == null) {
62 | return null;
63 | }
64 | if (INSTANCE.mActivityStack.isEmpty()) {
65 | return null;
66 | }
67 | return INSTANCE.mActivityStack.get(INSTANCE.mActivityStack.size() - 1);
68 | }
69 |
70 | @Override
71 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
72 | mActivityStack.add(activity);
73 | }
74 |
75 | @Override
76 | public void onActivityStarted(Activity activity) {
77 | }
78 |
79 | @Override
80 | public void onActivityResumed(Activity activity) {
81 | }
82 |
83 | @Override
84 | public void onActivityPaused(Activity activity) {
85 | }
86 |
87 | @Override
88 | public void onActivityStopped(Activity activity) {
89 | }
90 |
91 | @Override
92 | public void onActivityDestroyed(Activity activity) {
93 | mActivityStack.remove(activity);
94 | }
95 |
96 | @Override
97 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/manager/DragCompat.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.manager;
2 |
3 | import android.graphics.Rect;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.webkit.WebView;
7 | import android.widget.AbsListView;
8 | import android.widget.HorizontalScrollView;
9 | import android.widget.ScrollView;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | /**
14 | * @author zhangliyang
15 | * GitHub: https://github.com/ZLYang110
16 | */
17 | public class DragCompat {
18 |
19 | @Deprecated
20 | public static boolean canViewScrollUp(View view, float x, float y, boolean defaultValueForNull) {
21 | if (view == null || !contains(view, x, y)) {
22 | return defaultValueForNull;
23 | }
24 | return view.canScrollVertically(-1);
25 | }
26 |
27 | public static boolean canViewScrollUp(List views, float x, float y, boolean defaultValueForNull) {
28 | if (views == null) {
29 | return defaultValueForNull;
30 | }
31 | List contains = contains(views, x, y);
32 | if (contains == null) {
33 | return defaultValueForNull;
34 | }
35 | boolean canViewScroll = false;
36 | for (int i = contains.size() - 1; i >= 0; i--) {
37 | canViewScroll = ScrollCompat.canScrollVertically(contains.get(i), -1);
38 | if (canViewScroll) {
39 | break;
40 | }
41 | }
42 | return canViewScroll;
43 | }
44 |
45 | public static View canScrollUpView(List views, float x, float y) {
46 | if (views == null) {
47 | return null;
48 | }
49 | List contains = contains(views, x, y);
50 | if (contains == null) {
51 | return null;
52 | }
53 | for (int i = contains.size() - 1; i >= 0; i--) {
54 | View view = contains.get(i);
55 | if (ScrollCompat.canScrollVertically(view, -1)) {
56 | return view;
57 | }
58 | }
59 | return null;
60 | }
61 |
62 | @Deprecated
63 | public static boolean canViewScrollDown(View view, float x, float y, boolean defaultValueForNull) {
64 | if (view == null || !contains(view, x, y)) {
65 | return defaultValueForNull;
66 | }
67 | return view.canScrollVertically(1);
68 | }
69 |
70 | public static boolean canViewScrollDown(List views, float x, float y, boolean defaultValueForNull) {
71 | if (views == null) {
72 | return defaultValueForNull;
73 | }
74 | List contains = contains(views, x, y);
75 | if (contains == null) {
76 | return defaultValueForNull;
77 | }
78 | boolean canViewScroll = false;
79 | for (int i = contains.size() - 1; i >= 0; i--) {
80 | canViewScroll = ScrollCompat.canScrollVertically(contains.get(i), 1);
81 | if (canViewScroll) {
82 | break;
83 | }
84 | }
85 | return canViewScroll;
86 | }
87 |
88 | public static View canScrollDownView(List views, float x, float y) {
89 | if (views == null) {
90 | return null;
91 | }
92 | List contains = contains(views, x, y);
93 | if (contains == null) {
94 | return null;
95 | }
96 | for (int i = contains.size() - 1; i >= 0; i--) {
97 | View view = contains.get(i);
98 | if (ScrollCompat.canScrollVertically(view, 1)) {
99 | return view;
100 | }
101 | }
102 | return null;
103 | }
104 |
105 | @Deprecated
106 | public static boolean canViewScrollRight(View view, float x, float y, boolean defaultValueForNull) {
107 | if (view == null || !contains(view, x, y)) {
108 | return defaultValueForNull;
109 | }
110 | return view.canScrollHorizontally(-1);
111 | }
112 |
113 | public static boolean canViewScrollRight(List views, float x, float y, boolean defaultValueForNull) {
114 | if (views == null) {
115 | return defaultValueForNull;
116 | }
117 | List contains = contains(views, x, y);
118 | if (contains == null) {
119 | return defaultValueForNull;
120 | }
121 | boolean canViewScroll = false;
122 | for (int i = contains.size() - 1; i >= 0; i--) {
123 | canViewScroll = ScrollCompat.canScrollHorizontally(contains.get(i), 1);
124 | if (canViewScroll) {
125 | break;
126 | }
127 | }
128 | return canViewScroll;
129 | }
130 |
131 | public static View canScrollRightView(List views, float x, float y) {
132 | if (views == null) {
133 | return null;
134 | }
135 | List contains = contains(views, x, y);
136 | if (contains == null) {
137 | return null;
138 | }
139 | for (int i = contains.size() - 1; i >= 0; i--) {
140 | View view = contains.get(i);
141 | if (ScrollCompat.canScrollHorizontally(view, 1)) {
142 | return view;
143 | }
144 | }
145 | return null;
146 | }
147 |
148 | @Deprecated
149 | public static boolean canViewScrollLeft(View view, float x, float y, boolean defaultValueForNull) {
150 | if (view == null || !contains(view, x, y)) {
151 | return defaultValueForNull;
152 | }
153 | return view.canScrollHorizontally(1);
154 | }
155 |
156 | public static boolean canViewScrollLeft(List views, float x, float y, boolean defaultValueForNull) {
157 | if (views == null) {
158 | return defaultValueForNull;
159 | }
160 | List contains = contains(views, x, y);
161 | if (contains == null) {
162 | return defaultValueForNull;
163 | }
164 | boolean canViewScroll = false;
165 | for (int i = contains.size() - 1; i >= 0; i--) {
166 | canViewScroll = ScrollCompat.canScrollHorizontally(contains.get(i), -1);
167 | if (canViewScroll) {
168 | break;
169 | }
170 | }
171 | return canViewScroll;
172 | }
173 |
174 | public static View canScrollLeftView(List views, float x, float y) {
175 | if (views == null) {
176 | return null;
177 | }
178 | List contains = contains(views, x, y);
179 | if (contains == null) {
180 | return null;
181 | }
182 | for (int i = contains.size() - 1; i >= 0; i--) {
183 | View view = contains.get(i);
184 | if (ScrollCompat.canScrollHorizontally(view, -1)) {
185 | return view;
186 | }
187 | }
188 | return null;
189 | }
190 |
191 | public static List findAllScrollViews(ViewGroup viewGroup) {
192 | List views = new ArrayList<>();
193 | for (int i = 0; i < viewGroup.getChildCount(); i++) {
194 | View view = viewGroup.getChildAt(i);
195 | if (view.getVisibility() != View.VISIBLE) {
196 | continue;
197 | }
198 | if (isScrollableView(view)) {
199 | views.add(view);
200 | }
201 | if (view instanceof ViewGroup) {
202 | views.addAll(findAllScrollViews((ViewGroup) view));
203 | }
204 | }
205 | return views;
206 | }
207 |
208 | public static boolean isScrollableView(View view) {
209 | return view instanceof ScrollView
210 | || view instanceof HorizontalScrollView
211 | || view instanceof AbsListView
212 | || view instanceof WebView;
213 | }
214 |
215 | public static boolean contains(View view, float x, float y) {
216 | Rect localRect = new Rect();
217 | view.getGlobalVisibleRect(localRect);
218 | return localRect.contains((int) x, (int) y);
219 | }
220 |
221 | public static List contains(List views, float x, float y) {
222 | if (views == null) {
223 | return null;
224 | }
225 | List contains = new ArrayList<>(views.size());
226 | for (int i = views.size() - 1; i >= 0; i--) {
227 | View v = views.get(i);
228 | Rect localRect = new Rect();
229 | int[] l = new int[2];
230 | v.getLocationOnScreen(l);
231 | localRect.set(l[0], l[1], l[0] + v.getWidth(), l[1] + v.getHeight());
232 | if (localRect.contains((int) x, (int) y)) {
233 | contains.add(v);
234 | }
235 | }
236 | return contains;
237 | }
238 | }
239 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/manager/ScrollCompat.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.manager;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * @author zhangliyang
7 | */
8 | public class ScrollCompat {
9 |
10 | public static boolean canScrollHorizontally(View v, int direction) {
11 | return v.canScrollHorizontally(direction);
12 | }
13 |
14 | public static boolean canScrollVertically(View v, int direction) {
15 | return v.canScrollVertically(direction);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/manager/SoftInputHelper.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.manager;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.app.Activity;
5 | import android.graphics.Rect;
6 | import android.os.Build;
7 | import android.view.View;
8 | import android.view.ViewTreeObserver;
9 | import android.view.Window;
10 | import android.view.WindowManager;
11 | import android.view.animation.DecelerateInterpolator;
12 |
13 | import com.zlylib.upperdialog.utils.Utils;
14 |
15 | import java.util.HashMap;
16 | import java.util.Map;
17 |
18 | /**
19 | * 监听软键盘的打开和隐藏
20 | * 打开时滚动布局,可设置仅在某几个EditText获取焦点时开启
21 | *
22 | * @author zhangliyang
23 | */
24 | public final class SoftInputHelper implements ViewTreeObserver.OnGlobalLayoutListener, ViewTreeObserver.OnGlobalFocusChangeListener {
25 |
26 | private final Window window;
27 | private final View rootView;
28 |
29 | private long duration = 300;
30 | private View moveView = null;
31 | private Map focusBottomMap = new HashMap<>(1);
32 | private OnSoftInputListener onSoftInputListener = null;
33 |
34 | private boolean moveWithScroll = false;
35 |
36 | private boolean isOpened = false;
37 | private int moveHeight = 0;
38 | private boolean isFocusChange = false;
39 |
40 | private Runnable moveRunnable = new Runnable() {
41 | @Override
42 | public void run() {
43 | calcToMove();
44 | }
45 | };
46 |
47 | public static SoftInputHelper attach(Activity activity) {
48 | Utils.requireNonNull(activity, "activity == null");
49 | return new SoftInputHelper(activity);
50 | }
51 |
52 | private SoftInputHelper(Activity activity) {
53 | Utils.requireNonNull(activity, "activity == null");
54 | this.window = activity.getWindow();
55 | this.rootView = window.getDecorView().getRootView();
56 | ViewTreeObserver observer = rootView.getViewTreeObserver();
57 | observer.addOnGlobalLayoutListener(this);
58 | observer.addOnGlobalFocusChangeListener(this);
59 | window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
60 | }
61 |
62 | public void detach() {
63 | if (rootView.getViewTreeObserver().isAlive()) {
64 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
65 | rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
66 | } else {
67 | rootView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
68 | }
69 | rootView.getViewTreeObserver().removeOnGlobalFocusChangeListener(this);
70 | }
71 | }
72 |
73 | public SoftInputHelper moveBy(View moveView) {
74 | Utils.requireNonNull(moveView, "moveView == null");
75 | this.moveView = moveView;
76 | return this;
77 | }
78 |
79 | public SoftInputHelper moveWith(View bottomView, View... focusViews) {
80 | Utils.requireNonNull(bottomView, "bottomView == null");
81 | for (View focusView : focusViews) {
82 | focusBottomMap.put(focusView, bottomView);
83 | }
84 | return this;
85 | }
86 |
87 | public SoftInputHelper listener(OnSoftInputListener onSoftInputListener) {
88 | this.onSoftInputListener = onSoftInputListener;
89 | return this;
90 | }
91 |
92 | public SoftInputHelper duration(long duration) {
93 | this.duration = duration;
94 | return this;
95 | }
96 |
97 | /**
98 | * 设置moveView移动以ScrollY属性滚动内容
99 | *
100 | * @return SoftInputHelper
101 | */
102 | public SoftInputHelper moveWithScroll() {
103 | this.moveWithScroll = true;
104 | return this;
105 | }
106 |
107 | /**
108 | * 设置moveView移动以TranslationY属性移动位置
109 | *
110 | * @return SoftInputHelper
111 | */
112 | public SoftInputHelper moveWithTranslation() {
113 | this.moveWithScroll = false;
114 | return this;
115 | }
116 |
117 | @Override
118 | public void onGlobalLayout() {
119 | boolean isOpen = isSoftOpen();
120 | if (isOpen) {
121 | if (!isOpened) {
122 | isOpened = true;
123 | if (onSoftInputListener != null) {
124 | onSoftInputListener.onOpen();
125 | }
126 | }
127 | if (moveView != null) {
128 | if (isFocusChange) {
129 | isFocusChange = false;
130 | rootView.removeCallbacks(moveRunnable);
131 | }
132 | calcToMove();
133 | }
134 | } else {
135 | if (isOpened) {
136 | isOpened = false;
137 | if (onSoftInputListener != null) {
138 | onSoftInputListener.onClose();
139 | }
140 | }
141 | if (moveView != null) {
142 | moveHeight = 0;
143 | move();
144 | }
145 | }
146 | }
147 |
148 | private void calcToMove(){
149 | View focusView = isViewFocus();
150 | if (focusView != null) {
151 | View bottomView = focusBottomMap.get(focusView);
152 | if (bottomView != null) {
153 | Rect rect = getRootViewRect();
154 | int bottomViewY = getBottomViewY(bottomView);
155 | if (bottomViewY > rect.bottom) {
156 | int offHeight = bottomViewY - rect.bottom;
157 | moveHeight += offHeight;
158 | move();
159 | } else if (bottomViewY < rect.bottom) {
160 | int offHeight = -(bottomViewY - rect.bottom);
161 | if (moveHeight > 0) {
162 | if (moveHeight >= offHeight) {
163 | moveHeight -= offHeight;
164 | } else {
165 | moveHeight = 0;
166 | }
167 | move();
168 | }
169 | }
170 | }
171 | } else {
172 | moveHeight = 0;
173 | move();
174 | }
175 | }
176 |
177 | @Override
178 | public void onGlobalFocusChanged(View oldFocus, View newFocus) {
179 | if (isOpened) {
180 | if (moveView != null) {
181 | isFocusChange = true;
182 | rootView.postDelayed(moveRunnable, 100);
183 | }
184 | }
185 | }
186 |
187 | private int getBottomViewY(View bottomView) {
188 | int[] bottomLocation = new int[2];
189 | bottomView.getLocationOnScreen(bottomLocation);
190 | return bottomLocation[1] + bottomView.getHeight();
191 | }
192 |
193 | private Rect getRootViewRect() {
194 | Rect rect = new Rect();
195 | rootView.getWindowVisibleDisplayFrame(rect);
196 | return rect;
197 | }
198 |
199 | private void move() {
200 | if (moveWithScroll) {
201 | scrollTo(moveHeight);
202 | } else {
203 | translationTo(-moveHeight);
204 | }
205 | }
206 |
207 | private void translationTo(int to) {
208 | float translationY = moveView.getTranslationY();
209 | if (translationY == to) {
210 | return;
211 | }
212 | ObjectAnimator anim = ObjectAnimator.ofFloat(moveView, "translationY", translationY, to);
213 | anim.setInterpolator(new DecelerateInterpolator());
214 | anim.setDuration(duration);
215 | anim.start();
216 | }
217 |
218 | private void scrollTo(int to) {
219 | int scrollY = moveView.getScrollY();
220 | if (scrollY == to) {
221 | return;
222 | }
223 | ObjectAnimator anim = ObjectAnimator.ofInt(moveView, "scrollY", scrollY, to);
224 | anim.setInterpolator(new DecelerateInterpolator());
225 | anim.setDuration(duration);
226 | anim.start();
227 | }
228 |
229 | /**
230 | * 判断软键盘打开状态的阈值
231 | * 此处以用户可用高度变化值大于1/4总高度时作为判断依据。
232 | *
233 | * @return boolean
234 | */
235 | private boolean isSoftOpen() {
236 | Rect rect = getRootViewRect();
237 | int usableHeightNow = rect.bottom - rect.top;
238 | int usableHeightSansKeyboard = rootView.getHeight();
239 | int heightDifference = usableHeightSansKeyboard - usableHeightNow;
240 | if (heightDifference > (usableHeightSansKeyboard / 4)) {
241 | return true;
242 | } else {
243 | return false;
244 | }
245 | }
246 |
247 | private View isViewFocus() {
248 | View focusView = window.getCurrentFocus();
249 | for (View view : focusBottomMap.keySet()) {
250 | if (focusView == view) {
251 | return view;
252 | }
253 | }
254 | return null;
255 | }
256 |
257 | public interface OnSoftInputListener {
258 | /**
259 | * 软键盘由关闭变为打开时调用
260 | */
261 | void onOpen();
262 |
263 | /**
264 | * 软键盘由打开变为关闭时调用
265 | */
266 | void onClose();
267 | }
268 | }
269 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/manager/ViewManager.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.manager;
2 |
3 |
4 | import android.view.KeyEvent;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.view.ViewTreeObserver;
8 |
9 | import com.zlylib.upperdialog.utils.Utils;
10 |
11 |
12 | /**
13 | * 描述:管理view的动态添加和移除
14 | * 这里有几个生命周期的回调:
15 | * {@link #onAttach()}
16 | * {@link #onDetach()}
17 | *
18 | * @author zhangliyang
19 | * @date 2018/10/25
20 | */
21 | public class ViewManager {
22 | private ViewGroup mParent = null;
23 | private View mChild = null;
24 |
25 | private LayerKeyListener mLayerKeyListener = null;
26 | private LayerGlobalFocusChangeListener mLayerGlobalFocusChangeListener = null;
27 |
28 | private View currentKeyView = null;
29 |
30 | private OnLifeListener mOnLifeListener = null;
31 | private OnPreDrawListener mOnPreDrawListener = null;
32 | private OnKeyListener mOnKeyListener = null;
33 |
34 | public ViewManager() {
35 | }
36 |
37 | public void setParent(ViewGroup parent) {
38 | Utils.requireNonNull(parent, "parent == null");
39 | mParent = parent;
40 | }
41 |
42 | public void setChild(View child) {
43 | Utils.requireNonNull(child, "child == null");
44 | mChild = child;
45 | }
46 |
47 | public ViewGroup getParent() {
48 | return mParent;
49 | }
50 |
51 | public View getChild() {
52 | return mChild;
53 | }
54 |
55 | private void checkChildParent() {
56 | ViewGroup parent = (ViewGroup) mChild.getParent();
57 | if (parent != null && parent != mParent) {
58 | parent.removeView(mChild);
59 | }
60 | }
61 |
62 | public void attach() {
63 | Utils.requireNonNull(mParent, "parent cannot be null on attach");
64 | Utils.requireNonNull(mChild, "child cannot be null on attach");
65 | checkChildParent();
66 | if (!isAttached()) {
67 | onAttach();
68 | }
69 | }
70 |
71 | public void detach() {
72 | if (isAttached()) {
73 | onDetach();
74 | }
75 | }
76 |
77 | public boolean isAttached() {
78 | return mChild != null && mChild.getParent() != null;
79 | }
80 |
81 | public void setOnLifeListener(OnLifeListener onLifeListener) {
82 | mOnLifeListener = onLifeListener;
83 | }
84 |
85 | public void setOnPreDrawListener(OnPreDrawListener onPreDrawListener) {
86 | mOnPreDrawListener = onPreDrawListener;
87 | }
88 |
89 | public void setOnKeyListener(OnKeyListener onKeyListener) {
90 | mOnKeyListener = onKeyListener;
91 | }
92 |
93 | /**
94 | * 添加到父View
95 | */
96 | private void onAttach() {
97 | if (mOnKeyListener != null) {
98 | mChild.setFocusable(true);
99 | mChild.setFocusableInTouchMode(true);
100 | mChild.requestFocus();
101 | currentKeyView = mChild;
102 | mLayerGlobalFocusChangeListener = new LayerGlobalFocusChangeListener();
103 | mChild.getViewTreeObserver().addOnGlobalFocusChangeListener(mLayerGlobalFocusChangeListener);
104 | mLayerKeyListener = new LayerKeyListener();
105 | currentKeyView.setOnKeyListener(mLayerKeyListener);
106 | }
107 | mChild.getViewTreeObserver().addOnPreDrawListener(new LayerPreDrawListener());
108 | mParent.addView(mChild);
109 | if (mOnLifeListener != null) {
110 | mOnLifeListener.onAttach();
111 | }
112 | }
113 |
114 | /**
115 | * 从父View移除
116 | */
117 | private void onDetach() {
118 | if (currentKeyView != null) {
119 | currentKeyView.setOnKeyListener(null);
120 | mLayerKeyListener = null;
121 | mChild.getViewTreeObserver().removeOnGlobalFocusChangeListener(mLayerGlobalFocusChangeListener);
122 | mLayerGlobalFocusChangeListener = null;
123 | }
124 | mParent.removeView(mChild);
125 | if (mOnLifeListener != null) {
126 | mOnLifeListener.onDetach();
127 | }
128 | }
129 |
130 | private final class LayerPreDrawListener implements ViewTreeObserver.OnPreDrawListener {
131 | @Override
132 | public boolean onPreDraw() {
133 | if (mChild.getViewTreeObserver().isAlive()) {
134 | mChild.getViewTreeObserver().removeOnPreDrawListener(this);
135 | }
136 | if (mOnPreDrawListener != null) {
137 | mOnPreDrawListener.onPreDraw();
138 | }
139 | return true;
140 | }
141 | }
142 |
143 | private final class LayerGlobalFocusChangeListener implements ViewTreeObserver.OnGlobalFocusChangeListener {
144 | @Override
145 | public void onGlobalFocusChanged(android.view.View oldFocus, android.view.View newFocus) {
146 | if (currentKeyView != null) {
147 | currentKeyView.setOnKeyListener(null);
148 | }
149 | if (oldFocus != null) {
150 | oldFocus.setOnKeyListener(null);
151 | }
152 | if (newFocus != null) {
153 | currentKeyView = newFocus;
154 | currentKeyView.setOnKeyListener(mLayerKeyListener);
155 | }
156 | }
157 | }
158 |
159 | private final class LayerKeyListener implements View.OnKeyListener {
160 | @Override
161 | public boolean onKey(View v, int keyCode, KeyEvent event) {
162 | if (!isAttached()) {
163 | return false;
164 | }
165 | if (mOnKeyListener == null) {
166 | return false;
167 | }
168 | return mOnKeyListener.onKey(keyCode, event);
169 | }
170 | }
171 |
172 | public interface OnLifeListener {
173 | void onAttach();
174 |
175 | void onDetach();
176 | }
177 |
178 | public interface OnPreDrawListener {
179 | void onPreDraw();
180 | }
181 |
182 | public interface OnKeyListener {
183 | boolean onKey(int keyCode, KeyEvent event);
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/pro/ActivityProvider.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.pro;
2 |
3 | import android.app.Application;
4 | import android.content.ContentProvider;
5 | import android.content.ContentValues;
6 | import android.content.Context;
7 | import android.database.Cursor;
8 | import android.net.Uri;
9 |
10 | import com.zlylib.upperdialog.manager.ActivityHolder;
11 |
12 |
13 | /**
14 | * @author zhangliyang
15 | * GitHub: https://github.com/ZLYang110
16 | */
17 | public final class ActivityProvider extends ContentProvider {
18 |
19 | @Override
20 | public boolean onCreate() {
21 | Context context = getContext();
22 | if (context instanceof Application) {
23 | ActivityHolder.init((Application) context);
24 | return true;
25 | } else {
26 | return false;
27 | }
28 | }
29 |
30 | @Override
31 | public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
32 | return null;
33 | }
34 |
35 | @Override
36 | public String getType(Uri uri) {
37 | return null;
38 | }
39 |
40 | @Override
41 | public Uri insert(Uri uri, ContentValues values) {
42 | return null;
43 | }
44 |
45 | @Override
46 | public int delete(Uri uri, String selection, String[] selectionArgs) {
47 | return 0;
48 | }
49 |
50 | @Override
51 | public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
52 | return 0;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/utils/ResUtils.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 | import android.content.res.Resources;
6 | import android.graphics.drawable.Drawable;
7 | import android.view.View;
8 |
9 | import androidx.annotation.ArrayRes;
10 | import androidx.annotation.BoolRes;
11 | import androidx.annotation.ColorRes;
12 | import androidx.annotation.DimenRes;
13 | import androidx.annotation.DrawableRes;
14 | import androidx.annotation.IntegerRes;
15 | import androidx.annotation.StringRes;
16 | import androidx.core.content.ContextCompat;
17 |
18 | import java.io.BufferedReader;
19 | import java.io.IOException;
20 | import java.io.InputStreamReader;
21 |
22 | /**
23 | * 获取资源文件的工具类
24 | *
25 | * @author zhangliyang
26 | * @date 2018/7/9-下午4:56
27 | */
28 | public class ResUtils {
29 |
30 | public static Resources getResources() {
31 | return Utils.getAppContext().getResources();
32 | }
33 |
34 | public static Drawable getDrawable(@DrawableRes int id) {
35 | return ContextCompat.getDrawable(Utils.getAppContext(), id);
36 | }
37 |
38 | public static String getString(@StringRes int id) {
39 | return getResources().getString(id);
40 | }
41 |
42 | @Deprecated
43 | public static int getColor(@ColorRes int id) {
44 | return ContextCompat.getColor(Utils.getAppContext(), id);
45 | }
46 |
47 | public static int getColor(Context context, @ColorRes int id) {
48 | return context.getResources().getColor(id);
49 | }
50 |
51 | public static int getColor(View view, @ColorRes int id) {
52 | return view.getContext().getResources().getColor(id);
53 | }
54 |
55 | public static float getDimens(@DimenRes int id) {
56 | return getResources().getDimension(id);
57 | }
58 |
59 | public static String[] getStringArray(@ArrayRes int id) {
60 | return getResources().getStringArray(id);
61 | }
62 |
63 | public static boolean getBoolean(@BoolRes int id) {
64 | return getResources().getBoolean(id);
65 | }
66 |
67 | public static int getInteger(@IntegerRes int id) {
68 | return getResources().getInteger(id);
69 | }
70 |
71 | public static String getAssets(String fileName) {
72 | StringBuilder stringBuilder = new StringBuilder();
73 | try {
74 | AssetManager assetManager = Utils.getAppContext().getAssets();
75 | BufferedReader bf = new BufferedReader(new InputStreamReader(assetManager.open(fileName)));
76 | String line;
77 | while ((line = bf.readLine()) != null) {
78 | stringBuilder.append(line);
79 | }
80 | } catch (IOException e) {
81 | e.printStackTrace();
82 | }
83 | return stringBuilder.toString();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.utils;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.ContextWrapper;
7 | import android.graphics.Bitmap;
8 | import android.graphics.Canvas;
9 | import android.graphics.Color;
10 | import android.os.Build;
11 | import android.view.View;
12 | import android.view.ViewTreeObserver;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 | import android.widget.FrameLayout;
16 | import android.widget.ImageView;
17 |
18 | import com.zlylib.upperdialog.manager.DecorLayer;
19 | import com.zlylib.upperdialog.view.ContainerLayout;
20 |
21 |
22 | /**
23 | * @author zhangliyang
24 | * @date 2018/10/25
25 | */
26 | public final class Utils {
27 | @SuppressLint("StaticFieldLeak")
28 | private static Context context = null;
29 |
30 | public static void init(Context context) {
31 | Utils.context = context;
32 |
33 | }
34 |
35 | public static Context getAppContext() {
36 | if (context == null) {
37 | throw new RuntimeException("Utils未在Application中初始化");
38 | }
39 | return context;
40 | }
41 | public static T requireNonNull(T obj, String msg) {
42 | if (obj == null) {
43 | throw new NullPointerException(msg);
44 | }
45 | return obj;
46 | }
47 |
48 | public static T requireNonNull(T obj) {
49 | if (obj == null) {
50 | throw new NullPointerException();
51 | }
52 | return obj;
53 | }
54 |
55 | public static float floatRange01(float value) {
56 | return floatRange(value, 0F, 1F);
57 | }
58 |
59 | public static float floatRange(float value, float min, float max) {
60 | if (value < min) return min;
61 | if (value > max) return max;
62 | return value;
63 | }
64 |
65 | static int intRange(int value, int min, int max) {
66 | if (value < min) return min;
67 | if (value > max) return max;
68 | return value;
69 | }
70 |
71 | public static int getStatusBarHeight(Context context) {
72 | int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
73 | if (resourceId > 0) {
74 | return context.getResources().getDimensionPixelSize(resourceId);
75 | }
76 | return 0;
77 | }
78 |
79 | /**
80 | * 从当前上下文获取Activity
81 | */
82 | public static Activity getActivity(Context context) {
83 | if (context == null) {
84 | return null;
85 | }
86 | if (context instanceof Activity) {
87 | return (Activity) context;
88 | }
89 | if (context instanceof ContextWrapper) {
90 | Context baseContext = ((ContextWrapper) context).getBaseContext();
91 | if (baseContext instanceof Activity) {
92 | return (Activity) baseContext;
93 | }
94 | }
95 | return null;
96 | }
97 |
98 | public static Bitmap snapshot(FrameLayout decor,
99 | ImageView iv,
100 | float scale,
101 | DecorLayer.LevelLayout currLevelLayout,
102 | ContainerLayout currContainerLayout) {
103 | int w = iv.getWidth();
104 | int h = iv.getHeight();
105 | int oW = (int) (w / scale);
106 | int oH = (int) (h / scale);
107 | Bitmap bitmap = Bitmap.createBitmap(oW, oH, Bitmap.Config.ARGB_8888);
108 | Canvas canvas = new Canvas(bitmap);
109 | canvas.save();
110 | int[] locationRootView = new int[2];
111 | decor.getLocationOnScreen(locationRootView);
112 | int[] locationBackground = new int[2];
113 | iv.getLocationOnScreen(locationBackground);
114 | int x = locationBackground[0] - locationRootView[0];
115 | int y = locationBackground[1] - locationRootView[1];
116 | canvas.scale(1 / scale, 1 / scale);
117 | canvas.translate(x / scale, y / scale);
118 | if (decor.getBackground() != null) {
119 | decor.getBackground().draw(canvas);
120 | }
121 | out:
122 | for (int i = 0; i < decor.getChildCount(); i++) {
123 | View decorChildAt = decor.getChildAt(i);
124 | if (decorChildAt instanceof DecorLayer.LayerLayout) {
125 | DecorLayer.LayerLayout layerLayout = (DecorLayer.LayerLayout) decorChildAt;
126 | for (int j = 0; j < layerLayout.getChildCount(); j++) {
127 | View layerChildAt = layerLayout.getChildAt(j);
128 | if (layerChildAt instanceof DecorLayer.LevelLayout) {
129 | DecorLayer.LevelLayout levelLayout = (DecorLayer.LevelLayout) layerChildAt;
130 | if (levelLayout == currLevelLayout) {
131 | for (int k = 0; k < levelLayout.getChildCount(); k++) {
132 | View containerLayout = levelLayout.getChildAt(k);
133 | if (containerLayout == currContainerLayout) {
134 | break out;
135 | } else {
136 | containerLayout.draw(canvas);
137 | }
138 | }
139 | break out;
140 | } else {
141 | levelLayout.draw(canvas);
142 | }
143 | } else {
144 | break out;
145 | }
146 | }
147 | break;
148 | } else {
149 | decorChildAt.draw(canvas);
150 | }
151 | }
152 | canvas.restore();
153 |
154 | return bitmap;
155 | }
156 |
157 | public static void transparent(Activity activity) {
158 | final Window window = activity.getWindow();
159 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
160 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
161 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
162 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
163 | window.setStatusBarColor(Color.TRANSPARENT);
164 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
165 | window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
166 | }
167 | }
168 |
169 | public static void getViewSize(final View view,final Runnable runnable) {
170 | requireNonNull(view);
171 | view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
172 | @Override
173 | public void onGlobalLayout() {
174 | if (view.getViewTreeObserver().isAlive()) {
175 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
176 | view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
177 | } else {
178 | view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
179 | }
180 | }
181 | runnable.run();
182 | }
183 | });
184 | }
185 |
186 |
187 |
188 | }
189 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/view/BackgroundView.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 | import android.widget.ImageView;
7 |
8 | /**
9 | * Create by zhangliyang
10 | */
11 | public class BackgroundView extends ImageView {
12 |
13 | private OnTouchedListener mOnTouchedListener = null;
14 |
15 | public BackgroundView(Context context) {
16 | this(context, null);
17 | }
18 |
19 | public BackgroundView(Context context, AttributeSet attrs) {
20 | this(context, attrs, 0);
21 | }
22 |
23 | public BackgroundView(Context context, AttributeSet attrs, int defStyleAttr) {
24 | super(context, attrs, defStyleAttr);
25 | }
26 |
27 | @Override
28 | public boolean onTouchEvent(MotionEvent ev) {
29 | switch (ev.getAction()) {
30 | case MotionEvent.ACTION_DOWN:
31 | if (mOnTouchedListener != null) {
32 | mOnTouchedListener.onTouched();
33 | }
34 | break;
35 | default:
36 | break;
37 | }
38 | return false;
39 | }
40 |
41 | public void setOnTouchedListener(OnTouchedListener onTouchedListener) {
42 | this.mOnTouchedListener = onTouchedListener;
43 | }
44 |
45 | public interface OnTouchedListener {
46 | void onTouched();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/view/ContainerLayout.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.view;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 | import android.widget.FrameLayout;
8 |
9 | /**
10 | * @author zhangliyang
11 | * GitHub: https://github.com/ZLYang110
12 | */
13 | public class ContainerLayout extends FrameLayout {
14 |
15 | private OnTouchedListener mOnTouchedListener = null;
16 |
17 | public ContainerLayout(Context context) {
18 | this(context, null);
19 | }
20 |
21 | public ContainerLayout(Context context, AttributeSet attrs) {
22 | this(context, attrs, 0);
23 | }
24 |
25 | public ContainerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
26 | super(context, attrs, defStyleAttr);
27 | }
28 |
29 | @SuppressLint("ClickableViewAccessibility")
30 | @Override
31 | public boolean onTouchEvent(MotionEvent ev) {
32 | switch (ev.getAction()) {
33 | case MotionEvent.ACTION_DOWN:
34 | if (mOnTouchedListener != null) {
35 | mOnTouchedListener.onTouched();
36 | }
37 | break;
38 | default:
39 | break;
40 | }
41 | return super.onTouchEvent(ev);
42 | }
43 |
44 | public void setOnTouchedListener(OnTouchedListener onTouchedListener) {
45 | this.mOnTouchedListener = onTouchedListener;
46 | }
47 |
48 | public interface OnTouchedListener {
49 | void onTouched();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/java/com/zlylib/upperdialog/view/UpperActivity.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog.view;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 |
8 | import com.zlylib.upperdialog.Upper;
9 | import com.zlylib.upperdialog.dialog.DialogLayer;
10 | import com.zlylib.upperdialog.manager.Layer;
11 | import com.zlylib.upperdialog.utils.Utils;
12 |
13 | public class UpperActivity extends Activity implements Layer.OnVisibleChangeListener {
14 |
15 | private static OnLayerCreatedCallback sOnLayerCreatedCallback = null;
16 |
17 | public static void start(Context context, OnLayerCreatedCallback callback) {
18 | sOnLayerCreatedCallback = callback;
19 | Intent intent = new Intent(context, UpperActivity.class);
20 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
21 | context.startActivity(intent);
22 | }
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | overridePendingTransition(0, 0);
27 | super.onCreate(savedInstanceState);
28 | Utils.transparent(this);
29 | DialogLayer dialogLayer = Upper.dialog(this);
30 | dialogLayer.onVisibleChangeListener(this);
31 | if (sOnLayerCreatedCallback != null) {
32 | sOnLayerCreatedCallback.onLayerCreated(dialogLayer);
33 | }
34 | }
35 |
36 | @Override
37 | public void onShow(Layer layer) {
38 | }
39 |
40 | @Override
41 | public void onDismiss(Layer layer) {
42 | finish();
43 | overridePendingTransition(0, 0);
44 | }
45 |
46 | public interface OnLayerCreatedCallback {
47 | /**
48 | * 浮层已创建,可在这里进行浮层的初始化和数据绑定
49 | */
50 | void onLayerCreated(DialogLayer dialogLayer);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/basic_ui_dialog_download_progress_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
14 |
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
28 |
29 |
30 |
31 |
32 | -
33 |
34 |
35 |
36 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/basic_ui_dialog_loading_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_press_color_main_radius_max.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_press_color_surface.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_press_color_surface_radius_def.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_press_color_surface_radius_max.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_solid_round_color_accent_radius_def.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_solid_round_color_background_radius_max.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_solid_round_color_main_radius_max.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_solid_round_color_surface_radius_def.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_solid_round_color_surface_radius_max.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/bg_solid_round_color_surface_radius_top_def.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/drawable/upper_toast_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/anylayer_dialog_layer.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/anylayer_toast_layer.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
29 |
30 |
38 |
39 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/basic_ui_dialog_download.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
21 |
22 |
32 |
33 |
37 |
38 |
42 |
43 |
51 |
52 |
60 |
61 |
68 |
69 |
70 |
71 |
76 |
77 |
84 |
85 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/basic_ui_dialog_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
32 |
33 |
38 |
39 |
44 |
45 |
54 |
55 |
60 |
61 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/basic_ui_dialog_tip.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
36 |
37 |
41 |
42 |
46 |
47 |
56 |
57 |
62 |
63 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/basic_ui_rv_item_dialog_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/layout/loading_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
26 |
27 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_calendar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_calendar.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_camera.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_contacts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_contacts.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_location.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_microphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_microphone.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_phone.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_sensors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_sensors.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_sms.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_sms.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_storage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_storage.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_unknow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_permission_unknow.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_update.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/basic_ui_dialog_update.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/mipmap-xhdpi/loading_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZLYang110/UpperDialog/00040f6e031807726f47d354353839c9bde3e103/upperdialoglib/src/main/res/mipmap-xhdpi/loading_bg.png
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 | #86000000
7 | #ffffff
8 | #11000000
9 | #11ffffff
10 |
11 | #4282f4
12 | #994282f4
13 | #3cdc86
14 | #f86734
15 | #00000000
16 | #f5f5f5
17 | #f5f5f5
18 | #ccf5f5f5
19 | #11000000
20 | #ffffff
21 | #ccffffff
22 | #ccffffff
23 | #f5f5f5
24 | #ffffff
25 | #ccffffff
26 | #ccffffff
27 | #f5f5f5
28 | #ccf5f5f5
29 | #11000000
30 | #333333
31 | #11000000
32 | #666666
33 | #999999
34 | #cccccc
35 | #CD3333
36 |
37 |
38 | @color/main
39 | @color/main_alpha
40 | @color/accent
41 | #333333
42 | #88333333
43 | #666666
44 | #999999
45 | #cccccc
46 | #ffffff
47 | #88ffffff
48 | #ffffff
49 |
50 |
51 |
52 | #ff050505
53 | #ff5f5f5f
54 |
55 |
56 | @color/transparent
57 |
58 | @color/main
59 |
60 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 8dp
6 | 4dp
7 | 2dp
8 |
9 | 52dp
10 | 52dp
11 | 56dp
12 | 106dp
13 | 200dp
14 | 3dp
15 | 3dp
16 | 300dp
17 |
18 |
19 | 44dp
20 | 0dp
21 | 49dp
22 | 44dp
23 | 36dp
24 |
25 | 1dp
26 |
27 | 12dp
28 | 3dp
29 |
30 | 6dp
31 | 8dp
32 | 10dp
33 | 16dp
34 | 32dp
35 | 48dp
36 |
37 |
38 | 22sp
39 | 18sp
40 | 17sp
41 | 15sp
42 | 13sp
43 | 12sp
44 | 11sp
45 |
46 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | upperdialoglib
3 |
4 | 确定
5 | 取消
6 | 关闭
7 |
8 |
9 | 发现新版本
10 | 立即更新
11 | 暂不更新
12 |
13 |
14 | 下载更新中...
15 | 立即安装
16 |
17 |
--------------------------------------------------------------------------------
/upperdialoglib/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
29 |
30 |
--------------------------------------------------------------------------------
/upperdialoglib/src/test/java/com/zlylib/upperdialog/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.zlylib.upperdialog;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------