Skip to content

Commit

Permalink
Merge branch 'dev_androidx' into dev
Browse files Browse the repository at this point in the history
# 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
AlexLiuSheng committed Dec 19, 2020
2 parents 88b1ce8 + dd302fd commit dbbbe73
Show file tree
Hide file tree
Showing 35 changed files with 1,234 additions and 1,507 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The strongest feature is easier to integrate than version of V1.+

#### jcenter
```
implementation 'com.allenliu.versionchecklib:library:2.2.2'
implementation 'com.allenliu.versionchecklib:library:2.2.3'
```
#### jitpack && androiud x
```
Expand All @@ -39,7 +39,7 @@ allprojects {
}
}
dependencies {
implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.2.2'
implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.2.3'
}
```

Expand Down
4 changes: 2 additions & 2 deletions README_UN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#### jcenter
```
implementation 'com.allenliu.versionchecklib:library:2.2.2'
implementation 'com.allenliu.versionchecklib:library:2.2.3'
```
#### jitpack && androiud x
```
Expand All @@ -38,7 +38,7 @@ allprojects {
}
}
dependencies {
implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.2.2'
implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.2.3'
}
```

Expand Down
18 changes: 11 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = "1.4.0"

repositories {
jcenter()
maven {
Expand All @@ -9,9 +11,12 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// classpath 'me.tatarka:gradle-retrolambda:3.2.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -20,17 +25,16 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {
url 'https://maven.google.com/'
name 'Google'


}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

ext{
BUILD_VERSION=29
}
87 changes: 6 additions & 81 deletions library/build.gradle
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
}
Expand All @@ -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')
}

2 changes: 1 addition & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
android:name=".core.MyService"
android:enabled="true"

android:exported="true" />
android:exported="false" />
<service
android:name=".v2.ui.VersionService"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Created by allenliu on 2017/8/16.
*/

public interface DownloadListener {
public interface DownloadListener {
void onCheckerDownloading(int progress);
void onCheckerDownloadSuccess(File file);
void onCheckerDownloadFail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,5 @@ public void showCustomDialog() {

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private static <T extends Request.Builder> T assembleHeader(T builder, RequestVe
}
public static Request.Builder get(RequestVersionBuilder versionParams) {
Request.Builder builder = new Request.Builder();
builder = assembleHeader(builder, versionParams);
assembleHeader(builder, versionParams);
builder.url(assembleUrl(versionParams.getRequestUrl(), versionParams.getRequestParams()));

return builder;
Expand All @@ -191,7 +191,7 @@ public static Request.Builder get(RequestVersionBuilder versionParams) {
public static Request.Builder post(RequestVersionBuilder versionParams) {
FormBody formBody = getRequestParams(versionParams);
Request.Builder builder = new Request.Builder();
builder = assembleHeader(builder, versionParams);
assembleHeader(builder, versionParams);
builder.post(formBody).url(versionParams.getRequestUrl());
return builder;
}
Expand All @@ -201,7 +201,7 @@ public static Request.Builder postJson(RequestVersionBuilder versionParams) {
String json = getRequestParamsJson(versionParams.getRequestParams());
RequestBody body = RequestBody.create(JSON, json);
Request.Builder builder = new Request.Builder();
builder = assembleHeader(builder, versionParams);
assembleHeader(builder, versionParams);
builder.post(body).url(versionParams.getRequestUrl());
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.allenliu.versionchecklib.utils;

import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.NonNull;

import java.io.File;

import androidx.annotation.NonNull;

import java.io.File;

public class FileHelper {
@Deprecated
Expand All @@ -31,7 +31,11 @@ public static String getDownloadApkCachePath() {
public static String getDownloadApkCachePath(Context context) {
String appCachePath;
if (checkSDCard()) {
appCachePath = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/AllenVersionPath/";
if (Build.VERSION.SDK_INT >= 29) {
appCachePath = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/AllenVersionPath/";
} else {
appCachePath = context.getExternalCacheDir() + "/AllenVersionPath/";
}

} else {
appCachePath = context.getFilesDir().getAbsolutePath() + "/AllenVersionPath/";
Expand Down

This file was deleted.

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
}

}
Loading

0 comments on commit dbbbe73

Please sign in to comment.