Skip to content

Commit

Permalink
Upgrade to Glide 4.8.0 and AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoanglam committed Oct 4, 2018
1 parent f178ac5 commit 8f75204
Show file tree
Hide file tree
Showing 27 changed files with 90 additions and 66 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ImagePicker.with(this) // Initialize ImagePicker with a
.setSavePath("ImagePicker") // Image capture folder name
.setSelectedImages(images) // Selected images
.setAlwaysShowDoneButton(true) // Set always show done button in multiple mode
.setRequestCode(100) // Set request code, default Config.RC_PICK_IMAGES
.setKeepScreenOn(true) // Keep screen on when selecting images
.start(); // Start ImagePicker
```
Expand All @@ -80,7 +81,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
What's New
--------

- Support Glide 4.7.1
- Allow to set request code
- Migrate to AndroidX
- Support Glide 4.8.0


License
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This config should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
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 @@
#Fri Jun 15 09:33:37 ICT 2018
#Thu Oct 04 09:49:35 ICT 2018
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-4.6-all.zip
20 changes: 10 additions & 10 deletions imagepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.nguyenhoanglam'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -23,15 +23,15 @@ android {
}

ext {
supportVersion = "27.1.1"
supportVersion = "28.0.0"
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:recyclerview-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"
implementation "com.android.support:support-v4:$supportVersion"
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
2 changes: 1 addition & 1 deletion imagepicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:theme="@style/imagepicker_CameraTheme" />

<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nguyenhoanglam.imagepicker.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.nguyenhoanglam.imagepicker.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public Config[] newArray(int size) {
private SavePath savePath;
private boolean isAlwaysShowDoneButton;
private boolean isKeepScreenOn;
private int requestCode;
private ArrayList<Image> selectedImages;


Expand All @@ -79,6 +80,7 @@ protected Config(Parcel in) {
this.savePath = in.readParcelable(SavePath.class.getClassLoader());
this.isAlwaysShowDoneButton = in.readByte() != 0;
this.isKeepScreenOn = in.readByte() != 0;
this.requestCode = in.readInt();
this.selectedImages = in.createTypedArrayList(Image.CREATOR);
}

Expand Down Expand Up @@ -244,6 +246,14 @@ public void setKeepScreenOn(boolean keepScreenOn) {
isKeepScreenOn = keepScreenOn;
}

public int getRequestCode() {
return requestCode;
}

public void setRequestCode(int requestCode) {
this.requestCode = requestCode;
}

public ArrayList<Image> getSelectedImages() {
return selectedImages;
}
Expand Down Expand Up @@ -277,6 +287,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.savePath, flags);
dest.writeByte(this.isAlwaysShowDoneButton ? (byte) 1 : (byte) 0);
dest.writeByte(this.isKeepScreenOn ? (byte) 1 : (byte) 0);
dest.writeInt(this.requestCode);
dest.writeTypedList(this.selectedImages);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
import androidx.core.content.FileProvider;

import com.nguyenhoanglam.imagepicker.helper.ImageHelper;
import com.nguyenhoanglam.imagepicker.model.Config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nguyenhoanglam.imagepicker.ui.common;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;

import com.nguyenhoanglam.imagepicker.ui.imagepicker.ImageLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;

import com.nguyenhoanglam.imagepicker.R;
import com.nguyenhoanglam.imagepicker.model.Config;
Expand Down Expand Up @@ -50,11 +50,12 @@ public ActivityBuilder(Activity activity) {
@Override
public void start() {
Intent intent = getIntent();
int requestCode = config.getRequestCode() != 0 ? config.getRequestCode() : Config.RC_PICK_IMAGES;
if (!config.isCameraOnly()) {
activity.startActivityForResult(intent, Config.RC_PICK_IMAGES);
activity.startActivityForResult(intent, requestCode);
} else {
activity.overridePendingTransition(0, 0);
activity.startActivityForResult(intent, Config.RC_PICK_IMAGES);
activity.startActivityForResult(intent, requestCode);
}
}

Expand Down Expand Up @@ -84,11 +85,12 @@ public FragmentBuilder(Fragment fragment) {
@Override
public void start() {
Intent intent = getIntent();
int requestCode = config.getRequestCode() != 0 ? config.getRequestCode() : Config.RC_PICK_IMAGES;
if (!config.isCameraOnly()) {
fragment.startActivityForResult(intent, Config.RC_PICK_IMAGES);
fragment.startActivityForResult(intent, requestCode);
} else {
fragment.getActivity().overridePendingTransition(0, 0);
fragment.startActivityForResult(intent, Config.RC_PICK_IMAGES);
fragment.startActivityForResult(intent, requestCode);
}
}

Expand Down Expand Up @@ -187,7 +189,7 @@ public Builder setImageTitle(String imageTitle) {
return this;
}

public Builder setLimitMessage(String message){
public Builder setLimitMessage(String message) {
config.setLimitMessage(message);
return this;
}
Expand All @@ -212,6 +214,11 @@ public Builder setSelectedImages(ArrayList<Image> selectedImages) {
return this;
}

public Builder setRequestCode(int requestCode) {
config.setRequestCode(requestCode);
return this;
}

public abstract void start();

public abstract Intent getIntent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import android.os.Handler;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import android.content.Context;
import android.content.res.Configuration;
import android.os.Parcelable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.Toast;

import com.nguyenhoanglam.imagepicker.R;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nguyenhoanglam.imagepicker.widget;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nguyenhoanglam.imagepicker.widget;

import android.content.Context;
import android.support.v7.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.interpolator.view.animation.FastOutLinearInInterpolator;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
wheel:matProg_barColor="@color/imagepicker_teal"
wheel:matProg_progressIndeterminate="true" />

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions imagepicker/src/main/res/layout/imagepicker_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image_toolbar_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -30,7 +30,7 @@
android:textColor="@color/imagepicker_white" />


<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image_toolbar_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
14 changes: 7 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.nguyenhoanglam.sample"
minSdkVersion 15
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -22,9 +22,9 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation project(':imagepicker')
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nguyenhoanglam.sample;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Loading

0 comments on commit 8f75204

Please sign in to comment.