Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
罗孟伟 committed Apr 28, 2021
1 parent 227b714 commit eb65141
Show file tree
Hide file tree
Showing 152 changed files with 1,184 additions and 969 deletions.
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />

<uses-feature android:name="android.hardware.camera.any" />


<!--适配Android R包可见性 开始-->
<queries package="${applicationId}">
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<intent>
<action android:name="android.media.action.ACTION_VIDEO_CAPTURE" />
</intent>
</queries>
<!--适配Android R包可见性 结束-->

<application
android:name=".App"
android:allowBackup="true"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/luck/pictureselector/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,16 @@ public void onAddPicClick() {
//.loadCacheResourcesCallback(GlideCacheEngine.createCacheEngine())// 获取图片资源缓存,主要是解决华为10部分机型在拷贝文件过多时会出现卡的问题,这里可以判断只在会出现一直转圈问题机型上使用
//.setOutputCameraPath(createCustomCameraOutPath())// 自定义相机输出目录
//.setButtonFeatures(CustomCameraView.BUTTON_STATE_BOTH)// 设置自定义相机按钮状态
.setCaptureLoadingColor(ContextCompat.getColor(getContext(), R.color.app_color_blue))
.maxSelectNum(maxSelectNum)// 最大图片选择数量
.minSelectNum(1)// 最小选择数量
.maxVideoSelectNum(1) // 视频最大选择数量
//.minVideoSelectNum(1)// 视频最小选择数量
//.closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 关闭在AndroidQ下获取图片或视频宽高相反自动转换
.imageSpanCount(4)// 每行显示个数
//.queryFileSize() // 过滤最大资源,已废弃
//.filterMinFileSize()// 过滤最小资源,单位kb
//.filterMaxFileSize()// 过滤最大资源,单位kb
.isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回
.closeAndroidQChangeWH(true)//如果图片有旋转角度则对换宽高,默认为true
.closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 如果视频有旋转角度则对换宽高,默认为false
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ apply from: "config.gradle"
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.android.tools.build:gradle:4.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
version = VERSION_NAME
group = GROUP

repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
Expand Down
17 changes: 8 additions & 9 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ext {
cfgs = [
compileSdkVersion : 30,
buildToolsVersion : "28.0.3",
buildToolsVersion : "29.0.2",
minSdkVersion : 19,
targetSdkVersion : 30,
versionCode : 31,
versionName : "2.6.1",
versionCode : 37,
versionName : "v2.6.7-test",
ucropVersionCode : 24,
ucropVersionName : "2.2.4-non-native",

Expand All @@ -15,19 +15,18 @@ ext {
version_appcompat : "1.2.0",
localbroadcastmanager : "1.0.0",

camerax_view : "1.0.0-alpha23",
camerax_version : "1.1.0-alpha03",
camera_core_version : "1.0.0-beta03",
camerax_view : "1.0.0-alpha24",
camerax_version : "1.1.0-alpha04",
camera_core_version : "1.0.0-rc04",
experimental_version : "1.1.0",
futures_version : "1.1.0",

// ucrop
androidx_appcompat_version : "1.2.0",
androidx_exifinterface_version: "1.3.2",
androidx_transition_version : "1.4.0",
androidx_transition_version : "1.4.1",

// okio
okio_version : "2.10.0",
okio_version : '3.0.0-alpha.1',

// glide
glide_version : "4.12.0",
Expand Down
32 changes: 18 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
# 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
VERSION_NAME=2.2.4-non-native
VERSION_CODE=24
GROUP=com.yalantis
POM_DESCRIPTION=Android Library for cropping images
POM_URL=https://github.com/Yalantis/uCrop
POM_SCM_URL=https://github.com/Yalantis/uCrop
POM_SCM_CONNECTION=scm:[email protected]/Yalantis/uCrop.git
POM_SCM_DEV_CONNECTION=scm:[email protected]/Yalantis/uCrop.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=yalantis
POM_DEVELOPER_NAME=Yalantis
android.useAndroidX=true

android.useAndroidX=true


# PictureSelector
sonatype.username=LuckSiege
sonatype.password=ShiRT6421191@
signing.keyId=D2E84A41
signing.password=ShiRT6421191@
signing.secretKeyRingFile=/Users/luck/secring.gpg

groupId = io.github.lucksiege
artifactId = pictureselector
email = [email protected]
gitUrl = https://github.com/LuckSiege/PictureSelector
description = Picture Selector Library for Android
license = Apache License 2.0

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 16 20:22:07 CST 2020
#Tue Apr 27 15:06:02 CST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
10 changes: 8 additions & 2 deletions picture_library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ android {
targetSdkVersion cfgs.targetSdkVersion
versionCode cfgs.versionCode
versionName cfgs.versionName

vectorDrawables.useSupportLibrary = true
}

compileOptions {
Expand All @@ -24,8 +26,12 @@ android {
lintOptions {
abortOnError false
}

resourcePrefix 'ucrop_'
}

apply from: '../publish.gradle'

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:${cfgs.version_appcompat}"
Expand All @@ -34,8 +40,8 @@ dependencies {
implementation "androidx.annotation:annotation-experimental:${cfgs.experimental_version}"
implementation "com.squareup.okio:okio:${cfgs.okio_version}"
implementation "androidx.exifinterface:exifinterface:${cfgs.androidx_exifinterface_version}"
implementation "androidx.camera:camera-lifecycle:${cfgs.camerax_version}"
implementation "androidx.localbroadcastmanager:localbroadcastmanager:${cfgs.localbroadcastmanager}"
implementation "androidx.camera:camera-view:${cfgs.camerax_view}"
api project(':ucrop')
implementation "androidx.transition:transition:${cfgs.androidx_transition_version}"
implementation "androidx.camera:camera-lifecycle:${cfgs.camerax_version}"
}
11 changes: 0 additions & 11 deletions picture_library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
androidx.camera.camera2,androidx.camera.lifecycle,
androidx.camera.core" />

<!--适配Android R包可见性 开始-->
<queries package="${applicationId}">
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<intent>
<action android:name="android.media.action.ACTION_VIDEO_CAPTURE" />
</intent>
</queries>
<!--适配Android R包可见性 结束-->

<application>
<provider
android:name="com.luck.picture.lib.PictureFileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public abstract class PictureBaseActivity extends AppCompatActivity {
protected boolean openWhiteStatusBar, numComplete;
protected int colorPrimary, colorPrimaryDark;
protected PictureLoadingDialog mLoadingDialog;
protected List<LocalMedia> selectionMedias;
protected List<LocalMedia> selectionMedias = new ArrayList<>();
protected Handler mHandler = new Handler(Looper.getMainLooper());
protected View container;
/**
Expand Down Expand Up @@ -229,7 +229,10 @@ protected Context getContext() {
* init Config
*/
private void initConfig() {
selectionMedias = config.selectionMedias == null ? new ArrayList<>() : config.selectionMedias;
if (config.selectionMedias != null) {
selectionMedias.clear();
selectionMedias.addAll(config.selectionMedias);
}
if (PictureSelectionConfig.uiStyle != null) {
openWhiteStatusBar = PictureSelectionConfig.uiStyle.picture_statusBarChangeTextColor;
if (PictureSelectionConfig.uiStyle.picture_top_titleBarBackgroundColor != 0) {
Expand Down Expand Up @@ -500,8 +503,7 @@ protected void onResult(List<LocalMedia> images) {
} else {
dismissDialog();
if (config.camera
&& config.selectionMode == PictureConfig.MULTIPLE
&& selectionMedias != null) {
&& config.selectionMode == PictureConfig.MULTIPLE) {
images.addAll(images.size() > 0 ? images.size() - 1 : 0, selectionMedias);
}
if (config.isCheckOriginalImage) {
Expand Down Expand Up @@ -562,8 +564,7 @@ public void onSuccess(List<LocalMedia> images) {
dismissDialog();
if (images != null) {
if (config.camera
&& config.selectionMode == PictureConfig.MULTIPLE
&& selectionMedias != null) {
&& config.selectionMode == PictureConfig.MULTIPLE) {
images.addAll(images.size() > 0 ? images.size() - 1 : 0, selectionMedias);
}
if (PictureSelectionConfig.listener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.camera.view.CameraView;

import com.luck.picture.lib.camera.CustomCameraView;
import com.luck.picture.lib.camera.listener.CameraListener;
Expand All @@ -25,7 +24,6 @@
import com.luck.picture.lib.permissions.PermissionChecker;

import java.io.File;
import java.lang.ref.WeakReference;

/**
* @author:luck
Expand Down Expand Up @@ -129,8 +127,6 @@ protected void onResume() {
*/
protected void initView() {
mCameraView.setPictureSelectionConfig(config);
// 绑定生命周期
mCameraView.setBindToLifecycle(new WeakReference<>(this).get());
// 视频最大拍摄时长
if (config.recordVideoSecond > 0) {
mCameraView.setRecordVideoMaxTime(config.recordVideoSecond);
Expand All @@ -139,10 +135,13 @@ protected void initView() {
if (config.recordVideoMinSecond > 0) {
mCameraView.setRecordVideoMinTime(config.recordVideoMinSecond);
}
// 设置拍照时loading色值
if (config.captureLoadingColor != 0) {
mCameraView.setCaptureLoadingColor(config.captureLoadingColor);
}
// 获取CameraView
CameraView cameraView = mCameraView.getCameraView();
if (cameraView != null && config.isCameraAroundState) {
cameraView.toggleCamera();
if (config.isCameraAroundState) {
mCameraView.toggleCamera();
}
// 获取录制按钮
CaptureLayout captureLayout = mCameraView.getCaptureLayout();
Expand Down Expand Up @@ -274,4 +273,12 @@ protected void showPermissionsDialog(boolean isCamera, String errorMsg) {
});
dialog.show();
}

@Override
protected void onDestroy() {
if (mCameraView != null) {
mCameraView.unbindCameraController();
}
super.onDestroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ protected boolean isSelected(LocalMedia image) {

protected void onSelectNumChange(boolean isRefresh) {
this.refresh = isRefresh;
boolean enable = selectData != null && selectData.size() != 0;
boolean enable = selectData.size() != 0;
if (enable) {
mTvPictureOk.setEnabled(true);
mTvPictureOk.setSelected(true);
Expand Down Expand Up @@ -741,8 +741,7 @@ protected void onCheckedComplete() {
ToastUtils.s(getContext(), PictureMimeType.s(getContext(), image.getMimeType()));
return;
}
String mimeType = selectData.size() > 0 ?
selectData.get(0).getMimeType() : "";
String mimeType = selectData.size() > 0 ? selectData.get(0).getMimeType() : "";
int currentSize = selectData.size();
if (config.isWithVideoImage) {
// 混选模式
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
*/

public class PictureSelectionModel {
private PictureSelectionConfig selectionConfig;
private PictureSelector selector;
private final PictureSelectionConfig selectionConfig;
private final PictureSelector selector;

public PictureSelectionModel(PictureSelector selector, int chooseMode) {
this.selector = selector;
Expand Down Expand Up @@ -232,6 +232,17 @@ public PictureSelectionModel setButtonFeatures(int buttonFeatures) {
return this;
}

/**
* Set Custom Camera Photo Loading color
*
* @param color
* @return
*/
public PictureSelectionModel setCaptureLoadingColor(int color) {
selectionConfig.captureLoadingColor = color;
return this;
}

/**
* @param enableCrop Do you want to start cutting ?
* @return Use {link .isEnableCrop()}
Expand Down Expand Up @@ -889,11 +900,43 @@ public PictureSelectionModel setOutputCameraPath(String outPutCameraPath) {
/**
* # file size The unit is M
*
* @param fileSize Filter file size
* @param fileSize Filter max file size
* Use {@link .filterMaxFileSize()}
* @return
*/
public PictureSelectionModel queryMaxFileSize(float fileSize) {
selectionConfig.filterFileSize = fileSize;
@Deprecated
public PictureSelectionModel queryFileSize(float fileMSize) {
selectionConfig.filterFileSize = fileMSize;
return this;
}

/**
* # file size The unit is KB
*
* @param fileSize Filter max file size
* @return
*/
public PictureSelectionModel filterMaxFileSize(long fileKbSize) {
if (fileKbSize >= PictureConfig.MB) {
selectionConfig.filterMaxFileSize = fileKbSize;
} else {
selectionConfig.filterMaxFileSize = fileKbSize * 1024;
}
return this;
}

/**
* # file size The unit is KB
*
* @param fileSize Filter min file size
* @return
*/
public PictureSelectionModel filterMinFileSize(long fileKbSize) {
if (fileKbSize >= PictureConfig.MB) {
selectionConfig.filterMinFileSize = fileKbSize;
} else {
selectionConfig.filterMinFileSize = fileKbSize * 1024;
}
return this;
}

Expand Down
Loading

0 comments on commit eb65141

Please sign in to comment.