Easy to use and highly customizable image picker for Android with helpful extras to deal with outputs. Minimum API 9+, gets better with newer API versions
API 9+ (Gingerbread) functionality:
Uri
content to a File
API 11+ (Honeycomb):
API 18+ (Jelly Bean MR2):
API 19+ (KitKat):
Uri
, multiple pick options, etc) FileUriExposedException
issue on API 24+ target)repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile ('com.github.aviadmini:quickimagepick:${qip.release.version}'){
// Uncomment next line if you have dependency conflict with AppCompat v7
// exclude group: 'com.android.support', module: 'appcompat-v7'
}
}
Latest release: []() (Use without 'v')
For detailed explanation refer to Documentation and sample app
@PickTriggerResult final int triggerResult;
triggerResult = QiPick.in(Activity or Fragment)
.fromMultipleSources("All sources", PickSource.CAMERA, PickSource.DOCUMENTS);
Here triggerResult
defines whether pick request was fired successfully. If not, it can be treated as error code.
In onActivityResult
of Activity or Fragment:
private final PickCallback mCallback = new PickCallback() {
@Override
public void onImagePicked(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final Uri pImageUri) {
// Do something with Uri, for example load image into an ImageView
Glide.with(getApplicationContext())
.load(pImageUri)
.fitCenter()
.into(mImageView);
}
@Override
public void onMultipleImagesPicked(final int pRequestType, @NonNull final List<Uri> pImageUris) {
// meh whatever, just show first picked ;D
this.onImagePicked(PickSource.DOCUMENTS, pRequestType, pImageUris.get(0));
}
@Override
public void onError(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final String pErrorString) {
Log.e(TAG, "Err: " + pErrorString);
}
@Override
public void onCancel(@NonNull final PickSource pPickSource, final int pRequestType) {
Log.d(TAG, "Cancel: " + pPickSource.name());
}
};
@Override
protected void onActivityResult(final int pRequestCode, final int pResultCode, final Intent pData) {
super.onActivityResult(pRequestCode, pResultCode, pData);
super.onActivityResult(pRequestCode, pResultCode, pData);
QiPick.handleActivityResult(getApplicationContext(), pRequestCode, pResultCode, pData, this.mCallback);
}
There's a bunch of useful methods to work with Uri
in UriUtils
There's a few extension ideas that might make the library even more useful.
If your app uses this library send me market links ;)
Copyright 2017 Bohdan Semeniuk
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.