diff --git a/README.md b/README.md index 63100ee..f229fde 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +#本项目为更新FitAndroid7 + 原项目地址: + https://github.com/hongyangAndroid/FitAndroid7 + + One line of code completes Android 7 fileprovider adaptation~ # FitAndroid7 一行代码完成Android 7 FileProvider适配~ @@ -10,7 +15,7 @@ ## 使用 ``` -compile 'com.zhy.base:fileprovider:1.0.0' +compile 'com.mg.RxCustomizedImagePicker:1.1.0' ``` 通过FileProvider7这个类完成uri的获取即可,例如: diff --git a/app/build.gradle b/app/build.gradle index 5dfc12d..135bd13 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 28 + buildToolsVersion '28.0.3' defaultConfig { applicationId "com.zhy.fitandroid7" - minSdkVersion 14 - targetSdkVersion 25 + minSdkVersion 16 + targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -20,11 +20,11 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.zhy.base:fileprovider:1.0.0' - testCompile 'junit:junit:4.12' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'com.github.shijingsh:fileprovider:1.1.0' + testImplementation 'junit:junit:4.12' } diff --git a/app/src/main/java/com/zhy/fitandroid7/MainActivity.java b/app/src/main/java/com/zhy/fitandroid7/MainActivity.java index f15def4..2e03760 100644 --- a/app/src/main/java/com/zhy/fitandroid7/MainActivity.java +++ b/app/src/main/java/com/zhy/fitandroid7/MainActivity.java @@ -5,18 +5,18 @@ import android.content.pm.PackageManager; import android.graphics.BitmapFactory; import android.net.Uri; +import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; -import android.support.annotation.NonNull; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + import com.zhy.base.fileprovider.FileProvider7; import java.io.File; diff --git a/build.gradle b/build.gradle index 9823df7..549cf02 100644 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,15 @@ buildscript { repositories { + google() jcenter() + maven { + url "https://maven.google.com" + } } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0' - classpath 'com.novoda:bintray-release:0.3.4' + classpath 'com.android.tools.build:gradle:3.5.2' + //classpath 'com.novoda:bintray-release:0.9.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,7 +19,11 @@ buildscript { allprojects { repositories { + mavenCentral() + mavenLocal() jcenter() + google() + } } diff --git a/gradle.properties b/gradle.properties index aac7c9b..20541ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,14 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true +## This file is automatically generated by Android Studio. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Thu May 12 09:33:07 CST 2016 + +android.enableJetifier=true +android.useAndroidX=true +android.useDeprecatedNdk=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04e285f..8c7d966 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Tue Dec 03 13:46:45 GMT+08:00 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/librararyforfileprovdider/build.gradle b/librararyforfileprovdider/build.gradle index 4bf3fa4..0396197 100644 --- a/librararyforfileprovdider/build.gradle +++ b/librararyforfileprovdider/build.gradle @@ -1,14 +1,15 @@ apply plugin: 'com.android.library' -apply plugin: 'com.novoda.bintray-release'//添加 - +//apply plugin: 'com.novoda.bintray-release'//添加 +apply plugin: 'maven' +apply plugin: 'signing' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 28 + buildToolsVersion '28.0.3' defaultConfig { - minSdkVersion 7 - targetSdkVersion 25 + minSdkVersion 16 + targetSdkVersion 28 versionCode 1 versionName "1.0" } @@ -16,18 +17,76 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - provided 'com.android.support:appcompat-v7:25.3.1' + api fileTree(dir: 'libs', include: ['*.jar']) + compileOnly 'androidx.appcompat:appcompat:1.1.0' } -//添加 -publish { - userOrg = 'hongyangandroid'//bintray.com用户名 - groupId = 'com.zhy.base'//jcenter上的路径 - artifactId = 'fileprovider'//项目名称 - publishVersion = '1.0.0'//版本号 - desc = 'Oh hi, this is a nice description for a project, right?'//描述,不重要 - website = 'https://github.com/hyman/basetools'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了 + +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + + +def ossrhUsername = properties.getProperty("ossrhUsername") //在SonaType上申请的账号 +def ossrhPassword = properties.getProperty("ossrhPassword") //在SonaType上申请的密码 + +def PUBLISH_GROUP_ID = 'com.github.shijingsh' //这里可以不是直接申请时候的groupId只要开头是就可以 + +def PUBLISH_ARTIFACT_ID = "fileprovider" //引用库的artifactId + +def PUBLISH_VERSION = "1.1.0" //这个是直接获取的库gradle里配置好的版本号,不用到处修改版本号,只需要维护一份就可以。 + +//签名 +signing { + required { gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives } -// ./gradlew :librararyforfileprovdider:clean :librararyforfileprovdider:build bintrayUpload -PbintrayUser=hongyangandroid -PbintrayKey= -PdryRun=false \ No newline at end of file +uploadArchives { + repositories { + mavenDeployer { + + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.groupId = PUBLISH_GROUP_ID + pom.artifactId = PUBLISH_ARTIFACT_ID + pom.version = PUBLISH_VERSION + + pom.project { + name 'fileprovider' + packaging 'aar' //我这里发布的是安卓的包,所以写的aar + // optionally artifactId can be defined here + description 'One line of code completes Android 7 fileprovider adaptation~' + url 'https://github.com/shijingsh/FitAndroid7' + + scm { + connection 'https://github.com/shijingsh/FitAndroid7' + developerConnection 'scm:git:git@github.com:shijingsh/FitAndroid7.git' + url 'https://github.com/shijingsh' + } + + licenses { + license { + name 'The Apache License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + id 'liukefu' + name 'liukefu' + email 'liukefu2050@sina.com' + } + } + } + } + } +} \ No newline at end of file diff --git a/librararyforfileprovdider/src/main/AndroidManifest.xml b/librararyforfileprovdider/src/main/AndroidManifest.xml index 145c3c6..bdfec83 100644 --- a/librararyforfileprovdider/src/main/AndroidManifest.xml +++ b/librararyforfileprovdider/src/main/AndroidManifest.xml @@ -4,13 +4,13 @@ + android:resource="@xml/mg_file_paths" /> diff --git a/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/FileProvider7.java b/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/FileProvider7.java index 37e7040..334e498 100644 --- a/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/FileProvider7.java +++ b/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/FileProvider7.java @@ -29,8 +29,8 @@ public static Uri getUriForFile(Context context, File file) { public static Uri getUriForFile24(Context context, File file) { - Uri fileUri = android.support.v4.content.FileProvider.getUriForFile(context, - context.getPackageName() + ".android7.fileprovider", + Uri fileUri = androidx.core.content.FileProvider.getUriForFile(context, + context.getPackageName() + ".android7.mg.fileprovider", file); return fileUri; } diff --git a/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/MgFileProvider.java b/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/MgFileProvider.java new file mode 100644 index 0000000..5405083 --- /dev/null +++ b/librararyforfileprovdider/src/main/java/com/zhy/base/fileprovider/MgFileProvider.java @@ -0,0 +1,4 @@ +package com.zhy.base.fileprovider; + +public class MgFileProvider extends androidx.core.content.FileProvider { +} diff --git a/librararyforfileprovdider/src/main/res/xml/file_paths.xml b/librararyforfileprovdider/src/main/res/xml/mg_file_paths.xml similarity index 100% rename from librararyforfileprovdider/src/main/res/xml/file_paths.xml rename to librararyforfileprovdider/src/main/res/xml/mg_file_paths.xml