├── .github
└── FUNDING.yml
├── .gitignore
├── .idea
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── cretin.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── markdown-navigator.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── qaplug_profiles.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cretin
│ │ └── www
│ │ └── autoupdateproject
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── cretin
│ │ │ └── www
│ │ │ └── autoupdateproject
│ │ │ ├── CustomActivity.java
│ │ │ ├── InfoActivity.java
│ │ │ ├── MD5HelperActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── adapter
│ │ │ └── RecyclerviewAdapter.java
│ │ │ ├── app
│ │ │ └── BaseApp.java
│ │ │ ├── model
│ │ │ ├── ListModel.java
│ │ │ └── UpdateModel.java
│ │ │ └── utils
│ │ │ ├── Md5Utils.java
│ │ │ └── OkHttp3Connection.java
│ └── res
│ │ ├── drawable
│ │ ├── shape_black.xml
│ │ └── shape_btn.xml
│ │ ├── layout
│ │ ├── activity_custom.xml
│ │ ├── activity_info.xml
│ │ ├── activity_main.xml
│ │ ├── activity_md5_helper.xml
│ │ └── item_recyclerview.xml
│ │ ├── menu
│ │ └── menu_layout.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ ├── download_icon.png
│ │ ├── ic_launcher.png
│ │ └── logo.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── install_file.xml
│ └── test
│ └── java
│ └── com
│ └── cretin
│ └── www
│ └── autoupdateproject
│ └── ExampleUnitTest.java
├── build.gradle
├── cretinautoupdatelibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cretin
│ │ └── www
│ │ └── cretinautoupdatelibrary
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── cretin
│ │ │ └── www
│ │ │ └── cretinautoupdatelibrary
│ │ │ ├── activity
│ │ │ ├── UpdateBackgroundActivity.java
│ │ │ ├── UpdateType10Activity.java
│ │ │ ├── UpdateType11Activity.java
│ │ │ ├── UpdateType12Activity.java
│ │ │ ├── UpdateType1Activity.java
│ │ │ ├── UpdateType2Activity.java
│ │ │ ├── UpdateType3Activity.java
│ │ │ ├── UpdateType4Activity.java
│ │ │ ├── UpdateType5Activity.java
│ │ │ ├── UpdateType6Activity.java
│ │ │ ├── UpdateType7Activity.java
│ │ │ ├── UpdateType8Activity.java
│ │ │ └── UpdateType9Activity.java
│ │ │ ├── interfaces
│ │ │ ├── AppDownloadListener.java
│ │ │ ├── AppUpdateInfoListener.java
│ │ │ ├── ForceExitCallBack.java
│ │ │ ├── MD5CheckListener.java
│ │ │ └── OnDialogClickListener.java
│ │ │ ├── model
│ │ │ ├── DownloadInfo.java
│ │ │ ├── LibraryUpdateEntity.java
│ │ │ ├── TypeConfig.java
│ │ │ └── UpdateConfig.java
│ │ │ ├── net
│ │ │ ├── HttpCallbackModelListener.java
│ │ │ ├── HttpUtils.java
│ │ │ └── ResponseCall.java
│ │ │ ├── service
│ │ │ ├── UpdateReceiver.java
│ │ │ └── UpdateService.java
│ │ │ ├── utils
│ │ │ ├── AppUpdateUtils.java
│ │ │ ├── AppUtils.java
│ │ │ ├── CretinAutoUpdateUtils.java
│ │ │ ├── DownloadReceiver.java
│ │ │ ├── DownloadService.java
│ │ │ ├── InstallFileProvider.java
│ │ │ ├── JSONHelper.java
│ │ │ ├── LogUtils.java
│ │ │ ├── Md5Utils.java
│ │ │ ├── NetWorkUtils.java
│ │ │ ├── ResUtils.java
│ │ │ ├── RootActivity.java
│ │ │ └── SSLUtils.java
│ │ │ └── view
│ │ │ └── ProgressView.java
│ └── res
│ │ ├── anim
│ │ ├── dialog_enter.xml
│ │ └── dialog_out.xml
│ │ ├── drawable
│ │ ├── btn_bg_type_3.xml
│ │ ├── btn_bg_type_4.xml
│ │ ├── btn_bg_type_5.xml
│ │ ├── btn_bg_type_6.xml
│ │ ├── btn_bg_type_7.xml
│ │ ├── dialog_item_bg_selector_white_left_bottom.xml
│ │ ├── dialog_item_bg_selector_white_left_right_bottom.xml
│ │ ├── dialog_item_bg_selector_white_right_bottom.xml
│ │ ├── light_orange_button_round.xml
│ │ ├── round_background.xml
│ │ ├── shape_btn_border_fc8680.xml
│ │ ├── shape_btn_border_ff721e.xml
│ │ ├── shape_btn_border_white.xml
│ │ ├── shape_btn_round_42c6a6.xml
│ │ ├── shape_btn_round_4c92f0.xml
│ │ ├── shape_btn_round_e23932.xml
│ │ ├── shape_btn_round_fe8b80.xml
│ │ ├── shape_btn_round_ff721e.xml
│ │ ├── shape_btn_round_gray.xml
│ │ └── shape_btn_round_white.xml
│ │ ├── layout
│ │ ├── activity_update.xml
│ │ ├── activity_update_background.xml
│ │ ├── activity_update_type10.xml
│ │ ├── activity_update_type11.xml
│ │ ├── activity_update_type12.xml
│ │ ├── activity_update_type2.xml
│ │ ├── activity_update_type3.xml
│ │ ├── activity_update_type4.xml
│ │ ├── activity_update_type5.xml
│ │ ├── activity_update_type6.xml
│ │ ├── activity_update_type7.xml
│ │ ├── activity_update_type8.xml
│ │ ├── activity_update_type9.xml
│ │ ├── download_dialog.xml
│ │ ├── download_dialog_super.xml
│ │ ├── filemgr.xml
│ │ ├── layout_notification.xml
│ │ └── new_download_dialog.xml
│ │ ├── mipmap-xhdpi
│ │ ├── dialog_bg.png
│ │ ├── dialog_bg_type_10.png
│ │ ├── dialog_bg_type_11.png
│ │ ├── dialog_bg_type_12.png
│ │ ├── dialog_bg_type_3.png
│ │ ├── dialog_bg_type_4.png
│ │ ├── dialog_bg_type_5.png
│ │ ├── dialog_bg_type_6.png
│ │ ├── dialog_bg_type_7.png
│ │ ├── dialog_bg_type_8.png
│ │ ├── dialog_bg_type_9.png
│ │ ├── dialog_update_bg.png
│ │ ├── progress.png
│ │ ├── progress_tips.png
│ │ ├── update_close.png
│ │ └── update_close_img.png
│ │ ├── mipmap-xxhdpi
│ │ ├── dialog_bg.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher1.png
│ │ ├── progress.png
│ │ ├── progress_tips.png
│ │ └── update_close.png
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ ├── install_file.xml
│ │ └── network_security_config.xml
│ └── test
│ └── java
│ └── com
│ └── cretin
│ └── www
│ └── cretinautoupdatelibrary
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pic
├── WEIXIN.JPG
├── demo.apk
├── erweima.png
├── type01.png
├── type02.png
├── type03.png
├── type04.png
├── type05.png
├── type06.png
├── type07.png
├── type08.png
├── type09.png
├── type10.png
├── type11.png
└── type12.png
└── settings.gradle
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: ['https://github.com/MZCretin/CretinDocs/blob/master/%E6%8D%90%E8%B5%A0.md']
2 | #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
3 | #patreon: # Replace with a single Patreon username
4 | #open_collective: # Replace with a single Open Collective username
5 | #ko_fi: # Replace with a single Ko-fi username
6 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
7 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
8 | #liberapay: # Replace with a single Liberapay username
9 | #issuehunt: # Replace with a single IssueHunt username
10 | #otechie: # Replace with a single Otechie username
11 | #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /.idea/
11 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/cretin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/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.cretin.www.autoupdateproject"
7 | minSdkVersion 19
8 | targetSdkVersion 30
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | lintOptions {
20 | abortOnError false
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation fileTree(include: ['*.jar'], dir: 'libs')
26 | implementation 'com.android.support:appcompat-v7:28.0.0'
27 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
28 | implementation 'com.android.support:recyclerview-v7:28.0.0'
29 | implementation 'com.blankj:utilcode:1.25.9'
30 |
31 | //使用jitpack
32 | // implementation 'com.github.MZCretin:AutoUpdateProject:v2.0.5'
33 |
34 | //使用本地库依赖
35 | implementation project(':cretinautoupdatelibrary')
36 |
37 | //如果你需要使用okhttp作为你的下载器 你需要自主引入okhttp的依赖
38 | implementation 'com.squareup.okhttp3:okhttp:3.11.0'
39 | }
40 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/cretin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/cretin/www/autoupdateproject/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith( AndroidJUnit4.class )
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.cretin.www.autoupdateproject", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
17 |
20 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/CustomActivity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 | import android.widget.Toast;
7 |
8 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
9 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
10 | import com.cretin.www.cretinautoupdatelibrary.interfaces.MD5CheckListener;
11 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
12 |
13 | /**
14 | * 自定义UI类型
15 | * 你需要注意:
16 | * 1、Activity需要继承RootActivity才有效,并实现需要实现的方法
17 | * 2、你需要在你的AndroidManifest.xml中为这个自定义的Activity设置
18 | *
19 | * @style/DialogActivityTheme 这个对话框的主题;
20 | * 当然这只是建议,你只要撸出来的页面好看,咋地都行
21 | */
22 | public class CustomActivity extends RootActivity {
23 | private TextView tvInfo;
24 | private TextView tvUpdate;
25 | private TextView tvCancel;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_custom);
31 |
32 | findView();
33 |
34 | //当是强制更新的时候需要隐藏取消按钮 这个如果你在自定义UI的时候要注意
35 | if (downloadInfo.isForceUpdateFlag()) {
36 | tvCancel.setVisibility(View.GONE);
37 | } else {
38 | tvCancel.setVisibility(View.VISIBLE);
39 | }
40 |
41 | //设置更新信息
42 | tvInfo.setText("v" + downloadInfo.getProdVersionName() + "\n" +
43 | downloadInfo.getUpdateLog());
44 | }
45 |
46 | private void findView() {
47 | tvInfo = findViewById(R.id.tv_info);
48 | tvUpdate = findViewById(R.id.tv_update);
49 | tvCancel = findViewById(R.id.tv_cancel);
50 |
51 | //设置取消按钮的事件
52 | tvCancel.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | //如果你希望取消的同事也取消任务就调用cancelTask方法 否则直接finish就好
56 | cancelTask();
57 | finish();
58 | }
59 | });
60 |
61 | //开始获取信息并且下载
62 | tvUpdate.setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | download();
66 | }
67 | });
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | //设置下载按钮的文案
76 | tvUpdate.setText(ResUtils.getString(com.cretin.www.cretinautoupdatelibrary.R.string.downloading) + progress + "%");
77 | }
78 |
79 | @Override
80 | public void downloadFail(String msg) {
81 | //下载失败的时候重新设置文案
82 | tvUpdate.setText(ResUtils.getString(com.cretin.www.cretinautoupdatelibrary.R.string.btn_update_now));
83 | Toast.makeText(CustomActivity.this, ResUtils.getString(com.cretin.www.cretinautoupdatelibrary.R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
84 | }
85 |
86 | @Override
87 | public void downloadComplete(String path) {
88 | //只需要你设置自定义页面上的文案即可 其他操作sdk会自己处理
89 | tvUpdate.setText(ResUtils.getString(com.cretin.www.cretinautoupdatelibrary.R.string.btn_update_now));
90 | }
91 |
92 | @Override
93 | public void downloadStart() {
94 | //下载开始了,设置按钮文案
95 | tvUpdate.setText(ResUtils.getString(com.cretin.www.cretinautoupdatelibrary.R.string.btn_update_now));
96 | }
97 |
98 | @Override
99 | public void reDownload() {
100 |
101 | }
102 |
103 | @Override
104 | public void pause() {
105 |
106 | }
107 | };
108 | }
109 |
110 | /**
111 | * 如果需要知道文件MD5校验结果就重写此方法
112 | *
113 | * @return
114 | */
115 | @Override
116 | public MD5CheckListener obtainMD5CheckListener() {
117 | return new MD5CheckListener() {
118 | @Override
119 | public void fileMd5CheckFail(String originMD5, String localMD5) {
120 |
121 | }
122 |
123 | @Override
124 | public void fileMd5CheckSuccess() {
125 |
126 | }
127 | };
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/InfoActivity.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cretin.www.autoupdateproject;
3 |
4 | import android.support.v4.text.util.LinkifyCompat;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.text.SpannableString;
8 | import android.text.method.LinkMovementMethod;
9 | import android.text.util.Linkify;
10 | import android.widget.TextView;
11 |
12 | public class InfoActivity extends AppCompatActivity {
13 | private TextView tv_info;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_info);
19 |
20 | tv_info = findViewById(R.id.tv_info);
21 |
22 | String info = "首先,感谢您体验或使用我的版本更新库!\n" +
23 | "另外,这是一个大的版本修改,之前的老版本的方式依然可以使用,只是我不再推荐,也不做文档说明了!新版本做了很多优化!\n\n" +
24 | "功能介绍:\n\n" +
25 | "一、最大亮点,提供12种更新的样式,总有一个是你喜欢的!\n\n" +
26 | "二、支持三种设置更新信息的方式,您可以直接传model,传json数据,或者直接配置请求链接,sdk会自主请求并发起app的更新!\n\n" +
27 | "三、文件下载支持断点续传,节省流量!\n\n" +
28 | "四、相同版本的apk只会下载一次,减少重复下载\n\n" +
29 | "五、已适配Android 6.0,7.0,8.0,9.0\n\n" +
30 | "六、提供强制更新,不更新则无法使用APP\n\n" +
31 | "七、通知栏图片自定义\n\n" +
32 | "其他说明:\n\n" +
33 | "Demo下载下来的App是我业余写的一个段子类的App(段子乐),定期更新大量的搞笑段子和搞笑趣图,如果您感兴趣,可以安装之后在空闲的时候娱乐娱乐,如果您也是段友,还可发布您的作品!\n\n" +
34 | "Github地址:\n\n" +
35 | "https://github.com/MZCretin/AutoUpdateProject\n\n" +
36 | "记得点赞哦!!!";
37 | final SpannableString value = SpannableString.valueOf(info);
38 | LinkifyCompat.addLinks(value, Linkify.ALL);
39 | tv_info.setMovementMethod(LinkMovementMethod.getInstance());
40 | tv_info.setText(value);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 | import android.widget.Toast;
11 | import com.cretin.www.autoupdateproject.adapter.RecyclerviewAdapter;
12 | import com.cretin.www.autoupdateproject.model.ListModel;
13 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppUpdateInfoListener;
14 | import com.cretin.www.cretinautoupdatelibrary.model.TypeConfig;
15 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUpdateUtils;
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class MainActivity extends AppCompatActivity {
20 |
21 | private RecyclerView recyclerView;
22 | private RecyclerviewAdapter recyclerviewAdapter;
23 | private List list;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main);
29 |
30 | recyclerView = findViewById(R.id.recyclerview);
31 |
32 | list = new ArrayList<>();
33 | obtainData();
34 | recyclerviewAdapter = new RecyclerviewAdapter(this, list);
35 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
36 | recyclerView.setAdapter(recyclerviewAdapter);
37 | }
38 |
39 | //造假数据
40 | private void obtainData() {
41 | for (int i = 0; i < 13; i++) {
42 | ListModel listModel = new ListModel();
43 | listModel.setForceUpdate(false);
44 | listModel.setUiTypeValue(300 + i);
45 | listModel.setCheckFileMD5(true);
46 | listModel.setSourceTypeVaule(TypeConfig.DATA_SOURCE_TYPE_MODEL);
47 | list.add(listModel);
48 | }
49 | }
50 |
51 | //清除数据
52 | public void clear() {
53 | AppUpdateUtils.getInstance().clearAllData();
54 | Toast.makeText(this, "下载的所有数据清除成功", Toast.LENGTH_SHORT).show();
55 | }
56 |
57 | @Override
58 | public boolean onCreateOptionsMenu(Menu menu) {
59 | getMenuInflater().inflate(R.menu.menu_layout, menu);
60 | return super.onCreateOptionsMenu(menu);
61 | }
62 |
63 | @Override
64 | public boolean onOptionsItemSelected(MenuItem item) {
65 | switch (item.getItemId()) {
66 | case R.id.action_01:
67 | //使用说明
68 | startActivity(new Intent(this, InfoActivity.class));
69 | break;
70 | case R.id.action_02:
71 | //清除本地缓存
72 | clear();
73 | break;
74 | case R.id.action_03:
75 | //自定义UI
76 | AppUpdateUtils.getInstance().getUpdateConfig().setUiThemeType(TypeConfig.UI_THEME_CUSTOM);//类型为自定义样式类型
77 | AppUpdateUtils.getInstance().getUpdateConfig().setDataSourceType(TypeConfig.DATA_SOURCE_TYPE_JSON); //使用本地json提供数据
78 | AppUpdateUtils.getInstance().checkUpdate(recyclerviewAdapter.jsonDataUnForce);
79 | Toast.makeText(this, "为了展示是真的可以自定义UI的,我写了个很丑的页面", Toast.LENGTH_SHORT).show();
80 | break;
81 | case R.id.action_04:
82 | //获取文件MD5检验码工具
83 | startActivity(new Intent(this, MD5HelperActivity.class));
84 | break;
85 | case R.id.action_05:
86 | //带提示的更新
87 | AppUpdateUtils.getInstance().getUpdateConfig().setUiThemeType(TypeConfig.UI_THEME_A);//类型为自定义样式类型
88 | AppUpdateUtils.getInstance().getUpdateConfig().setDataSourceType(TypeConfig.DATA_SOURCE_TYPE_JSON); //使用本地json提供数据
89 | AppUpdateUtils.getInstance().addAppUpdateInfoListener(new AppUpdateInfoListener() {
90 | @Override
91 | public void isLatestVersion(boolean isLatest) {
92 | if(isLatest){
93 | Toast.makeText(MainActivity.this, "已是最新版本", Toast.LENGTH_SHORT).show();
94 | }else {
95 | Toast.makeText(MainActivity.this, "发现新版本,将会提示更新", Toast.LENGTH_SHORT).show();
96 | }
97 | }
98 | }).checkUpdate(recyclerviewAdapter.jsonDataNoUpdate);
99 | break;
100 | }
101 | return super.onOptionsItemSelected(item);
102 | }
103 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/app/BaseApp.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject.app;
2 |
3 | import android.app.Application;
4 |
5 | import com.blankj.utilcode.util.Utils;
6 | import com.cretin.www.autoupdateproject.CustomActivity;
7 | import com.cretin.www.autoupdateproject.R;
8 | import com.cretin.www.autoupdateproject.model.UpdateModel;
9 | import com.cretin.www.cretinautoupdatelibrary.model.TypeConfig;
10 | import com.cretin.www.cretinautoupdatelibrary.model.UpdateConfig;
11 | import com.cretin.www.autoupdateproject.utils.OkHttp3Connection;
12 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUpdateUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.utils.SSLUtils;
14 |
15 | import java.util.concurrent.TimeUnit;
16 |
17 | import okhttp3.OkHttpClient;
18 |
19 | public class BaseApp extends Application {
20 | @Override
21 | public void onCreate() {
22 | super.onCreate();
23 |
24 | //BlankJ的初始化 跟更新库没有关系哦
25 | Utils.init(this);
26 |
27 | //如果你想使用okhttp作为下载的载体,那么你需要自己依赖okhttp,更新库不强制依赖okhttp!可以使用如下代码创建一个OkHttpClient 并在UpdateConfig中配置setCustomDownloadConnectionCreator start
28 | OkHttpClient.Builder builder = new OkHttpClient.Builder();
29 | builder.connectTimeout(30_000, TimeUnit.SECONDS)
30 | .readTimeout(30_000, TimeUnit.SECONDS)
31 | .writeTimeout(30_000, TimeUnit.SECONDS)
32 | //如果你需要信任所有的证书,可解决根证书不被信任导致无法下载的问题 start
33 | .sslSocketFactory(SSLUtils.createSSLSocketFactory())
34 | .hostnameVerifier(new SSLUtils.TrustAllHostnameVerifier())
35 | //如果你需要信任所有的证书,可解决根证书不被信任导致无法下载的问题 end
36 | .retryOnConnectionFailure(true);
37 | //如果你想使用okhttp作为下载的载体,那么你需要自己依赖okhttp,更新库不强制依赖okhttp!可以使用如下代码创建一个OkHttpClient 并在UpdateConfig中配置setCustomDownloadConnectionCreator end
38 |
39 | //更新库配置
40 | UpdateConfig updateConfig = new UpdateConfig()
41 | .setDebug(true)//是否是Debug模式
42 | .setBaseUrl("http://www.cretinzp.com/system/versioninfo")//当dataSourceType为DATA_SOURCE_TYPE_URL时,配置此接口用于获取更新信息
43 | .setMethodType(TypeConfig.METHOD_GET)//当dataSourceType为DATA_SOURCE_TYPE_URL时,设置请求的方法
44 | .setDataSourceType(TypeConfig.DATA_SOURCE_TYPE_URL)//设置获取更新信息的方式
45 | .setShowNotification(true)//配置更新的过程中是否在通知栏显示进度
46 | .setNotificationIconRes(R.mipmap.download_icon)//配置通知栏显示的图标
47 | .setUiThemeType(TypeConfig.UI_THEME_AUTO)//配置UI的样式,一种有12种样式可供选择
48 | .setRequestHeaders(null)//当dataSourceType为DATA_SOURCE_TYPE_URL时,设置请求的请求头
49 | .setRequestParams(null)//当dataSourceType为DATA_SOURCE_TYPE_URL时,设置请求的请求参数
50 | .setAutoDownloadBackground(false)//是否需要后台静默下载,如果设置为true,则调用checkUpdate方法之后会直接下载安装,不会弹出更新页面。当你选择UI样式为TypeConfig.UI_THEME_CUSTOM,静默安装失效,您需要在自定义的Activity中自主实现静默下载,使用这种方式的时候建议setShowNotification(false),这样基本上用户就会对下载无感知了
51 | .setCustomActivityClass(CustomActivity.class)//如果你选择的UI样式为TypeConfig.UI_THEME_CUSTOM,那么你需要自定义一个Activity继承自RootActivity,并参照demo实现功能,在此处填写自定义Activity的class
52 | .setNeedFileMD5Check(false)//是否需要进行文件的MD5检验,如果开启需要提供文件本身正确的MD5校验码,DEMO中提供了获取文件MD5检验码的工具页面,也提供了加密工具类Md5Utils
53 | .setCustomDownloadConnectionCreator(new OkHttp3Connection.Creator(builder))//如果你想使用okhttp作为下载的载体,可以使用如下代码创建一个OkHttpClient,并使用demo中提供的OkHttp3Connection构建一个ConnectionCreator传入,在这里可以配置信任所有的证书,可解决根证书不被信任导致无法下载apk的问题
54 | .setModelClass(new UpdateModel());
55 | //初始化
56 | AppUpdateUtils.init(this, updateConfig);
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/model/ListModel.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject.model;
2 |
3 | /**
4 | * @date: on 2019-10-14
5 | * @author: a112233
6 | * @email: mxnzp_life@163.com
7 | * @desc: 添加描述
8 | */
9 | public class ListModel {
10 | private boolean isForceUpdate;
11 | private int uiTypeValue;
12 | private int sourceTypeVaule;
13 | private boolean isCheckFileMD5;
14 | private boolean isAutoUpdateBackground;
15 |
16 | public boolean isAutoUpdateBackground() {
17 | return isAutoUpdateBackground;
18 | }
19 |
20 | public void setAutoUpdateBackground(boolean autoUpdateBackground) {
21 | isAutoUpdateBackground = autoUpdateBackground;
22 | }
23 |
24 | public boolean isCheckFileMD5() {
25 | return isCheckFileMD5;
26 | }
27 |
28 | public void setCheckFileMD5(boolean checkFileMD5) {
29 | isCheckFileMD5 = checkFileMD5;
30 | }
31 |
32 | public int getUiTypeValue() {
33 | return uiTypeValue;
34 | }
35 |
36 | public void setUiTypeValue(int uiTypeValue) {
37 | this.uiTypeValue = uiTypeValue;
38 | }
39 |
40 | public boolean isForceUpdate() {
41 | return isForceUpdate;
42 | }
43 |
44 | public void setForceUpdate(boolean forceUpdate) {
45 | isForceUpdate = forceUpdate;
46 | }
47 |
48 | public int getSourceTypeVaule() {
49 | return sourceTypeVaule;
50 | }
51 |
52 | public void setSourceTypeVaule(int sourceTypeVaule) {
53 | this.sourceTypeVaule = sourceTypeVaule;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/model/UpdateModel.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject.model;
2 |
3 | import com.cretin.www.cretinautoupdatelibrary.model.LibraryUpdateEntity;
4 |
5 | /**
6 | * Created by cretin on 2017/4/21.
7 | * 这个model是调用 http://www.cretinzp.com/system/versioninfo 这个接口之后返回的数据
8 | */
9 | public class UpdateModel implements LibraryUpdateEntity {
10 |
11 | /**
12 | * id : test
13 | * page : 1
14 | * rows : 10
15 | * isForceUpdateFlag : 0
16 | * preBaselineCode : 0
17 | * versionName : V1.0.1
18 | * versionCode : 3
19 | * downurl : http://120.24.5.102/Webconfig/frj01_211_jiagu_sign.apk
20 | * updateLog : 1、修复bug
21 | * size : 10291218
22 | * hasAffectCodes : 1|2
23 | * createTime : 1489651956000
24 | * iosVersion : 1
25 | */
26 |
27 | private int isForceUpdate;
28 | private int preBaselineCode;
29 | private String versionName;
30 | private int versionCode;
31 | private String downurl;
32 | private String updateLog;
33 | private String size;
34 | private String hasAffectCodes;
35 | private long createTime;
36 | private int iosVersion;
37 |
38 | public int getIsForceUpdate() {
39 | return isForceUpdate;
40 | }
41 |
42 | public void setIsForceUpdate(int isForceUpdate) {
43 | this.isForceUpdate = isForceUpdate;
44 | }
45 |
46 | public int getPreBaselineCode() {
47 | return preBaselineCode;
48 | }
49 |
50 | public void setPreBaselineCode(int preBaselineCode) {
51 | this.preBaselineCode = preBaselineCode;
52 | }
53 |
54 | public String getVersionName() {
55 | return versionName;
56 | }
57 |
58 | public void setVersionName(String versionName) {
59 | this.versionName = versionName;
60 | }
61 |
62 | public int getVersionCode() {
63 | return versionCode;
64 | }
65 |
66 | public void setVersionCode(int versionCode) {
67 | this.versionCode = versionCode;
68 | }
69 |
70 | public String getDownurl() {
71 | return downurl;
72 | }
73 |
74 | public void setDownurl(String downurl) {
75 | this.downurl = downurl;
76 | }
77 |
78 | public String getUpdateLog() {
79 | return updateLog;
80 | }
81 |
82 | public void setUpdateLog(String updateLog) {
83 | this.updateLog = updateLog;
84 | }
85 |
86 | public String getSize() {
87 | return size;
88 | }
89 |
90 | public void setSize(String size) {
91 | this.size = size;
92 | }
93 |
94 | public String getHasAffectCodes() {
95 | return hasAffectCodes;
96 | }
97 |
98 | public void setHasAffectCodes(String hasAffectCodes) {
99 | this.hasAffectCodes = hasAffectCodes;
100 | }
101 |
102 | public long getCreateTime() {
103 | return createTime;
104 | }
105 |
106 | public void setCreateTime(long createTime) {
107 | this.createTime = createTime;
108 | }
109 |
110 | public int getIosVersion() {
111 | return iosVersion;
112 | }
113 |
114 | public void setIosVersion(int iosVersion) {
115 | this.iosVersion = iosVersion;
116 | }
117 |
118 | @Override
119 | public int getAppVersionCode() {
120 | return getVersionCode();
121 | }
122 |
123 | @Override
124 | public int forceAppUpdateFlag() {
125 | return getIsForceUpdate();
126 | }
127 |
128 | @Override
129 | public String getAppVersionName() {
130 | return getVersionName().replaceFirst("v", "");
131 | }
132 |
133 | @Override
134 | public String getAppApkUrls() {
135 | return getDownurl();
136 | }
137 |
138 | @Override
139 | public String getAppUpdateLog() {
140 | return getUpdateLog();
141 | }
142 |
143 | @Override
144 | public String getAppApkSize() {
145 | return getSize();
146 | }
147 |
148 | @Override
149 | public String getAppHasAffectCodes() {
150 | return getHasAffectCodes();
151 | }
152 |
153 | @Override
154 | public String getFileMd5Check() {
155 | return null;
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cretin/www/autoupdateproject/utils/Md5Utils.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject.utils;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.IOException;
6 | import java.security.MessageDigest;
7 |
8 | /**
9 | * MD5加密工具类
10 | *
11 | */
12 | public final class Md5Utils {
13 |
14 | private Md5Utils() {
15 | throw new UnsupportedOperationException("cannot be instantiated");
16 | }
17 |
18 | /**
19 | * 获取文件的MD5值
20 | *
21 | * @param file
22 | * @return
23 | */
24 | public static String getFileMD5(File file) {
25 | if (file == null || !file.exists()) {
26 | return "";
27 | }
28 | FileInputStream fis = null;
29 | try {
30 | MessageDigest digest = MessageDigest.getInstance("MD5");
31 | fis = new FileInputStream(file);
32 | byte[] buffer = new byte[8192];
33 | int len;
34 | while ((len = fis.read(buffer)) != -1) {
35 | digest.update(buffer, 0, len);
36 | }
37 | return bytes2Hex(digest.digest());
38 | } catch (Exception e) {
39 | e.printStackTrace();
40 | } finally {
41 | if (fis != null) {
42 | try {
43 | fis.close();
44 | } catch (IOException ignored) {
45 | }
46 | }
47 | }
48 | return "";
49 | }
50 |
51 | /**
52 | * 一个byte转为2个hex字符
53 | *
54 | * @param src byte数组
55 | * @return 16进制大写字符串
56 | */
57 | private static String bytes2Hex(byte[] src) {
58 | char[] res = new char[src.length << 1];
59 | final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
60 | for (int i = 0, j = 0; i < src.length; i++) {
61 | res[j++] = hexDigits[src[i] >>> 4 & 0x0F];
62 | res[j++] = hexDigits[src[i] & 0x0F];
63 | }
64 | return new String(res);
65 | }
66 |
67 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_custom.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
32 |
33 |
44 |
45 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_md5_helper.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
27 |
28 |
40 |
41 |
49 |
50 |
63 |
64 |
72 |
73 |
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
23 |
24 |
37 |
38 |
51 |
52 |
65 |
66 |
79 |
80 |
81 |
91 |
92 |
101 |
102 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/download_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-xxhdpi/download_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-xxhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | APP内部更新
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/install_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/test/java/com/cretin/www/autoupdateproject/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.autoupdateproject;
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() throws Exception {
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 | jcenter()
6 | google()
7 | maven { url 'https://jitpack.io' }
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.1'
11 |
12 | classpath 'com.novoda:bintray-release:0.9.1'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | jcenter()
22 | google()
23 | maven { url 'https://jitpack.io' }
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 |
4 | android {
5 | compileSdkVersion 30
6 |
7 | defaultConfig {
8 | minSdkVersion 19
9 | targetSdkVersion 30
10 | versionCode 20
11 | versionName "2.0.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | // 忽略错误信息
24 | lintOptions {
25 | abortOnError false
26 | }
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(include: ['*.jar'], dir: 'libs')
31 | implementation 'com.android.support:appcompat-v7:28.0.0'
32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
33 | api 'com.liulishuo.filedownloader:library:1.7.6'
34 | }
35 |
36 | repositories {
37 | mavenCentral()
38 | }
39 |
40 | publish {
41 | userOrg = 'cretin'
42 | groupId = 'com.cretin'
43 | artifactId = 'cretinautoupdatelibrary'
44 | publishVersion = '2.0.0'
45 | desc = 'CRETINAUTOUPDATELIBRARY'
46 | website = 'https://github.com/MZCretin/AutoUpdateProject'
47 | }
48 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/cretin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/androidTest/java/com/cretin/www/cretinautoupdatelibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith( AndroidJUnit4.class )
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.cretin.www.cretinautoupdatelibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
22 |
25 |
28 |
31 |
34 |
37 |
40 |
43 |
46 |
49 |
52 |
55 |
56 |
57 |
58 |
59 |
64 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateBackgroundActivity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.Gravity;
7 | import android.view.WindowManager;
8 |
9 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
10 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
11 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
12 |
13 | public class UpdateBackgroundActivity extends RootActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | getWindow().setGravity(Gravity.LEFT | Gravity.TOP);
19 | WindowManager.LayoutParams attributes = getWindow().getAttributes();
20 | attributes.x = 0;
21 | attributes.y = 0;
22 | attributes.height = 1;
23 | attributes.width = 1;
24 |
25 | download();
26 | finish();
27 | }
28 |
29 | @Override
30 | public AppDownloadListener obtainDownloadListener() {
31 | return null;
32 | }
33 |
34 | /**
35 | * 启动Activity
36 | *
37 | * @param context
38 | * @param info
39 | */
40 | public static void launch(Context context, DownloadInfo info) {
41 | launchActivity(context, info, UpdateBackgroundActivity.class);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType10Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType10Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 | private TextView tvVersion;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_update_type10);
30 |
31 | findView();
32 |
33 | setDataAndListener();
34 | }
35 |
36 | private void setDataAndListener() {
37 | tvMsg.setText(downloadInfo.getUpdateLog());
38 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
39 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
40 |
41 | if (downloadInfo.isForceUpdateFlag()) {
42 | ivClose.setVisibility(View.GONE);
43 | } else {
44 | ivClose.setVisibility(View.VISIBLE);
45 | }
46 |
47 | ivClose.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | finish();
51 | }
52 | });
53 |
54 | tvBtn2.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | //右边的按钮
58 | download();
59 | }
60 | });
61 | }
62 |
63 | private void findView() {
64 | tvMsg = findViewById(R.id.tv_content);
65 | tvBtn2 = findViewById(R.id.tv_update);
66 | ivClose = findViewById(R.id.iv_close);
67 | tvVersion = findViewById(R.id.tv_version);
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
76 | }
77 |
78 | @Override
79 | public void downloadFail(String msg) {
80 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
81 | Toast.makeText(UpdateType10Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
82 | }
83 |
84 | @Override
85 | public void downloadComplete(String path) {
86 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
87 | }
88 |
89 | @Override
90 | public void downloadStart() {
91 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
92 | }
93 |
94 | @Override
95 | public void reDownload() {
96 | LogUtils.log("下载失败后点击重试");
97 | }
98 |
99 | @Override
100 | public void pause() {
101 |
102 | }
103 | };
104 | }
105 |
106 | /**
107 | * 启动Activity
108 | *
109 | * @param context
110 | * @param info
111 | */
112 | public static void launch(Context context, DownloadInfo info) {
113 | launchActivity(context, info, UpdateType10Activity.class);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType11Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
14 | import com.cretin.www.cretinautoupdatelibrary.R;
15 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
16 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUtils;
18 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
19 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
20 |
21 | public class UpdateType11Activity extends RootActivity {
22 |
23 | private TextView tvMsg;
24 | private TextView tvBtn2;
25 | private ImageView ivClose;
26 | private TextView tvBtn1;
27 | private TextView tvVersion;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_update_type11);
33 |
34 | findView();
35 |
36 | setDataAndListener();
37 | }
38 |
39 | private void setDataAndListener() {
40 | tvMsg.setText(downloadInfo.getUpdateLog());
41 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
42 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
43 |
44 | if (downloadInfo.isForceUpdateFlag()) {
45 | ivClose.setVisibility(View.GONE);
46 | tvBtn1.setVisibility(View.GONE);
47 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tvBtn2.getLayoutParams();
48 | layoutParams.setMargins(AppUtils.dp2px(55), AppUtils.dp2px(25), AppUtils.dp2px(55), AppUtils.dp2px(40));
49 | tvBtn2.setLayoutParams(layoutParams);
50 | } else {
51 | ivClose.setVisibility(View.VISIBLE);
52 | }
53 |
54 | ivClose.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | finish();
58 | }
59 | });
60 |
61 | tvBtn1.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | //左边的按钮
65 | cancelTask();
66 | finish();
67 | }
68 | });
69 |
70 | tvBtn2.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | //右边的按钮
74 | download();
75 | }
76 | });
77 | }
78 |
79 | private void findView() {
80 | tvMsg = findViewById(R.id.tv_content);
81 | tvBtn2 = findViewById(R.id.tv_update);
82 | ivClose = findViewById(R.id.iv_close);
83 | tvBtn1 = (TextView) findViewById(R.id.tv_btn1);
84 | tvVersion = findViewById(R.id.tv_version);
85 | }
86 |
87 | @Override
88 | public AppDownloadListener obtainDownloadListener() {
89 | return new AppDownloadListener() {
90 | @Override
91 | public void downloading(int progress) {
92 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
93 | }
94 |
95 | @Override
96 | public void downloadFail(String msg) {
97 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
98 | Toast.makeText(UpdateType11Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
99 | }
100 |
101 | @Override
102 | public void downloadComplete(String path) {
103 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
104 | }
105 |
106 | @Override
107 | public void downloadStart() {
108 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
109 | }
110 |
111 | @Override
112 | public void reDownload() {
113 | LogUtils.log("下载失败后点击重试");
114 | }
115 |
116 | @Override
117 | public void pause() {
118 |
119 | }
120 | };
121 | }
122 |
123 | /**
124 | * 启动Activity
125 | *
126 | * @param context
127 | * @param info
128 | */
129 | public static void launch(Context context, DownloadInfo info) {
130 | launchActivity(context, info, UpdateType11Activity.class);
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType12Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
14 | import com.cretin.www.cretinautoupdatelibrary.R;
15 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
16 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUtils;
18 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
19 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
20 |
21 | public class UpdateType12Activity extends RootActivity {
22 |
23 | private TextView tvMsg;
24 | private TextView tvBtn2;
25 | private ImageView ivClose;
26 | private TextView tvVersion;
27 | private TextView tvBtn1;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_update_type12);
33 |
34 | findView();
35 |
36 | setDataAndListener();
37 | }
38 |
39 | private void setDataAndListener() {
40 | tvMsg.setText(downloadInfo.getUpdateLog());
41 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
42 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
43 |
44 | if (downloadInfo.isForceUpdateFlag()) {
45 | ivClose.setVisibility(View.GONE);
46 | tvBtn1.setVisibility(View.GONE);
47 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tvBtn2.getLayoutParams();
48 | layoutParams.setMargins(AppUtils.dp2px(45), AppUtils.dp2px(15), AppUtils.dp2px(45), AppUtils.dp2px(40));
49 | tvBtn2.setLayoutParams(layoutParams);
50 | } else {
51 | ivClose.setVisibility(View.VISIBLE);
52 | }
53 |
54 | ivClose.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | finish();
58 | }
59 | });
60 |
61 |
62 | tvBtn1.setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | //左边的按钮
66 | cancelTask();
67 | finish();
68 | }
69 | });
70 |
71 | tvBtn2.setOnClickListener(new View.OnClickListener() {
72 | @Override
73 | public void onClick(View v) {
74 | //右边的按钮
75 | download();
76 | }
77 | });
78 | }
79 |
80 | private void findView() {
81 | tvMsg = findViewById(R.id.tv_content);
82 | tvBtn2 = findViewById(R.id.tv_update);
83 | ivClose = findViewById(R.id.iv_close);
84 | tvVersion = findViewById(R.id.tv_version);
85 | tvBtn1 = (TextView) findViewById(R.id.tv_btn1);
86 | }
87 |
88 | @Override
89 | public AppDownloadListener obtainDownloadListener() {
90 | return new AppDownloadListener() {
91 | @Override
92 | public void downloading(int progress) {
93 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
94 | }
95 |
96 | @Override
97 | public void downloadFail(String msg) {
98 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
99 | Toast.makeText(UpdateType12Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
100 | }
101 |
102 | @Override
103 | public void downloadComplete(String path) {
104 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
105 | }
106 |
107 | @Override
108 | public void downloadStart() {
109 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
110 | }
111 |
112 | @Override
113 | public void reDownload() {
114 | LogUtils.log("下载失败后点击重试");
115 | }
116 |
117 | @Override
118 | public void pause() {
119 |
120 | }
121 | };
122 | }
123 |
124 | /**
125 | * 启动Activity
126 | *
127 | * @param context
128 | * @param info
129 | */
130 | public static void launch(Context context, DownloadInfo info) {
131 | launchActivity(context, info, UpdateType12Activity.class);
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType2Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | /**
20 | * 类似虎牙直播的更新样式
21 | */
22 | public class UpdateType2Activity extends RootActivity {
23 |
24 | private TextView tvMsg;
25 | private TextView tvBtn2;
26 | private ImageView ivClose;
27 | private TextView tvVersion;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_update_type2);
33 |
34 | findView();
35 |
36 | setDataAndListener();
37 | }
38 |
39 | private void setDataAndListener() {
40 | tvMsg.setText(downloadInfo.getUpdateLog());
41 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
42 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
43 |
44 | if (downloadInfo.isForceUpdateFlag()) {
45 | ivClose.setVisibility(View.GONE);
46 | } else {
47 | ivClose.setVisibility(View.VISIBLE);
48 | }
49 |
50 | ivClose.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View v) {
53 | finish();
54 | }
55 | });
56 |
57 | tvBtn2.setOnClickListener(new View.OnClickListener() {
58 | @Override
59 | public void onClick(View v) {
60 | //右边的按钮
61 | download();
62 | }
63 | });
64 | }
65 |
66 | private void findView() {
67 | tvMsg = findViewById(R.id.tv_content);
68 | tvBtn2 = findViewById(R.id.tv_update);
69 | ivClose = findViewById(R.id.iv_close);
70 | tvVersion = findViewById(R.id.tv_version);
71 | }
72 |
73 | @Override
74 | public AppDownloadListener obtainDownloadListener() {
75 | return new AppDownloadListener() {
76 | @Override
77 | public void downloading(int progress) {
78 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
79 | }
80 |
81 | @Override
82 | public void downloadFail(String msg) {
83 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
84 | Toast.makeText(UpdateType2Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
85 | }
86 |
87 | @Override
88 | public void downloadComplete(String path) {
89 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
90 | }
91 |
92 | @Override
93 | public void downloadStart() {
94 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
95 | }
96 |
97 | @Override
98 | public void reDownload() {
99 | LogUtils.log("下载失败后点击重试");
100 | }
101 |
102 | @Override
103 | public void pause() {
104 |
105 | }
106 | };
107 | }
108 |
109 | /**
110 | * 启动Activity
111 | *
112 | * @param context
113 | * @param info
114 | */
115 | public static void launch(Context context, DownloadInfo info) {
116 | launchActivity(context, info, UpdateType2Activity.class);
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType3Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType3Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 | private TextView tvVersion;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_update_type3);
30 |
31 | findView();
32 |
33 | setDataAndListener();
34 | }
35 |
36 | private void setDataAndListener() {
37 | tvMsg.setText(downloadInfo.getUpdateLog());
38 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
39 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
40 |
41 | if (downloadInfo.isForceUpdateFlag()) {
42 | ivClose.setVisibility(View.GONE);
43 | } else {
44 | ivClose.setVisibility(View.VISIBLE);
45 | }
46 |
47 | ivClose.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | finish();
51 | }
52 | });
53 |
54 | tvBtn2.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | //右边的按钮
58 | download();
59 | }
60 | });
61 | }
62 |
63 | private void findView() {
64 | tvMsg = findViewById(R.id.tv_content);
65 | tvBtn2 = findViewById(R.id.tv_update);
66 | ivClose = findViewById(R.id.iv_close);
67 | tvVersion = findViewById(R.id.tv_version);
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
76 | }
77 |
78 | @Override
79 | public void downloadFail(String msg) {
80 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
81 | Toast.makeText(UpdateType3Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
82 | }
83 |
84 | @Override
85 | public void downloadComplete(String path) {
86 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
87 | }
88 |
89 | @Override
90 | public void downloadStart() {
91 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
92 | }
93 |
94 | @Override
95 | public void reDownload() {
96 | LogUtils.log("下载失败后点击重试");
97 | }
98 |
99 | @Override
100 | public void pause() {
101 |
102 | }
103 | };
104 | }
105 |
106 | /**
107 | * 启动Activity
108 | *
109 | * @param context
110 | * @param info
111 | */
112 | public static void launch(Context context, DownloadInfo info) {
113 | launchActivity(context, info, UpdateType3Activity.class);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType4Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType4Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_update_type4);
29 |
30 | findView();
31 |
32 | setDataAndListener();
33 | }
34 |
35 | private void setDataAndListener() {
36 | tvMsg.setText(downloadInfo.getUpdateLog() + "\nv" + downloadInfo.getProdVersionName());
37 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
38 |
39 | if (downloadInfo.isForceUpdateFlag()) {
40 | ivClose.setVisibility(View.GONE);
41 | } else {
42 | ivClose.setVisibility(View.VISIBLE);
43 | }
44 |
45 | ivClose.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | finish();
49 | }
50 | });
51 |
52 | tvBtn2.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | //右边的按钮
56 | download();
57 | }
58 | });
59 | }
60 |
61 | private void findView() {
62 | tvMsg = findViewById(R.id.tv_content);
63 | tvBtn2 = findViewById(R.id.tv_update);
64 | ivClose = findViewById(R.id.iv_close);
65 | }
66 |
67 | @Override
68 | public AppDownloadListener obtainDownloadListener() {
69 | return new AppDownloadListener() {
70 | @Override
71 | public void downloading(int progress) {
72 | tvBtn2.setText(ResUtils.getString(R.string.downloading) + progress + "%");
73 | }
74 |
75 | @Override
76 | public void downloadFail(String msg) {
77 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
78 | Toast.makeText(UpdateType4Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
79 | }
80 |
81 | @Override
82 | public void downloadComplete(String path) {
83 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
84 | }
85 |
86 | @Override
87 | public void downloadStart() {
88 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
89 | }
90 |
91 | @Override
92 | public void reDownload() {
93 | LogUtils.log("下载失败后点击重试");
94 | }
95 |
96 | @Override
97 | public void pause() {
98 |
99 | }
100 | };
101 | }
102 |
103 | /**
104 | * 启动Activity
105 | *
106 | * @param context
107 | * @param info
108 | */
109 | public static void launch(Context context, DownloadInfo info) {
110 | launchActivity(context, info, UpdateType4Activity.class);
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType5Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType5Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 | private TextView tvVersion;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_update_type5);
30 |
31 | findView();
32 |
33 | setDataAndListener();
34 | }
35 |
36 | private void setDataAndListener() {
37 | tvMsg.setText(downloadInfo.getUpdateLog());
38 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
39 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
40 |
41 | if (downloadInfo.isForceUpdateFlag()) {
42 | ivClose.setVisibility(View.GONE);
43 | } else {
44 | ivClose.setVisibility(View.VISIBLE);
45 | }
46 |
47 | ivClose.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | finish();
51 | }
52 | });
53 |
54 | tvBtn2.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | //右边的按钮
58 | download();
59 | }
60 | });
61 | }
62 |
63 | private void findView() {
64 | tvMsg = findViewById(R.id.tv_content);
65 | tvBtn2 = findViewById(R.id.tv_update);
66 | ivClose = findViewById(R.id.iv_close);
67 | tvVersion = findViewById(R.id.tv_version);
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
76 | }
77 |
78 | @Override
79 | public void downloadFail(String msg) {
80 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
81 | Toast.makeText(UpdateType5Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
82 | }
83 |
84 | @Override
85 | public void downloadComplete(String path) {
86 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
87 | }
88 |
89 | @Override
90 | public void downloadStart() {
91 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
92 | }
93 |
94 | @Override
95 | public void reDownload() {
96 | LogUtils.log("下载失败后点击重试");
97 | }
98 |
99 | @Override
100 | public void pause() {
101 |
102 | }
103 | };
104 | }
105 |
106 | /**
107 | * 启动Activity
108 | *
109 | * @param context
110 | * @param info
111 | */
112 | public static void launch(Context context, DownloadInfo info) {
113 | launchActivity(context, info, UpdateType5Activity.class);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType6Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType6Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 | private TextView tvVersion;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_update_type6);
30 |
31 | findView();
32 |
33 | setDataAndListener();
34 | }
35 |
36 | private void setDataAndListener() {
37 | tvMsg.setText(downloadInfo.getUpdateLog());
38 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
39 | tvVersion.setText("v" + downloadInfo.getProdVersionName());
40 |
41 | if (downloadInfo.isForceUpdateFlag()) {
42 | ivClose.setVisibility(View.GONE);
43 | } else {
44 | ivClose.setVisibility(View.VISIBLE);
45 | }
46 |
47 | ivClose.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | finish();
51 | }
52 | });
53 |
54 | tvBtn2.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | //右边的按钮
58 | download();
59 | }
60 | });
61 | }
62 |
63 | private void findView() {
64 | tvMsg = findViewById(R.id.tv_content);
65 | tvBtn2 = findViewById(R.id.tv_update);
66 | ivClose = findViewById(R.id.iv_close);
67 | tvVersion = findViewById(R.id.tv_version);
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | tvBtn2.setText(ResUtils.getString(R.string.downloading) + progress + "%");
76 | }
77 |
78 | @Override
79 | public void downloadFail(String msg) {
80 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
81 | Toast.makeText(UpdateType6Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
82 | }
83 |
84 | @Override
85 | public void downloadComplete(String path) {
86 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
87 | }
88 |
89 | @Override
90 | public void downloadStart() {
91 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
92 | }
93 |
94 | @Override
95 | public void reDownload() {
96 | LogUtils.log("下载失败后点击重试");
97 | }
98 |
99 | @Override
100 | public void pause() {
101 |
102 | }
103 | };
104 | }
105 |
106 | /**
107 | * 启动Activity
108 | *
109 | * @param context
110 | * @param info
111 | */
112 | public static void launch(Context context, DownloadInfo info) {
113 | launchActivity(context, info, UpdateType6Activity.class);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType7Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType7Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 | private TextView tvVersion;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_update_type7);
30 |
31 | findView();
32 |
33 | setDataAndListener();
34 | }
35 |
36 | private void setDataAndListener() {
37 | tvMsg.setText(downloadInfo.getUpdateLog());
38 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
39 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
40 |
41 | if (downloadInfo.isForceUpdateFlag()) {
42 | ivClose.setVisibility(View.GONE);
43 | } else {
44 | ivClose.setVisibility(View.VISIBLE);
45 | }
46 |
47 | ivClose.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | finish();
51 | }
52 | });
53 |
54 | tvBtn2.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | //右边的按钮
58 | download();
59 | }
60 | });
61 | }
62 |
63 | private void findView() {
64 | tvMsg = findViewById(R.id.tv_content);
65 | tvBtn2 = findViewById(R.id.tv_update);
66 | ivClose = findViewById(R.id.iv_close);
67 | tvVersion = findViewById(R.id.tv_version);
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
76 | }
77 |
78 | @Override
79 | public void downloadFail(String msg) {
80 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
81 | Toast.makeText(UpdateType7Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
82 | }
83 |
84 | @Override
85 | public void downloadComplete(String path) {
86 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
87 | }
88 |
89 | @Override
90 | public void downloadStart() {
91 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
92 | }
93 |
94 | @Override
95 | public void reDownload() {
96 | LogUtils.log("下载失败后点击重试");
97 | }
98 |
99 | @Override
100 | public void pause() {
101 |
102 | }
103 | };
104 | }
105 |
106 | /**
107 | * 启动Activity
108 | *
109 | * @param context
110 | * @param info
111 | */
112 | public static void launch(Context context, DownloadInfo info) {
113 | launchActivity(context, info, UpdateType7Activity.class);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType8Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
14 | import com.cretin.www.cretinautoupdatelibrary.R;
15 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
16 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUtils;
18 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
19 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
20 |
21 | public class UpdateType8Activity extends RootActivity {
22 |
23 | private TextView tvMsg;
24 | private TextView tvBtn2;
25 | private ImageView ivClose;
26 | private TextView tvBtn1;
27 | private TextView tvVersion;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_update_type8);
33 |
34 | findView();
35 |
36 | setDataAndListener();
37 | }
38 |
39 | private void setDataAndListener() {
40 | tvMsg.setText(downloadInfo.getUpdateLog());
41 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
42 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
43 |
44 | if (downloadInfo.isForceUpdateFlag()) {
45 | ivClose.setVisibility(View.GONE);
46 | tvBtn1.setVisibility(View.GONE);
47 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tvBtn2.getLayoutParams();
48 | layoutParams.setMargins(AppUtils.dp2px(35), AppUtils.dp2px(25), AppUtils.dp2px(35), AppUtils.dp2px(40));
49 | tvBtn2.setLayoutParams(layoutParams);
50 | } else {
51 | ivClose.setVisibility(View.VISIBLE);
52 | }
53 |
54 | ivClose.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | finish();
58 | }
59 | });
60 |
61 | tvBtn1.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | //左边的按钮
65 | cancelTask();
66 | finish();
67 | }
68 | });
69 |
70 | tvBtn2.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | //右边的按钮
74 | download();
75 | }
76 | });
77 | }
78 |
79 | private void findView() {
80 | tvMsg = findViewById(R.id.tv_content);
81 | tvBtn2 = findViewById(R.id.tv_update);
82 | ivClose = findViewById(R.id.iv_close);
83 | tvBtn1 = (TextView) findViewById(R.id.tv_btn1);
84 | tvVersion = findViewById(R.id.tv_version);
85 | }
86 |
87 | @Override
88 | public AppDownloadListener obtainDownloadListener() {
89 | return new AppDownloadListener() {
90 | @Override
91 | public void downloading(int progress) {
92 | tvBtn2.setText(ResUtils.getString(R.string.downloading) + progress + "%");
93 | }
94 |
95 | @Override
96 | public void downloadFail(String msg) {
97 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
98 | Toast.makeText(UpdateType8Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
99 | }
100 |
101 | @Override
102 | public void downloadComplete(String path) {
103 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
104 | }
105 |
106 | @Override
107 | public void downloadStart() {
108 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
109 | }
110 |
111 | @Override
112 | public void reDownload() {
113 | LogUtils.log("下载失败后点击重试");
114 | }
115 |
116 | @Override
117 | public void pause() {
118 |
119 | }
120 | };
121 | }
122 |
123 | /**
124 | * 启动Activity
125 | *
126 | * @param context
127 | * @param info
128 | */
129 | public static void launch(Context context, DownloadInfo info) {
130 | launchActivity(context, info, UpdateType8Activity.class);
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/activity/UpdateType9Activity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.method.ScrollingMovementMethod;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.cretin.www.cretinautoupdatelibrary.utils.LogUtils;
13 | import com.cretin.www.cretinautoupdatelibrary.R;
14 | import com.cretin.www.cretinautoupdatelibrary.interfaces.AppDownloadListener;
15 | import com.cretin.www.cretinautoupdatelibrary.model.DownloadInfo;
16 | import com.cretin.www.cretinautoupdatelibrary.utils.ResUtils;
17 | import com.cretin.www.cretinautoupdatelibrary.utils.RootActivity;
18 |
19 | public class UpdateType9Activity extends RootActivity {
20 |
21 | private TextView tvMsg;
22 | private TextView tvBtn2;
23 | private ImageView ivClose;
24 | private TextView tvVersion;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_update_type9);
30 |
31 | findView();
32 |
33 | setDataAndListener();
34 | }
35 |
36 | private void setDataAndListener() {
37 | tvMsg.setText(downloadInfo.getUpdateLog());
38 | tvMsg.setMovementMethod(ScrollingMovementMethod.getInstance());
39 | tvVersion.setText("v"+downloadInfo.getProdVersionName());
40 |
41 | if (downloadInfo.isForceUpdateFlag()) {
42 | ivClose.setVisibility(View.GONE);
43 | } else {
44 | ivClose.setVisibility(View.VISIBLE);
45 | }
46 |
47 | ivClose.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | finish();
51 | }
52 | });
53 |
54 | tvBtn2.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | //右边的按钮
58 | download();
59 | }
60 | });
61 | }
62 |
63 | private void findView() {
64 | tvMsg = findViewById(R.id.tv_content);
65 | tvBtn2 = findViewById(R.id.tv_update);
66 | ivClose = findViewById(R.id.iv_close);
67 | tvVersion = findViewById(R.id.tv_version);
68 | }
69 |
70 | @Override
71 | public AppDownloadListener obtainDownloadListener() {
72 | return new AppDownloadListener() {
73 | @Override
74 | public void downloading(int progress) {
75 | tvBtn2.setText(ResUtils.getString(R.string.downloading)+progress+"%");
76 | }
77 |
78 | @Override
79 | public void downloadFail(String msg) {
80 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
81 | Toast.makeText(UpdateType9Activity.this, ResUtils.getString(R.string.apk_file_download_fail), Toast.LENGTH_SHORT).show();
82 | }
83 |
84 | @Override
85 | public void downloadComplete(String path) {
86 | tvBtn2.setText(ResUtils.getString(R.string.btn_update_now));
87 | }
88 |
89 | @Override
90 | public void downloadStart() {
91 | tvBtn2.setText(ResUtils.getString(R.string.downloading));
92 | }
93 |
94 | @Override
95 | public void reDownload() {
96 | LogUtils.log("下载失败后点击重试");
97 | }
98 |
99 | @Override
100 | public void pause() {
101 |
102 | }
103 | };
104 | }
105 |
106 | /**
107 | * 启动Activity
108 | *
109 | * @param context
110 | * @param info
111 | */
112 | public static void launch(Context context, DownloadInfo info) {
113 | launchActivity(context, info, UpdateType9Activity.class);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/interfaces/AppDownloadListener.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.interfaces;
2 |
3 | /**
4 | * @date: on 2019-10-11
5 | * @author: a112233
6 | * @email: mxnzp_life@163.com
7 | * @desc: 添加描述
8 | */
9 | public interface AppDownloadListener {
10 | void downloading(int progress);
11 | void downloadFail(String msg);
12 | void downloadComplete(String path);
13 | void downloadStart();
14 | void reDownload();
15 | void pause();
16 | }
17 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/interfaces/AppUpdateInfoListener.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.interfaces;
2 |
3 | /**
4 | * @date: on 2019-10-25
5 | * @author: a112233
6 | * @email: mxnzp_life@163.com
7 | * @desc: 回调当前是否是最新版本
8 | */
9 | public interface AppUpdateInfoListener {
10 | void isLatestVersion(boolean isLatest);
11 | }
12 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/interfaces/ForceExitCallBack.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.interfaces;
2 |
3 | /**
4 | * Created by cretin on 2017/7/25.
5 | */
6 |
7 | public interface ForceExitCallBack {
8 | void exit();
9 | }
10 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/interfaces/MD5CheckListener.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.interfaces;
2 |
3 | /**
4 | * @date: on 2019-10-22
5 | * @author: a112233
6 | * @email: mxnzp_life@163.com
7 | * @desc: MD5检验监听 如果开启了MD5校验才会回调
8 | */
9 | public interface MD5CheckListener {
10 | void fileMd5CheckFail(String originMD5, String localMD5);
11 |
12 | void fileMd5CheckSuccess();
13 | }
14 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/interfaces/OnDialogClickListener.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.interfaces;
2 |
3 | import android.content.DialogInterface;
4 |
5 | /**
6 | * @date: on 2019-10-10
7 | * @author: a112233
8 | * @email: mxnzp_life@163.com
9 | * @desc: 添加描述
10 | */
11 | public interface OnDialogClickListener {
12 | void onOkClick(DialogInterface dialog);
13 |
14 | void onCancelClick(DialogInterface dialog);
15 | }
16 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/model/DownloadInfo.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * @date: on 2019-10-09
8 | * @author: a112233
9 | * @email: mxnzp_life@163.com
10 | * @desc: 下载需要的信息
11 | */
12 | public class DownloadInfo implements Parcelable {
13 | //apk下载地址
14 | private String apkUrl;
15 | //apk文件大小 单位byte
16 | private long fileSize;
17 | //生产环境最新的版本号 用于做比较
18 | private int prodVersionCode;
19 | //生产环境最新的版本名称 用于做展示
20 | private String prodVersionName;
21 | //更新日志
22 | private String updateLog;
23 | //是否强制更新 0 不强制更新 1 hasAffectCodes拥有字段强制更新 2 所有版本强制更新
24 | private int forceUpdateFlag;
25 | //受影响的版本号 如果开启强制更新 那么这个字段包含的所有版本都会被强制更新 格式 2|3|4
26 | private String hasAffectCodes;
27 | //文件MD5的校验值
28 | private String md5Check;
29 |
30 | public String getMd5Check() {
31 | return md5Check;
32 | }
33 |
34 | public DownloadInfo setMd5Check(String md5Check) {
35 | this.md5Check = md5Check;
36 | return this;
37 | }
38 |
39 | public String getHasAffectCodes() {
40 | return hasAffectCodes;
41 | }
42 |
43 | public DownloadInfo setHasAffectCodes(String hasAffectCodes) {
44 | this.hasAffectCodes = hasAffectCodes;
45 | return this;
46 | }
47 |
48 | public boolean isForceUpdateFlag() {
49 | return forceUpdateFlag > 0;
50 | }
51 |
52 | public int getForceUpdateFlag() {
53 | return forceUpdateFlag;
54 | }
55 |
56 | public DownloadInfo setForceUpdateFlag(int forceUpdateFlag) {
57 | this.forceUpdateFlag = forceUpdateFlag;
58 | return this;
59 | }
60 |
61 | public String getUpdateLog() {
62 | return updateLog;
63 | }
64 |
65 | public DownloadInfo setUpdateLog(String updateLog) {
66 | this.updateLog = updateLog;
67 | return this;
68 | }
69 |
70 | public String getApkUrl() {
71 | return apkUrl;
72 | }
73 |
74 | public DownloadInfo setApkUrl(String apkUrl) {
75 | this.apkUrl = apkUrl;
76 | return this;
77 | }
78 |
79 | public long getFileSize() {
80 | return fileSize;
81 | }
82 |
83 | public DownloadInfo setFileSize(long fileSize) {
84 | this.fileSize = fileSize;
85 | return this;
86 | }
87 |
88 | public int getProdVersionCode() {
89 | return prodVersionCode;
90 | }
91 |
92 | public DownloadInfo setProdVersionCode(int prodVersionCode) {
93 | this.prodVersionCode = prodVersionCode;
94 | return this;
95 | }
96 |
97 | public String getProdVersionName() {
98 | return prodVersionName;
99 | }
100 |
101 | public DownloadInfo setProdVersionName(String prodVersionName) {
102 | this.prodVersionName = prodVersionName;
103 | return this;
104 | }
105 |
106 |
107 | @Override
108 | public int describeContents() {
109 | return 0;
110 | }
111 |
112 | @Override
113 | public void writeToParcel(Parcel dest, int flags) {
114 | dest.writeString(this.apkUrl);
115 | dest.writeLong(this.fileSize);
116 | dest.writeInt(this.prodVersionCode);
117 | dest.writeString(this.prodVersionName);
118 | dest.writeString(this.updateLog);
119 | dest.writeInt(this.forceUpdateFlag);
120 | dest.writeString(this.hasAffectCodes);
121 | dest.writeString(this.md5Check);
122 | }
123 |
124 | public DownloadInfo() {
125 | }
126 |
127 | protected DownloadInfo(Parcel in) {
128 | this.apkUrl = in.readString();
129 | this.fileSize = in.readLong();
130 | this.prodVersionCode = in.readInt();
131 | this.prodVersionName = in.readString();
132 | this.updateLog = in.readString();
133 | this.forceUpdateFlag = in.readInt();
134 | this.hasAffectCodes = in.readString();
135 | this.md5Check = in.readString();
136 | }
137 |
138 | public static final Creator CREATOR = new Creator() {
139 | @Override
140 | public DownloadInfo createFromParcel(Parcel source) {
141 | return new DownloadInfo(source);
142 | }
143 |
144 | @Override
145 | public DownloadInfo[] newArray(int size) {
146 | return new DownloadInfo[size];
147 | }
148 | };
149 | }
150 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/model/LibraryUpdateEntity.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.model;
2 |
3 | /**
4 | * Created by cretin on 2017/4/20.
5 | */
6 |
7 | public interface LibraryUpdateEntity {
8 | //获取版本号
9 | int getAppVersionCode();
10 |
11 | //是否强制更新 0 不强制更新 1 hasAffectCodes拥有字段强制更新 2 所有版本强制更新
12 | int forceAppUpdateFlag();
13 |
14 | //版本号 描述作用
15 | String getAppVersionName();
16 |
17 | //新安装包的下载地址
18 | String getAppApkUrls();
19 |
20 | //更新日志
21 | String getAppUpdateLog();
22 |
23 | //安装包大小 单位字节
24 | String getAppApkSize();
25 |
26 | //受影响的版本号 如果开启强制更新 那么这个字段包含的所有版本都会被强制更新 格式 2|3|4
27 | String getAppHasAffectCodes();
28 |
29 | //获取文件的加密校验值
30 | String getFileMd5Check();
31 | }
32 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/model/TypeConfig.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.model;
2 |
3 | /**
4 | * @date: on 2019-10-13
5 | * @author: ctetin
6 | * @email: mxnzp_life@163.com
7 | * @desc: 类型配置类
8 | */
9 | public class TypeConfig {
10 | /**
11 | * 更新信息的来源
12 | */
13 | public static final int DATA_SOURCE_TYPE_MODEL = 10;//调用方提供信息model
14 | public static final int DATA_SOURCE_TYPE_URL = 11;//通过配置链接供sdk自主请求
15 | public static final int DATA_SOURCE_TYPE_JSON = 12;//调用方提供信息json
16 |
17 | /**
18 | * 请求方式类型
19 | */
20 | public static final int METHOD_GET = 20; //GET请求
21 | public static final int METHOD_POST = 21; //POST请求
22 |
23 | /**
24 | * UI样式类型
25 | */
26 | public static final int UI_THEME_AUTO = 300;//sdk自主决定,随机从十几种样式中选择一种,并保证同一个设备选择的唯一的
27 | public static final int UI_THEME_CUSTOM = 399;//用户自定义UI
28 | public static final int UI_THEME_A = 301;//类型A,具体样式效果请关注demo
29 | public static final int UI_THEME_B = 302;//类型B,具体样式效果请关注demo
30 | public static final int UI_THEME_C = 303;//类型C,具体样式效果请关注demo
31 | public static final int UI_THEME_D = 304;//类型D,具体样式效果请关注demo
32 | public static final int UI_THEME_E = 305;//类型E,具体样式效果请关注demo
33 | public static final int UI_THEME_F = 306;//类型F,具体样式效果请关注demo
34 | public static final int UI_THEME_G = 307;//类型G,具体样式效果请关注demo
35 | public static final int UI_THEME_H = 308;//类型H,具体样式效果请关注demo
36 | public static final int UI_THEME_I = 309;//类型I,具体样式效果请关注demo
37 | public static final int UI_THEME_J = 310;//类型J,具体样式效果请关注demo
38 | public static final int UI_THEME_K = 311;//类型K,具体样式效果请关注demo
39 | public static final int UI_THEME_L = 312;//类型K,具体样式效果请关注demo
40 | }
41 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/net/HttpCallbackModelListener.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.net;
2 |
3 | /**
4 | * HttpURLConnection网络请求返回监听器
5 | */
6 | public interface HttpCallbackModelListener {
7 | // 网络请求成功
8 | void onFinish(T response);
9 |
10 | // 网络请求失败
11 | void onError(Exception e);
12 | }
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/net/ResponseCall.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.net;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Looper;
6 | import android.os.Message;
7 |
8 | /**
9 | * Created by cretin on 2017/3/20.
10 | */
11 |
12 | public class ResponseCall {
13 | //用于在子线程和主线程的数据交换
14 | private Handler mHandler;
15 |
16 | public ResponseCall(Context context, final HttpCallbackModelListener listener) {
17 | Looper looper = context.getMainLooper();
18 | mHandler = new Handler(looper) {
19 | @Override
20 | public void handleMessage(Message msg) {
21 | super.handleMessage(msg);
22 | if (msg.what == 0) {
23 | //成功
24 | if (listener != null)
25 | listener.onFinish(msg.obj);
26 | } else if (msg.what == 1) {
27 | //失败
28 | if (listener != null)
29 | listener.onError((Exception) msg.obj);
30 | }
31 | }
32 | };
33 | }
34 |
35 | public void doSuccess(T response) {
36 | Message message = Message.obtain();
37 | message.obj = response;
38 | message.what = 0;
39 | mHandler.sendMessage(message);
40 | }
41 |
42 | public void doFail(Exception e) {
43 | Message message = Message.obtain();
44 | message.obj = e;
45 | message.what = 1;
46 | mHandler.sendMessage(message);
47 | }
48 | }
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/service/UpdateService.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.content.IntentFilter;
6 | import android.os.IBinder;
7 | import android.support.annotation.Nullable;
8 |
9 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUpdateUtils;
10 |
11 | /**
12 | * @date: on 2019-10-10
13 | * @author: a112233
14 | * @email: mxnzp_life@163.com
15 | * @desc: 添加描述
16 | */
17 | public class UpdateService extends Service {
18 |
19 | private UpdateReceiver updateReceiver = new UpdateReceiver();
20 |
21 | @Nullable
22 | @Override
23 | public IBinder onBind(Intent intent) {
24 | return null;
25 | }
26 |
27 | @Override
28 | public void onCreate() {
29 | super.onCreate();
30 | registerReceiver(updateReceiver, new IntentFilter(getPackageName() + UpdateReceiver.DOWNLOAD_ONLY));
31 | registerReceiver(updateReceiver, new IntentFilter(getPackageName() + UpdateReceiver.RE_DOWNLOAD));
32 | registerReceiver(updateReceiver, new IntentFilter(getPackageName() + UpdateReceiver.CANCEL_DOWNLOAD));
33 | }
34 |
35 | @Override
36 | public void onDestroy() {
37 | super.onDestroy();
38 | unregisterReceiver(updateReceiver);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/DownloadReceiver.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 |
8 | /**
9 | * Created by cretin on 2017/3/9.
10 | */
11 |
12 | public abstract class DownloadReceiver extends BroadcastReceiver {
13 | @Override
14 | public void onReceive(Context context, Intent intent) {
15 | Bundle bundle = intent.getExtras();
16 | String tag = bundle.getString("type");
17 | if ( tag.equals("err") ) {
18 | String err = bundle.getString("err");
19 | downloadFail(err);
20 | } else if ( tag.equals("doing") ) {
21 | int progress = bundle.getInt("progress");
22 | downloading(progress);
23 | if ( progress == 100 ) {
24 | downloadComplete();
25 | }
26 | }
27 | }
28 |
29 | //下载完成调用
30 | protected abstract void downloadComplete();
31 |
32 | //下载中调用
33 | protected abstract void downloading(int progress);
34 |
35 | //下载中调用
36 | protected abstract void downloadFail(String e);
37 | }
38 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/InstallFileProvider.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import android.support.v4.content.FileProvider;
4 |
5 | /**
6 | * @date: on 2019-10-11
7 | * @author: a112233
8 | * @email: mxnzp_life@163.com
9 | * @desc: 添加描述
10 | */
11 | public class InstallFileProvider extends FileProvider {
12 | }
13 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import android.os.IInterface;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import com.cretin.www.cretinautoupdatelibrary.utils.AppUpdateUtils;
8 |
9 | /**
10 | * @date: on 2019-10-11
11 | * @author: a112233
12 | * @email: mxnzp_life@163.com
13 | * @desc: 日志
14 | */
15 | public class LogUtils {
16 | /**
17 | * Log日志工具
18 | *
19 | * @param msg
20 | */
21 | public static void log(String msg) {
22 | if (!TextUtils.isEmpty(msg)) {
23 | if (AppUpdateUtils.getInstance().getUpdateConfig().isDebug()) {
24 | Log.e("【AppUpdateUtils】", msg);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/Md5Utils.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.IOException;
6 | import java.security.MessageDigest;
7 |
8 | /**
9 | * MD5加密工具类
10 | *
11 | */
12 | public final class Md5Utils {
13 |
14 | private Md5Utils() {
15 | throw new UnsupportedOperationException("cannot be instantiated");
16 | }
17 |
18 | /**
19 | * 获取文件的MD5值
20 | *
21 | * @param file
22 | * @return
23 | */
24 | public static String getFileMD5(File file) throws Exception {
25 | if (file == null || !file.exists()) {
26 | return "";
27 | }
28 | FileInputStream fis = null;
29 | try {
30 | MessageDigest digest = MessageDigest.getInstance("MD5");
31 | fis = new FileInputStream(file);
32 | byte[] buffer = new byte[8192];
33 | int len;
34 | while ((len = fis.read(buffer)) != -1) {
35 | digest.update(buffer, 0, len);
36 | }
37 | return bytes2Hex(digest.digest());
38 | } catch (Exception e) {
39 | throw new Exception(e);
40 | } finally {
41 | if (fis != null) {
42 | try {
43 | fis.close();
44 | } catch (IOException ignored) {
45 | }
46 | }
47 | }
48 | }
49 |
50 | /**
51 | * 一个byte转为2个hex字符
52 | *
53 | * @param src byte数组
54 | * @return 16进制大写字符串
55 | */
56 | private static String bytes2Hex(byte[] src) {
57 | char[] res = new char[src.length << 1];
58 | final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
59 | for (int i = 0, j = 0; i < src.length; i++) {
60 | res[j++] = hexDigits[src[i] >>> 4 & 0x0F];
61 | res[j++] = hexDigits[src[i] & 0x0F];
62 | }
63 | return new String(res);
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/NetWorkUtils.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 | import android.telephony.TelephonyManager;
7 |
8 | /**
9 | * Created by cretin on 2017/4/21.
10 | */
11 |
12 | public class NetWorkUtils {
13 | public static String getCurrentNetType(Context context) {
14 | String type = "";
15 | ConnectivityManager cm = ( ConnectivityManager ) context.getSystemService(Context.CONNECTIVITY_SERVICE);
16 | NetworkInfo info = cm.getActiveNetworkInfo();
17 | if ( info == null ) {
18 | type = "null";
19 | } else if ( info.getType() == ConnectivityManager.TYPE_WIFI ) {
20 | type = "wifi";
21 | } else if ( info.getType() == ConnectivityManager.TYPE_MOBILE ) {
22 | int subType = info.getSubtype();
23 | if ( subType == TelephonyManager.NETWORK_TYPE_CDMA || subType == TelephonyManager.NETWORK_TYPE_GPRS
24 | || subType == TelephonyManager.NETWORK_TYPE_EDGE ) {
25 | type = "2g";
26 | } else if ( subType == TelephonyManager.NETWORK_TYPE_UMTS || subType == TelephonyManager.NETWORK_TYPE_HSDPA
27 | || subType == TelephonyManager.NETWORK_TYPE_EVDO_A || subType == TelephonyManager.NETWORK_TYPE_EVDO_0
28 | || subType == TelephonyManager.NETWORK_TYPE_EVDO_B ) {
29 | type = "3g";
30 | } else if ( subType == TelephonyManager.NETWORK_TYPE_LTE ) {// LTE是3g到4g的过渡,是3.9G的全球标准
31 | type = "4g";
32 | }
33 | }
34 | return type;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/ResUtils.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.Configuration;
6 | import android.content.res.Resources;
7 | import android.graphics.drawable.Drawable;
8 | import android.support.annotation.ArrayRes;
9 | import android.support.annotation.ColorInt;
10 | import android.support.annotation.ColorRes;
11 | import android.support.annotation.DimenRes;
12 | import android.support.annotation.DrawableRes;
13 | import android.support.annotation.NonNull;
14 | import android.support.annotation.StringRes;
15 | import android.support.v4.content.ContextCompat;
16 | import android.widget.RelativeLayout;
17 | import java.util.Locale;
18 |
19 | /**
20 | * author: deemons
21 | * date: 2017/3/24
22 | * desc:
23 | */
24 |
25 | public class ResUtils {
26 |
27 | private static Context mContext;
28 |
29 | public static void init(Context context) {
30 | mContext = context;
31 | }
32 |
33 | @NonNull
34 | private static Context getContext() {
35 | return mContext;
36 | }
37 |
38 | /**
39 | * 得到Resouce对象
40 | */
41 | public static Resources getResource() {
42 | return getContext().getResources();
43 | }
44 |
45 | /**
46 | * 得到String.xml中的字符串
47 | */
48 | public static String getString(@StringRes int resId) {
49 | return getResource().getString(resId);
50 | }
51 |
52 | /**
53 | * 得到String.xml中的字符串,带占位符
54 | */
55 | public static String getString(@StringRes int id, Object... formatArgs) {
56 | return getResource().getString(id, formatArgs);
57 | }
58 |
59 | /**
60 | * 格式 String 字符版本
61 | */
62 | public static String getString(String format, Object... formatArgs) {
63 | return String.format(Locale.getDefault(), format, formatArgs);
64 | }
65 |
66 | /**
67 | * array.xml中的字符串数组
68 | */
69 | public static String[] getStringArr(@ArrayRes int resId) {
70 | return getResource().getStringArray(resId);
71 | }
72 |
73 |
74 | /**
75 | * array.xml中的数组
76 | */
77 | public static int[] getIntArr(@ArrayRes int resId) {
78 | return getResource().getIntArray(resId);
79 | }
80 |
81 | public static float getDimension(@DimenRes int demenId) {
82 | return getResource().getDimension(demenId);
83 | }
84 |
85 | public static int getDimensionPixelOffset(@DimenRes int demenId) {
86 | return getResource().getDimensionPixelOffset(demenId);
87 | }
88 |
89 | /**
90 | * 得到colors.xml中的颜色
91 | */
92 | @ColorInt
93 | public static int getColor(@ColorRes int colorId) {
94 | return ContextCompat.getColor(getContext(), colorId);
95 | }
96 |
97 |
98 | /**
99 | * 获取 drawable
100 | *
101 | * @param resId 资源 id
102 | * @return Drawable
103 | */
104 | public static Drawable getDrawable(@DrawableRes int resId) {
105 | return getResource().getDrawable(resId);
106 | }
107 |
108 | public static Configuration getConfiguration() {
109 | return getResource().getConfiguration();
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/SSLUtils.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary.utils;
2 |
3 | import android.annotation.SuppressLint;
4 |
5 | import java.security.SecureRandom;
6 | import java.security.cert.CertificateException;
7 | import java.security.cert.X509Certificate;
8 |
9 | import javax.net.ssl.HostnameVerifier;
10 | import javax.net.ssl.SSLContext;
11 | import javax.net.ssl.SSLSession;
12 | import javax.net.ssl.SSLSocketFactory;
13 | import javax.net.ssl.TrustManager;
14 | import javax.net.ssl.X509TrustManager;
15 |
16 | /**
17 | * @date: on 2019-11-04
18 | * @author: a112233
19 | * @email: mxnzp_life@163.com
20 | * @desc: 添加描述
21 | */
22 | public class SSLUtils {
23 | @SuppressLint("TrulyRandom")
24 | public static SSLSocketFactory createSSLSocketFactory() {
25 | SSLSocketFactory sSLSocketFactory = null;
26 | try {
27 | SSLContext sc = SSLContext.getInstance("TLS");
28 | sc.init(null, new TrustManager[]{new TrustAllManager()},
29 | new SecureRandom());
30 | sSLSocketFactory = sc.getSocketFactory();
31 | } catch (Exception ignored) {
32 | }
33 | return sSLSocketFactory;
34 | }
35 |
36 | public static class TrustAllManager implements X509TrustManager {
37 | @SuppressLint("TrustAllX509TrustManager")
38 | @Override
39 | public void checkClientTrusted(X509Certificate[] chain, String authType)
40 | throws CertificateException {
41 | }
42 |
43 | @SuppressLint("TrustAllX509TrustManager")
44 | @Override
45 | public void checkServerTrusted(X509Certificate[] chain, String authType)
46 | throws CertificateException {
47 | }
48 |
49 | @Override
50 | public X509Certificate[] getAcceptedIssuers() {
51 | return new X509Certificate[0];
52 | }
53 | }
54 |
55 | public static class TrustAllHostnameVerifier implements HostnameVerifier {
56 | @SuppressLint("BadHostnameVerifier")
57 | @Override
58 | public boolean verify(String hostname, SSLSession session) {
59 | return true;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/anim/dialog_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/anim/dialog_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/btn_bg_type_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/btn_bg_type_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/btn_bg_type_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/btn_bg_type_6.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/btn_bg_type_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/dialog_item_bg_selector_white_left_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 | -
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/dialog_item_bg_selector_white_left_right_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 | -
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/dialog_item_bg_selector_white_right_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 | -
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/light_orange_button_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/round_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_border_fc8680.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_border_ff721e.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_border_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_42c6a6.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_4c92f0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_e23932.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_fe8b80.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_ff721e.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/drawable/shape_btn_round_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type10.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
22 |
27 |
28 |
41 |
42 |
43 |
44 |
58 |
59 |
60 |
74 |
75 |
76 |
80 |
81 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
25 |
26 |
40 |
41 |
42 |
43 |
58 |
59 |
60 |
74 |
75 |
76 |
80 |
81 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type3.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
25 |
26 |
41 |
42 |
43 |
57 |
58 |
59 |
74 |
75 |
76 |
77 |
81 |
82 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type4.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
25 |
26 |
34 |
35 |
36 |
37 |
51 |
52 |
53 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type5.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
25 |
26 |
39 |
40 |
50 |
51 |
52 |
53 |
67 |
68 |
69 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type6.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
26 |
27 |
40 |
41 |
42 |
43 |
57 |
58 |
59 |
73 |
74 |
75 |
79 |
80 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type7.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
25 |
26 |
38 |
39 |
40 |
41 |
55 |
56 |
57 |
58 |
72 |
73 |
74 |
75 |
79 |
80 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/activity_update_type9.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
26 |
27 |
42 |
43 |
44 |
45 |
59 |
60 |
61 |
75 |
76 |
77 |
81 |
82 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/download_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
23 |
24 |
31 |
32 |
33 |
40 |
41 |
45 |
46 |
47 |
48 |
62 |
63 |
67 |
68 |
72 |
73 |
84 |
85 |
89 |
90 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/download_dialog_super.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
26 |
27 |
39 |
40 |
41 |
55 |
56 |
57 |
61 |
62 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/filemgr.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
19 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/layout_notification.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
18 |
19 |
23 |
24 |
33 |
34 |
44 |
45 |
46 |
47 |
55 |
56 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/layout/new_download_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
23 |
24 |
25 |
35 |
36 |
43 |
44 |
45 |
52 |
53 |
57 |
58 |
59 |
60 |
74 |
75 |
79 |
80 |
84 |
85 |
97 |
98 |
103 |
104 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_10.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_11.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_12.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_3.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_4.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_5.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_6.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_7.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_8.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_bg_type_9.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_update_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/dialog_update_bg.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/progress.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/progress_tips.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/progress_tips.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/update_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/update_close.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/update_close_img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xhdpi/update_close_img.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/dialog_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/dialog_bg.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/ic_launcher1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/ic_launcher1.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/progress.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/progress_tips.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/progress_tips.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/update_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/cretinautoupdatelibrary/src/main/res/mipmap-xxhdpi/update_close.png
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00000000
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CretinAutoUpdateLibrary
3 | 下次再说
4 | 立即更新
5 | 发现新版本...
6 | 下载失败
7 | 已下载
8 | 暂无储存权限,是否前往打开
9 | 取消
10 | 前往
11 | 当前处于非WIFI连接,是否继续?
12 | 提示
13 | 确定
14 | 下载中...
15 | 安装中...
16 | 安装
17 | 安装文件下载失败
18 |
19 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
34 |
35 |
39 |
40 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/xml/install_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/cretinautoupdatelibrary/src/test/java/com/cretin/www/cretinautoupdatelibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.cretin.www.cretinautoupdatelibrary;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/pic/WEIXIN.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/WEIXIN.JPG
--------------------------------------------------------------------------------
/pic/demo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/demo.apk
--------------------------------------------------------------------------------
/pic/erweima.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/erweima.png
--------------------------------------------------------------------------------
/pic/type01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type01.png
--------------------------------------------------------------------------------
/pic/type02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type02.png
--------------------------------------------------------------------------------
/pic/type03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type03.png
--------------------------------------------------------------------------------
/pic/type04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type04.png
--------------------------------------------------------------------------------
/pic/type05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type05.png
--------------------------------------------------------------------------------
/pic/type06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type06.png
--------------------------------------------------------------------------------
/pic/type07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type07.png
--------------------------------------------------------------------------------
/pic/type08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type08.png
--------------------------------------------------------------------------------
/pic/type09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type09.png
--------------------------------------------------------------------------------
/pic/type10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type10.png
--------------------------------------------------------------------------------
/pic/type11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type11.png
--------------------------------------------------------------------------------
/pic/type12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MZCretin/AutoUpdateProject/ba739c98b022d37025a5e91f99ec223f31cd712f/pic/type12.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':cretinautoupdatelibrary'
2 |
--------------------------------------------------------------------------------