Skip to content

Commit

Permalink
V 1.3.7 修复拍照在API19以下的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smuyyh committed Feb 16, 2017
1 parent 7999355 commit 76a61c9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Android 图片选择器。充分自由定制,极大程度简化使用,支持
## 依赖
```
dependencies {
compile 'com.yuyh.imgsel:library:1.3.6'
compile 'com.yuyh.imgsel:library:1.3.7'
}
```

## 版本

**V1.3.6 图片裁剪适配android-7.0**
**V1.3.7 图片裁剪适配android-7.0**

## 注意事项

Expand Down
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.3.6" // 版本号
version = "1.3.7" // 版本号

android {
compileSdkVersion 23
Expand All @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 14
versionName "1.3.6"
versionCode 15
versionName "1.3.7"
}
buildTypes {
release {
Expand Down
29 changes: 22 additions & 7 deletions library/src/main/java/com/yuyh/library/imgsel/ImgSelFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -224,10 +226,10 @@ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (!hasFolderGened) {
File imageFile = new File(path);
File folderFile = imageFile.getParentFile();
if(folderFile==null){
System.out.println(path);
return;
}
if (folderFile == null) {
System.out.println(path);
return;
}
Folder folder = new Folder();
folder.name = folderFile.getName();
folder.path = folderFile.getAbsolutePath();
Expand Down Expand Up @@ -292,7 +294,7 @@ public void onChange(int position, Folder folder) {
imageList.add(new Image());
imageList.addAll(folder.images);
imageListAdapter.notifyDataSetChanged();

btnAlbumSelected.setText(folder.name);
}
}
Expand Down Expand Up @@ -323,6 +325,7 @@ public void onClick(View v) {
}

private void showCameraAction() {

if (config.maxNum <= Constant.imageList.size()) {
Toast.makeText(getActivity(), String.format(getString(R.string.maxnum), config.maxNum), Toast.LENGTH_SHORT).show();
return;
Expand All @@ -335,12 +338,24 @@ private void showCameraAction() {
}

Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

if (cameraIntent.resolveActivity(getActivity().getPackageManager()) != null) {
tempFile = new File(FileUtils.createRootPath(getActivity()) + "/" + System.currentTimeMillis() + ".jpg");
LogUtils.e(tempFile.getAbsolutePath());
FileUtils.createFile(tempFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(getActivity(),
BuildConfig.APPLICATION_ID + ".provider", tempFile)); //Uri.fromFile(tempFile)

Uri uri = FileProvider.getUriForFile(getActivity(),
BuildConfig.APPLICATION_ID + ".provider", tempFile);

List<ResolveInfo> resInfoList = getActivity().getPackageManager()
.queryIntentActivities(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
getActivity().grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_READ_URI_PERMISSION);
}

cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); //Uri.fromFile(tempFile)
startActivityForResult(cameraIntent, REQUEST_CAMERA);
} else {
Toast.makeText(getActivity(), getString(R.string.open_camera_failure), Toast.LENGTH_SHORT).show();
Expand Down

0 comments on commit 76a61c9

Please sign in to comment.