diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 1ac7d9df2..cd1d80a90 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,6 +3,9 @@ - + - - $USER_HOME$/.subversion - diff --git a/README.md b/README.md index 1e1f5c9b2..8a4bacd38 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,5 @@ # PictureSelector 2.0 - 一款针对android平台下的图片选择器,支持从相册或拍照选择图片或视频、音频,支持动态权限获取、裁剪(单图or多图裁剪)、压缩、主题自定义配置等功能、适配android 6.0+系统的开源图片选择框架。
-   -
项目会一直维护(有bug修复完成,一般周末会更新(不好意思,最近比较忙有时间会解决~有问题先提issue)),有bug请描述清楚,并请Issues会第一时间修复,个人QQ 893855882@qq.com 希望用得着的朋友点个star。
- Android开发交流 群一 619458861 (已满)
- Android开发交流 群二 679824206 (已满)
- -  [我的博客地址](http://blog.csdn.net/luck_mw) - -[![](https://jitpack.io/v/LuckSiege/PictureSelector.svg)](https://jitpack.io/#LuckSiege/PictureSelector) -[![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/LuckSiege) -[![CSDN](https://img.shields.io/twitter/url/http/blog.csdn.net/luck_mw.svg?style=social)](http://blog.csdn.net/luck_mw) -[![I](https://img.shields.io/github/issues/LuckSiege/PictureSelector.svg)](https://github.com/LuckSiege/PictureSelector/issues) -[![Star](https://img.shields.io/github/stars/LuckSiege/PictureSelector.svg)](https://github.com/LuckSiege/PictureSelector) + 一款针对android平台下的图片选择器,支持从相册或拍照选择图片或视频、音频,支持动态权限获取、裁剪(单图or多图裁剪)、压缩、主题自定义配置等功能的开源图片选择框架。
## 目录 -[功能特点](#功能特点)
@@ -24,40 +12,35 @@ -[结果回调](#结果回调)
-[更新日志](#更新日志)
-[混淆配置](#混淆配置)
--[兼容性测试](#兼容性测试)
-[演示效果](#演示效果)
--[打赏](#打赏)
# 功能特点 -* 1.适配android6.0+系统 -* 2.解决部分机型裁剪闪退问题 -* 3.解决图片过大oom闪退问题 -* 4.动态获取系统权限,避免闪退 -* 5.支持相片or视频的单选和多选 -* 6.支持裁剪比例设置,如常用的 1:1、3:4、3:2、16:9 默认为图片大小 -* 7.支持视频预览 -* 8.支持gif图片 -* 9.支持.webp格式图片 -* 10.支持一些常用场景设置:如:是否裁剪、是否预览图片、是否显示相机等 -* 11.新增自定义主题设置 -* 12.新增图片勾选样式设置 -* 13.新增图片裁剪宽高设置 -* 14.新增图片压缩处理 -* 15.新增录视频最大时间设置 -* 16.新增视频清晰度设置 -* 17.新增QQ选择风格,带数字效果 -* 18.新增自定义 文字颜色 背景色让风格和项目更搭配 -* 19.新增多图裁剪功能 -* 20.新增LuBan多图压缩 -* 21.新增单独拍照功能 -* 22.新增压缩大小设置 -* 23.新增Luban压缩档次设置 -* 24.新增圆形头像裁剪 -* 25.新增音频功能查询 - - -重要的事情说三遍记得添加权限 +* 兼容至Android 4.4 +* 支持相片or视频的单选和多选 +* 支持裁剪比例设置,如常用的 1:1、3:4、3:2、16:9 默认为图片大小 +* 支持视频预览 +* 支持gif图片 +* 支持.webp格式图片 +* 支持一些常用场景设置:如:是否裁剪、是否预览图片、是否显示相机等 +* 新增自定义主题设置 +* 新增图片勾选样式设置 +* 新增图片裁剪宽高设置 +* 新增图片压缩处理 +* 新增录视频最大时间设置 +* 新增视频清晰度设置 +* 新增QQ选择风格,带数字效果 +* 新增自定义 文字颜色 背景色让风格和项目更搭配 +* 新增多图裁剪功能 +* 新增LuBan多图压缩 +* 新增单独拍照功能 +* 新增压缩大小设置 +* 新增Luban压缩档次设置 +* 新增圆形头像裁剪 +* 新增音频功能查询 + + +添加权限 ``` @@ -69,48 +52,26 @@ ## 集成方式 -方式一 compile引入 - -``` -dependencies { -    implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.3' -} - -``` - 项目根目录build.gradle加入 ``` allprojects { repositories { - jcenter() + ... maven { url 'https://jitpack.io' } } } ``` +添加依赖项 -方式二 maven引入 - -step 1. -``` - -       -       jitpack.io - https://jitpack.io -       - -``` -step 2. ``` - - -     com.github.LuckSiege.PictureSelector -      picture_library -      v2.2.3 - +dependencies { +    implementation 'com.github.labmem005.PictureSelector:picture_library:v2.3.1' +} ``` + ## 常见错误 ``` 重要:PictureSelector.create();调用此方法时,在activity中传activity.this,在fragment中请传fragment.this, @@ -185,7 +146,7 @@ Glide.with(context).load(url).apply(options).into(imageView); .isCamera()// 是否显示拍照按钮 true or false .imageFormat(PictureMimeType.PNG)// 拍照保存图片格式后缀,默认jpeg .isZoomAnim(true)// 图片列表点击 缩放效果 默认true - .sizeMultiplier(0.5f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效 + .sizeMultiplierOf(0.5f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效 .setOutputCameraPath("/CustomPath")// 自定义拍照保存路径,可不填 .enableCrop()// 是否裁剪 true or false .compress()// 是否压缩 true or false @@ -337,11 +298,13 @@ PictureSelector.create(MainActivity.this).externalPictureVideo(video_path); ## 更新日志 -# 当前版本: +[Lastest release & changes](https://github.com/labmem005/PictureSelector/releases) + +# 历史版本: + * v2.2.3 * 1.修复沉浸式在部分机型标题栏遮挡情况 -# 历史版本: * v2.2.2 * 1.优化外部预览界面样式不同步问题 * 2.优化沉浸式方案,适配更多机型 @@ -409,12 +372,12 @@ PictureSelector.create(MainActivity.this).externalPictureVideo(video_path); * 修复录音不显示时长问题 # 项目使用第三方库: -* glide:4.5.0 -* rxjava:2.0.5 -* rxandroid:2.0.1 -* PhotoView:2.1.3 +* glide +* rxjava +* rxandroid +* PhotoView * luban -* 裁剪使用ucrop +* ucrop ## 混淆配置 ``` @@ -463,14 +426,6 @@ PictureSelector.create(MainActivity.this).externalPictureVideo(video_path); -keepresourcexmlelements manifest/application/meta-data@value=GlideModule ``` -## 打赏 -# ~如果您觉得好,对你有帮助,可以给我一点打赏当做鼓励,蚊子再小也是肉呀(*^__^*) 嘻嘻…… -![image](https://github.com/LuckSiege/PictureSelector/blob/master/image/apply.png) - -## 兼容性测试 -******腾讯优测-深度测试-通过率达到100%****** - -![image](https://github.com/LuckSiege/PictureSelector/blob/master/image/test.png) ## 演示效果 diff --git a/app/build.gradle b/app/build.gradle index 139b63b20..fa48ce9e5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,14 @@ android { } dependencies { - compile project(':picture_library') - testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' - debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' - releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'io.reactivex.rxjava2:rxjava:2.1.17' + implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' + implementation 'com.github.bumptech.glide:glide:4.9.0' + //implementation project(':picture_library') + implementation 'com.github.labmem005:PictureSelector:v2.3.1' + testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1' + releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 271337ddd..d7721f5c2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,7 +30,6 @@ android:screenOrientation="portrait" /> - (); } @@ -155,7 +156,7 @@ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(this.overrideHeight); dest.writeInt(this.aspect_ratio_x); dest.writeInt(this.aspect_ratio_y); - dest.writeFloat(this.sizeMultiplier); + dest.writeFloat(this.sizeMultiplierOf); dest.writeInt(this.cropWidth); dest.writeInt(this.cropHeight); dest.writeByte(this.zoomAnim ? (byte) 1 : (byte) 0); @@ -205,7 +206,7 @@ protected PictureSelectionConfig(Parcel in) { this.overrideHeight = in.readInt(); this.aspect_ratio_x = in.readInt(); this.aspect_ratio_y = in.readInt(); - this.sizeMultiplier = in.readFloat(); + this.sizeMultiplierOf = in.readFloat(); this.cropWidth = in.readInt(); this.cropHeight = in.readInt(); this.zoomAnim = in.readByte() != 0; diff --git a/picture_library/src/main/java/com/luck/picture/lib/decoration/GridSpacingItemDecoration.java b/picture_library/src/main/java/com/luck/picture/lib/decoration/GridSpacingItemDecoration.java index af9c466bf..01ac8d3cf 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/decoration/GridSpacingItemDecoration.java +++ b/picture_library/src/main/java/com/luck/picture/lib/decoration/GridSpacingItemDecoration.java @@ -1,9 +1,10 @@ package com.luck.picture.lib.decoration; import android.graphics.Rect; -import android.support.v7.widget.RecyclerView; import android.view.View; +import androidx.recyclerview.widget.RecyclerView; + /** * author:luck * project:GridSpacingItemDecoration diff --git a/picture_library/src/main/java/com/luck/picture/lib/decoration/RecycleViewDivider.java b/picture_library/src/main/java/com/luck/picture/lib/decoration/RecycleViewDivider.java index a3da694dd..5173f8eb1 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/decoration/RecycleViewDivider.java +++ b/picture_library/src/main/java/com/luck/picture/lib/decoration/RecycleViewDivider.java @@ -6,11 +6,12 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; import android.view.View; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + /** * author:luck * project:PictureSelector diff --git a/picture_library/src/main/java/com/luck/picture/lib/immersive/ImmersiveManage.java b/picture_library/src/main/java/com/luck/picture/lib/immersive/ImmersiveManage.java index 82ff45988..dfa86c012 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/immersive/ImmersiveManage.java +++ b/picture_library/src/main/java/com/luck/picture/lib/immersive/ImmersiveManage.java @@ -3,10 +3,11 @@ import android.app.Activity; import android.graphics.Color; import android.os.Build; -import android.support.v7.app.AppCompatActivity; import android.view.Window; import android.view.WindowManager; +import androidx.appcompat.app.AppCompatActivity; + /** * @author:luck * @data:2018/3/28 下午1:00 diff --git a/picture_library/src/main/java/com/luck/picture/lib/model/LocalMediaLoader.java b/picture_library/src/main/java/com/luck/picture/lib/model/LocalMediaLoader.java index e5602060e..35c078328 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/model/LocalMediaLoader.java +++ b/picture_library/src/main/java/com/luck/picture/lib/model/LocalMediaLoader.java @@ -4,10 +4,11 @@ import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; + +import androidx.fragment.app.FragmentActivity; +import androidx.loader.app.LoaderManager; +import androidx.loader.content.CursorLoader; +import androidx.loader.content.Loader; import com.luck.picture.lib.R; import com.luck.picture.lib.config.PictureConfig; diff --git a/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissions.java b/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissions.java index a3060d908..b9fa83b7a 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissions.java +++ b/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissions.java @@ -4,9 +4,10 @@ import android.app.Activity; import android.app.FragmentManager; import android.os.Build; -import android.support.annotation.NonNull; import android.text.TextUtils; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.List; diff --git a/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissionsFragment.java b/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissionsFragment.java index bb5f55941..c6e8900ee 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissionsFragment.java +++ b/picture_library/src/main/java/com/luck/picture/lib/permissions/RxPermissionsFragment.java @@ -5,9 +5,10 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; + import java.util.HashMap; import java.util.Map; diff --git a/picture_library/src/main/java/com/luck/picture/lib/photoview/PhotoViewAttacher.java b/picture_library/src/main/java/com/luck/picture/lib/photoview/PhotoViewAttacher.java index e679a7d64..ca10b9741 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/photoview/PhotoViewAttacher.java +++ b/picture_library/src/main/java/com/luck/picture/lib/photoview/PhotoViewAttacher.java @@ -20,7 +20,6 @@ import android.graphics.Matrix.ScaleToFit; import android.graphics.RectF; import android.graphics.drawable.Drawable; -import android.support.v4.view.MotionEventCompat; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; @@ -32,6 +31,8 @@ import android.widget.ImageView.ScaleType; import android.widget.OverScroller; +import androidx.core.view.MotionEventCompat; + /** * The component of {@link PhotoView} which does the work allowing for zooming, scaling, panning, etc. * It is made public in case you need to subclass something other than {@link ImageView} and still diff --git a/picture_library/src/main/java/com/luck/picture/lib/tools/PictureFileUtils.java b/picture_library/src/main/java/com/luck/picture/lib/tools/PictureFileUtils.java index 4dbc78524..c33debe9a 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/tools/PictureFileUtils.java +++ b/picture_library/src/main/java/com/luck/picture/lib/tools/PictureFileUtils.java @@ -19,10 +19,11 @@ import android.os.Environment; import android.provider.DocumentsContract; import android.provider.MediaStore; -import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.Log; +import androidx.annotation.NonNull; + import com.luck.picture.lib.config.PictureConfig; import java.io.BufferedOutputStream; diff --git a/picture_library/src/main/java/com/luck/picture/lib/widget/FolderPopWindow.java b/picture_library/src/main/java/com/luck/picture/lib/widget/FolderPopWindow.java index ee88ab44a..4753242b5 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/widget/FolderPopWindow.java +++ b/picture_library/src/main/java/com/luck/picture/lib/widget/FolderPopWindow.java @@ -7,9 +7,6 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.animation.Animation; @@ -18,6 +15,10 @@ import android.widget.PopupWindow; import android.widget.TextView; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import com.luck.picture.lib.R; import com.luck.picture.lib.adapter.PictureAlbumDirectoryAdapter; import com.luck.picture.lib.decoration.RecycleViewDivider; diff --git a/picture_library/src/main/java/com/luck/picture/lib/widget/PreviewViewPager.java b/picture_library/src/main/java/com/luck/picture/lib/widget/PreviewViewPager.java index d05ebe351..920daeac4 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/widget/PreviewViewPager.java +++ b/picture_library/src/main/java/com/luck/picture/lib/widget/PreviewViewPager.java @@ -1,10 +1,11 @@ package com.luck.picture.lib.widget; import android.content.Context; -import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; +import androidx.viewpager.widget.ViewPager; + /** * author:luck * project:PreviewViewPager diff --git a/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/CompatDecoderFactory.java b/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/CompatDecoderFactory.java index 1af2847f1..903b41686 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/CompatDecoderFactory.java +++ b/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/CompatDecoderFactory.java @@ -1,6 +1,6 @@ package com.luck.picture.lib.widget.longimage; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * Compatibility factory to instantiate decoders with empty public constructors. diff --git a/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/SubsamplingScaleImageView.java b/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/SubsamplingScaleImageView.java index a72d99642..5d4fa126e 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/SubsamplingScaleImageView.java +++ b/picture_library/src/main/java/com/luck/picture/lib/widget/longimage/SubsamplingScaleImageView.java @@ -37,8 +37,6 @@ import android.os.Handler; import android.os.Message; import android.provider.MediaStore; -import android.support.annotation.AnyThread; -import android.support.annotation.NonNull; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; @@ -48,6 +46,9 @@ import android.view.View; import android.view.ViewParent; +import androidx.annotation.AnyThread; +import androidx.annotation.NonNull; + import com.luck.picture.lib.R; import java.lang.ref.WeakReference; diff --git a/picture_library/src/main/res/layout/picture_selector.xml b/picture_library/src/main/res/layout/picture_selector.xml index ab540642e..10b644b81 100644 --- a/picture_library/src/main/res/layout/picture_selector.xml +++ b/picture_library/src/main/res/layout/picture_selector.xml @@ -70,7 +70,7 @@ - - - - + - - + -