From a9071e9906152d214fe777b252cfd7346e405701 Mon Sep 17 00:00:00 2001 From: IvanLuLyf <835498692@qq.com> Date: Wed, 17 Apr 2019 03:14:01 +0800 Subject: [PATCH] Add Chinese README --- .idea/vcs.xml | 6 +++ README.md | 7 +++ README_CN.md | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 README_CN.md diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index ba892ce..675ae22 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,14 @@ # ImagePicker +[![](https://jitpack.io/v/IvanLuLyf/ImagePicker.svg)](https://jitpack.io/#IvanLuLyf/ImagePicker) +[![API](https://img.shields.io/badge/API-23%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=23) +[![Build Status](https://travis-ci.org/IvanLuLyf/ImagePicker.svg?branch=master)](https://travis-ci.org/IvanLuLyf/ImagePicker) +[![GitHub](https://img.shields.io/github/license/IvanLuLyf/ImagePicker.svg?color=blue)](https://github.com/IvanLuLyf/ImagePicker/blob/master/LICENSE) + This repo made for using system image picker to select image. +[中文](README_CN.md) + ## Configure Add it in your root build.gradle at the end of repositories: diff --git a/README_CN.md b/README_CN.md new file mode 100644 index 0000000..f85f8c0 --- /dev/null +++ b/README_CN.md @@ -0,0 +1,132 @@ +# ImagePicker + +[![](https://jitpack.io/v/IvanLuLyf/ImagePicker.svg)](https://jitpack.io/#IvanLuLyf/ImagePicker) +[![API](https://img.shields.io/badge/API-23%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=23) +[![Build Status](https://travis-ci.org/IvanLuLyf/ImagePicker.svg?branch=master)](https://travis-ci.org/IvanLuLyf/ImagePicker) +[![GitHub](https://img.shields.io/github/license/IvanLuLyf/ImagePicker.svg?color=blue)](https://github.com/IvanLuLyf/ImagePicker/blob/master/LICENSE) + +使用系统图片选择器选择图片. + +## 项目配置 + +添加以下内容到项目的build.gradle文件里面: + +```gradle +allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } + } +} +``` + +添加项目依赖 + +```gradle +dependencies { + implementation 'com.github.IvanLuLyf:ImagePicker:1.0' +} +``` + +在```res/xml```目录下创建文件```file_paths.xml``` . + +> 内容样例 + +```xml + + + + +``` + +你可以把```[pathname]```和```[path]```换成你要的内容. + +例如: + +```xml + +``` + +在AndroidManifest.xml的``````标记之间添加如下内容. + +```xml + + + +``` + +你可以更换```[ProviderName]```为你想要的内容.例如```com.test.FileProvider```. + +```com.test```可以更换为你自己的包名. + +## 使用 + +> 样例 + +```java +public class MainActivity extends AppCompatActivity { + + private PickImageUtil pickImageUtil; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + pickImageUtil = new PickImageUtil(this, "[ProviderName]", "[pathname]"); //换成你上面定义的内容 + + final ImageView imgShow = findViewById(R.id.imgShow); + Button btnAlbum = findViewById(R.id.btnAlbum); + Button btnCamera = findViewById(R.id.btnCamera); + Button btnAlbumCrop = findViewById(R.id.btnAlbumCrop); + Button btnCameraCrop = findViewById(R.id.btnCameraCrop); + + btnAlbum.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + pickImageUtil.selectAlbum(false); // 从相册选取图片(不裁剪) + } + }); + + btnCamera.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + pickImageUtil.selectCamera(false); // 从相机拍摄图片(不裁剪) + } + }); + + btnAlbumCrop.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + pickImageUtil.setSize(300, 300).selectAlbum(true); // 从相册选取图片并裁剪,图片大小为300x300 + } + }); + + btnCameraCrop.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + pickImageUtil.setSize(300, 300).selectCamera(true);// 从相机拍摄图片并裁剪,图片大小为300x300 + } + }); + + pickImageUtil.setCallback(new PickImageCallback() { // 处理返回 + @Override + public void onResult(Uri uri, String filePath) { // 你可以直接使用uri或者用文件路径 + imgShow.setImageURI(uri); + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { //处理onActivityResult + if (!pickImageUtil.onActivityResult(requestCode, resultCode, data)) + super.onActivityResult(requestCode, resultCode, data); + } +} +```