├── .gitignore
├── .idea
├── caches
│ └── gradle_models.ser
├── codeStyles
│ └── Project.xml
├── compiler.xml
├── dictionaries
│ └── myzcx.xml
├── encodings.xml
├── gradle.xml
├── jarRepositories.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── kongzue
│ │ └── updatedemo
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ └── activity_main.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
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── updateui
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
└── main
├── AndroidManifest.xml
├── java
└── com
│ └── kongzue
│ └── updateui
│ ├── UpdateUI.java
│ ├── interfaces
│ └── OnUpdateUIEventListener.java
│ └── util
│ └── ViewWrapper.java
└── res
├── anim
├── anim_pop_update_ui_enter.xml
└── anim_pop_update_ui_exit.xml
├── drawable-xxxhdpi
├── button_update_ui_button.xml
├── button_update_ui_button_dark.xml
├── img_update_ui_bkg.9.png
├── img_update_ui_bkg_dark.9.png
├── img_update_ui_shadow.png
├── progress_bar_update_ui.xml
├── progress_bar_update_ui_dark.xml
├── rect_update_ui_button_normal.xml
├── rect_update_ui_button_normal_dark.xml
├── rect_update_ui_button_press.xml
└── rect_update_ui_button_press_dark.xml
├── layout
└── layout_update_ui.xml
├── mipmap-xxhdpi
├── img_update_ui_more.png
└── img_update_ui_update_ico.png
└── values
├── colors.xml
├── strings.xml
└── styles.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | xmlns:android
32 |
33 | ^$
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | xmlns:.*
43 |
44 | ^$
45 |
46 |
47 | BY_NAME
48 |
49 |
50 |
51 |
52 |
53 |
54 | .*:id
55 |
56 | http://schemas.android.com/apk/res/android
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | .*:name
66 |
67 | http://schemas.android.com/apk/res/android
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | name
77 |
78 | ^$
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | style
88 |
89 | ^$
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | .*
99 |
100 | ^$
101 |
102 |
103 | BY_NAME
104 |
105 |
106 |
107 |
108 |
109 |
110 | .*
111 |
112 | http://schemas.android.com/apk/res/android
113 |
114 |
115 | ANDROID_ATTRIBUTE_ORDER
116 |
117 |
118 |
119 |
120 |
121 |
122 | .*
123 |
124 | .*
125 |
126 |
127 | BY_NAME
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/dictionaries/myzcx.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Kongzue UpdateUI
2 | 使用 PopupWindow 为基础构建非打扰式更新提醒组件
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | 
18 |
19 | ## Kongzue UpdateUI 是什么
20 | · UpdateUI可以为您提供非打扰式的更新提示、更新过程以及下载完成三步界面;
21 |
22 | · 这个框架是一个 UI 框架,并不包含更新或安装功能,要使用更新功能请移步 https://github.com/kongzue/KongzueUpdateSDK
23 |
24 | · 提供亮色和暗色两种可选样式,方便实现更新 UI 逻辑。
25 |
26 | ## 开始使用
27 |
28 | ### jitpack
29 |
30 | 最新版本:
31 |
32 | [](https://jitpack.io/#kongzue/UpdateUI)
33 |
34 | 1. 进入 build.gradle(project) 引入 jitpack 仓库:
35 | ```
36 | allprojects {
37 | repositories {
38 | ...
39 | maven { url 'https://jitpack.io' }
40 | }
41 | }
42 | ```
43 |
44 | 2. 进入 build.gradle(app) 引入 UpdateUI:
45 |
46 | ```
47 | implementation 'com.github.kongzue:UpdateUI:1.0.4.3'
48 | ```
49 |
50 | ### jCenter(已废弃)
51 | Maven仓库:
52 | ```
53 |
54 | com.kongzue.updateui
55 | updateui
56 | 1.0.4
57 | pom
58 |
59 | ```
60 | Gradle:
61 | 在dependencies{}中添加引用:
62 | ```
63 | implementation 'com.kongzue.updateui:updateui:1.0.4'
64 | ```
65 |
66 | 在代码中构建:
67 | ```
68 | UpdateUI updateUI;
69 | //初始化
70 | updateUI = new UpdateUI();
71 | ```
72 |
73 | 建议在 Activity 的 onDestroy() 中添加卸载方法:
74 | ```
75 | @Override
76 | protected void onDestroy() {
77 | super.onDestroy();
78 | if (updateUI != null) {
79 | updateUI.dismiss();
80 | }
81 | }
82 | ```
83 |
84 | ## 预配置
85 | 修改默认提示文案
86 | ```
87 | UpdateUI.beforeUpdateTitle = "有新版本可用";
88 | UpdateUI.afterUpdateTitle = "安装包已就绪";
89 | UpdateUI.buttonUpdateDetails = "查看详情";
90 | UpdateUI.buttonUpdateNow = "立即更新";
91 | UpdateUI.txtUpdateLogs = "- 这里是一些更新日志...\n- 这里是一些更新日志...\n- 这里是一些更新日志...";
92 | UpdateUI.buttonInstallNow = "立即安装";
93 | ```
94 |
95 | 调整暗色模式:
96 | ```
97 | UpdateUI.darkMode = true;
98 | ```
99 |
100 | 状态回调方法配置:
101 | ```
102 | updateUI.setOnUpdateUIEventListener(new OnUpdateUIEventListener() {
103 | @Override
104 | public void onShow(int status) {
105 | //用于返回界面状态的回调
106 | //status 值解释如下:
107 | //status = STATUS_BEFORE_UPDATE:处于默认状态
108 | //status = STATUS_BEFORE_UPDATE_LOGS:打开更新日志详情的状态
109 | //status = STATUS_PROGRESSING:正在更新状态
110 | //status = STATUS_FINISH:完成更新状态
111 | }
112 |
113 | @Override
114 | public void onStartDownload() {
115 | //此方法回调时说明用户点击了“立即更新”按钮,应开始执行下载过程
116 | //此时可使用 updateUI.setProgress(进度); 来更新 updateUI 的进度显示,取值范围 0~100
117 | //当更新完成时请调用 updateUI.readyInstall(); 来变更 updateUI 为待安装界面
118 | }
119 |
120 | @Override
121 | public void onIgnore(int status) {
122 | //用户上划界面忽略更新提示时执行
123 | //if (status == UpdateUI.STATUS_PROGRESSING) {
124 | // 正在下载的状态时产生的忽略
125 | // 您可以在下载完成后调用以下语句重新弹出安装提示:
126 | // updateUI.readyInstall();
127 | // updateUI.showUpdateUI(me);
128 | //}
129 | //if (status == UpdateUI.STATUS_FINISH) {
130 | // //完成后产生的忽略操作
131 | //}
132 | }
133 |
134 | @Override
135 | public void onInstallNow() {
136 | //点击立即安装后的回调
137 | }
138 | });
139 | ```
140 |
141 | ### 显示一个更新提示:
142 | ```
143 | updateUI.showUpdateUI(me);
144 | ```
145 |
146 | ## 开源协议
147 | ```
148 | Copyright Kongzue UpdateUI
149 |
150 | Licensed under the Apache License, Version 2.0 (the "License");
151 | you may not use this file except in compliance with the License.
152 | You may obtain a copy of the License at
153 |
154 | http://www.apache.org/licenses/LICENSE-2.0
155 |
156 | Unless required by applicable law or agreed to in writing, software
157 | distributed under the License is distributed on an "AS IS" BASIS,
158 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159 | See the License for the specific language governing permissions and
160 | limitations under the License.
161 | ```
162 |
163 | ## 更新日志:
164 | v1.0.4
165 | - 修复日志高度没有正确计算的bug;
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 30
5 | defaultConfig {
6 | applicationId "com.kongzue.updatedemo"
7 | minSdkVersion 19
8 | targetSdkVersion 30
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | }
19 |
20 | dependencies {
21 | implementation fileTree(include: ['*.jar'], dir: 'libs')
22 | implementation 'androidx.appcompat:appcompat:1.0.0'
23 | implementation 'com.kongzue.baseframework:baseframework:6.6.3'
24 | implementation project(':updateui')
25 | }
26 |
--------------------------------------------------------------------------------
/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/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kongzue/updatedemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.kongzue.updatedemo;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.view.View;
6 | import android.widget.Button;
7 |
8 | import com.kongzue.baseframework.BaseActivity;
9 | import com.kongzue.baseframework.interfaces.DarkStatusBarTheme;
10 | import com.kongzue.baseframework.interfaces.Layout;
11 | import com.kongzue.baseframework.util.JumpParameter;
12 | import com.kongzue.updateui.UpdateUI;
13 | import com.kongzue.updateui.interfaces.OnUpdateUIEventListener;
14 |
15 | @Layout(R.layout.activity_main)
16 | @DarkStatusBarTheme(true)
17 | public class MainActivity extends BaseActivity {
18 |
19 | private Button btnShowUpdate;
20 | private UpdateUI updateUI;
21 |
22 | @Override
23 | public void initViews() {
24 | btnShowUpdate = findViewById(R.id.btn_showUpdate);
25 | }
26 |
27 | @Override
28 | public void initDatas(JumpParameter paramer) {
29 | UpdateUI.darkMode = false;
30 | UpdateUI.txtUpdateLogs="- 新增 618“冤枉钱”账本,可以把任何账目标记为“冤枉钱”,并在冤枉钱账本中追溯你认为购买的不值/不好/没用的消费;\n- 修复 部分情况可能引发的错误显示或闪退问题;\n- 新增 618“冤枉钱”账本,可以把任何账目标记为“冤枉钱”,并在冤枉钱账本中追溯你认为购买的不值/不好/没用的消费;\n- 修复 部分情况可能引发的错误显示或闪退问题;";
31 |
32 | updateUI = new UpdateUI();
33 | updateUI.setOnUpdateUIEventListener(new OnUpdateUIEventListener() {
34 | @Override
35 | public void onShow(int status) {
36 | log("onShow:" + status);
37 | }
38 |
39 | @Override
40 | public void onStartDownload() {
41 | log("onStartDownload");
42 | runOnMainDelayed(new Runnable() {
43 | @Override
44 | public void run() {
45 | updateUI.setProgress(50);
46 | runOnMainDelayed(new Runnable() {
47 | @Override
48 | public void run() {
49 | updateUI.readyInstall();
50 | }
51 | }, 1000);
52 | }
53 | }, 1000);
54 | }
55 |
56 | @Override
57 | public void onIgnore(int status) {
58 | log("onIgnore:" + status);
59 | //if (status == UpdateUI.STATUS_PROGRESSING) {
60 | // //正在下载的状态时产生的忽略
61 | // runOnMainDelayed(new Runnable() {
62 | // @Override
63 | // public void run() {
64 | // updateUI.readyInstall();
65 | // updateUI.showUpdateUI(me);
66 | // }
67 | // }, 2000);
68 | //}
69 | //if (status == UpdateUI.STATUS_FINISH) {
70 | // //完成后产生的忽略操作
71 | //}
72 | }
73 |
74 | @Override
75 | public void onInstallNow() {
76 | log("onInstallNow");
77 | }
78 | });
79 |
80 | btnShowUpdate.setOnClickListener(new View.OnClickListener() {
81 | @Override
82 | public void onClick(View v) {
83 | updateUI.showUpdateUI(me);
84 | }
85 | });
86 | }
87 |
88 | @Override
89 | public void setEvents() {
90 |
91 | }
92 |
93 | @Override
94 | protected void onDestroy() {
95 | super.onDestroy();
96 | if (updateUI != null) {
97 | updateUI.dismiss();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/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/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/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
15 |
20 |
25 |
30 |
35 |
36 |
41 |
42 |
48 |
53 |
58 |
63 |
68 |
73 |
78 |
84 |
85 |
--------------------------------------------------------------------------------
/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/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UpdateDemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:4.2.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 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/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 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx1536m
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 |
17 |
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 26 12:44:19 CST 2019
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-6.8.2-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':updateui'
2 |
--------------------------------------------------------------------------------
/updateui/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/updateui/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | group = "com.kongzue.updateui"//发布aar前缀根节点
4 | version = "1.0.4.3"//发布aar的库版本
5 |
6 | android {
7 | compileSdkVersion 30
8 |
9 | defaultConfig {
10 | minSdkVersion 19
11 | targetSdkVersion 30
12 | versionCode 4
13 | versionName "1.0.4.3"
14 |
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 | task sourcesJar(type: Jar) {
26 | from android.sourceSets.main.java.srcDirs
27 | classifier = 'sources'
28 | }
29 |
30 | artifacts {
31 | archives sourcesJar
32 | }
33 | dependencies {
34 | implementation fileTree(dir: 'libs', include: ['*.jar'])
35 | compileOnly('androidx.appcompat:appcompat:1.0.0')
36 | }
37 |
--------------------------------------------------------------------------------
/updateui/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 |
--------------------------------------------------------------------------------
/updateui/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/updateui/src/main/java/com/kongzue/updateui/UpdateUI.java:
--------------------------------------------------------------------------------
1 | package com.kongzue.updateui;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.app.Activity;
5 | import android.content.res.Resources;
6 | import android.graphics.Color;
7 | import android.graphics.drawable.ColorDrawable;
8 | import android.os.Build;
9 | import android.os.Handler;
10 | import android.os.Looper;
11 | import android.text.Layout;
12 | import android.util.Log;
13 | import android.view.Gravity;
14 | import android.view.LayoutInflater;
15 | import android.view.MotionEvent;
16 | import android.view.View;
17 | import android.view.ViewGroup;
18 | import android.view.ViewTreeObserver;
19 | import android.view.WindowManager;
20 | import android.widget.ImageView;
21 | import android.widget.LinearLayout;
22 | import android.widget.PopupWindow;
23 | import android.widget.ProgressBar;
24 | import android.widget.TextView;
25 |
26 | import com.kongzue.updateui.interfaces.OnUpdateUIEventListener;
27 | import com.kongzue.updateui.util.ViewWrapper;
28 |
29 | import java.lang.ref.WeakReference;
30 | import java.lang.reflect.Field;
31 | import java.util.Timer;
32 | import java.util.TimerTask;
33 |
34 | import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
35 |
36 | /**
37 | * Author: @Kongzue
38 | * Github: https://github.com/kongzue/
39 | * Homepage: http://kongzue.com/
40 | * Mail: myzcxhh@live.cn
41 | * CreateTime: 2019/1/13 15:06
42 | */
43 | public class UpdateUI {
44 |
45 | public static final int STATUS_BEFORE_UPDATE = 0; //默认状态
46 | public static final int STATUS_BEFORE_UPDATE_LOGS = 1; //打开更新日志详情的状态
47 | public static final int STATUS_PROGRESSING = 2; //正在更新状态
48 | public static final int STATUS_FINISH = 3; //完成更新状态
49 |
50 | private int status = STATUS_BEFORE_UPDATE; //当前状态
51 |
52 | public static String beforeUpdateTitle = "有新版本可用";
53 | public static String afterUpdateTitle = "安装包已就绪";
54 | public static String buttonUpdateDetails = "查看详情";
55 | public static String buttonUpdateNow = "立即更新";
56 | public static String txtUpdateLogs = "- 这里是一些更新日志...\n- 这里是一些更新日志...\n- 这里是一些更新日志...";
57 | public static String buttonInstallNow = "立即安装";
58 | public static boolean darkMode = false; //暗色模式
59 |
60 | private PopupWindow window;
61 | private WeakReference activity;
62 | private View rootView;
63 |
64 | private OnUpdateUIEventListener onUpdateUIEventListener; //事件监听器
65 |
66 | private Handler mainHandler = new Handler(Looper.getMainLooper());
67 |
68 | private LinearLayout boxUpdateUIAllViews;
69 | private LinearLayout sysStatusBar;
70 | private LinearLayout boxUpdateUISimple;
71 | private TextView txtUpdateUITitle;
72 | private ProgressBar progressUpdateUI;
73 | private TextView btnUpdateUIDetails;
74 | private TextView btnUpdateUIInstall;
75 | private ImageView imgUpdateUIMore;
76 | private LinearLayout boxUpdateUIMore;
77 | private TextView txtUpdateUILogs;
78 | private TextView btnUpdateUIUpdateNow;
79 |
80 | private int moreHeight;
81 | private int simpleHeight;
82 |
83 | private void bindChildViews(View rootView) {
84 | boxUpdateUIAllViews = rootView.findViewById(R.id.box_updateUI_allViews);
85 | sysStatusBar = rootView.findViewById(R.id.sys_statusBar);
86 | boxUpdateUISimple = rootView.findViewById(R.id.box_updateUI_Simple);
87 | txtUpdateUITitle = rootView.findViewById(R.id.txt_updateUI_title);
88 | progressUpdateUI = rootView.findViewById(R.id.progress_updateUI);
89 | btnUpdateUIDetails = rootView.findViewById(R.id.btn_updateUI_details);
90 | btnUpdateUIInstall = rootView.findViewById(R.id.btn_updateUI_install);
91 | imgUpdateUIMore = rootView.findViewById(R.id.img_updateUI_more);
92 | boxUpdateUIMore = rootView.findViewById(R.id.box_updateUI_more);
93 | txtUpdateUILogs = rootView.findViewById(R.id.txt_updateUI_logs);
94 | btnUpdateUIUpdateNow = rootView.findViewById(R.id.btn_updateUI_updateNow);
95 | }
96 |
97 | public void showUpdateUI(Activity a) {
98 | dismiss();
99 | activity = new WeakReference<>(a);
100 |
101 | rootView = LayoutInflater.from(activity.get()).inflate(R.layout.layout_update_ui, null, false);
102 |
103 | //绑定组件
104 | bindChildViews(rootView);
105 |
106 | txtUpdateUITitle.setText(beforeUpdateTitle);
107 | btnUpdateUIDetails.setText(buttonUpdateDetails);
108 | btnUpdateUIUpdateNow.setText(buttonUpdateNow);
109 | txtUpdateUILogs.setText(txtUpdateLogs);
110 | btnUpdateUIInstall.setText(buttonInstallNow);
111 |
112 | boxUpdateUIAllViews.post(new Runnable() {
113 | @Override
114 | public void run() {
115 | simpleHeight = measureHeight(boxUpdateUIAllViews);
116 | }
117 | });
118 |
119 | //初始化
120 | window = new PopupWindow(rootView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
121 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
122 | window.setOutsideTouchable(false);
123 | window.setTouchable(true);
124 | window.setClippingEnabled(false);
125 |
126 | window.setAnimationStyle(R.style.popwin_anim_style);
127 |
128 | window.setOnDismissListener(new PopupWindow.OnDismissListener() {
129 | @Override
130 | public void onDismiss() {
131 | if (onUpdateUIEventListener != null) onUpdateUIEventListener.onIgnore(status);
132 | }
133 | });
134 |
135 | //全屏化
136 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
137 | try {
138 | Field mLayoutInScreen = PopupWindow.class.getDeclaredField("mLayoutInScreen");
139 | mLayoutInScreen.setAccessible(true);
140 | mLayoutInScreen.set(window, true);
141 |
142 | Field mClipToScreen = PopupWindow.class.getDeclaredField("mClipToScreen");
143 | mClipToScreen.setAccessible(true);
144 | mClipToScreen.set(window, true);
145 | } catch (Exception e) {
146 | }
147 | }
148 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
149 | sysStatusBar.setVisibility(View.VISIBLE);
150 | int statusHeight = getStatusBarHeight();
151 | ViewGroup.LayoutParams params = sysStatusBar.getLayoutParams();
152 | params.height = statusHeight;
153 | sysStatusBar.setLayoutParams(params);
154 | }
155 |
156 | window.showAtLocation(activity.get().getWindow().getDecorView(), Gravity.TOP, 0, 0);
157 |
158 | switch (status) {
159 | case STATUS_PROGRESSING:
160 | progressUpdateUI.setVisibility(View.VISIBLE);
161 | txtUpdateUITitle.setVisibility(View.GONE);
162 | openMoreEnable = false;
163 | progressUpdateUI.setProgress(progress);
164 | break;
165 | case STATUS_FINISH:
166 | openMoreEnable = false;
167 | readyInstall();
168 | break;
169 | }
170 |
171 | if (onUpdateUIEventListener != null) onUpdateUIEventListener.onShow(status);
172 |
173 | if (darkMode) {
174 | boxUpdateUIAllViews.setBackgroundResource(R.drawable.img_update_ui_bkg_dark);
175 | txtUpdateUILogs.setTextColor(Color.WHITE);
176 | btnUpdateUIUpdateNow.setBackgroundResource(R.drawable.button_update_ui_button_dark);
177 | progressUpdateUI.setProgressDrawable(activity.get().getResources().getDrawable(R.drawable.progress_bar_update_ui_dark));
178 | }
179 |
180 | setEvents();
181 | }
182 |
183 | private boolean isTouchDown = false;
184 | private float touchDownY;
185 |
186 | private void setEvents() {
187 | boxUpdateUIAllViews.setOnTouchListener(new View.OnTouchListener() {
188 | @Override
189 | public boolean onTouch(View v, MotionEvent event) {
190 | if (event.getAction() == MotionEvent.ACTION_DOWN) {
191 | touchDownY = event.getY();
192 | isTouchDown = true;
193 | }
194 | if (event.getAction() == MotionEvent.ACTION_MOVE) {
195 | if (isTouchDown) {
196 | float deltaY = event.getY() - touchDownY;
197 | float aimY = boxUpdateUIAllViews.getY() + deltaY;
198 | if (aimY <= 0) {
199 | boxUpdateUIAllViews.setY(aimY);
200 | if (imgUpdateUIMore.getVisibility() == View.VISIBLE)
201 | imgUpdateUIMore.setVisibility(View.GONE);
202 | } else {
203 | if (imgUpdateUIMore.getVisibility() == View.GONE && openMoreEnable)
204 | imgUpdateUIMore.setVisibility(View.VISIBLE);
205 | }
206 | }
207 | }
208 | if (event.getAction() == MotionEvent.ACTION_UP) {
209 | isTouchDown = false;
210 | float deltaY = event.getY() - touchDownY;
211 | if (boxUpdateUIAllViews.getY() < -dip2px(15)) {
212 | window.dismiss();
213 | } else {
214 | if (deltaY > dip2px(15)) {
215 | showDetails(true);
216 | }
217 | }
218 | }
219 | return true;
220 | }
221 | });
222 |
223 | btnUpdateUIDetails.setOnClickListener(new View.OnClickListener() {
224 | @Override
225 | public void onClick(View v) {
226 | showDetails(true);
227 | }
228 | });
229 |
230 | btnUpdateUIUpdateNow.setOnClickListener(new View.OnClickListener() {
231 | @Override
232 | public void onClick(View v) {
233 | status = STATUS_PROGRESSING;
234 | progressUpdateUI.setVisibility(View.VISIBLE);
235 | txtUpdateUITitle.setVisibility(View.GONE);
236 | openMoreEnable = false;
237 | showDetails(false);
238 | if (onUpdateUIEventListener != null) onUpdateUIEventListener.onStartDownload();
239 | }
240 | });
241 |
242 | btnUpdateUIInstall.setOnClickListener(new View.OnClickListener() {
243 | @Override
244 | public void onClick(View v) {
245 | dismiss();
246 | if (onUpdateUIEventListener != null) onUpdateUIEventListener.onInstallNow();
247 | }
248 | });
249 | }
250 |
251 | private Timer timer;
252 | private int progress;
253 |
254 | private void doCheckProgress() {
255 | timer = new Timer();
256 | timer.schedule(new TimerTask() {
257 | @Override
258 | public void run() {
259 | progress = progress + 5;
260 | mainHandler.post(new Runnable() {
261 | @Override
262 | public void run() {
263 | if (progress < 100) {
264 | progressUpdateUI.setProgress(progress);
265 | } else {
266 | readyInstall();
267 | }
268 | }
269 | });
270 | }
271 | }, 100, 100);
272 | }
273 |
274 | public void readyInstall() {
275 | status = STATUS_FINISH;
276 | txtUpdateUITitle.setText(afterUpdateTitle);
277 | txtUpdateUITitle.setVisibility(View.VISIBLE);
278 | btnUpdateUIDetails.setVisibility(View.GONE);
279 | btnUpdateUIInstall.setVisibility(View.VISIBLE);
280 | progressUpdateUI.setVisibility(View.GONE);
281 | }
282 |
283 | private boolean openMoreEnable = true;
284 |
285 | private Runnable runnable;
286 |
287 | private void showDetails(boolean visible) {
288 | if (visible) {
289 | if (!openMoreEnable) {
290 | return;
291 | }
292 | btnUpdateUIDetails.setVisibility(View.GONE);
293 | if (boxUpdateUIMore.getVisibility() == View.GONE) {
294 | boxUpdateUIMore.setVisibility(View.VISIBLE);
295 |
296 | measureHeight(txtUpdateUILogs);
297 |
298 | if (moreHeight == 0) {
299 | txtUpdateUILogs.post(new Runnable() {
300 | @Override
301 | public void run() {
302 | int height = getTextViewHeight(txtUpdateUILogs);
303 | new ViewWrapper(txtUpdateUILogs).setHeight(height);
304 |
305 | boxUpdateUIMore.post(new Runnable() {
306 | @Override
307 | public void run() {
308 | boxUpdateUIMore.setAlpha(1f);
309 | moreHeight = measureHeight(boxUpdateUIMore);
310 |
311 | final ViewWrapper boxUpdateUIAllViewViewWrapper = new ViewWrapper(boxUpdateUIAllViews);
312 | moveAnimation(boxUpdateUIAllViewViewWrapper, "height",
313 | simpleHeight,
314 | simpleHeight + moreHeight,
315 | 300, 0
316 | );
317 |
318 | new ViewWrapper(window.getContentView()).setHeight(simpleHeight + moreHeight + dip2px(60));
319 | }
320 | });
321 | }
322 | });
323 | } else {
324 | boxUpdateUIMore.setAlpha(1f);
325 | final ViewWrapper boxUpdateUIAllViewViewWrapper = new ViewWrapper(boxUpdateUIAllViews);
326 | moveAnimation(boxUpdateUIAllViewViewWrapper, "height",
327 | simpleHeight,
328 | simpleHeight + moreHeight,
329 | 300, 0
330 | );
331 |
332 | new ViewWrapper(window.getContentView()).setHeight(simpleHeight + moreHeight + dip2px(60));
333 | }
334 |
335 | }
336 | if (status < STATUS_PROGRESSING) status = STATUS_BEFORE_UPDATE_LOGS;
337 | } else {
338 | boxUpdateUIMore.setVisibility(View.GONE);
339 | final ViewWrapper boxUpdateUIAllViewViewWrapper = new ViewWrapper(boxUpdateUIAllViews);
340 | moveAnimation(boxUpdateUIAllViewViewWrapper, "height",
341 | simpleHeight + moreHeight,
342 | simpleHeight,
343 | 300, 0
344 | );
345 | mainHandler.postDelayed(new Runnable() {
346 | @Override
347 | public void run() {
348 | boxUpdateUIAllViewViewWrapper.setHeight(simpleHeight);
349 | new ViewWrapper(window.getContentView()).setHeight(simpleHeight + dip2px(60));
350 | }
351 | }, 300);
352 | if (status < STATUS_PROGRESSING) status = STATUS_BEFORE_UPDATE;
353 | }
354 | }
355 |
356 | private int getStatusBarHeight() {
357 | try {
358 | Resources resources = activity.get().getResources();
359 | int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
360 | int height = resources.getDimensionPixelSize(resourceId);
361 | return height;
362 | } catch (Exception e) {
363 | e.printStackTrace();
364 | }
365 | return 0;
366 | }
367 |
368 | private int dip2px(float dpValue) {
369 | final float scale = activity.get().getResources().getDisplayMetrics().density;
370 | return (int) (dpValue * scale + 0.5f);
371 | }
372 |
373 | private ObjectAnimator moveAnimation(ViewWrapper obj, String perference, float fromValue, float aimValue, long time, long delay) {
374 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(obj, perference, fromValue, aimValue);
375 | objectAnimator.setDuration(time);
376 | objectAnimator.setStartDelay(delay);
377 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
378 | objectAnimator.setAutoCancel(true);
379 | }
380 | objectAnimator.start();
381 | return objectAnimator;
382 | }
383 |
384 | private int measureHeight(View v) {
385 | int width = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
386 | int height = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
387 | v.measure(width, height);
388 | return v.getMeasuredHeight();
389 | }
390 |
391 | private int getTextViewHeight(TextView pTextView) {
392 | Layout layout = pTextView.getLayout();
393 | int desired = layout.getLineTop(pTextView.getLineCount());
394 | int padding = pTextView.getCompoundPaddingTop() + pTextView.getCompoundPaddingBottom();
395 | return desired + padding;
396 | }
397 |
398 | public void dismiss() {
399 | if (window != null) window.dismiss();
400 | }
401 |
402 | public int getStatus() {
403 | return status;
404 | }
405 |
406 | public void setProgress(int progress) {
407 | if (progressUpdateUI != null) progressUpdateUI.setProgress(progress);
408 | }
409 |
410 | public OnUpdateUIEventListener getOnUpdateUIEventListener() {
411 | return onUpdateUIEventListener;
412 | }
413 |
414 | public UpdateUI setOnUpdateUIEventListener(OnUpdateUIEventListener onUpdateUIEventListener) {
415 | this.onUpdateUIEventListener = onUpdateUIEventListener;
416 | return this;
417 | }
418 |
419 | public void createNewUpdate(Activity a) {
420 | status = STATUS_BEFORE_UPDATE;
421 | showUpdateUI(a);
422 | }
423 | }
424 |
--------------------------------------------------------------------------------
/updateui/src/main/java/com/kongzue/updateui/interfaces/OnUpdateUIEventListener.java:
--------------------------------------------------------------------------------
1 | package com.kongzue.updateui.interfaces;
2 |
3 | /**
4 | * Author: @Kongzue
5 | * Github: https://github.com/kongzue/
6 | * Homepage: http://kongzue.com/
7 | * Mail: myzcxhh@live.cn
8 | * CreateTime: 2019/1/14 17:20
9 | */
10 | public interface OnUpdateUIEventListener {
11 |
12 | void onShow(int status);
13 |
14 | void onStartDownload();
15 |
16 | void onIgnore(int status);
17 |
18 | void onInstallNow();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/updateui/src/main/java/com/kongzue/updateui/util/ViewWrapper.java:
--------------------------------------------------------------------------------
1 | package com.kongzue.updateui.util;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Author: @Kongzue
7 | * Github: https://github.com/kongzue/
8 | * Homepage: http://kongzue.com/
9 | * Mail: myzcxhh@live.cn
10 | * CreateTime: 2018/7/5 17:06
11 | */
12 | public class ViewWrapper {
13 |
14 | private View mTargetView;
15 |
16 | public ViewWrapper(View target) {
17 | mTargetView = target;
18 | }
19 |
20 | public int getWidth() {
21 | return mTargetView.getLayoutParams().width;
22 | }
23 |
24 | public int getHeight() {
25 | return mTargetView.getLayoutParams().height;
26 | }
27 |
28 | public void setWidth(int width) {
29 | mTargetView.getLayoutParams().width = width;
30 | mTargetView.requestLayout();
31 | }
32 |
33 | public void setWidth(float width) {
34 | mTargetView.getLayoutParams().width = (int) width;
35 | mTargetView.requestLayout();
36 | }
37 |
38 | public void setHeight(int height) {
39 | mTargetView.getLayoutParams().height = height;
40 | mTargetView.requestLayout();
41 | }
42 |
43 | public void setHeight(float height) {
44 | mTargetView.getLayoutParams().height = (int) height;
45 | mTargetView.requestLayout();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/updateui/src/main/res/anim/anim_pop_update_ui_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
--------------------------------------------------------------------------------
/updateui/src/main/res/anim/anim_pop_update_ui_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/button_update_ui_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/button_update_ui_button_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/img_update_ui_bkg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/updateui/src/main/res/drawable-xxxhdpi/img_update_ui_bkg.9.png
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/img_update_ui_bkg_dark.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/updateui/src/main/res/drawable-xxxhdpi/img_update_ui_bkg_dark.9.png
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/img_update_ui_shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/updateui/src/main/res/drawable-xxxhdpi/img_update_ui_shadow.png
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/progress_bar_update_ui.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/progress_bar_update_ui_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/rect_update_ui_button_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/rect_update_ui_button_normal_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/rect_update_ui_button_press.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
--------------------------------------------------------------------------------
/updateui/src/main/res/drawable-xxxhdpi/rect_update_ui_button_press_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
--------------------------------------------------------------------------------
/updateui/src/main/res/layout/layout_update_ui.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
19 |
20 |
28 |
29 |
33 |
34 |
44 |
45 |
56 |
57 |
67 |
68 |
79 |
80 |
81 |
82 |
83 |
91 |
92 |
99 |
100 |
108 |
109 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/updateui/src/main/res/mipmap-xxhdpi/img_update_ui_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/updateui/src/main/res/mipmap-xxhdpi/img_update_ui_more.png
--------------------------------------------------------------------------------
/updateui/src/main/res/mipmap-xxhdpi/img_update_ui_update_ico.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kongzue/UpdateUI/e902c28b26afe52a3736b0f1b74c04d57cbaf9a6/updateui/src/main/res/mipmap-xxhdpi/img_update_ui_update_ico.png
--------------------------------------------------------------------------------
/updateui/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2aa515
4 | #4a98da
5 | #f2f2f2
6 | #0c000000
7 | #15000000
8 |
9 | #1AFFFFFF
10 | #33FFFFFF
11 |
--------------------------------------------------------------------------------
/updateui/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UpdateUI
3 |
4 |
--------------------------------------------------------------------------------
/updateui/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------