Skip to content

Androidx #7

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Android 照片选择器 ,支持单图、多图、视频、gif选择,内置
简书:[PhotoPicker](http://www.jianshu.com/p/a6b5831797d0)

### 各位读者来点Star支持一下吧
==如使用请尽快更新到2.0.0版本+,本版本新增多个功能,修复旧版本已知问题==

参考项目:
- https://github.com/donglua/PhotoPicker
Expand Down Expand Up @@ -52,7 +51,10 @@ allprojects {
**在APP目录下的build.gradle中添加依赖**

```java
implementation 'com.github.yudu233:PhotoPicker:2.0.3'
//support版本
implementation 'com.github.yudu233:PhotoPicker:2.0.4'
//androidx版本
implementation 'com.github.yudu233:PhotoPicker:3.0.0'
```

**AndroidManifest.xml 配置**
Expand Down Expand Up @@ -101,7 +103,7 @@ new PhotoPickConfig

> **pickMode(PhotoPickConfig.MODE_PICK_SINGLE)**</br>
设置照片选择模式(单选、多选),默认为单选

> **maxPickSize(9)**</br>
多选时可以选择的图片数量,当pickMode为多选时默认为9张,单选默认为1

Expand All @@ -116,17 +118,17 @@ new PhotoPickConfig

> **showOriginal(true)**</br>
是否显示原图按钮,默认显示,选中后若开启了图片压缩将不再压缩图片,返回原图

> **startCompression(true)**</br>
是否启动图片压缩功能,默认开启(目前图片裁剪后没有再做压缩处理)

> **selectedMimeType(List<MediaData> data)**</br>
传入上一次选中的数据,用于判断下次进入是否可展示其他类型文件。如类似朋友圈,第一次选择了图片,此时数据类型为MimeType.TYPE_ALL,打开时将过滤视频文件。</br>
**==注:如果没有多类型的文件限制,可以不加该api==**

> **setCallback(new PhotoSelectCallback())**</br>
回调方式1:setCallback();回调方式2:onActivityResult()

### 初始化
> 在Application中初始化:
```
Expand All @@ -145,8 +147,8 @@ new PhotoPickConfig
//自定义主题颜色 同步APP
options.photoPickThemeColor = R.color.colorAccent;
return options;
}
}

```

### 回调方式
Expand All @@ -158,7 +160,7 @@ new PhotoPickConfig
.setCallback(new PhotoSelectCallback() {
@Override
public void selectResult(ArrayList<MediaData> photos) {

}).build();
```
#### 方式二:
Expand Down Expand Up @@ -199,12 +201,20 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
[ucrop](https://github.com/Yalantis/uCrop)

## 更新日志
# 当前版本:v2.0.3(紧急修复)
* 修复部分小米手机打开相册直接崩溃问题
# 当前版本:v3.0.0
* 支持AndroidX
* 修复已知的问题
* 移除无效代码


# 历史版本
### v2.0.3
### v2.0.4
* 新增文件夹有效性校验
---
### v2.0.3(紧急修复)
* 修复部分小米手机打开相册直接崩溃问题
---
### v2.0.2
* 优化裁剪时不显示其他类型文件(video、gif)
* 优化选择gif时默认原图,非原图时不压缩
---
Expand Down
33 changes: 17 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.ext.sdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.rain.photopicker"
minSdkVersion 15
targetSdkVersion rootProject.ext.sdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 19
targetSdkVersion 28
versionCode 23
versionName "2.0.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$supportLibVersion"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation project(':photopicker')

implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.android.support:multidex:1.0.1'
//PhotoView
implementation project(':library')
implementation "com.github.chrisbanes:PhotoView:2.3.0"
implementation 'androidx.appcompat:appcompat:1.2.0'

}
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
</activity>

<activity
android:name="com.rain.library.ui.PhotoPickActivity"
android:name="com.rain.crow.ui.activity.PhotoPickActivity"
android:theme="@style/PhoAppTheme.AppTheme"/>

<activity
android:name="com.rain.library.ui.PhotoPreviewActivity"
android:name="com.rain.crow.ui.activity.PhotoPreviewActivity"
android:theme="@style/PhoAppTheme.AppTheme"/>

<activity
Expand All @@ -40,7 +40,7 @@
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="@string/file_provider_authorities"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/rain/photopicker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.rain.library.bean.MediaData;
import com.rain.library.controller.PhotoPickConfig;
import com.rain.library.impl.PhotoSelectCallback;
import com.rain.library.utils.MimeType;
import com.rain.photopicker.bean.MediaData;
import com.rain.photopicker.controller.PhotoPickConfig;
import com.rain.photopicker.glide.GlideImageLoader;
import com.rain.photopicker.impl.PhotoSelectCallback;
import com.rain.photopicker.utils.MimeType;

import java.util.ArrayList;
import java.util.List;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/rain/photopicker/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.rain.library.PhotoPick;
import androidx.multidex.MultiDex;


/**
* Describe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;

/**
* Descriptions :自定义ImageView
* Created by Rain on 16-9-14.
*/
public class GridImageView extends ImageView {
public class GridImageView extends androidx.appcompat.widget.AppCompatImageView {

public GridImageView(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.os.Environment;
import android.text.TextUtils;

import com.rain.library.PhotoPickOptions;

import java.io.File;
import java.io.IOException;
Expand All @@ -23,7 +22,6 @@ public static PhotoPickOptions getPhotoPickOptions(Context context) {
PhotoPickOptions options = new PhotoPickOptions();
options.filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "eWorld/";
options.imagePath = options.filePath + "cytx/";
options.photoPickAuthority = context.getString(R.string.file_provider_authorities);
options.photoPickThemeColor = R.color.colorAccent;
return options;
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/rain/photopicker/Utils/ImageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import android.os.Environment;
import android.text.TextUtils;

import com.rain.library.utils.UtilsHelper;

import com.rain.photopicker.utils.UtilsHelper;

import java.io.File;
import java.io.FileOutputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.rain.library.loader.ImageLoader;
import com.rain.photopicker.R;
import com.rain.photopicker.loader.ImageLoader;

/**
* Describe :GlideImageLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_view_big_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:background="#000000">

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:layout_above="@+id/rllButton"
android:id="@+id/very_image_viewpager"
android:layout_width="match_parent"
Expand Down
14 changes: 1 addition & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // Add this line


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.3.0'
}
}

Expand All @@ -24,12 +18,6 @@ allprojects {
}
}

ext {
sdkVersion = 27
buildToolsVersion = '27.0.3'
supportLibVersion = '27.1.0'
}

task clean(type: Delete) {
delete rootProject.buildDir
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
13 changes: 0 additions & 13 deletions library/.gitignore

This file was deleted.

42 changes: 0 additions & 42 deletions library/build.gradle

This file was deleted.

Loading