diff --git a/checkstyle.xml b/checkstyle.xml index 14dc9d673..673e04bec 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,7 +1,7 @@ + "https://checkstyle.org/dtds/configuration_1_3.dtd"> diff --git a/matisse/src/main/java/com/zhihu/matisse/SelectionCreator.java b/matisse/src/main/java/com/zhihu/matisse/SelectionCreator.java index 670921523..ade61f8df 100644 --- a/matisse/src/main/java/com/zhihu/matisse/SelectionCreator.java +++ b/matisse/src/main/java/com/zhihu/matisse/SelectionCreator.java @@ -343,6 +343,16 @@ public SelectionCreator setOnCheckedListener(@Nullable OnCheckedListener listene return this; } + /** + * Let users decide whether click on a media thumbnail to preview. + * @param mClickableThumbToPreview + * @return {@link SelectionCreator} for fluent API. + */ + public SelectionCreator setClickableThumbToPreview(boolean mClickableThumbToPreview) { + mSelectionSpec.mClickableThumbToPreview = mClickableThumbToPreview; + return this; + } + /** * Start to select media and wait for result. * diff --git a/matisse/src/main/java/com/zhihu/matisse/internal/entity/SelectionSpec.java b/matisse/src/main/java/com/zhihu/matisse/internal/entity/SelectionSpec.java index a95ce739a..ed9adc05f 100644 --- a/matisse/src/main/java/com/zhihu/matisse/internal/entity/SelectionSpec.java +++ b/matisse/src/main/java/com/zhihu/matisse/internal/entity/SelectionSpec.java @@ -56,6 +56,7 @@ public final class SelectionSpec { public boolean autoHideToobar; public int originalMaxSize; public OnCheckedListener onCheckedListener; + public boolean mClickableThumbToPreview = true; private SelectionSpec() { } @@ -91,6 +92,7 @@ private void reset() { originalable = false; autoHideToobar = false; originalMaxSize = Integer.MAX_VALUE; + mClickableThumbToPreview = true; } public boolean singleSelectionModeEnabled() { diff --git a/matisse/src/main/java/com/zhihu/matisse/internal/ui/adapter/AlbumMediaAdapter.java b/matisse/src/main/java/com/zhihu/matisse/internal/ui/adapter/AlbumMediaAdapter.java index 875738635..513a968db 100644 --- a/matisse/src/main/java/com/zhihu/matisse/internal/ui/adapter/AlbumMediaAdapter.java +++ b/matisse/src/main/java/com/zhihu/matisse/internal/ui/adapter/AlbumMediaAdapter.java @@ -117,6 +117,7 @@ protected void onBindViewHolder(final RecyclerView.ViewHolder holder, Cursor cur getImageResize(mediaViewHolder.mMediaGrid.getContext()), mPlaceholder, mSelectionSpec.countable, + mSelectionSpec.mClickableThumbToPreview, holder )); mediaViewHolder.mMediaGrid.bindMedia(item); diff --git a/matisse/src/main/java/com/zhihu/matisse/internal/ui/widget/MediaGrid.java b/matisse/src/main/java/com/zhihu/matisse/internal/ui/widget/MediaGrid.java index 0abb367cf..c11d1ee00 100644 --- a/matisse/src/main/java/com/zhihu/matisse/internal/ui/widget/MediaGrid.java +++ b/matisse/src/main/java/com/zhihu/matisse/internal/ui/widget/MediaGrid.java @@ -66,7 +66,11 @@ private void init(Context context) { public void onClick(View v) { if (mListener != null) { if (v == mThumbnail) { - mListener.onThumbnailClicked(mThumbnail, mMedia, mPreBindInfo.mViewHolder); + if (mPreBindInfo.mClickableThumbToPreview) { + mListener.onThumbnailClicked(mThumbnail, mMedia, mPreBindInfo.mViewHolder); + } else { + mListener.onCheckViewClicked(mCheckView, mMedia, mPreBindInfo.mViewHolder); + } } else if (v == mCheckView) { mListener.onCheckViewClicked(mCheckView, mMedia, mPreBindInfo.mViewHolder); } @@ -147,14 +151,19 @@ public static class PreBindInfo { int mResize; Drawable mPlaceholder; boolean mCheckViewCountable; + boolean mClickableThumbToPreview; RecyclerView.ViewHolder mViewHolder; - public PreBindInfo(int resize, Drawable placeholder, boolean checkViewCountable, + public PreBindInfo(int resize, + Drawable placeholder, + boolean mCheckViewCountable, + boolean mClickableThumbToPreview, RecyclerView.ViewHolder viewHolder) { - mResize = resize; - mPlaceholder = placeholder; - mCheckViewCountable = checkViewCountable; - mViewHolder = viewHolder; + this.mResize = resize; + this.mPlaceholder = placeholder; + this.mCheckViewCountable = mCheckViewCountable; + this.mClickableThumbToPreview = mClickableThumbToPreview; + this.mViewHolder = viewHolder; } } diff --git a/matisse/src/main/res/values-vi-rVN/strings.xml b/matisse/src/main/res/values-vi-rVN/strings.xml new file mode 100644 index 000000000..3d763335e --- /dev/null +++ b/matisse/src/main/res/values-vi-rVN/strings.xml @@ -0,0 +1,27 @@ + + + Tất cả + + Xem trước + Áp dụng + Áp dụng(%1$d) + Quay lại + Chụp ảnh + Chưa có tệp nào! + OK + + Đã chọn tối đa tệp! + Bạn chỉ có thể chọn tối đa %1$d tệp! + Chất lượng ảnh/video quá thấp + Chất lượng ảnh/video quá cao + Loại tệp không được hỗ trợ! + Không thể chọn ảnh và video cùng một thời điểm. + Không tìm thấy ứng dụng hỗ trợ xem trước video! + Không thể chọn ảnh có dung lượng lớn hơn %1$d MB. + Có %1$d có dung lượng quá %2$d MB. Ảnh gốc sẽ được bỏ chọn! + Tệp gốc + Chọn + Chọn(%1$d) + diff --git a/sample/src/main/java/com/zhihu/matisse/sample/SampleActivity.java b/sample/src/main/java/com/zhihu/matisse/sample/SampleActivity.java index 9e6358804..bdd4ad9a5 100644 --- a/sample/src/main/java/com/zhihu/matisse/sample/SampleActivity.java +++ b/sample/src/main/java/com/zhihu/matisse/sample/SampleActivity.java @@ -127,6 +127,7 @@ public void onCheck(boolean isChecked) { .originalEnable(true) .maxOriginalSize(10) .imageEngine(new PicassoEngine()) + .setClickableThumbToPreview(false) .forResult(REQUEST_CODE_CHOOSE); break; case R.id.only_gif: