1:修改系统和官方公告展示html出现标签展示的问题
2:添加群全员禁言和单个禁言的功能 3:将道具商城做成原生的 4:添加应用更新的时候,添加版本判断和重新刷新手机文本,预防出现安装缓存(自己测试十几次,未在出现问题,还需要大量测试)
This commit is contained in:
@@ -39,7 +39,7 @@ class DownloadManager private constructor(builder: Builder) : Serializable {
|
||||
}
|
||||
|
||||
private var application: Application = builder.application
|
||||
private var apkVersionCode: Int
|
||||
internal var apkVersionCode: Int
|
||||
private var showNewerToast: Boolean
|
||||
internal var contextClsName: String = builder.contextClsName
|
||||
internal var apkUrl: String
|
||||
|
||||
@@ -151,7 +151,15 @@ class DownloadService : Service(), OnDownloadListener {
|
||||
)
|
||||
}
|
||||
if (manager.jumpInstallPage) {
|
||||
ApkUtil.installApk(this@DownloadService, Constant.AUTHORITIES!!, apk)
|
||||
if (apk.toPath().toString().contains(manager.apkVersionCode.toString())) {
|
||||
ApkUtil.installApk(this@DownloadService, Constant.AUTHORITIES!!, apk)
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this@DownloadService,
|
||||
"当前下载的版本不正确,重新下载或者联系管理员",
|
||||
Toast.LENGTH_SHORT
|
||||
)
|
||||
}
|
||||
}
|
||||
manager.onDownloadListeners.forEach { it.done(apk) }
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.azhon.appupdate.util
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.media.MediaScannerConnection
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.PatternMatcher
|
||||
import androidx.core.content.FileProvider
|
||||
import java.io.File
|
||||
@@ -23,7 +26,20 @@ class ApkUtil {
|
||||
* install package form file
|
||||
*/
|
||||
fun installApk(context: Context, authorities: String, apk: File) {
|
||||
context.startActivity(createInstallIntent(context, authorities, apk))
|
||||
// context.startActivity(createInstallIntent(context, authorities, apk))
|
||||
// 偏方:针对某些厂商安装器的缓存问题
|
||||
// 1. 主动刷新媒体库(即使我们用了FileProvider,也扫描一下,影响系统相册的数据库)
|
||||
MediaScannerConnection.scanFile(context,
|
||||
arrayOf(apk.absolutePath),
|
||||
arrayOf("application/vnd.android.package-archive"),
|
||||
null)
|
||||
|
||||
// 2. 短暂延迟,给系统一点处理时间
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
// 3. 再启动安装
|
||||
val intent = createInstallIntent(context, authorities, apk)
|
||||
context.startActivity(intent)
|
||||
}, 500) // 延迟500毫秒
|
||||
}
|
||||
|
||||
fun createInstallIntent(context: Context, authorities: String, apk: File): Intent {
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.view.WindowManager
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
@@ -177,8 +178,14 @@ class UpdateDialogActivity : AppCompatActivity(), View.OnClickListener {
|
||||
}
|
||||
R.id.btn_update -> {
|
||||
if (btnUpdate.tag == install) {
|
||||
ApkUtil.installApk(this, Constant.AUTHORITIES!!, apk)
|
||||
return
|
||||
if (apk.toString().contains(manager?.apkVersionCode.toString())){
|
||||
ApkUtil.installApk(this, Constant.AUTHORITIES!!, apk)
|
||||
return
|
||||
}else{
|
||||
Toast.makeText(this, "当前版本不对,请联系管理员", Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
if (!checkPermission()) {
|
||||
startUpdate()
|
||||
|
||||
Reference in New Issue
Block a user