Skip to content

Commit

Permalink
Fix android10 (#1)
Browse files Browse the repository at this point in the history
* fix mPathList nullpointexception bug

* temporary solution adaptation android 10

* fix thumbnail null bug

* compatible android q scan image and video

* adaptation android10
Upgrade Fresco to solve the problem of not supporting uri at the beginning of content
convert to androidx to solve in compatibility bug

* add geturi method

* fix Thumbnail build failed bug
return Thumbnail result change to uri

* modify the parameters returned by recording video and taking photos
optimize fresco image loader

* remove useless code
modify irregular code
  • Loading branch information
wodaoaicc authored Jul 23, 2020
1 parent 3c330b9 commit 92e5aad
Show file tree
Hide file tree
Showing 96 changed files with 1,291 additions and 885 deletions.
8 changes: 4 additions & 4 deletions album/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2017 Yan Zhenjie.
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,8 +20,9 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<application>
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>

<application android:requestLegacyExternalStorage="true">
<activity
android:name=".app.album.AlbumActivity"
android:configChanges="orientation|screenSize"
Expand Down
2 changes: 1 addition & 1 deletion album/src/main/java/com/yanzhenjie/album/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.yanzhenjie.album;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

/**
* <p>Any action takes place.</p>
Expand Down
14 changes: 7 additions & 7 deletions album/src/main/java/com/yanzhenjie/album/Album.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.support.annotation.IntDef;
import androidx.annotation.IntDef;
import android.util.Log;

import com.yanzhenjie.album.api.AlbumMultipleWrapper;
Expand Down Expand Up @@ -247,42 +247,42 @@ public static BasicGalleryWrapper<GalleryAlbumWrapper, AlbumFile, String, AlbumF
/**
* Open the camera from the activity.
*/
public static Camera<ImageCameraWrapper, VideoCameraWrapper> camera(android.support.v4.app.Fragment fragment) {
public static Camera<ImageCameraWrapper, VideoCameraWrapper> camera(androidx.fragment.app.Fragment fragment) {
return new AlbumCamera(fragment.getContext());
}

/**
* Select images.
*/
public static Choice<ImageMultipleWrapper, ImageSingleWrapper> image(android.support.v4.app.Fragment fragment) {
public static Choice<ImageMultipleWrapper, ImageSingleWrapper> image(androidx.fragment.app.Fragment fragment) {
return new ImageChoice(fragment.getContext());
}

/**
* Select videos.
*/
public static Choice<VideoMultipleWrapper, VideoSingleWrapper> video(android.support.v4.app.Fragment fragment) {
public static Choice<VideoMultipleWrapper, VideoSingleWrapper> video(androidx.fragment.app.Fragment fragment) {
return new VideoChoice(fragment.getContext());
}

/**
* Select images and videos.
*/
public static Choice<AlbumMultipleWrapper, AlbumSingleWrapper> album(android.support.v4.app.Fragment fragment) {
public static Choice<AlbumMultipleWrapper, AlbumSingleWrapper> album(androidx.fragment.app.Fragment fragment) {
return new AlbumChoice(fragment.getContext());
}

/**
* Preview picture.
*/
public static BasicGalleryWrapper<GalleryWrapper, String, String, String> gallery(android.support.v4.app.Fragment fragment) {
public static BasicGalleryWrapper<GalleryWrapper, String, String, String> gallery(androidx.fragment.app.Fragment fragment) {
return new GalleryWrapper(fragment.getContext());
}

/**
* Preview Album.
*/
public static BasicGalleryWrapper<GalleryAlbumWrapper, AlbumFile, String, AlbumFile> galleryAlbum(android.support.v4.app.Fragment fragment) {
public static BasicGalleryWrapper<GalleryAlbumWrapper, AlbumFile, String, AlbumFile> galleryAlbum(androidx.fragment.app.Fragment fragment) {
return new GalleryAlbumWrapper(fragment.getContext());
}
}
103 changes: 103 additions & 0 deletions album/src/main/java/com/yanzhenjie/album/AlbumCameraFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright 2017 Yan Zhenjie.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yanzhenjie.album;

import android.content.Context;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

import com.yanzhenjie.album.util.AlbumUtils;

/**
* Created by cc on 2020/7/22.
*/
public class AlbumCameraFile implements Parcelable {

public AlbumCameraFile(Uri uri, String path) {
this.uri = uri;
this.path = path;
}

public static AlbumCameraFile getAlbumCameraFile(Context context, String filePath) {
return new AlbumCameraFile(AlbumUtils.getUri(context, filePath), filePath);
}

/**
* File uri.
*/
private Uri uri;
/**
* File path.
*/
private String path;

public Uri getUri() {
return uri;
}

public void setUri(Uri uri) {
this.uri = uri;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.uri, flags);
dest.writeString(this.path);
}

public AlbumCameraFile() {
}

protected AlbumCameraFile(Parcel in) {
this.uri = in.readParcelable(Uri.class.getClassLoader());
this.path = in.readString();
}


public static final Parcelable.Creator<AlbumCameraFile> CREATOR = new Parcelable.Creator<AlbumCameraFile>() {
@Override
public AlbumCameraFile createFromParcel(Parcel source) {
return new AlbumCameraFile(source);
}

@Override
public AlbumCameraFile[] newArray(int size) {
return new AlbumCameraFile[size];
}
};

@Override
public String toString() {
return "AlbumCameraFile{" +
"uri=" + uri +
", path='" + path + '\'' +
'}';
}
}
129 changes: 73 additions & 56 deletions album/src/main/java/com/yanzhenjie/album/AlbumFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/
package com.yanzhenjie.album;

import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.IntDef;
import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -34,11 +35,10 @@ public class AlbumFile implements Parcelable, Comparable<AlbumFile> {
@IntDef({TYPE_IMAGE, TYPE_VIDEO})
public @interface MediaType {
}

/**
* File path.
* File uri.
*/
private String mPath;
private Uri uri;
/**
* Folder mName.
*/
Expand Down Expand Up @@ -68,9 +68,9 @@ public class AlbumFile implements Parcelable, Comparable<AlbumFile> {
*/
private long mDuration;
/**
* Thumb path.
* Thumb path uri.
*/
private String mThumbPath;
private Uri mThumbUri;
/**
* MediaType.
*/
Expand Down Expand Up @@ -101,25 +101,25 @@ else if (time < -Integer.MAX_VALUE)
public boolean equals(Object obj) {
if (obj != null && obj instanceof AlbumFile) {
AlbumFile o = (AlbumFile) obj;
String inPath = o.getPath();
if (mPath != null && inPath != null) {
return mPath.equals(inPath);
Uri inPath = o.getUri();
if (uri != null && inPath != null) {
return uri.equals(inPath);
}
}
return super.equals(obj);
}

@Override
public int hashCode() {
return mPath != null ? mPath.hashCode() : super.hashCode();
return uri != null ? uri.hashCode() : super.hashCode();
}

public String getPath() {
return mPath;
public Uri getUri() {
return uri;
}

public void setPath(String path) {
mPath = path;
public void setUri(Uri uri) {
this.uri = uri;
}

public String getBucketName() {
Expand Down Expand Up @@ -178,12 +178,12 @@ public void setDuration(long duration) {
mDuration = duration;
}

public String getThumbPath() {
return mThumbPath;
public Uri getThumbUri() {
return mThumbUri;
}

public void setThumbPath(String thumbPath) {
mThumbPath = thumbPath;
public void setThumbPath(Uri thumbUri) {
mThumbUri = thumbUri;
}

@MediaType
Expand All @@ -210,53 +210,70 @@ public boolean isDisable() {
public void setDisable(boolean disable) {
this.isDisable = disable;
}

protected AlbumFile(Parcel in) {
mPath = in.readString();
mBucketName = in.readString();
mMimeType = in.readString();
mAddDate = in.readLong();
mLatitude = in.readFloat();
mLongitude = in.readFloat();
mSize = in.readLong();
mDuration = in.readLong();
mThumbPath = in.readString();
mMediaType = in.readInt();
isChecked = in.readByte() != 0;
isDisable = in.readByte() != 0;
}


@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mPath);
dest.writeString(mBucketName);
dest.writeString(mMimeType);
dest.writeLong(mAddDate);
dest.writeFloat(mLatitude);
dest.writeFloat(mLongitude);
dest.writeLong(mSize);
dest.writeLong(mDuration);
dest.writeString(mThumbPath);
dest.writeInt(mMediaType);
dest.writeByte((byte) (isChecked ? 1 : 0));
dest.writeByte((byte) (isDisable ? 1 : 0));
}

public String toString() {
return "AlbumFile{" +
"uri=" + uri +
", mBucketName='" + mBucketName + '\'' +
", mMimeType='" + mMimeType + '\'' +
", mAddDate=" + mAddDate +
", mLatitude=" + mLatitude +
", mLongitude=" + mLongitude +
", mSize=" + mSize +
", mDuration=" + mDuration +
", mThumbUri='" + mThumbUri + '\'' +
", mMediaType=" + mMediaType +
", isChecked=" + isChecked +
", isDisable=" + isDisable +
'}';
}

@Override
public int describeContents() {
return 0;
}


@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.uri, flags);
dest.writeString(this.mBucketName);
dest.writeString(this.mMimeType);
dest.writeLong(this.mAddDate);
dest.writeFloat(this.mLatitude);
dest.writeFloat(this.mLongitude);
dest.writeLong(this.mSize);
dest.writeLong(this.mDuration);
dest.writeParcelable(this.mThumbUri, flags);
dest.writeInt(this.mMediaType);
dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0);
dest.writeByte(this.isDisable ? (byte) 1 : (byte) 0);
}

protected AlbumFile(Parcel in) {
this.uri = in.readParcelable(Uri.class.getClassLoader());
this.mBucketName = in.readString();
this.mMimeType = in.readString();
this.mAddDate = in.readLong();
this.mLatitude = in.readFloat();
this.mLongitude = in.readFloat();
this.mSize = in.readLong();
this.mDuration = in.readLong();
this.mThumbUri = in.readParcelable(Uri.class.getClassLoader());
this.mMediaType = in.readInt();
this.isChecked = in.readByte() != 0;
this.isDisable = in.readByte() != 0;
}

public static final Creator<AlbumFile> CREATOR = new Creator<AlbumFile>() {
@Override
public AlbumFile createFromParcel(Parcel in) {
return new AlbumFile(in);
public AlbumFile createFromParcel(Parcel source) {
return new AlbumFile(source);
}

@Override
public AlbumFile[] newArray(int size) {
return new AlbumFile[size];
}
};

}
Loading

0 comments on commit 92e5aad

Please sign in to comment.