Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
esafirm committed Jul 30, 2017
2 parents 829a2e3 + 3be3cba commit 5e8fa22
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 27 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ And add this to your module's `build.gradle`

```groovy
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.esafirm.android-image-picker:imagepicker:x.y.z@aar'
compile 'com.github.esafirm.android-image-picker:imagepicker:x.y.z'
// for experimental rx picker
compile 'com.github.esafirm.android-image-picker:rximagepicker:x.y.z@aar'
compile 'com.github.esafirm.android-image-picker:rximagepicker:x.y.z'
}
```

Expand Down Expand Up @@ -119,7 +118,11 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

<<<<<<< HEAD
## Original License
=======
##Original License
>>>>>>> Update the readme 📚
[The Original Image Picker](https://github.com/nguyenhoanglam/ImagePicker)

Expand Down
5 changes: 4 additions & 1 deletion imagepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'

final supportLibraryVersion = '25.3.1'
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
compile("com.android.support:appcompat-v7:$supportLibraryVersion") {
exclude module: 'animated-vector-drawable'
exclude module: 'support-media-compat'
}

testCompile 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void onBindViewHolder(final FolderViewHolder holder, int position) {

public void setData(List<Folder> folders) {
if (folders != null) {
this.folders.clear();
this.folders.addAll(folders);
}
notifyDataSetChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public ImagePicker imageDirectory(String directory) {
return this;
}

public ImagePicker imageFullDirectory(String fullPath) {
config.setImageFullDirectory(fullPath);
return this;
}

public ImagePicker theme(@StyleRes int theme) {
config.setTheme(theme);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ImagePickerConfig implements Parcelable {

private String folderTitle;
private String imageTitle;
private String imageDirectory;
private ImagePickerSavePath savePath;

private int mode;
private int limit;
Expand Down Expand Up @@ -94,12 +94,20 @@ public void setFolderMode(boolean folderMode) {
this.folderMode = folderMode;
}

public String getImageDirectory() {
return imageDirectory;
public ImagePickerSavePath getImageDirectory() {
return savePath;
}

public void setImageDirectory(String imageDirectory) {
this.imageDirectory = imageDirectory;
public void setSavePath(ImagePickerSavePath savePath) {
this.savePath = savePath;
}

public void setImageDirectory(String dirName) {
savePath = new ImagePickerSavePath(dirName, false);
}

public void setImageFullDirectory(String path) {
savePath = new ImagePickerSavePath(path, true);
}

public void setTheme(@StyleRes int theme) {
Expand Down Expand Up @@ -132,7 +140,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeTypedList(this.selectedImages);
dest.writeString(this.folderTitle);
dest.writeString(this.imageTitle);
dest.writeString(this.imageDirectory);
dest.writeParcelable(this.savePath, flags);
dest.writeInt(this.mode);
dest.writeInt(this.limit);
dest.writeInt(this.theme);
Expand All @@ -146,7 +154,7 @@ protected ImagePickerConfig(Parcel in) {
this.selectedImages = in.createTypedArrayList(Image.CREATOR);
this.folderTitle = in.readString();
this.imageTitle = in.readString();
this.imageDirectory = in.readString();
this.savePath = in.readParcelable(ImagePickerSavePath.class.getClassLoader());
this.mode = in.readInt();
this.limit = in.readInt();
this.theme = in.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static ImagePickerConfig createDefault(Context context) {
config.setFolderTitle(context.getString(R.string.ef_title_folder));
config.setImageTitle(context.getString(R.string.ef_title_select_image));
config.setSelectedImages(new ArrayList<>());
config.setImageDirectory(context.getString(R.string.ef_image_directory));
config.setSavePath(ImagePickerSavePath.DEFAULT);
config.setReturnAfterFirst(true);
config.setImageLoader(new DefaultImageLoader());
return config;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.esafirm.imagepicker.features;

import android.os.Parcel;
import android.os.Parcelable;

public class ImagePickerSavePath implements Parcelable {

public static final ImagePickerSavePath DEFAULT = new ImagePickerSavePath("Camera", false);

private final String path;
private final boolean isFullPath;

public ImagePickerSavePath(String path, boolean isFullPath) {
this.path = path;
this.isFullPath = isFullPath;
}

public String getPath() {
return path;
}

public boolean isFullPath() {
return isFullPath;
}

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

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.path);
dest.writeByte(this.isFullPath ? (byte) 1 : (byte) 0);
}

protected ImagePickerSavePath(Parcel in) {
this.path = in.readString();
this.isFullPath = in.readByte() != 0;
}

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

@Override
public ImagePickerSavePath[] newArray(int size) {
return new ImagePickerSavePath[size];
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;

import com.esafirm.imagepicker.features.ImagePickerSavePath;
import com.esafirm.imagepicker.model.Image;

import java.io.File;
Expand All @@ -19,16 +19,17 @@

public class ImagePickerUtils {

private static final String TAG = "ImageUtils";

public static File createImageFile(String directory) {
public static File createImageFile(ImagePickerSavePath savePath) {
// External sdcard location
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), directory);
final String path = savePath.getPath();
File mediaStorageDir = savePath.isFullPath()
? new File(path)
: new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), path);

// Create the storage directory if it does not exist
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.d(TAG, "Oops! Failed create " + directory + " directory");
IpLogger.getInstance().d("Oops! Failed create " + path);
return null;
}
}
Expand All @@ -41,7 +42,7 @@ public static File createImageFile(String directory) {
try {
imageFile = File.createTempFile(imageFileName, ".jpg", mediaStorageDir);
} catch (IOException e) {
Log.d(TAG, "Oops! Failed create " + imageFileName + " file");
IpLogger.getInstance().d("Oops! Failed create " + imageFileName + " file");
}
return imageFile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public void setPath(String path) {
this.path = path;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Image image = (Image) o;
return image.getPath().equalsIgnoreCase(getPath());
}

/* --------------------------------------------------- */
/* > Parcelable */
/* --------------------------------------------------- */
Expand Down
3 changes: 0 additions & 3 deletions imagepicker/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@
<!--Don't Translate-->
<string name="ef_gif">GIF</string>

<!--Config-->
<string name="ef_image_directory" translatable="false">Camera</string>

</resources>
17 changes: 13 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
buildToolsVersion '25.0.3'

defaultConfig {
applicationId "com.esafirm.imagepicker.sample"
Expand All @@ -19,10 +19,19 @@ android {
}
}

repositories {
maven { url "https://jitpack.io" }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile project(':imagepicker')

/* Development */
compile project(':rximagepicker')
compile project(':imagepicker')

/* Release Check */
// final imagePickerVersion = '1.7.4'
// compile "com.github.esafirm.android-image-picker:imagepicker:${imagePickerVersion}"
// compile("com.github.esafirm.android-image-picker:rximagepicker:${imagePickerVersion}")
}
5 changes: 4 additions & 1 deletion sample/src/main/java/com/esafirm/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
Expand Down Expand Up @@ -117,11 +118,12 @@ public void start() {
final boolean returnAfterCapture = ((Switch) findViewById(R.id.ef_switch_return_after_capture)).isChecked();
final boolean isSingleMode = ((Switch) findViewById(R.id.ef_switch_single)).isChecked();
final boolean useCustomImageLoader = ((Switch) findViewById(R.id.ef_switch_imageloader)).isChecked();
final boolean folderMode = ((Switch) findViewById(R.id.ef_switch_folder_mode)).isChecked();

ImagePicker imagePicker = ImagePicker.create(this)
.theme(R.style.ImagePickerTheme)
.returnAfterFirst(returnAfterCapture) // set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker
.folderMode(false) // set folder mode (false by default)
.folderMode(folderMode) // set folder mode (false by default)
.folderTitle("Folder") // folder selection title
.imageTitle("Tap to select"); // image selection title

Expand All @@ -138,6 +140,7 @@ public void start() {
imagePicker.limit(10) // max images can be selected (99 by default)
.showCamera(true) // show camera or not (true by default)
.imageDirectory("Camera") // captured image directory name ("Camera" folder by default)
.imageFullDirectory(Environment.getExternalStorageDirectory().getPath()) // can be full path
.origin(images) // original selected images, used in multi mode
.start(RC_CODE_PICKER); // start image picker activity with request code
}
Expand Down
8 changes: 8 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="Return After First "/>


<Switch
android:id="@+id/ef_switch_folder_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="Folder Mode "/>

<Switch
android:id="@+id/ef_switch_single"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 5e8fa22

Please sign in to comment.