优化细节

android 1.0.7
jenly1314 5 years ago
parent 946b6e8550
commit 32e71c030e
  1. 19
      README.md
  2. 4
      app-dialog/src/main/java/com/king/app/dialog/AppDialog.java
  3. 16
      app-dialog/src/main/java/com/king/app/dialog/AppDialogConfig.java
  4. 14
      app-updater/src/main/java/com/king/app/updater/AppUpdater.java
  5. 22
      app-updater/src/main/java/com/king/app/updater/UpdateConfig.java
  6. 9
      app-updater/src/main/java/com/king/app/updater/service/DownloadService.java
  7. BIN
      app/release/app-release.apk
  8. 2
      app/release/output.json
  9. 1
      app/src/main/java/com/king/appupdater/MainActivity.java
  10. 4
      versions.gradle

@ -41,7 +41,7 @@ AppUpdater for Android 是一个专注于App更新,一键傻瓜式集成App版
<dependency>
<groupId>com.king.app</groupId>
<artifactId>app-updater</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<type>pom</type>
</dependency>
@ -49,7 +49,7 @@ AppUpdater for Android 是一个专注于App更新,一键傻瓜式集成App版
<dependency>
<groupId>com.king.app</groupId>
<artifactId>app-dialog</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<type>pom</type>
</dependency>
```
@ -58,25 +58,25 @@ AppUpdater for Android 是一个专注于App更新,一键傻瓜式集成App版
//----------AndroidX 版本
//app-updater
implementation 'com.king.app:app-updater:1.0.6-androidx'
implementation 'com.king.app:app-updater:1.0.7-androidx'
//app-dialog
implementation 'com.king.app:app-dialog:1.0.6-androidx'
implementation 'com.king.app:app-dialog:1.0.7-androidx'
//----------Android Support 版本
//app-updater
implementation 'com.king.app:app-updater:1.0.6'
implementation 'com.king.app:app-updater:1.0.7'
//app-dialog
implementation 'com.king.app:app-dialog:1.0.6'
implementation 'com.king.app:app-dialog:1.0.7'
```
### Lvy:
```lvy
//app-updater
<dependency org='com.king.app' name='app-dialog' rev='1.0.6'>
<dependency org='com.king.app' name='app-dialog' rev='1.0.7'>
<artifact name='$AID' ext='pom'></artifact>
</dependency>
//app-dialog
<dependency org='com.king.app' name='app-dialog' rev='1.0.6'>
<dependency org='com.king.app' name='app-dialog' rev='1.0.7'>
<artifact name='$AID' ext='pom'></artifact>
</dependency>
```
@ -142,6 +142,9 @@ AppUpdater for Android 是一个专注于App更新,一键傻瓜式集成App版
## 版本记录
#### v1.0.7:2019-12-18
* 优化细节
#### v1.0.6:2019-11-27
* 新增OkHttpManager 如果使用了OkHttpManager则必须依赖[okhttp](https://github.com/square/okhttp)
* 优化细节 (progress,total 变更 int -> long)

@ -55,7 +55,9 @@ public enum AppDialog {
try{
//不强制要求要有中间的线
View line = view.findViewById(R.id.line);
line.setVisibility(config.isHideCancel() ? View.GONE : View.VISIBLE);
if(line != null){
line.setVisibility(config.isHideCancel() ? View.GONE : View.VISIBLE);
}
}catch (Exception e){
}

@ -4,6 +4,7 @@ import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.view.LayoutInflater;
import android.view.View;
@ -129,6 +130,11 @@ public class AppDialogConfig {
return this;
}
public AppDialogConfig setTitle(@NonNull Context context,@StringRes int resId) {
this.title = context.getString(resId);
return this;
}
public CharSequence getContent() {
return content;
}
@ -147,6 +153,11 @@ public class AppDialogConfig {
return this;
}
public AppDialogConfig setCancel(@NonNull Context context,@StringRes int resId) {
this.cancel = context.getString(resId);
return this;
}
public CharSequence getOk() {
return ok;
}
@ -156,6 +167,11 @@ public class AppDialogConfig {
return this;
}
public AppDialogConfig setOk(@NonNull Context context,@StringRes int resId) {
this.ok = context.getString(resId);
return this;
}
public boolean isHideCancel() {
return isHideCancel;
}

@ -286,8 +286,8 @@ public class AppUpdater {
}
/**
* 设置下载失败是是否支持点击通知栏重新下载
* @param reDownload 下载失败时是否支持点击通知栏重新下载默认true 最多重新下载3次
* 设置下载失败是否支持点击通知栏重新下载与之相关联的方法{@link #setReDownloads(int)}
* @param reDownload 下载失败时是否支持点击通知栏重新下载默认true
* @return
*/
public Builder setReDownload(boolean reDownload) {
@ -295,6 +295,16 @@ public class AppUpdater {
return this;
}
/**
* 设置下载失败时最多重新下载次数与之相关联的方法{@link #setReDownload(boolean)}
* @param reDownloads 下载失败时是否支持点击通知栏重新下载默认最多重新下载3次
* @return
*/
public Builder setReDownloads(int reDownloads) {
mConfig.setReDownloads(reDownloads);
return this;
}
/**
* 设置要下载APK的versionCode
* @param versionCode 为null表示不处理默认不存在则下载存在则重新下载不为null时表示会优先校验本地是否存在已下载版本号为versionCode的APK

@ -59,9 +59,13 @@ public class UpdateConfig implements Parcelable {
*/
private String mAuthority;
/**
* 下载失败是否支持点击通知栏重下载
* 下载失败是否支持点击通知栏重下载
*/
private boolean isReDownload = true;
/**
* 下载失败后最大重新下载次数
*/
private int reDownloads = 3;
/**
* 是否显示百分比
*/
@ -193,6 +197,14 @@ public class UpdateConfig implements Parcelable {
isReDownload = reDownload;
}
public int getReDownloads() {
return reDownloads;
}
public void setReDownloads(int reDownloads) {
this.reDownloads = reDownloads;
}
public boolean isVibrate() {
return isVibrate;
}
@ -237,7 +249,6 @@ public class UpdateConfig implements Parcelable {
}
}
public boolean isDeleteCancelFile() {
return isDeleteCancelFile;
}
@ -265,17 +276,21 @@ public class UpdateConfig implements Parcelable {
dest.writeString(this.mChannelName);
dest.writeString(this.mAuthority);
dest.writeByte(this.isReDownload ? (byte) 1 : (byte) 0);
dest.writeInt(this.reDownloads);
dest.writeByte(this.isShowPercentage ? (byte) 1 : (byte) 0);
dest.writeByte(this.isVibrate ? (byte) 1 : (byte) 0);
dest.writeByte(this.isSound ? (byte) 1 : (byte) 0);
dest.writeValue(this.versionCode);
dest.writeInt(mRequestProperty!=null ? this.mRequestProperty.size() : 0);
if(mRequestProperty!=null){
dest.writeInt(this.mRequestProperty.size());
for (Map.Entry<String, String> entry : this.mRequestProperty.entrySet()) {
dest.writeString(entry.getKey());
dest.writeString(entry.getValue());
}
}else{
dest.writeInt(0);
}
dest.writeByte(this.isDeleteCancelFile ? (byte) 1 : (byte) 0);
}
@ -291,6 +306,7 @@ public class UpdateConfig implements Parcelable {
this.mChannelName = in.readString();
this.mAuthority = in.readString();
this.isReDownload = in.readByte() != 0;
this.reDownloads = in.readInt();
this.isShowPercentage = in.readByte() != 0;
this.isVibrate = in.readByte() != 0;
this.isSound = in.readByte() != 0;

@ -227,12 +227,15 @@ public class DownloadService extends Service {
private UpdateCallback callback;
private int reDownloads;
private AppDownloadCallback(UpdateConfig config,UpdateCallback callback){
this.config = config;
this.callback = callback;
this.isShowNotification = config.isShowNotification();
this.notifyId = config.getNotificationId();
this.reDownloads = config.getReDownloads();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
this.channelId = TextUtils.isEmpty(config.getChannelId()) ? Constants.DEFAULT_NOTIFICATION_CHANNEL_ID : config.getChannelId();
@ -280,7 +283,7 @@ public class DownloadService extends Service {
mLastTime = curTime;
int currProgress = Math.round(progress * 1.0f / total * 100.0f);
if(currProgress!=mLastProgress){//百分比改变了才更新
if(currProgress != mLastProgress){//百分比改变了才更新
isChange = true;
String percentage = currProgress + "%";
if(isShowNotification) {
@ -319,8 +322,8 @@ public class DownloadService extends Service {
public void onError(Exception e) {
Log.w(Constants.TAG,"onError:"+ e.getMessage());
isDownloading = false;
//支持下载失败重新并最多支持失败下载3次
boolean isReDownload = this.isReDownload && mCount < 3;
//支持下载失败时重新下载,当重新下载次数不超过限制时才被允许
boolean isReDownload = this.isReDownload && mCount < reDownloads;
String content = isReDownload ? getString(R.string.app_updater_error_notification_content_re_download) : getString(R.string.app_updater_error_notification_content);
showErrorNotification(notifyId,channelId,notificationIcon,getString(R.string.app_updater_error_notification_title),content,isReDownload,config);

Binary file not shown.

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"1.0.6","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":11,"versionName":"1.0.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

@ -31,6 +31,7 @@ public class MainActivity extends AppCompatActivity {
private final Object mLock = new Object();
//下载出现Failed to connect to raw.githubusercontent.com时,可以换个下载链接测试,github的raw.githubusercontent.com目前不太稳定。
private String mUrl = "https://raw.githubusercontent.com/jenly1314/AppUpdater/master/app/release/app-release.apk";
private ProgressBar progressBar;

@ -1,7 +1,7 @@
//App
def app_version = [:]
app_version.versionCode = 9 //androidx 10
app_version.versionName = "1.0.6"
app_version.versionCode = 11 //androidx 12
app_version.versionName = "1.0.7"
ext.app_version = app_version
//build version

Loading…
Cancel
Save