├── .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 | 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 | 9 | 10 | 14 | 15 | 19 | 20 | 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 | 36 | 37 | 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 | 102 | 122 | 123 | 124 | 125 | 126 | 127 | 129 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kongzue UpdateUI 2 | 使用 PopupWindow 为基础构建非打扰式更新提醒组件 3 | 4 | 5 | Kongzue UpdateUI 6 | 7 | 8 | Maven 9 | 10 | 11 | License 12 | 13 | 14 | Homepage 15 | 16 | 17 | ![Kongzue UpdateUI](https://github.com/kongzue/Res/raw/master/app/src/main/res/mipmap-xxxhdpi/img_update_demo.png) 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/v/kongzue/UpdateUI.svg)](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 |