Android library for getting photo or video from a device gallery, cloud or camera. Working with samsung devices. Made by Stfalcon

Overview

ContentManager

Library for getting photos, videos or files of any type from a device gallery, external storage, cloud(Google Drive, Dropbox and etc) or camera. With asynchronous load from the cloud and fixed bugs for some problem devices like Samsung or Sony.

Who we are

Need iOS and Android apps, MVP development or prototyping? Contact us via info@stfalcon.com. We develop software since 2009, and we're known experts in this field. Check out our portfolio and see more libraries from stfalcon-studio.

Download

Download via Gradle:

compile 'com.github.stfalcon:contentmanager:0.5'

or Maven:

<dependency>
  <groupId>com.github.stfalcon</groupId>
  <artifactId>contentmanager</artifactId>
  <version>0.5</version>
  <type>pom</type>
</dependency>

Migration to version 0.5

In version 0.5 we have removed callback onLoadContentProgress(int loadPercent)(because it is very hard to calculate loadPercent correctly) and replaced it with callback onStartContentLoading() to handle a start of loading content. So if you are using ContentManager previous version, you need to make some correction after updating ContentManager version to 0.5. Also, we have added new cool feature: picking files with any types.

Usage

Add the folowing permission to AndroidManifest.xml:

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

Implement callback interface:

public class MainActivity extends AppCompatActivity implements ContentManager.PickContentListener {

Then implement PickContentListener methods:

/**
* Success result callback
*
* @param uri         Content uri
* @param contentType If you pick content can be Image or Video, if take - only Image
*/
@Override
public void onContentLoaded(Uri uri, String contentType) {
   if (contentType.equals(ContentManager.Content.IMAGE.toString())) {
       //You can use any library for display image Fresco, Picasso, ImageLoader
       //For sample:
       ImageLoader.getInstance().displayImage(uri.toString(), ivPicture);
   } else if (contentType.equals(ContentManager.Content.FILE.toString())) {
       //handle file result
       tvUri.setText(uri.toString());
   }
}
        
/**
* Call when loading started
*/
@Override
public void onStartContentLoading() {
  //Show loader or something like that
  progressBar.setVisibility(View.VISIBLE);
}

/**
* Call if have some problem with getting content
*
* @param error message
*/
@Override
public void onError(String error) {
  //Show error
}

/**
* Call if user manual cancel picking or taking content
*/
@Override
public void onCanceled() {
  //User canceled
}

Declare field:

private ContentManager contentManager;

Create instance where "this" is your activity:

contentManager = new ContentManager(this, this);

Override onActivityResult method of activity. It is needed for handling the result:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  contentManager.onActivityResult(requestCode, resultCode, data);
}

Override onRequestPermissionsResult method to handle realtime permissions:

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    contentManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

Override onSaveInstanceState, onRestoreInstanceState. It is needed for fixing bugs with some Samsung and Sony devices when taking photo in a landscape mode:

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  contentManager.onRestoreInstanceState(savedInstanceState);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  contentManager.onSaveInstanceState(outState);
}

Pick image:

contentManager.pickContent(ContentManager.Content.IMAGE);

Pick video:

contentManager.pickContent(ContentManager.Content.VIDEO);

Pick file:

contentManager.pickContent(ContentManager.Content.FILE);

Take photo from camera:

contentManager.takePhoto();

Take a look at the sample project for more information

Thanks

Thanks to @coomar2841 and his Android Multipicker Library. We peeked at him some points in the implementation of picking files.

License

