Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1931

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Develop #1931

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
03a059c
微信选择优化
zzuliyikai1 Sep 8, 2020
291b50f
选择图片样式修改
zzuliyikai1 Oct 20, 2020
fb93973
添加圆角风格
zzuliyikai1 Oct 20, 2020
d23cf48
点击next 添加loading
zzuliyikai1 Oct 21, 2020
8bbde5a
Tablayout 选择字体颜色修改,兼容video独自展示
zzuliyikai1 Oct 21, 2020
66c4cd6
选择图片或者视频之后 展示loading
zzuliyikai1 Oct 22, 2020
580448b
文案 样式修改
zzuliyikai1 Oct 23, 2020
334de8d
next 样式
zzuliyikai1 Oct 27, 2020
0c9ae89
添加过滤文件类型
zzuliyikai1 Oct 29, 2020
8824cd9
点击选择item优化
zzuliyikai1 Oct 30, 2020
7beb2ed
过滤文件后缀
zzuliyikai1 Oct 30, 2020
b0af4ca
选择文件过滤优化
zzuliyikai1 Nov 2, 2020
654b45c
交换顺序image 和 video
zzuliyikai1 Nov 12, 2020
7f96997
资源不可用时,文案修改
zzuliyikai1 Nov 14, 2020
3ac6858
选择图片优化
zzuliyikai1 Nov 24, 2020
2d00e11
空图片选择文案
zzuliyikai1 Nov 25, 2020
5db13ef
空文案提示优化
zzuliyikai1 Nov 27, 2020
a117284
添加支持messageStyle 样式
zzuliyikai1 Nov 30, 2020
74dfcd4
修改圆角
zzuliyikai1 Jan 14, 2021
ff2e9ca
send 距离底部16dp
zzuliyikai1 Jan 15, 2021
7aa8fbc
Merge branch 'master' into develop
zzuliyikai Apr 20, 2021
6967fd1
合并冲突,完成api30 适配
zzuliyikai1 Apr 21, 2021
89fbf30
修改选择图片控件及其ui
zzuliyikai1 May 13, 2021
43aa578
ui 修改
zzuliyikai1 May 21, 2021
e7b8ccb
修改toast
zzuliyikai1 May 21, 2021
167bbea
修改文案
zzuliyikai1 May 24, 2021
c520ade
修改视频时间显示方式 四舍五入
zzuliyikai1 May 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ android {

debug {
minifyEnabled false
signingConfig signingConfigs.pictureSelectorKey
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

Expand Down Expand Up @@ -75,4 +74,5 @@ dependencies {
implementation "androidx.camera:camera-camera2:${cfgs.camerax_version}"
implementation "com.github.bumptech.glide:glide:${cfgs.glide_version}"
implementation "com.squareup.picasso:picasso:${cfgs.picasso_version}"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
}
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="q">
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/luck/pictureselector/GlideEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.ImageViewTarget;
import com.luck.picture.lib.engine.ImageEngine;
import com.luck.picture.lib.listener.OnImageCompleteCallback;
import com.luck.picture.lib.tools.MediaUtils;
import com.luck.picture.lib.tools.ScreenUtils;
import com.luck.picture.lib.widget.longimage.ImageSource;
import com.luck.picture.lib.widget.longimage.ImageViewState;
import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView;
Expand Down Expand Up @@ -211,6 +215,25 @@ public void loadGridImage(@NonNull Context context, @NonNull String url, @NonNul
.into(imageView);
}

/**
* 加载图片列表图片
*
* @param context 上下文
* @param url 图片路径
* @param imageView 承载图片ImageView
*/
@Override
public void loadGridImageRound(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
Glide.with(context)
.load(url)
.centerCrop()
.transform(new CenterCrop(),new RoundedCorners(ScreenUtils.dip2px(context,4)))
.into(imageView);

imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

}


private GlideEngine() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.luck.pictureselector;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;

import java.security.MessageDigest;

/**
* @author yikai
*/
public class GlideRoundTransform extends BitmapTransformation {
private float radius = 0f;

public GlideRoundTransform(Context context) {
this(context, 4);
}

public GlideRoundTransform(Context context, int dp) {
this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
}

@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight);
return roundCrop(pool, bitmap);
}

private Bitmap roundCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;

Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
}

Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rectF, radius, radius, paint);
return result;
}

