From 03a059c6c3cd0f0bf998b933d2264c69420463cd Mon Sep 17 00:00:00 2001 From: yikai <15738800415@163.com> Date: Tue, 8 Sep 2020 19:05:54 +0800 Subject: [PATCH 01/26] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/luck/pictureselector/GlideEngine.java | 27 +++++++ .../pictureselector/GlideRoundTransform.java | 59 +++++++++++++++ .../luck/pictureselector/PicassoEngine.java | 5 ++ .../picture/lib/PictureSelectorActivity.java | 27 +++++++ .../lib/adapter/SelectedLocalDataMedia.java | 65 +++++++++++++++++ .../luck/picture/lib/engine/ImageEngine.java | 12 +++ .../src/main/res/drawable/radius_bg_shape.xml | 17 +++++ .../res/layout/picture_image_grid_item.xml | 1 + .../layout/picture_wechat_style_selector.xml | 73 ++++++++++++++++++- .../main/res/layout/selected_local_data.xml | 22 ++++++ picture_library/src/main/res/values/attrs.xml | 15 ++++ .../src/main/res/values/colors.xml | 1 + 12 files changed, 321 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/luck/pictureselector/GlideRoundTransform.java create mode 100644 picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java create mode 100644 picture_library/src/main/res/drawable/radius_bg_shape.xml create mode 100644 picture_library/src/main/res/layout/selected_local_data.xml diff --git a/app/src/main/java/com/luck/pictureselector/GlideEngine.java b/app/src/main/java/com/luck/pictureselector/GlideEngine.java index d5ada2f2a..920dfa44b 100644 --- a/app/src/main/java/com/luck/pictureselector/GlideEngine.java +++ b/app/src/main/java/com/luck/pictureselector/GlideEngine.java @@ -13,6 +13,8 @@ import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; import com.bumptech.glide.Glide; +import com.bumptech.glide.load.Transformation; +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; @@ -213,6 +215,31 @@ 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) { + + //设置图片圆角角度 + RoundedCorners roundedCorners= new RoundedCorners(8); + //通过RequestOptions扩展功能 + RequestOptions options=RequestOptions.bitmapTransform(roundedCorners); + + Glide.with(context) + .load(url) + .fitCenter() + .apply(options) + .into(imageView); + + imageView.setScaleType(ImageView.ScaleType.FIT_XY); + + } + private GlideEngine() { } diff --git a/app/src/main/java/com/luck/pictureselector/GlideRoundTransform.java b/app/src/main/java/com/luck/pictureselector/GlideRoundTransform.java new file mode 100644 index 000000000..cd154a311 --- /dev/null +++ b/app/src/main/java/com/luck/pictureselector/GlideRoundTransform.java @@ -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) { + + } +} diff --git a/app/src/main/java/com/luck/pictureselector/PicassoEngine.java b/app/src/main/java/com/luck/pictureselector/PicassoEngine.java index b4d604dc8..bbeded5e8 100644 --- a/app/src/main/java/com/luck/pictureselector/PicassoEngine.java +++ b/app/src/main/java/com/luck/pictureselector/PicassoEngine.java @@ -269,6 +269,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() { } diff --git a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java index 7b5cdbad5..bd55b3c47 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java +++ b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java @@ -3,6 +3,7 @@ import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.media.MediaPlayer; import android.net.Uri; @@ -25,10 +26,12 @@ import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.SimpleItemAnimator; import com.luck.picture.lib.adapter.PictureImageGridAdapter; +import com.luck.picture.lib.adapter.SelectedLocalDataMedia; import com.luck.picture.lib.animators.AlphaInAnimationAdapter; import com.luck.picture.lib.animators.AnimationType; import com.luck.picture.lib.animators.SlideInBottomAnimationAdapter; @@ -103,6 +106,9 @@ public class PictureSelectorActivity extends PictureBaseActivity implements View private long intervalClickTime = 0; private int allFolderSize; private int mOpenCameraCount; + private RecyclerView mSelectedLocalMedia; + private SelectedLocalDataMedia mSelectedLocalAdapter; + private TextView mtTvCount; @Override protected void onCreate(Bundle savedInstanceState) { @@ -163,6 +169,8 @@ protected void initWidgets() { mRecyclerView = findViewById(R.id.picture_recycler); mBottomLayout = findViewById(R.id.rl_bottom); mTvEmpty = findViewById(R.id.tv_empty); + mSelectedLocalMedia = findViewById(R.id.rv_selected); + mtTvCount = findViewById(R.id.tv_count); isNumComplete(numComplete); if (!numComplete) { animation = AnimationUtils.loadAnimation(this, R.anim.picture_anim_modal_in); @@ -229,6 +237,21 @@ protected void initWidgets() { config.isCheckOriginalImage = isChecked; }); } + + if (config.isWeChatStyle) { + mSelectedLocalMedia.setLayoutManager(new LinearLayoutManager(this, + LinearLayoutManager.HORIZONTAL,false)); + mSelectedLocalAdapter = new SelectedLocalDataMedia(); + mSelectedLocalMedia.setAdapter(mSelectedLocalAdapter); + mSelectedLocalMedia.addItemDecoration(new RecyclerView.ItemDecoration() { + @Override + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.getItemOffsets(outRect, view, parent, state); + outRect.right = ScreenUtils.dip2px(PictureSelectorActivity.this, 4); + outRect.left = ScreenUtils.dip2px(PictureSelectorActivity.this, 4); + } + }); + } } @Override @@ -1287,6 +1310,10 @@ public void onTakePhoto() { @Override public void onChange(List selectData) { changeImageNumber(selectData); + if (mSelectedLocalAdapter != null) { + mSelectedLocalAdapter.setList(selectData); + mtTvCount.setText("Next (" +selectData.size()+")"); + } } @Override diff --git a/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java b/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java new file mode 100644 index 000000000..7a8cbc346 --- /dev/null +++ b/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java @@ -0,0 +1,65 @@ +package com.luck.picture.lib.adapter; + +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.luck.picture.lib.R; +import com.luck.picture.lib.config.PictureSelectionConfig; +import com.luck.picture.lib.entity.LocalMedia; + +import java.util.ArrayList; +import java.util.List; + +public class SelectedLocalDataMedia extends RecyclerView + .Adapter { + + private List list = new ArrayList<>(); + + @NonNull + @Override + public SelectedLocalDataMedia.SelectedLocalDataMediaViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + + View inflate = View.inflate(parent.getContext(), R.layout.selected_local_data, null); + + SelectedLocalDataMediaViewHolder selectedLocalDataMediaViewHolder + = new SelectedLocalDataMediaViewHolder(inflate); + return selectedLocalDataMediaViewHolder; + } + + @Override + public void onBindViewHolder(@NonNull SelectedLocalDataMedia + .SelectedLocalDataMediaViewHolder holder, int position) { + + if (PictureSelectionConfig.imageEngine != null) { + PictureSelectionConfig.imageEngine.loadGridImageRound(holder.itemView.getContext(), + list.get(position).getPath(), holder.ivCover); + } + + } + + @Override + public int getItemCount() { + return list.size(); + } + + public void setList(List list) { + this.list.clear(); + this.list.addAll(list); + notifyDataSetChanged(); + } + + static class SelectedLocalDataMediaViewHolder extends RecyclerView.ViewHolder { + + private ImageView ivClose; + private ImageView ivCover; + public SelectedLocalDataMediaViewHolder(@NonNull View itemView) { + super(itemView); + ivClose = itemView.findViewById(R.id.iv_close); + ivCover = itemView.findViewById(R.id.iv_cover); + } + } +} diff --git a/picture_library/src/main/java/com/luck/picture/lib/engine/ImageEngine.java b/picture_library/src/main/java/com/luck/picture/lib/engine/ImageEngine.java index 9fa7ac559..ecbdbc08f 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/engine/ImageEngine.java +++ b/picture_library/src/main/java/com/luck/picture/lib/engine/ImageEngine.java @@ -69,4 +69,16 @@ public interface ImageEngine { * @param imageView */ void loadGridImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView); + + + /** + * Load picture list picture + * + * @param context + * @param url + * @param imageView + */ + void loadGridImageRound(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView); + + } diff --git a/picture_library/src/main/res/drawable/radius_bg_shape.xml b/picture_library/src/main/res/drawable/radius_bg_shape.xml new file mode 100644 index 000000000..ce7f3ce48 --- /dev/null +++ b/picture_library/src/main/res/drawable/radius_bg_shape.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/picture_library/src/main/res/layout/picture_image_grid_item.xml b/picture_library/src/main/res/layout/picture_image_grid_item.xml index 85e317a88..b05bb178c 100644 --- a/picture_library/src/main/res/layout/picture_image_grid_item.xml +++ b/picture_library/src/main/res/layout/picture_image_grid_item.xml @@ -1,6 +1,7 @@ @@ -73,14 +74,80 @@ + + + + + + + + + + + + + + + + + + + + + android:background="@color/picture_color_white" + /> + + + + + + + \ No newline at end of file diff --git a/picture_library/src/main/res/values/attrs.xml b/picture_library/src/main/res/values/attrs.xml index d66b06fac..566309be1 100644 --- a/picture_library/src/main/res/values/attrs.xml +++ b/picture_library/src/main/res/values/attrs.xml @@ -37,4 +37,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/picture_library/src/main/res/values/colors.xml b/picture_library/src/main/res/values/colors.xml index cd5d333d9..aa027f55c 100644 --- a/picture_library/src/main/res/values/colors.xml +++ b/picture_library/src/main/res/values/colors.xml @@ -36,4 +36,5 @@ #99FFFFFF #ff572e #529BeA + #ff6500 \ No newline at end of file From 291b50fd4a935ab7a34ff49de9bf3a4cff26c992 Mon Sep 17 00:00:00 2001 From: yikai <15738800415@163.com> Date: Tue, 20 Oct 2020 17:01:02 +0800 Subject: [PATCH 02/26] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luck/pictureselector/MainActivity.java | 4 +- picture_library/build.gradle | 1 + picture_library/src/main/AndroidManifest.xml | 2 + .../picture/lib/PictureSelectorActivity.java | 88 +++++++- .../lib/adapter/PictureImageGridAdapter.java | 202 ++++++++++-------- .../lib/adapter/SelectedLocalDataMedia.java | 20 ++ .../lib/config/PictureSelectionConfig.java | 2 + .../res/drawable-xxhdpi/ic_video_close.png | Bin 0 -> 1982 bytes .../main/res/drawable-xxhdpi/item_close.png | Bin 0 -> 5489 bytes .../picture_wechat_num_oval_selected.xml | 2 +- .../res/drawable/radius_bg_shape_gray.xml | 17 ++ .../res/layout/picture_image_grid_item.xml | 2 +- .../layout/picture_wechat_style_selector.xml | 130 ++++++++++- .../main/res/layout/selected_local_data.xml | 5 +- .../src/main/res/values-v21/styles.xml | 11 + .../src/main/res/values/colors.xml | 1 + 16 files changed, 386 insertions(+), 101 deletions(-) create mode 100644 picture_library/src/main/res/drawable-xxhdpi/ic_video_close.png create mode 100644 picture_library/src/main/res/drawable-xxhdpi/item_close.png create mode 100644 picture_library/src/main/res/drawable/radius_bg_shape_gray.xml create mode 100644 picture_library/src/main/res/values-v21/styles.xml diff --git a/app/src/main/java/com/luck/pictureselector/MainActivity.java b/app/src/main/java/com/luck/pictureselector/MainActivity.java index d3bba68da..498969254 100644 --- a/app/src/main/java/com/luck/pictureselector/MainActivity.java +++ b/app/src/main/java/com/luck/pictureselector/MainActivity.java @@ -1214,9 +1214,9 @@ private void 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); // 相册列表标题栏右侧上拉箭头 diff --git a/picture_library/build.gradle b/picture_library/build.gradle index a41d1dd93..378bad33a 100644 --- a/picture_library/build.gradle +++ b/picture_library/build.gradle @@ -37,4 +37,5 @@ 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' } diff --git a/picture_library/src/main/AndroidManifest.xml b/picture_library/src/main/AndroidManifest.xml index c003a56fd..02c19ea08 100644 --- a/picture_library/src/main/AndroidManifest.xml +++ b/picture_library/src/main/AndroidManifest.xml @@ -21,9 +21,11 @@ { + mAdapter.changeCheckboxState(media); + }); + + } + + if (mTabLayout != null) { + mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + if (tab.getText().equals("Images")) { + config.chooseMode = 1; + mPage = 1; + LocalMediaPageLoader.getInstance(getContext(), config).loadPageMediaData(-1, mPage, + (OnQueryDataResultListener) (result, currentPage, isHasMore) -> { + if (!isFinishing()) { + if (result.size() == 0) { + mAdapter.clear(); + } + mAdapter.bindData(result); + mRecyclerView.onScrolled(0, 0); + mRecyclerView.smoothScrollToPosition(0); + dismissDialog(); + } + }); + } else { + config.chooseMode = 2; + mPage = 1; + LocalMediaPageLoader.getInstance(getContext(), config).loadPageMediaData(-1, mPage, + (OnQueryDataResultListener) (result, currentPage, isHasMore) -> { + if (!isFinishing()) { + if (result.size() == 0) { + mAdapter.clear(); + } + mAdapter.bindData(result); + mRecyclerView.onScrolled(0, 0); + mRecyclerView.smoothScrollToPosition(0); + dismissDialog(); + } + }); + } + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); } + + if (mIvClose != null) { + mIvClose.setOnClickListener(v -> finish()); + } + + if (mTvSelectMax != null && config.selectMaxPrompt != null) { + mTvSelectMax.setText(config.selectMaxPrompt); + } + } @Override @@ -1307,12 +1383,22 @@ public void onTakePhoto() { } } + @SuppressLint("UseCompatLoadingForDrawables") @Override public void onChange(List selectData) { changeImageNumber(selectData); if (mSelectedLocalAdapter != null) { mSelectedLocalAdapter.setList(selectData); - mtTvCount.setText("Next (" +selectData.size()+")"); + + if (selectData.size() > 0) { + mtTvCount.setText("Next (" +selectData.size()+")"); + mtTvCount.setTextColor(getResources().getColor(R.color.ucrop_color_white)); + mtTvCount.setBackground(getResources().getDrawable(R.drawable.radius_bg_shape)); + } else { + mtTvCount.setText("Next (0)"); + mtTvCount.setTextColor(getResources().getColor(R.color.picture_color_light_grey)); + mtTvCount.setBackground(getResources().getDrawable(R.drawable.radius_bg_shape_gray)); + } } } diff --git a/picture_library/src/main/java/com/luck/picture/lib/adapter/PictureImageGridAdapter.java b/picture_library/src/main/java/com/luck/picture/lib/adapter/PictureImageGridAdapter.java index 8f1b0031b..488b063e5 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/adapter/PictureImageGridAdapter.java +++ b/picture_library/src/main/java/com/luck/picture/lib/adapter/PictureImageGridAdapter.java @@ -219,7 +219,7 @@ public void onBindViewHolder(@NotNull final RecyclerView.ViewHolder holder, fina return; } // The width and height of the image are reversed if there is rotation information - MediaUtils.setOrientationAsynchronous(context, image, config.isAndroidQChangeWH, config.isAndroidQChangeVideoWH, null); + // MediaUtils.setOrientationAsynchronous(context, image, config.isAndroidQChangeWH, config.isAndroidQChangeVideoWH, null); changeCheckboxState(contentHolder, image); }); } @@ -416,47 +416,47 @@ private void changeCheckboxState(ViewHolder contentHolder, LocalMedia image) { String mimeType = count > 0 ? selectData.get(0).getMimeType() : ""; if (config.isWithVideoImage) { // isWithVideoImage mode - int videoSize = 0; - for (int i = 0; i < count; i++) { - LocalMedia media = selectData.get(i); - if (PictureMimeType.isHasVideo(media.getMimeType())) { - videoSize++; - } - } - - if (PictureMimeType.isHasVideo(image.getMimeType())) { - if (config.maxVideoSelectNum <= 0) { - showPromptDialog(context.getString(R.string.picture_rule)); - return; - } - - if (getSelectedSize() >= config.maxSelectNum && !isChecked) { - showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum)); - return; - } - - if (videoSize >= config.maxVideoSelectNum && !isChecked) { - showPromptDialog(StringUtils.getMsg(context, image.getMimeType(), config.maxVideoSelectNum)); - return; - } - - if (!isChecked && config.videoMinSecond > 0 && image.getDuration() < config.videoMinSecond) { - showPromptDialog(context.getString(R.string.picture_choose_min_seconds, config.videoMinSecond / 1000)); - return; - } - - if (!isChecked && config.videoMaxSecond > 0 && image.getDuration() > config.videoMaxSecond) { - showPromptDialog(context.getString(R.string.picture_choose_max_seconds, config.videoMaxSecond / 1000)); - return; - } - } - - if (PictureMimeType.isHasImage(image.getMimeType())) { - if (getSelectedSize() >= config.maxSelectNum && !isChecked) { - showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum)); - return; - } - } +// int videoSize = 0; +// for (int i = 0; i < count; i++) { +// LocalMedia media = selectData.get(i); +// if (PictureMimeType.isHasVideo(media.getMimeType())) { +// videoSize++; +// } +// } +// +// if (PictureMimeType.isHasVideo(image.getMimeType())) { +// if (config.maxVideoSelectNum <= 0) { +// showPromptDialog(context.getString(R.string.picture_rule)); +// return; +// } +// +// if (getSelectedSize() >= config.maxSelectNum && !isChecked) { +// showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum)); +// return; +// } +// +// if (videoSize >= config.maxVideoSelectNum && !isChecked) { +// showPromptDialog(StringUtils.getMsg(context, image.getMimeType(), config.maxVideoSelectNum)); +// return; +// } +// +// if (!isChecked && config.videoMinSecond > 0 && image.getDuration() < config.videoMinSecond) { +// showPromptDialog(context.getString(R.string.picture_choose_min_seconds, config.videoMinSecond / 1000)); +// return; +// } +// +// if (!isChecked && config.videoMaxSecond > 0 && image.getDuration() > config.videoMaxSecond) { +// showPromptDialog(context.getString(R.string.picture_choose_max_seconds, config.videoMaxSecond / 1000)); +// return; +// } +// } +// +// if (PictureMimeType.isHasImage(image.getMimeType())) { +// if (getSelectedSize() >= config.maxSelectNum && !isChecked) { +// showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum)); +// return; +// } +// } } else { if (!TextUtils.isEmpty(mimeType)) { @@ -555,53 +555,53 @@ private void changeCheckboxState(ViewHolder contentHolder, LocalMedia image) { contentHolder.tvCheck.startAnimation(AnimationUtils.loadAnimation(context, R.anim.picture_anim_modal_in)); } - boolean isRefreshAll = false; - if (config.isMaxSelectEnabledMask) { - if (config.chooseMode == PictureMimeType.ofAll()) { - // ofAll - if (config.isWithVideoImage && config.maxVideoSelectNum > 0) { - if (getSelectedSize() >= config.maxSelectNum) { - isRefreshAll = true; - } - if (isChecked) { - // delete - if (getSelectedSize() == config.maxSelectNum - 1) { - isRefreshAll = true; - } - } - } else { - if (!isChecked && getSelectedSize() == 1) { - // add - isRefreshAll = true; - } - if (isChecked && getSelectedSize() == 0) { - // delete - isRefreshAll = true; - } - } - } else { - // ofImage or ofVideo or ofAudio - if (config.chooseMode == PictureMimeType.ofVideo() && config.maxVideoSelectNum > 0) { - if (!isChecked && getSelectedSize() == config.maxVideoSelectNum) { - // add - isRefreshAll = true; - } - if (isChecked && getSelectedSize() == config.maxVideoSelectNum - 1) { - // delete - isRefreshAll = true; - } - } else { - if (!isChecked && getSelectedSize() == config.maxSelectNum) { - // add - isRefreshAll = true; - } - if (isChecked && getSelectedSize() == config.maxSelectNum - 1) { - // delete - isRefreshAll = true; - } - } - } - } + boolean isRefreshAll = true; +// if (config.isMaxSelectEnabledMask) { +// if (config.chooseMode == PictureMimeType.ofAll()) { +// // ofAll +// if (config.isWithVideoImage && config.maxVideoSelectNum > 0) { +// if (getSelectedSize() >= config.maxSelectNum) { +// isRefreshAll = true; +// } +// if (isChecked) { +// // delete +// if (getSelectedSize() == config.maxSelectNum - 1) { +// isRefreshAll = true; +// } +// } +// } else { +// if (!isChecked && getSelectedSize() == 1) { +// // add +// isRefreshAll = true; +// } +// if (isChecked && getSelectedSize() == 0) { +// // delete +// isRefreshAll = true; +// } +// } +// } else { +// // ofImage or ofVideo or ofAudio +// if (config.chooseMode == PictureMimeType.ofVideo() && config.maxVideoSelectNum > 0) { +// if (!isChecked && getSelectedSize() == config.maxVideoSelectNum) { +// // add +// isRefreshAll = true; +// } +// if (isChecked && getSelectedSize() == config.maxVideoSelectNum - 1) { +// // delete +// isRefreshAll = true; +// } +// } else { +// if (!isChecked && getSelectedSize() == config.maxSelectNum) { +// // add +// isRefreshAll = true; +// } +// if (isChecked && getSelectedSize() == config.maxSelectNum - 1) { +// // delete +// isRefreshAll = true; +// } +// } +// } +// } if (isRefreshAll) { notifyDataSetChanged(); @@ -609,7 +609,29 @@ private void changeCheckboxState(ViewHolder contentHolder, LocalMedia image) { notifyItemChanged(contentHolder.getAdapterPosition()); } - selectImage(contentHolder, !isChecked); + // selectImage(contentHolder, !isChecked); + if (imageSelectChangedListener != null) { + imageSelectChangedListener.onChange(selectData); + } + } + + + public void changeCheckboxState(LocalMedia image) { + int count = selectData.size(); + + for (int i = 0; i < count; i++) { + LocalMedia media = selectData.get(i); + if (media == null || TextUtils.isEmpty(media.getPath())) { + continue; + } + if (media.getPath().equals(image.getPath()) + || media.getId() == image.getId()) { + selectData.remove(media); + subSelectPosition(); + break; + } + } + notifyDataSetChanged(); if (imageSelectChangedListener != null) { imageSelectChangedListener.onChange(selectData); } diff --git a/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java b/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java index 7a8cbc346..d85f61dce 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java +++ b/picture_library/src/main/java/com/luck/picture/lib/adapter/SelectedLocalDataMedia.java @@ -18,6 +18,11 @@ public class SelectedLocalDataMedia extends RecyclerView .Adapter { private List list = new ArrayList<>(); + private OnItemClickListener mListener; + + public void setOnItemClickListener(OnItemClickListener listener){ + this.mListener = listener; + } @NonNull @Override @@ -39,6 +44,15 @@ public void onBindViewHolder(@NonNull SelectedLocalDataMedia list.get(position).getPath(), holder.ivCover); } + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + if (mListener != null) { + mListener.setOnItemClickListener(list.get(position)); + } + } + }); } @Override @@ -62,4 +76,10 @@ public SelectedLocalDataMediaViewHolder(@NonNull View itemView) { ivCover = itemView.findViewById(R.id.iv_cover); } } + + public interface OnItemClickListener{ + + void setOnItemClickListener(LocalMedia media); + + } } diff --git a/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java b/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java index eb1fcfa34..e13f0dd08 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java +++ b/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java @@ -161,6 +161,8 @@ public final class PictureSelectionConfig implements Parcelable { public boolean isFallbackVersion2; public boolean isFallbackVersion3; + public String selectMaxPrompt; + protected void initDefaultValue() { chooseMode = PictureMimeType.ofImage(); camera = false; diff --git a/picture_library/src/main/res/drawable-xxhdpi/ic_video_close.png b/picture_library/src/main/res/drawable-xxhdpi/ic_video_close.png new file mode 100644 index 0000000000000000000000000000000000000000..ff2a1098b7d5dd95f47fed470466ec36377f1eda GIT binary patch literal 1982 zcmV;v2SNCWP)?Z1&#p$K0qZ5Fd7wnyT-r>qA%-$%sM4CwMn&Jz}I4?@YRd2M4K?xqX4dy z)Z%0y{RfCslM9MU7#J8+fNbURk^&IB1IQLB0y+xFo&#d1L)aTY>?8>L2v|)>kTZ~d z1ISiL&PW8B!T1Bn)=5GVPe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!_L-w~)ZEGsK}WMgCF zD}ZW6j+bD+&eS>S1X6q_JV$j9nO}4)yNj#_F%yuXyu3U|kyMTygNg%*PJVuVBOn9H zp-tWoIHC5ykFYN#_Hn}%+PCnpurSZk+1G7Xw}FW8Vyxgn2itLRSIK#a2R`&cz1 zUXX3-hE)lJ8jt}xmUmQ3(jk@6fbFJDlhUc2Hsh(OsXldhQ~GFmLZGp>Ogfa^sYyjr z??_;o&zI3R>o#OLvmceWGaH*l6?cvrkU?72SXv^)gOvIV?NR?}@F+k!F_+1#Z>vQls4 z6jJ#yU_U}`RXS7teO6Xh?a0W;qDdDnMhv|H8N#~bkkX?Z1pR)08#nxMn85mTcx`R% zR(W}OzE!P7w4$OSXMKG=#Bf(cRCGApx*sLW7Z<*~d`MqyN@vRNF%4?u%Z<`KjHm&5 z-42qenj`izxtxXl7tk( Qr~m)}07*qoM6N<$f~dZey#N3J literal 0 HcmV?d00001 diff --git a/picture_library/src/main/res/drawable-xxhdpi/item_close.png b/picture_library/src/main/res/drawable-xxhdpi/item_close.png new file mode 100644 index 0000000000000000000000000000000000000000..e05c46d1734e445cd9f6322aa0d18e904f736ed6 GIT binary patch literal 5489 zcmV-%6^`nOP)?Z1&#p$K0qZ5Fd7wnyT-r>qA%-$%sM4CwMn&Jz}I4?@YRd2M4K?xqX4dy z)Z%0y{RfCslM9MU7#J8+fNbURk^&IB1IQLB0y+xFo&#d1L)aTY>?8>L2v|)>kTZ~d z1ISiL&PW8B!T1Bn)=5GVPe)=y?F9jDm(1dVoWx3n0Am8KB?FYCR+NBf=lp`oqRjM+ z5(P(KD5WZR<|XUtC>R+Snlmtf!W^Rdb09b@8O6>Z#G3CjFxc+@|NsAPgqYWU28NA5 zom@K+Vj30<41(MY3@3ILBo-xtg_wbuDJ_kG;nQ*k2Hr>p2H^`pJ<-K!#ztUyMjj^y z2G)E3|9@6vU|^rj!0>m%|Np-i{r~@WF;Mdz28IK902Lu+?ls5J`v3p{IAvH#W=%~1 zDgXcg2mk?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ccRy*#0Cjzdkdu6{mKiWY0sY75qBkx)1nV-s<)gps#2 zH1wEMb(q14!UZ`Efz&Q3lDXY=M#6VVzrm2Um6>P3|J3w(5eONuX`|)5jgO4DSz?pE zbQyuFsQ{a~m4FFCA!8rzEfjM$F - + diff --git a/picture_library/src/main/res/drawable/radius_bg_shape_gray.xml b/picture_library/src/main/res/drawable/radius_bg_shape_gray.xml new file mode 100644 index 000000000..015cb93a2 --- /dev/null +++ b/picture_library/src/main/res/drawable/radius_bg_shape_gray.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/picture_library/src/main/res/layout/picture_image_grid_item.xml b/picture_library/src/main/res/layout/picture_image_grid_item.xml index b05bb178c..c9cbb47bd 100644 --- a/picture_library/src/main/res/layout/picture_image_grid_item.xml +++ b/picture_library/src/main/res/layout/picture_image_grid_item.xml @@ -18,7 +18,7 @@ android:layout_margin="8dp" android:background="?attr/picture.checked.style" android:gravity="center" - android:textColor="@color/picture_color_white" + android:textColor="@color/picture_color_3" android:textSize="12sp" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/picture_library/src/main/res/layout/selected_local_data.xml b/picture_library/src/main/res/layout/selected_local_data.xml index 1db2ba2b9..6b9090a92 100644 --- a/picture_library/src/main/res/layout/selected_local_data.xml +++ b/picture_library/src/main/res/layout/selected_local_data.xml @@ -1,6 +1,5 @@ @@ -15,8 +14,8 @@ android:id="@+id/iv_close" android:layout_width="16dp" android:layout_height="16dp" - android:layout_alignParentEnd="true" - android:layout_alignParentTop="true" + android:src="@drawable/item_close" + android:layout_alignEnd="@id/iv_cover" /> \ No newline at end of file diff --git a/picture_library/src/main/res/values-v21/styles.xml b/picture_library/src/main/res/values-v21/styles.xml new file mode 100644 index 000000000..a134cdb9d --- /dev/null +++ b/picture_library/src/main/res/values-v21/styles.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/picture_library/src/main/res/values/colors.xml b/picture_library/src/main/res/values/colors.xml index aa027f55c..8456374da 100644 --- a/picture_library/src/main/res/values/colors.xml +++ b/picture_library/src/main/res/values/colors.xml @@ -6,6 +6,7 @@ #7D7DFF #999999 #a8333333 + #333333 #70000000 #80000000 #20000000 From fb93973812d94877b52c7a9effd5d64bbaf72526 Mon Sep 17 00:00:00 2001 From: yikai <15738800415@163.com> Date: Tue, 20 Oct 2020 19:16:23 +0800 Subject: [PATCH 03/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9C=86=E8=A7=92?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luck/pictureselector/MainActivity.java | 172 +++++++++--------- .../picture/lib/PictureSelectorActivity.java | 3 +- .../src/main/res/drawable/radius_shape.xml | 20 ++ .../layout/picture_wechat_style_selector.xml | 75 ++++---- 4 files changed, 145 insertions(+), 125 deletions(-) create mode 100644 picture_library/src/main/res/drawable/radius_shape.xml diff --git a/app/src/main/java/com/luck/pictureselector/MainActivity.java b/app/src/main/java/com/luck/pictureselector/MainActivity.java index 498969254..457640c73 100644 --- a/app/src/main/java/com/luck/pictureselector/MainActivity.java +++ b/app/src/main/java/com/luck/pictureselector/MainActivity.java @@ -425,90 +425,98 @@ public void onAddPicClick() { if (mode) { // 进入相册 以下是例子:不需要的api可以不写 PictureSelector.create(MainActivity.this) - .openGallery(chooseMode)// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio() - .imageEngine(GlideEngine.createGlideEngine())// 外部传入图片加载引擎,必传项 + .openGallery(PictureMimeType.ofVideo()) + .isWeChatStyle(true) + .imageEngine(GlideEngine.createGlideEngine()) + .isPreviewVideo(false) + .selectionMode(PictureConfig.SINGLE) + .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) + .isCamera(false) + .videoMinSecond(3) +// .openGallery(chooseMode)// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio() +// .imageEngine(GlideEngine.createGlideEngine())// 外部传入图片加载引擎,必传项 .theme(themeId)// 主题样式设置 具体参考 values/styles 用法:R.style.picture.white.style v2.3.3后 建议使用setPictureStyle()动态方式 - .isWeChatStyle(isWeChatStyle)// 是否开启微信图片选择风格 - .isUseCustomCamera(cb_custom_camera.isChecked())// 是否使用自定义相机 - .setLanguage(language)// 设置语言,默认中文 - .isPageStrategy(cbPage.isChecked())// 是否开启分页策略 & 每页多少条;默认开启 - .setPictureStyle(mPictureParameterStyle)// 动态自定义相册主题 - .setPictureCropStyle(mCropParameterStyle)// 动态自定义裁剪主题 - .setPictureWindowAnimationStyle(mWindowAnimationStyle)// 自定义相册启动退出动画 - .setRecyclerAnimationMode(animationMode)// 列表动画效果 +// .isWeChatStyle(isWeChatStyle)// 是否开启微信图片选择风格 +// .isUseCustomCamera(cb_custom_camera.isChecked())// 是否使用自定义相机 + .setLanguage(LanguageConfig.ENGLISH)// 设置语言,默认中文 +// .isPageStrategy(cbPage.isChecked())// 是否开启分页策略 & 每页多少条;默认开启 +// .setPictureStyle(mPictureParameterStyle)// 动态自定义相册主题 +// .setPictureCropStyle(mCropParameterStyle)// 动态自定义裁剪主题 +// .setPictureWindowAnimationStyle(mWindowAnimationStyle)// 自定义相册启动退出动画 +// .setRecyclerAnimationMode(animationMode)// 列表动画效果 .isWithVideoImage(true)// 图片和视频是否可以同选,只在ofAll模式下有效 - .isMaxSelectEnabledMask(cbEnabledMask.isChecked())// 选择数到了最大阀值列表是否启用蒙层效果 - //.isAutomaticTitleRecyclerTop(false)// 连续点击标题栏RecyclerView是否自动回到顶部,默认true - //.loadCacheResourcesCallback(GlideCacheEngine.createCacheEngine())// 获取图片资源缓存,主要是解决华为10部分机型在拷贝文件过多时会出现卡的问题,这里可以判断只在会出现一直转圈问题机型上使用 - //.setOutputCameraPath()// 自定义相机输出目录,只针对Android Q以下,例如 Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + File.separator + "Camera" + File.separator; - //.setButtonFeatures(CustomCameraView.BUTTON_STATE_BOTH)// 设置自定义相机按钮状态 - .maxSelectNum(maxSelectNum)// 最大图片选择数量 - .minSelectNum(1)// 最小选择数量 - .maxVideoSelectNum(1) // 视频最大选择数量 - //.minVideoSelectNum(1)// 视频最小选择数量 - //.closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 关闭在AndroidQ下获取图片或视频宽高相反自动转换 - .imageSpanCount(4)// 每行显示个数 - .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回 - .closeAndroidQChangeWH(true)//如果图片有旋转角度则对换宽高,默认为true - .closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 如果视频有旋转角度则对换宽高,默认为false - //.isAndroidQTransform(true)// 是否需要处理Android Q 拷贝至应用沙盒的操作,只针对compress(false); && .isEnableCrop(false);有效,默认处理 - .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)// 设置相册Activity方向,不设置默认使用系统 - .isOriginalImageControl(cb_original.isChecked())// 是否显示原图控制按钮,如果设置为true则用户可以自由选择是否使用原图,压缩、裁剪功能将会失效 - //.bindCustomPlayVideoCallback(new MyVideoSelectedPlayCallback(getContext()))// 自定义视频播放回调控制,用户可以使用自己的视频播放界面 - //.bindCustomPreviewCallback(new MyCustomPreviewInterfaceListener())// 自定义图片预览回调接口 - //.bindCustomCameraInterfaceListener(new MyCustomCameraInterfaceListener())// 提供给用户的一些额外的自定义操作回调 - //.cameraFileName(System.currentTimeMillis() +".jpg") // 重命名拍照文件名、如果是相册拍照则内部会自动拼上当前时间戳防止重复,注意这个只在使用相机时可以使用,如果使用相机又开启了压缩或裁剪 需要配合压缩和裁剪文件名api - //.renameCompressFile(System.currentTimeMillis() +".jpg")// 重命名压缩文件名、 如果是多张压缩则内部会自动拼上当前时间戳防止重复 - //.renameCropFileName(System.currentTimeMillis() + ".jpg")// 重命名裁剪文件名、 如果是多张裁剪则内部会自动拼上当前时间戳防止重复 - .selectionMode(cb_choose_mode.isChecked() ? - PictureConfig.MULTIPLE : PictureConfig.SINGLE)// 多选 or 单选 - .isSingleDirectReturn(cb_single_back.isChecked())// 单选模式下是否直接返回,PictureConfig.SINGLE模式下有效 - .isPreviewImage(cb_preview_img.isChecked())// 是否可预览图片 - .isPreviewVideo(cb_preview_video.isChecked())// 是否可预览视频 - //.querySpecifiedFormatSuffix(PictureMimeType.ofJPEG())// 查询指定后缀格式资源 - .isEnablePreviewAudio(cb_preview_audio.isChecked()) // 是否可播放音频 - .isCamera(cb_isCamera.isChecked())// 是否显示拍照按钮 - //.isMultipleSkipCrop(false)// 多图裁剪时是否支持跳过,默认支持 - //.isMultipleRecyclerAnimation(false)// 多图裁剪底部列表显示动画效果 - .isZoomAnim(true)// 图片列表点击 缩放效果 默认true - .imageFormat(PictureMimeType.PNG)// 拍照保存图片格式后缀,默认jpeg,Android Q使用PictureMimeType.PNG_Q - .isEnableCrop(cb_crop.isChecked())// 是否裁剪 - //.basicUCropConfig()//对外提供所有UCropOptions参数配制,但如果PictureSelector原本支持设置的还是会使用原有的设置 - .isCompress(cb_compress.isChecked())// 是否压缩 - //.compressQuality(80)// 图片压缩后输出质量 0~ 100 - .synOrAsy(false)//同步true或异步false 压缩 默认同步 - //.queryMaxFileSize(10)// 只查多少M以内的图片、视频、音频 单位M - //.compressSavePath(getPath())//压缩图片保存地址 - //.sizeMultiplier(0.5f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效 注:已废弃 - //.glideOverride(160, 160)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度 注:已废弃 - .withAspectRatio(aspect_ratio_x, aspect_ratio_y)// 裁剪比例 如16:9 3:2 3:4 1:1 可自定义 - .hideBottomControls(!cb_hide.isChecked())// 是否显示uCrop工具栏,默认不显示 - .isGif(cb_isGif.isChecked())// 是否显示gif图片 - //.isWebp(false)// 是否显示webp图片,默认显示 - //.isBmp(false)//是否显示bmp图片,默认显示 - .freeStyleCropEnabled(cb_styleCrop.isChecked())// 裁剪框是否可拖拽 - .circleDimmedLayer(cb_crop_circular.isChecked())// 是否圆形裁剪 - //.setCropDimmedColor(ContextCompat.getColor(getContext(), R.color.app_color_white))// 设置裁剪背景色值 - //.setCircleDimmedBorderColor(ContextCompat.getColor(getApplicationContext(), R.color.app_color_white))// 设置圆形裁剪边框色值 - //.setCircleStrokeWidth(3)// 设置圆形裁剪边框粗细 - .showCropFrame(cb_showCropFrame.isChecked())// 是否显示裁剪矩形边框 圆形裁剪时建议设为false - .showCropGrid(cb_showCropGrid.isChecked())// 是否显示裁剪矩形网格 圆形裁剪时建议设为false - .isOpenClickSound(cb_voice.isChecked())// 是否开启点击声音 - .selectionData(mAdapter.getData())// 是否传入已选图片 - //.isDragFrame(false)// 是否可拖动裁剪框(固定) - //.videoMinSecond(10)// 查询多少秒以内的视频 - //.videoMaxSecond(15)// 查询多少秒以内的视频 - //.recordVideoSecond(10)//录制视频秒数 默认60s - //.isPreviewEggs(true)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) - //.cropCompressQuality(90)// 注:已废弃 改用cutOutQuality() - .cutOutQuality(90)// 裁剪输出质量 默认100 - .minimumCompressSize(100)// 小于多少kb的图片不压缩 - //.cropWH()// 裁剪宽高比,设置如果大于图片本身宽高则无效 - //.cropImageWideHigh()// 裁剪宽高比,设置如果大于图片本身宽高则无效 - //.rotateEnabled(false) // 裁剪是否可旋转图片 - //.scaleEnabled(false)// 裁剪是否可放大缩小图片 - //.videoQuality()// 视频录制质量 0 or 1 - //.forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code +// .isMaxSelectEnabledMask(cbEnabledMask.isChecked())// 选择数到了最大阀值列表是否启用蒙层效果 +// //.isAutomaticTitleRecyclerTop(false)// 连续点击标题栏RecyclerView是否自动回到顶部,默认true +// //.loadCacheResourcesCallback(GlideCacheEngine.createCacheEngine())// 获取图片资源缓存,主要是解决华为10部分机型在拷贝文件过多时会出现卡的问题,这里可以判断只在会出现一直转圈问题机型上使用 +// //.setOutputCameraPath()// 自定义相机输出目录,只针对Android Q以下,例如 Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + File.separator + "Camera" + File.separator; +// //.setButtonFeatures(CustomCameraView.BUTTON_STATE_BOTH)// 设置自定义相机按钮状态 +// .maxSelectNum(maxSelectNum)// 最大图片选择数量 +// .minSelectNum(1)// 最小选择数量 +// .maxVideoSelectNum(1) // 视频最大选择数量 +// //.minVideoSelectNum(1)// 视频最小选择数量 +// //.closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 关闭在AndroidQ下获取图片或视频宽高相反自动转换 +// .imageSpanCount(4)// 每行显示个数 +// .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回 +// .closeAndroidQChangeWH(true)//如果图片有旋转角度则对换宽高,默认为true +// .closeAndroidQChangeVideoWH(!SdkVersionUtils.checkedAndroid_Q())// 如果视频有旋转角度则对换宽高,默认为false +// //.isAndroidQTransform(true)// 是否需要处理Android Q 拷贝至应用沙盒的操作,只针对compress(false); && .isEnableCrop(false);有效,默认处理 +// .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)// 设置相册Activity方向,不设置默认使用系统 +// .isOriginalImageControl(cb_original.isChecked())// 是否显示原图控制按钮,如果设置为true则用户可以自由选择是否使用原图,压缩、裁剪功能将会失效 +// //.bindCustomPlayVideoCallback(new MyVideoSelectedPlayCallback(getContext()))// 自定义视频播放回调控制,用户可以使用自己的视频播放界面 +// //.bindCustomPreviewCallback(new MyCustomPreviewInterfaceListener())// 自定义图片预览回调接口 +// //.bindCustomCameraInterfaceListener(new MyCustomCameraInterfaceListener())// 提供给用户的一些额外的自定义操作回调 +// //.cameraFileName(System.currentTimeMillis() +".jpg") // 重命名拍照文件名、如果是相册拍照则内部会自动拼上当前时间戳防止重复,注意这个只在使用相机时可以使用,如果使用相机又开启了压缩或裁剪 需要配合压缩和裁剪文件名api +// //.renameCompressFile(System.currentTimeMillis() +".jpg")// 重命名压缩文件名、 如果是多张压缩则内部会自动拼上当前时间戳防止重复 +// //.renameCropFileName(System.currentTimeMillis() + ".jpg")// 重命名裁剪文件名、 如果是多张裁剪则内部会自动拼上当前时间戳防止重复 +// .selectionMode(cb_choose_mode.isChecked() ? +// PictureConfig.MULTIPLE : PictureConfig.SINGLE)// 多选 or 单选 +// .isSingleDirectReturn(cb_single_back.isChecked())// 单选模式下是否直接返回,PictureConfig.SINGLE模式下有效 +// .isPreviewImage(cb_preview_img.isChecked())// 是否可预览图片 +// .isPreviewVideo(cb_preview_video.isChecked())// 是否可预览视频 +// //.querySpecifiedFormatSuffix(PictureMimeType.ofJPEG())// 查询指定后缀格式资源 +// .isEnablePreviewAudio(cb_preview_audio.isChecked()) // 是否可播放音频 +// .isCamera(cb_isCamera.isChecked())// 是否显示拍照按钮 +// //.isMultipleSkipCrop(false)// 多图裁剪时是否支持跳过,默认支持 +// //.isMultipleRecyclerAnimation(false)// 多图裁剪底部列表显示动画效果 +// .isZoomAnim(true)// 图片列表点击 缩放效果 默认true +// .imageFormat(PictureMimeType.PNG)// 拍照保存图片格式后缀,默认jpeg,Android Q使用PictureMimeType.PNG_Q +// .isEnableCrop(cb_crop.isChecked())// 是否裁剪 +// //.basicUCropConfig()//对外提供所有UCropOptions参数配制,但如果PictureSelector原本支持设置的还是会使用原有的设置 +// .isCompress(cb_compress.isChecked())// 是否压缩 +// //.compressQuality(80)// 图片压缩后输出质量 0~ 100 +// .synOrAsy(false)//同步true或异步false 压缩 默认同步 +// //.queryMaxFileSize(10)// 只查多少M以内的图片、视频、音频 单位M +// //.compressSavePath(getPath())//压缩图片保存地址 +// //.sizeMultiplier(0.5f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效 注:已废弃 +// //.glideOverride(160, 160)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度 注:已废弃 +// .withAspectRatio(aspect_ratio_x, aspect_ratio_y)// 裁剪比例 如16:9 3:2 3:4 1:1 可自定义 +// .hideBottomControls(!cb_hide.isChecked())// 是否显示uCrop工具栏,默认不显示 +// .isGif(cb_isGif.isChecked())// 是否显示gif图片 +// //.isWebp(false)// 是否显示webp图片,默认显示 +// //.isBmp(false)//是否显示bmp图片,默认显示 +// .freeStyleCropEnabled(cb_styleCrop.isChecked())// 裁剪框是否可拖拽 +// .circleDimmedLayer(cb_crop_circular.isChecked())// 是否圆形裁剪 +// //.setCropDimmedColor(ContextCompat.getColor(getContext(), R.color.app_color_white))// 设置裁剪背景色值 +// //.setCircleDimmedBorderColor(ContextCompat.getColor(getApplicationContext(), R.color.app_color_white))// 设置圆形裁剪边框色值 +// //.setCircleStrokeWidth(3)// 设置圆形裁剪边框粗细 +// .showCropFrame(cb_showCropFrame.isChecked())// 是否显示裁剪矩形边框 圆形裁剪时建议设为false +// .showCropGrid(cb_showCropGrid.isChecked())// 是否显示裁剪矩形网格 圆形裁剪时建议设为false +// .isOpenClickSound(cb_voice.isChecked())// 是否开启点击声音 +// .selectionData(mAdapter.getData())// 是否传入已选图片 +// //.isDragFrame(false)// 是否可拖动裁剪框(固定) +// //.videoMinSecond(10)// 查询多少秒以内的视频 +// //.videoMaxSecond(15)// 查询多少秒以内的视频 +// //.recordVideoSecond(10)//录制视频秒数 默认60s +// //.isPreviewEggs(true)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) +// //.cropCompressQuality(90)// 注:已废弃 改用cutOutQuality() +// .cutOutQuality(90)// 裁剪输出质量 默认100 +// .minimumCompressSize(100)// 小于多少kb的图片不压缩 +// //.cropWH()// 裁剪宽高比,设置如果大于图片本身宽高则无效 +// //.cropImageWideHigh()// 裁剪宽高比,设置如果大于图片本身宽高则无效 +// //.rotateEnabled(false) // 裁剪是否可旋转图片 +// //.scaleEnabled(false)// 裁剪是否可放大缩小图片 +// //.videoQuality()// 视频录制质量 0 or 1 +// //.forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code .forResult(new MyResultCallback(mAdapter)); } else { // 单独拍照 diff --git a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java index 7eaa069a2..bda2f8722 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java +++ b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java @@ -197,6 +197,7 @@ protected void initWidgets() { mIvPictureLeftBack.setOnClickListener(this); mTvPictureRight.setOnClickListener(this); mTvPictureOk.setOnClickListener(this); + mtTvCount.setOnClickListener(this); mTvPictureImgNum.setOnClickListener(this); mTvPictureTitle.setOnClickListener(this); mIvArrow.setOnClickListener(this); @@ -851,7 +852,7 @@ public void onClick(View v) { return; } - if (id == R.id.picture_tv_ok || id == R.id.picture_tvMediaNum) { + if (id == R.id.picture_tv_ok || id == R.id.picture_tvMediaNum || id == R.id.tv_count) { onComplete(); return; } diff --git a/picture_library/src/main/res/drawable/radius_shape.xml b/picture_library/src/main/res/drawable/radius_shape.xml new file mode 100644 index 000000000..2d9585258 --- /dev/null +++ b/picture_library/src/main/res/drawable/radius_shape.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/picture_library/src/main/res/layout/picture_wechat_style_selector.xml b/picture_library/src/main/res/layout/picture_wechat_style_selector.xml index 7e06fc4f2..e0d3d4c12 100644 --- a/picture_library/src/main/res/layout/picture_wechat_style_selector.xml +++ b/picture_library/src/main/res/layout/picture_wechat_style_selector.xml @@ -1,21 +1,21 @@ + android:visibility="visible"> + + android:background="@drawable/radius_shape"> + android:src="@drawable/ic_video_close" /> + app:tabIndicatorColor="@color/ucrop_color_black"> + android:text="Videos" /> + + android:text="Images" /> @@ -137,10 +134,10 @@ android:id="@+id/rl_bottom" android:layout_width="match_parent" android:layout_height="45dp" - android:visibility="gone" android:layout_alignParentBottom="true" android:background="?attr/picture.bottom.bg" - android:gravity="center_vertical"> + android:gravity="center_vertical" + android:visibility="gone"> + android:layout_marginTop="14dp" + android:layout_marginEnd="8dp" + android:background="#fff" /> + + android:background="#e8e8e8" /> + android:gravity="center_vertical"> + android:layout_marginStart="16dp" + android:text="You can Upload up to 1 videos" /> + android:textColor="@color/picture_color_white" + android:textSize="14sp" /> + android:background="#e8e8e8" /> - + android:background="@color/picture_color_white" /> Date: Wed, 21 Oct 2020 11:12:39 +0800 Subject: [PATCH 04/26] =?UTF-8?q?=E7=82=B9=E5=87=BBnext=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/luck/picture/lib/PictureSelectorActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java index bda2f8722..47d919174 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java +++ b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java @@ -279,6 +279,7 @@ public void onTabSelected(TabLayout.Tab tab) { if (tab.getText().equals("Images")) { config.chooseMode = 1; mPage = 1; + showPleaseDialog(); LocalMediaPageLoader.getInstance(getContext(), config).loadPageMediaData(-1, mPage, (OnQueryDataResultListener) (result, currentPage, isHasMore) -> { if (!isFinishing()) { @@ -853,7 +854,9 @@ public void onClick(View v) { } if (id == R.id.picture_tv_ok || id == R.id.picture_tvMediaNum || id == R.id.tv_count) { + showPleaseDialog(); onComplete(); + dismissDialog(); return; } From 8bbde5a1318d06a97877b9c1ac5a3ff3b469d1f2 Mon Sep 17 00:00:00 2001 From: yikai <15738800415@163.com> Date: Wed, 21 Oct 2020 14:08:43 +0800 Subject: [PATCH 05/26] =?UTF-8?q?Tablayout=20=E9=80=89=E6=8B=A9=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E9=A2=9C=E8=89=B2=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=85=BC?= =?UTF-8?q?=E5=AE=B9video=E7=8B=AC=E8=87=AA=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luck/pictureselector/MainActivity.java | 3 +- .../picture/lib/PictureSelectionModel.java | 10 +++++ .../picture/lib/PictureSelectorActivity.java | 18 ++++++++- .../lib/config/PictureSelectionConfig.java | 1 + .../drawable/select_text_color_selecter.xml | 7 ++++ .../layout/picture_wechat_style_selector.xml | 38 ++++++++++++++----- .../src/main/res/values/styles.xml | 5 +++ ucrop/src/main/res/values/colors.xml | 1 + 8 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 picture_library/src/main/res/drawable/select_text_color_selecter.xml diff --git a/app/src/main/java/com/luck/pictureselector/MainActivity.java b/app/src/main/java/com/luck/pictureselector/MainActivity.java index 457640c73..9f01bc479 100644 --- a/app/src/main/java/com/luck/pictureselector/MainActivity.java +++ b/app/src/main/java/com/luck/pictureselector/MainActivity.java @@ -429,10 +429,11 @@ public void onAddPicClick() { .isWeChatStyle(true) .imageEngine(GlideEngine.createGlideEngine()) .isPreviewVideo(false) - .selectionMode(PictureConfig.SINGLE) + .selectionMode(PictureConfig.MULTIPLE) .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) .isCamera(false) .videoMinSecond(3) + .isOnlyVideo(false) // .openGallery(chooseMode)// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio() // .imageEngine(GlideEngine.createGlideEngine())// 外部传入图片加载引擎,必传项 .theme(themeId)// 主题样式设置 具体参考 values/styles 用法:R.style.picture.white.style v2.3.3后 建议使用setPictureStyle()动态方式 diff --git a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectionModel.java b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectionModel.java index d58f43a4f..99cf5c225 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectionModel.java +++ b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectionModel.java @@ -598,6 +598,16 @@ public PictureSelectionModel videoMinSecond(int videoMinSecond) { return this; } + public PictureSelectionModel selectMaxPrompt(String prompt) { + selectionConfig.selectMaxPrompt = prompt; + return this; + } + + public PictureSelectionModel isOnlyVideo(boolean isOnlyVideo) { + selectionConfig.isOnlyVideo = isOnlyVideo; + return this; + } + /** * @param recordVideoSecond video record second diff --git a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java index 47d919174..abc55cd37 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java +++ b/picture_library/src/main/java/com/luck/picture/lib/PictureSelectorActivity.java @@ -93,6 +93,7 @@ public class PictureSelectorActivity extends PictureBaseActivity implements View protected ImageView mIvPictureLeftBack; protected ImageView mIvArrow; protected TabLayout mTabLayout; + protected TextView mTvVideoTitle; protected View titleViewBg; protected TextView mTvPictureTitle, mTvPictureRight, mTvPictureOk, mTvEmpty, mTvPictureImgNum, mTvPicturePreview, mTvPlayPause, mTvStop, mTvQuit, @@ -174,6 +175,7 @@ protected void initWidgets() { mCbOriginal = findViewById(R.id.cb_original); mIvArrow = findViewById(R.id.ivArrow); mTabLayout = findViewById(R.id.tl_tabs); + mTvVideoTitle = findViewById(R.id.tv_video_title); mIvClose = findViewById(R.id.iv_close); mTvPicturePreview = findViewById(R.id.picture_id_preview); mTvPictureImgNum = findViewById(R.id.picture_tvMediaNum); @@ -197,7 +199,9 @@ protected void initWidgets() { mIvPictureLeftBack.setOnClickListener(this); mTvPictureRight.setOnClickListener(this); mTvPictureOk.setOnClickListener(this); - mtTvCount.setOnClickListener(this); + if (mtTvCount != null) { + mtTvCount.setOnClickListener(this); + } mTvPictureImgNum.setOnClickListener(this); mTvPictureTitle.setOnClickListener(this); mIvArrow.setOnClickListener(this); @@ -272,6 +276,18 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R } + if (!config.isOnlyVideo) { + if (mTabLayout != null && mTvVideoTitle != null) { + mTabLayout.setVisibility(View.VISIBLE); + mTvVideoTitle.setVisibility(View.GONE); + } + } else { + if (mTabLayout != null && mTvVideoTitle != null) { + mTabLayout.setVisibility(View.GONE); + mTvVideoTitle.setVisibility(View.VISIBLE); + } + } + if (mTabLayout != null) { mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override diff --git a/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java b/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java index e13f0dd08..07e04a867 100644 --- a/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java +++ b/picture_library/src/main/java/com/luck/picture/lib/config/PictureSelectionConfig.java @@ -162,6 +162,7 @@ public final class PictureSelectionConfig implements Parcelable { public boolean isFallbackVersion3; public String selectMaxPrompt; + public boolean isOnlyVideo; protected void initDefaultValue() { chooseMode = PictureMimeType.ofImage(); diff --git a/picture_library/src/main/res/drawable/select_text_color_selecter.xml b/picture_library/src/main/res/drawable/select_text_color_selecter.xml new file mode 100644 index 000000000..a9b96525d --- /dev/null +++ b/picture_library/src/main/res/drawable/select_text_color_selecter.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/picture_library/src/main/res/layout/picture_wechat_style_selector.xml b/picture_library/src/main/res/layout/picture_wechat_style_selector.xml index e0d3d4c12..ccb239f29 100644 --- a/picture_library/src/main/res/layout/picture_wechat_style_selector.xml +++ b/picture_library/src/main/res/layout/picture_wechat_style_selector.xml @@ -96,22 +96,17 @@ android:layout_height="wrap_content" android:background="@drawable/radius_shape"> - + + + + + + + + + \ No newline at end of file diff --git a/ucrop/src/main/res/values/colors.xml b/ucrop/src/main/res/values/colors.xml index 86d4cbfae..235c51152 100755 --- a/ucrop/src/main/res/values/colors.xml +++ b/ucrop/src/main/res/values/colors.xml @@ -34,5 +34,6 @@ #b0567ba3 #ececec + #999999 \ No newline at end of file From 66c4cd6c283292decbbe351200df3692d80afde8 Mon Sep 17 00:00:00 2001 From: yikai <15738800415@163.com> Date: Thu, 22 Oct 2020 16:54:30 +0800 Subject: [PATCH 06/26] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=88=96=E8=80=85=E8=A7=86=E9=A2=91=E4=B9=8B=E5=90=8E=20?= =?UTF-8?q?=E5=B1=95=E7=A4=BAloading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luck/pictureselector/SimpleActivity.java | 19 ++++++- app/src/main/res/layout/activity_other.xml | 10 ++++ .../picture/lib/PictureSelectorActivity.java | 12 +++- .../yalantis/ucrop/util/LoadDialogUtils.java | 55 +++++++++++++++++++ .../view/widget/CustomLoadingDialog.java | 38 +++++++++++++ ucrop/src/main/res/drawable/bg_progress.xml | 7 +++ .../src/main/res/drawable/ic_close_light.xml | 11 ++++ .../main/res/layout/ucrop_dialog_loading.xml | 36 ++++++++++++ ucrop/src/main/res/values/styles.xml | 19 +++++++ 9 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 ucrop/src/main/java/com/yalantis/ucrop/util/LoadDialogUtils.java create mode 100644 ucrop/src/main/java/com/yalantis/ucrop/view/widget/CustomLoadingDialog.java create mode 100755 ucrop/src/main/res/drawable/bg_progress.xml create mode 100644 ucrop/src/main/res/drawable/ic_close_light.xml create mode 100644 ucrop/src/main/res/layout/ucrop_dialog_loading.xml diff --git a/app/src/main/java/com/luck/pictureselector/SimpleActivity.java b/app/src/main/java/com/luck/pictureselector/SimpleActivity.java index a3c23c420..12e9bf58b 100644 --- a/app/src/main/java/com/luck/pictureselector/SimpleActivity.java +++ b/app/src/main/java/com/luck/pictureselector/SimpleActivity.java @@ -4,11 +4,16 @@ import android.os.Bundle; import android.view.View; import android.widget.Button; +import android.widget.SeekBar; import androidx.appcompat.app.AppCompatActivity; +import com.yalantis.ucrop.util.LoadDialogUtils; +import com.yalantis.ucrop.util.ScreenUtils; +import com.yalantis.ucrop.view.widget.CustomLoadingDialog; + public class SimpleActivity extends AppCompatActivity implements View.OnClickListener { - private Button btn_activity, btn_fragment; + private Button btn_activity, btn_fragment, btn_dialog; @Override protected void onCreate(Bundle savedInstanceState) { @@ -16,8 +21,10 @@ protected void onCreate(Bundle 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); btn_activity.setOnClickListener(this); btn_fragment.setOnClickListener(this); + btn_dialog.setOnClickListener(this); } @Override @@ -29,6 +36,16 @@ public void onClick(View v) { 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; default: break; } diff --git a/app/src/main/res/layout/activity_other.xml b/app/src/main/res/layout/activity_other.xml index 27f9298be..4b7e3d42b 100644 --- a/app/src/main/res/layout/activity_other.xml +++ b/app/src/main/res/layout/activity_other.xml @@ -21,4 +21,14 @@ android:layout_marginTop="10dp" android:text="Fragment" android:textAllCaps="false" /> + + +