Copyright 2017 stfalcon.com

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.
Comments
  • onActivityResult data is null

    onActivityResult data is null

    Hi, when using contentmanager.takephoto() on some devices the app crashes. I can see this error in logs:

    Exception java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=16, result=-1, data=null} to activity {...activity.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference

    It seems that on those devices, intent data received in onActivityResult is null.

    Devices on which I tested it and it works perfectly:

    • Samsung Galaxy S5 mini with android 5.1.1
    • LG Nexus 5 with android 6.0.1

    Devices on which I see this error:

    • Motorola Moto G with android 5.1
    • Huawei honor 6 with android 4.4.2
    • Android Studio official emulator
    opened by dotocan 5
  • onContentLoaded not called when don't keep activities is set and picking from gallery

    onContentLoaded not called when don't keep activities is set and picking from gallery

    Hello,

    thank you for your library. I found out that when I turn on the "don't keep activities" option the onContentLoaded is not called when picking an image from gallery. It works fine when taking a picture from cammera. Also when I don't have this option turned on it works for camera and gallery.

    I was using 0.1.1 version but after upgrade to 0.4.2 it is still the same. Do you have any idea where can by the problem?

    Fragments onActivityResult is called and it contains this code:

    @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); contentManager.onActivityResult(requestCode, resultCode, data); }

    Thank you for you response.

    opened by danielto 2
  • Previewing captured image?

    Previewing captured image?

    Hi,

    Picking image from gallery and putting it in ImageView works as it should. But how can I take a picture with camera and put that captured image into ImageView? I need to be able to take a picture with camera on one activity and then show that picture to the user few activities later.

    opened by dotocan 2
  • onLoadContentProgress(int loadPercent) called even for local images

    onLoadContentProgress(int loadPercent) called even for local images

    Hello,

    First, I want to thank you for your library. I'm asking a question about the onLoadContentProgress() call. I logged some information in this callback method and I can see that calls are done even for local images. I think this method should be called only for cloud images.

    Thanks, 16arm

    opened by 16arm 1
  • Not able to pick image from the gallery

    Not able to pick image from the gallery

    The library is not working, I tried picking up the image from the Gallery in Samsung S7 Edge but onActivityResult is never called.

    I am testing it inside the Fragment on Android OS version 6.0

    opened by Shajeel-Afzal 1
  • Method onError() called with error 'null', when i use the pickContent() to pick image or video !!!

    Method onError() called with error 'null', when i use the pickContent() to pick image or video !!!

    My device is redmi Note 4 running 7.0 I am calling the contentManager inside SupportFragment

    1. onActivityResult() returns the image data
    2. then onStartContentLoading called
    3. then onError with null parameter called and nothing gets loaded

    this library worked for first two days, now it is loading nothing

    opened by DilbagSandhu 0
  • The method contentManager.takePhoto() crashes the application, requiring the permission of android.permission.CAMERA

    The method contentManager.takePhoto() crashes the application, requiring the permission of android.permission.CAMERA

    The method contentManager.pickContent(ContentManager.Content.IMAGE) asks for permission when called, and the method contentManager.takePhoto() does not request permission and crashes the system. java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.CaptureActivity clip={text/uri-list U:content://media/external/images/media/16349} (has extras) } from ProcessRecord{ea458e7 15188:com.kostasoft.help_signal_purchase/u0a207} (pid=15188, uid=10207) with revoked permission android.permission.CAMERA

    opened by kostasoft 0
  • Method onError() being called on Samsung Galaxy S7 device due to picture being taken on the past

    Method onError() being called on Samsung Galaxy S7 device due to picture being taken on the past

    Hi!

    I need to start saying thanks for the project, since it's being really helpful for implementing the functionality of taking photo and picking media from the gallery.

    About the issue I am having, it's related (at least until now) with the Samsung Galaxy S7 Device, which is not loading the picture after being taken (the picking from gallery works fine).

    It does call the method onError() with empty string from the interface ContentManager.PickContentListener. I have been debugging the internal code of the ContentManager class and have found this issue happens when verifying if the date of the picture is after the date that the camera intent has started (ContentManager.java, line 354). I notices this device is saving the picture as one day before the current day, so I am pretty sure this is the problem that is leading to this behaviour.

    Could you please provide one way to bypass this verification about the date of the picture being after the start date of the camera intent, or at least the fix (I don't know if it's Samsung software issue when saving the picture or the library is putting the date one day in the past)?

    Thanks one more time!

    opened by rodrigobressan 5
Owner
Stfalcon LLC
We are Stfalcon, mobile and web development company.
Stfalcon LLC
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❤️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Chili Labs 394 Nov 29, 2022
Stingle Photos is a secure, open-source photo, video cloud storage and backup application

Stingle Photos Stingle Photos is a secure, open-source photo, video cloud storage and backup application that is safe, ad-free and easy to use. It pro

Stingle 242 Dec 14, 2022
Android gallery & photo/video functionality simplified with RxJava2

RxGallery Android gallery & photo/video functionality simplified with RxJava2 Setup To use this library your minSdkVersion must be >= 9. Add it in you

Brian Rojas 38 Oct 11, 2022
Browse your memories without any interruptions with this photo and video gallery

Simple Gallery Simple Gallery Pro is a highly customizable lightweight gallery loved by millions of people for its great user experience. Organize and

Simple Mobile Tools 2.8k Jan 4, 2023
Browse your memories without any interruptions with this photo and video gallery

Simple Gallery Simple Gallery Pro is a highly customizable lightweight gallery loved by millions of people for its great user experience. Organize and

Simple Mobile Tools 2.8k Jan 8, 2023
Quick photo and video camera with a flash, customizable resolution and no ads.

Simple Camera A camera with flash, zoom and no ads. The camera is usable for both photo taking and video recording. You can switch between front and r

Simple Mobile Tools 644 Dec 26, 2022
Quick photo and video camera with a flash, customizable resolution and no ads.

Simple Camera A camera with flash, zoom and no ads. The camera is usable for both photo taking and video recording. You can switch between front and r

Simple Mobile Tools 644 Dec 26, 2022
Quick photo and video camera with a flash, customizable resolution and no ads.

Simple Camera A camera with flash, zoom and no ads. The camera is usable for both photo taking and video recording. You can switch between front and r

Simple Mobile Tools 644 Jan 7, 2023
☁️ cloud.sh is a lightweight self-hosted cloud for your home lab.

DISCLAIMER: cloud.sh is under development. We do not recommend you to use it in a production environment for now. The storage could be corrupted when

Quentin Guidée 13 Nov 24, 2022
A customized video view that will automatically pause video is user is not looking at device screen!!!!!

UserAwareVideoView Featured in: Medium What is this library for? UserAwareVideoView is a customizable VideoView that smartly play and pause the video

Keval Patel 51 Jun 27, 2021
An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.

ShortcutBadger: The ShortcutBadger makes your Android App show the count of unread messages as a badge on your App shortcut! Supported launchers: Sony

Leo Lin 7.2k Dec 30, 2022
Android library for adding price range with chart like in airbnb with flexible customization. Made by Stfalcon

Stfalcon-PriceRangeBar Demo Application Who we are Need iOS and Android apps, MVP development or prototyping? Contact us via info@stfalcon.com. We dev

Stfalcon LLC 223 Nov 25, 2022
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023
Android library to display a few images in one ImageView like avatar of group chat. Made by Stfalcon

MultiImageView Library for display a few images in one MultiImageView like avatar of group chat Who we are Need iOS and Android apps, MVP development

Stfalcon LLC 468 Dec 9, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Android library to choose image from gallery or camera with option to compress result image

ImagePicker Android library to choose image from gallery or camera with option to compress result image. Download Add this to your project's build.gra

Mayank Nagwanshi 73 May 20, 2022
Image Cropping Library for Android, optimised for Camera / Gallery.

Image Cropping Library for Android, optimised for Camera / Gallery.

CanHub 812 Dec 30, 2022
Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera.

Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera.

Simform Solutions 201 Jan 5, 2023
Android application allowing to sniff and inject Zigbee, Mosart and Enhanced ShockBurst packets on a Samsung Galaxy S20

This Android application allows to sniff and inject Zigbee, Mosart and Enhanced ShockBurst packets from a Samsung Galaxy S20 smartphone. It interacts with a set of patches installed on the phone Bluetooth controller, allowing to add new capabilities to communicate using the previously mentioned protocols.

Romain Cayre 52 Nov 1, 2022