@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {

}
}
37 changes: 28 additions & 9 deletions app/src/main/java/com/luck/pictureselector/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.Canvas;
Expand All @@ -27,6 +28,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
Expand Down Expand Up @@ -395,6 +397,20 @@ public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.
// 注册广播
BroadcastManager.getInstance(getContext()).registerReceiver(broadcastReceiver,
BroadcastAction.ACTION_DELETE_PREVIEW_POSITION);

IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.newsclapper.picture");
LocalReceiver localReceiver = new LocalReceiver();
//注册本地广播监听器
LocalBroadcastManager.getInstance(this).registerReceiver(localReceiver, intentFilter);

}

class LocalReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ArrayList<LocalMedia> result = intent.getParcelableArrayListExtra("LOCAL_MEDIA_LIST");
}
}

/**
Expand Down Expand Up @@ -427,6 +443,13 @@ private void clearCache() {
public void onAddPicClick() {
boolean mode = cb_mode.isChecked();
if (mode) {

List<String> filterMimeType = new ArrayList<>();
filterMimeType.add("video/mp4");
filterMimeType.add("video/mov");
filterMimeType.add("image/jpeg");
filterMimeType.add("image/png");

// 进入相册 以下是例子:不需要的api可以不写
PictureSelector.create(MainActivity.this)
.openGallery(chooseMode)// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
Expand All @@ -449,10 +472,12 @@ public void onAddPicClick() {
//.setButtonFeatures(CustomCameraView.BUTTON_STATE_BOTH)// 设置自定义相机按钮状态
.maxSelectNum(maxSelectNum)// 最大图片选择数量
.minSelectNum(1)// 最小选择数量
.maxVideoSelectNum(1) // 视频最大选择数量
.maxVideoSelectNum(maxSelectNum) // 视频最大选择数量
//.minVideoSelectNum(1)// 视频最小选择数量
//.closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 关闭在AndroidQ下获取图片或视频宽高相反自动转换
.imageSpanCount(4)// 每行显示个数
.selectCountText("yikai")
.isCloseActivity(false)
.isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回
.closeAndroidQChangeWH(true)//如果图片有旋转角度则对换宽高,默认为true
.closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 如果视频有旋转角度则对换宽高,默认为false
Expand Down Expand Up @@ -814,9 +839,6 @@ public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
chooseMode = PictureMimeType.ofAudio();
cb_preview_audio.setVisibility(View.VISIBLE);
break;
case R.id.rb_system:
language = -1;
break;
case R.id.rb_jpan:
language = LanguageConfig.JAPAN;
break;
Expand All @@ -835,9 +857,6 @@ public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
case R.id.rb_fr:
language = LanguageConfig.FRANCE;
break;
case R.id.rb_spanish:
language = LanguageConfig.SPANISH;
break;
case R.id.rb_crop_default:
aspect_ratio_x = 0;
aspect_ratio_y = 0;
Expand Down Expand Up @@ -1257,9 +1276,9 @@ private PictureParameterStyle getWeChatStyle() {
// 是否开启类似QQ相册带数字选择风格
mPictureParameterStyle.isOpenCheckNumStyle = true;
// 状态栏背景色
mPictureParameterStyle.pictureStatusBarColor = Color.parseColor("#393a3e");
mPictureParameterStyle.pictureStatusBarColor = Color.parseColor("#ffffff");
// 相册列表标题栏背景色
mPictureParameterStyle.pictureTitleBarBackgroundColor = Color.parseColor("#393a3e");
mPictureParameterStyle.pictureTitleBarBackgroundColor = Color.parseColor("#ffffff");
// 相册父容器背景色
mPictureParameterStyle.pictureContainerBackgroundColor = ContextCompat.getColor(getContext(), R.color.app_color_black);
// 相册列表标题栏右侧上拉箭头
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/luck/pictureselector/PicassoEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ public void loadGridImage(@NonNull Context context, @NonNull String url, @NonNul
}
}

@Override
public void loadGridImageRound(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {

}

private PicassoEngine() {
}

Expand Down
70 changes: 69 additions & 1 deletion app/src/main/java/com/luck/pictureselector/SimpleActivity.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
package com.luck.pictureselector;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.language.LanguageConfig;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.yalantis.ucrop.util.ScreenUtils;
import com.yalantis.ucrop.view.widget.CustomLoadingDialog;

import java.util.ArrayList;
import java.util.List;

public class SimpleActivity extends AppCompatActivity implements View.OnClickListener {
private Button btn_activity, btn_fragment;
private Button btn_activity, btn_fragment, btn_dialog, clapper,videoImage;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_other);
btn_activity = findViewById(R.id.btn_activity);
btn_fragment = findViewById(R.id.btn_fragment);
btn_dialog = findViewById(R.id.btn_dialog);
clapper = findViewById(R.id.clapper);
btn_activity.setOnClickListener(this);
btn_fragment.setOnClickListener(this);
btn_dialog.setOnClickListener(this);
clapper.setOnClickListener(this);

}

@Override
Expand All @@ -28,6 +45,57 @@ public void onClick(View v) {
break;
case R.id.btn_fragment:
startActivity(new Intent(SimpleActivity.this, PhotoFragmentActivity.class));
break;
case R.id.btn_dialog:
View view = getLayoutInflater().inflate(R.layout.ucrop_dialog_loading, null);
CustomLoadingDialog mMyDialog = new CustomLoadingDialog(this,
ScreenUtils.dip2px(this,228),
ScreenUtils.dip2px(this,108),
view,
R.style.ucrop_DialogStyle);
mMyDialog.setCancelable(true);
mMyDialog.show();
break;
case R.id.clapper:
List<String> filterMimeType = new ArrayList();
filterMimeType.add("video/mp4");
filterMimeType.add("video/quicktime");
filterMimeType.add("image/jpeg");
filterMimeType.add("image/jpg");
filterMimeType.add("image/png");
//upload
PictureSelector.create(this)
.openGallery(PictureMimeType.ofVideo())
.isWeChatStyle(true)
.imageEngine(GlideEngine.createGlideEngine())
.isWithVideoImage(true)
.theme(R.style.picture_WeChat_style)
.setLanguage(LanguageConfig.ENGLISH)
.maxVideoSelectNum(35)
.isMaxSelectEnabledMask(true)
.isOnlyVideo(false)
.isPreviewVideo(false)
.selectionMode(PictureConfig.MULTIPLE)
.isSingleDirectReturn(false)
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
.isCamera(false)
.maxSelectNum(35)
.videoMinSecond(6)
.setFilterMimeType(filterMimeType)
.isShowPreView(false)
.forResult(new OnResultCallbackListener(){

@Override
public void onResult(List result) {

}

@Override
public void onCancel() {

}
});

break;
default:
break;
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/res/layout/activity_other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,25 @@
android:layout_marginTop="10dp"
android:text="Fragment"
android:textAllCaps="false" />


<Button
android:id="@+id/btn_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btn_fragment"
android:layout_marginTop="10dp"
android:text="dialog"
android:textAllCaps="false" />


<Button
android:id="@+id/clapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btn_dialog"
android:layout_marginTop="10dp"
android:text="clapper"
android:textAllCaps="false" />

</RelativeLayout>
2 changes: 2 additions & 0 deletions picture_library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ dependencies {
implementation "androidx.localbroadcastmanager:localbroadcastmanager:${cfgs.localbroadcastmanager}"
implementation "androidx.camera:camera-view:${cfgs.camerax_view}"
api project(':ucrop')
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}
Loading