-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev_androidx' into dev
# Conflicts: # build.gradle # library/build.gradle # library/src/main/java/com/allenliu/versionchecklib/utils/FileHelper.java # library/src/main/java/com/allenliu/versionchecklib/v2/builder/DownloadBuilder.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/AllenBaseActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/DownloadFailedActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/DownloadingActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/NotificationHelper.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/UIActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/VersionService.java # sample/build.gradle
- Loading branch information
Showing
35 changed files
with
1,234 additions
and
1,507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.github.dcendents.android-maven' | ||
apply plugin: 'com.jfrog.bintray' | ||
version = "2.2.3.2" | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
android { | ||
compileSdkVersion BUILD_VERSION | ||
compileSdkVersion 29 | ||
// buildToolsVersion "29.0.3" | ||
resourcePrefix "versionchecklib" | ||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion BUILD_VERSION | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName version | ||
} | ||
|
@@ -26,83 +26,8 @@ android { | |
|
||
dependencies { | ||
implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
compileOnly 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'com.squareup.okhttp3:okhttp:4.3.1' | ||
implementation 'org.greenrobot:eventbus:3.1.1' | ||
|
||
} | ||
def siteUrl = 'https://github.com/AlexLiuSheng/CheckVersionLib' // 项目的主页 | ||
def gitUrl = 'https://github.com/AlexLiuSheng/CheckVersionLib.git' // Git仓库的url | ||
group = "com.allenliu.versionchecklib" // Maven Group ID for the artifact,一般填你唯一的包名 | ||
install { | ||
repositories.mavenInstaller { | ||
// This generates POM.xml with proper parameters | ||
pom { | ||
project { | ||
packaging 'aar' | ||
// Add your description here | ||
name 'a library that can auto check version on android ' //项目描述 | ||
url siteUrl | ||
// Set your license | ||
licenses { | ||
license { | ||
name 'The Apache Software License, Version 2.0' | ||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id 'liusheng' //填写的一些基本信息 | ||
name 'AllenLiu' | ||
email '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection gitUrl | ||
developerConnection gitUrl | ||
url siteUrl | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
task sourcesJar(type: Jar) { | ||
from android.sourceSets.main.java.srcDirs | ||
classifier = 'sources' | ||
} | ||
task javadoc(type: Javadoc) { | ||
options.encoding = "UTF-8" | ||
source = android.sourceSets.main.java.srcDirs | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
} | ||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
artifacts { | ||
archives javadocJar | ||
archives sourcesJar | ||
} | ||
Properties properties = new Properties() | ||
properties.load(project.rootProject.file('local.properties').newDataInputStream()) | ||
bintray { | ||
user = properties.getProperty("bintray.user") | ||
key = properties.getProperty("bintray.apiKey") | ||
configurations = ['archives'] | ||
pkg { | ||
repo = "maven" | ||
name = "VersionCheckLib" //发布到JCenter上的项目名字 | ||
websiteUrl = siteUrl | ||
vcsUrl = gitUrl | ||
licenses = ["Apache-2.0"] | ||
publish = true | ||
} | ||
} | ||
tasks.withType(Javadoc) { | ||
options.addStringOption('Xdoclint:none', '-quiet') | ||
options.addStringOption('encoding', 'UTF-8') | ||
options.addStringOption('charSet', 'UTF-8') | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,4 +373,5 @@ public void showCustomDialog() { | |
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
library/src/main/java/com/allenliu/versionchecklib/v2/builder/BuilderManager.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
library/src/main/java/com/allenliu/versionchecklib/v2/builder/BuilderManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.allenliu.versionchecklib.v2.builder | ||
|
||
import android.content.Context | ||
import com.allenliu.versionchecklib.R | ||
import com.allenliu.versionchecklib.core.DownloadManager | ||
import com.allenliu.versionchecklib.utils.ALog | ||
import com.allenliu.versionchecklib.v2.AllenVersionChecker | ||
import java.io.File | ||
|
||
/** | ||
* @author : shengliu7 | ||
* @e-mail : [email protected] | ||
* @date : 2020/12/19 12:34 PM | ||
* @desc : | ||
* | ||
*/ | ||
object BuilderManager { | ||
private var downloadBuilder: DownloadBuilder? = null | ||
lateinit var context: Context | ||
fun getDownloadBuilder(): DownloadBuilder? { | ||
return downloadBuilder | ||
} | ||
|
||
fun init(context: Context, downloadBuilder: DownloadBuilder): BuilderManager { | ||
this.context = context | ||
this.downloadBuilder = downloadBuilder | ||
return this | ||
} | ||
|
||
fun destroy() { | ||
downloadBuilder = null | ||
} | ||
|
||
/** | ||
* 验证安装包是否存在,并且在安装成功情况下删除安装包 | ||
*/ | ||
fun checkAndDeleteAPK() { | ||
doWhenNotNull { | ||
//判断versioncode与当前版本不一样的apk是否存在,存在删除安装包 | ||
try { | ||
val downloadPath: String = downloadAPKPath + context.getString(R.string.versionchecklib_download_apkname, context.packageName) | ||
if (!DownloadManager.checkAPKIsExists(context, downloadPath)) { | ||
ALog.e("删除本地apk") | ||
File(downloadPath).delete() | ||
} | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} | ||
} | ||
|
||
} | ||
|
||
fun checkForceUpdate() { | ||
doWhenNotNull { | ||
forceUpdateListener?.onShouldForceUpdate() | ||
} | ||
} | ||
|
||
fun <T> doWhenNotNull(nullBlock: (() -> T)? = null, block: DownloadBuilder.() -> T): T? { | ||
val builder = downloadBuilder | ||
if (builder != null) { | ||
return builder.block() | ||
|
||
} else { | ||
nullBlock?.invoke() | ||
AllenVersionChecker.getInstance().cancelAllMission() | ||
} | ||
return null | ||
} | ||
|
||
} |
Oops, something went wrong.