Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipyu committed Mar 2, 2020
2 parents e3d796e + 21591ae commit f2e6ee2
Show file tree
Hide file tree
Showing 48 changed files with 606 additions and 366 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ android:
components:
- tools
- platform-tools
- build-tools-27.0.3
- android-27
- build-tools-28.0.3
- android-28
- extra-android-m2repository

jdk:
Expand All @@ -14,6 +14,12 @@ jdk:
notifications:
email: false

before_install:
- chmod +x gradlew
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\d56f5187479451eabf01fb78af6dfcb131a6481e" "\n24333f8a63b6825ea9c5514f83c2829b004d1fee"> "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

script:
- ./gradlew assemble check
- ./gradlew checkstyle
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {
}
dependencies {
implementation 'com.asana.android:matisse:0.1'
implementation 'com.asana.android:matisse:0.3'
}
```

Expand Down Expand Up @@ -63,6 +63,7 @@ Matisse.from(MainActivity.this)
.restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.thumbnailScale(0.85f)
.imageEngine(new GlideEngine())
.showPreview(false) // Default is `true`
.forResult(REQUEST_CODE_CHOOSE);
```

Expand All @@ -89,16 +90,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
```

#### For Glide V4

To be honest,the library can't supply GlideEngine for Glide both v3 and v4 at the same time. (Anyone who
have good idea to achieve this. PR is welcomed)

GlideEngine with Glide v3 is default.

So if your project's glide version is 4.0+ ,then you must realize GlideEngine by yourself. More details
could refer with [Glide4Engine](https://github.com/zhihu/Matisse/blob/master/sample/src/main/java/com/zhihu/matisse/sample/Glide4Engine.java) in the sample.

#### More
Find more details about Matisse in [wiki](https://github.com/zhihu/Matisse/wiki). The original ReadMe can be found here: https://github.com/zhihu/Matisse/blob/master/README.md

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.novoda:bintray-release:0.9.1'
}
}

Expand Down
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<!--module name="NewlineAtEndOfFile"/-->
Expand Down
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
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jun 27 11:32:18 CST 2018
#Thu Aug 22 11:37:43 CST 2019
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
21 changes: 9 additions & 12 deletions matisse/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,31 @@ apply plugin: 'com.novoda.bintray-release'
apply plugin: 'checkstyle'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.2'

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 29
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
}

ext.supportLibVersion = '27.1.1'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:support-annotations:${supportLibVersion}"
implementation "com.android.support:recyclerview-v7:${supportLibVersion}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.0.0"
implementation 'it.sephiroth.android.library.imagezoom:library:1.0.4'

compileOnly 'com.github.bumptech.glide:glide:3.7.0'
compileOnly 'com.github.bumptech.glide:glide:4.9.0'
compileOnly 'com.squareup.picasso:picasso:2.71828'
}

Expand Down
4 changes: 2 additions & 2 deletions matisse/src/main/java/com/zhihu/matisse/Matisse.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.zhihu.matisse.ui.MatisseActivity;

Expand Down
12 changes: 11 additions & 1 deletion matisse/src/main/java/com/zhihu/matisse/MimeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import android.content.ContentResolver;
import android.net.Uri;
import android.text.TextUtils;
import android.support.v4.util.ArraySet;

import androidx.collection.ArraySet;

import android.webkit.MimeTypeMap;

import com.zhihu.matisse.internal.utils.PhotoMetadataUtils;
Expand Down Expand Up @@ -110,6 +112,14 @@ public static Set<MimeType> ofImage() {
return EnumSet.of(JPEG, PNG, GIF, BMP, WEBP);
}

public static Set<MimeType> ofImage(boolean onlyGif) {
return EnumSet.of(GIF);
}

public static Set<MimeType> ofGif() {
return ofImage(true);
}

public static Set<MimeType> ofVideo() {
return EnumSet.of(MPEG, MP4, QUICKTIME, THREEGPP, THREEGPP2, MKV, WEBM, TS, AVI);
}
Expand Down
18 changes: 11 additions & 7 deletions matisse/src/main/java/com/zhihu/matisse/SelectionCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.support.v4.app.Fragment;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StyleRes;
import androidx.fragment.app.Fragment;

import com.zhihu.matisse.engine.ImageEngine;
import com.zhihu.matisse.filter.Filter;
Expand Down Expand Up @@ -237,7 +237,7 @@ public SelectionCreator maxOriginalSize(int size) {

/**
* Capture strategy provided for the location to save photos including internal and external
* storage and also a authority for {@link android.support.v4.content.FileProvider}.
* storage and also a authority for {@link androidx.core.content.FileProvider}.
*
* @param captureStrategy {@link CaptureStrategy}, needed only when capturing is enabled.
* @return {@link SelectionCreator} for fluent API.
Expand Down Expand Up @@ -364,4 +364,8 @@ public void forResult(int requestCode) {
}
}

public SelectionCreator showPreview(boolean showPreview) {
mSelectionSpec.showPreview = showPreview;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.zhihu.matisse.engine.ImageEngine;

/**
Expand All @@ -33,43 +34,48 @@ public class GlideEngine implements ImageEngine {
@Override
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
Glide.with(context)
.asBitmap() // some .jpeg files are actually gif
.load(uri)
.asBitmap() // some .jpeg files are actually gif
.placeholder(placeholder)
.override(resize, resize)
.centerCrop()
.apply(new RequestOptions()
.override(resize, resize)
.placeholder(placeholder)
.centerCrop())
.into(imageView);
}

@Override
public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView,
Uri uri) {
Glide.with(context)
.asBitmap() // some .jpeg files are actually gif
.load(uri)
.asBitmap()
.placeholder(placeholder)
.override(resize, resize)
.centerCrop()
.apply(new RequestOptions()
.override(resize, resize)
.placeholder(placeholder)
.centerCrop())
.into(imageView);
}

@Override
public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
Glide.with(context)
.load(uri)
.override(resizeX, resizeY)
.priority(Priority.HIGH)
.fitCenter()
.apply(new RequestOptions()
.override(resizeX, resizeY)
.priority(Priority.HIGH)
.fitCenter())
.into(imageView);
}

@Override
public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
Glide.with(context)
.load(uri)
.asGif()
.override(resizeX, resizeY)
.priority(Priority.HIGH)
.load(uri)
.apply(new RequestOptions()
.override(resizeX, resizeY)
.priority(Priority.HIGH)
.fitCenter())
.into(imageView);
}

Expand Down
24 changes: 13 additions & 11 deletions matisse/src/main/java/com/zhihu/matisse/internal/entity/Album.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.Nullable;

import androidx.annotation.Nullable;

import com.zhihu.matisse.R;
import com.zhihu.matisse.internal.loader.AlbumLoader;
Expand All @@ -43,20 +44,20 @@ public Album[] newArray(int size) {
public static final String ALBUM_NAME_ALL = "All";

private final String mId;
private final String mCoverPath;
private final Uri mCoverUri;
private final String mDisplayName;
private long mCount;

Album(String id, String coverPath, String albumName, long count) {
public Album(String id, Uri coverUri, String albumName, long count) {
mId = id;
mCoverPath = coverPath;
mCoverUri = coverUri;
mDisplayName = albumName;
mCount = count;
}

Album(Parcel source) {
private Album(Parcel source) {
mId = source.readString();
mCoverPath = source.readString();
mCoverUri = source.readParcelable(Uri.class.getClassLoader());
mDisplayName = source.readString();
mCount = source.readLong();
}
Expand All @@ -66,9 +67,10 @@ public Album[] newArray(int size) {
* This method is not responsible for managing cursor resource, such as close, iterate, and so on.
*/
public static Album valueOf(Cursor cursor) {
String clumn = cursor.getString(cursor.getColumnIndex(AlbumLoader.COLUMN_URI));
return new Album(
cursor.getString(cursor.getColumnIndex("bucket_id")),
cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.DATA)),
Uri.parse(clumn != null ? clumn : ""),
cursor.getString(cursor.getColumnIndex("bucket_display_name")),
cursor.getLong(cursor.getColumnIndex(AlbumLoader.COLUMN_COUNT)));
}
Expand All @@ -81,7 +83,7 @@ public int describeContents() {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mId);
dest.writeString(mCoverPath);
dest.writeParcelable(mCoverUri, 0);
dest.writeString(mDisplayName);
dest.writeLong(mCount);
}
Expand All @@ -90,8 +92,8 @@ public String getId() {
return mId;
}

public String getCoverPath() {
return mCoverPath;
public Uri getCoverUri() {
return mCoverUri;
}

public long getCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package com.zhihu.matisse.internal.entity;

import android.content.Context;
import android.support.annotation.IntDef;
import android.support.v4.app.FragmentActivity;
import androidx.annotation.IntDef;
import androidx.fragment.app.FragmentActivity;
import android.widget.Toast;

import com.zhihu.matisse.internal.ui.widget.IncapableDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;

import com.zhihu.matisse.MimeType;

Expand Down
Loading

0 comments on commit f2e6ee2

Please sign in to comment.