{"id":13608256,"url":"https://github.com/aminography/ChoosePhotoHelper","last_synced_at":"2025-04-12T14:32:25.915Z","repository":{"id":56029772,"uuid":"187693603","full_name":"aminography/ChoosePhotoHelper","owner":"aminography","description":"ChoosePhotoHelper develops a component which facilitates the source code of picking photos in your Android apps.","archived":false,"fork":false,"pushed_at":"2020-11-30T08:29:36.000Z","size":228,"stargazers_count":57,"open_issues_count":9,"forks_count":26,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T16:12:30.563Z","etag":null,"topics":["image-picker-android","imagepicker","photo-picker"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aminography.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-20T18:30:53.000Z","updated_at":"2024-03-21T23:16:07.000Z","dependencies_parsed_at":"2022-08-15T11:50:13.632Z","dependency_job_id":null,"html_url":"https://github.com/aminography/ChoosePhotoHelper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FChoosePhotoHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FChoosePhotoHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FChoosePhotoHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FChoosePhotoHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aminography","download_url":"https://codeload.github.com/aminography/ChoosePhotoHelper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581317,"owners_count":21128147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-picker-android","imagepicker","photo-picker"],"created_at":"2024-08-01T19:01:25.629Z","updated_at":"2025-04-12T14:32:25.144Z","avatar_url":"https://github.com/aminography.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# `ChoosePhotoHelper` :zap:\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ChoosePhotoHelper-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/7777)\n[![Download](https://api.bintray.com/packages/aminography/maven/ChoosePhotoHelper/images/download.svg) ](https://bintray.com/aminography/maven/ChoosePhotoHelper/_latestVersion)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e6f9a19772c24493b0fc365a86f88b18)](https://www.codacy.com/manual/aminography/ChoosePhotoHelper?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=aminography/ChoosePhotoHelper\u0026amp;utm_campaign=Badge_Grade)\n\nPicking an image as an avatar in Android apps needs to write a bunch of error-prone boilerplate codes. **`ChoosePhotoHelper`** develops a component which facilitates picking photos from gallery or taking an image with the camera without any boilerplate codes.\nIt also internally handles some issues like **rotation correction of the taken photos**, **permission request** for camera and gallery (if needed), **URI exposure** problem, etc.\n\n| Take a Photo | Choose from Gallery |\n| --- | --- |\n| ![](https://media.giphy.com/media/KdBwb36QCTsgKbUftB/giphy.gif) | ![](https://media.giphy.com/media/H88UXvL0jqL4HS2vuJ/giphy.gif) |\n\n\u003cbr/\u003e\n\nDownload\n--------\n**`ChoosePhotoHelper`** is available on [bintray](https://bintray.com/aminography/maven/ChoosePhotoHelper) to download using build tools systems. Add the following lines to your `build.gradle` file:\n\n```gradle\nrepositories {\n    jcenter()\n}\n\ndependencies {\n    implementation 'com.aminography:choosephotohelper:1.3.1'\n}\n```\n\n\u003cbr/\u003e\n\nUsage\n-----\nFirst of all, **`ChoosePhotoHelper`** provides 3 types of result to access the chosen photo which are:\n\n| Builder Method | Result Type |\n| --- | --- |\n| `asFilePath()` | `String` |\n| `asUri()` | `Uri` |\n| `asBitmap()` | `Bitmap` |\n\nNow, use it simply in 3 steps:\n\n### • First\nCreate an instance of **`ChoosePhotoHelper`** using its builder pattern specifying the result type:\n\n```java\nchoosePhotoHelper = ChoosePhotoHelper.with(activity)\n        .asFilePath()\n        .build(new ChoosePhotoCallback\u003cString\u003e() {\n            @Override\n            public void onChoose(String photo) {\n                Glide.with(imageView)\n                        .load(photo)\n                        .into(imageView);\n            }\n        });\n```\n\n### • Second\nOverride `onActivityResult` and `onRequestPermissionsResult` in your **Activity** / **Fragment** class, then forward their result to the `choosePhotoHelper` instance:\n\n```java\n@Override\npublic void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {\n    super.onActivityResult(requestCode, resultCode, data);\n    choosePhotoHelper.onActivityResult(requestCode, resultCode, data);\n}\n\n@Override\npublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {\n    super.onRequestPermissionsResult(requestCode, permissions, grantResults);\n    choosePhotoHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);\n}\n```\n\n### • Finally\nCall `showChooser()` method on the `choosePhotoHelper` instance:\n\n```java\nchoosePhotoHelper.showChooser();\n```\n\n\u003chr/\u003e\n\nHere is a detailed example which is written in **kotlin**:\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n    private lateinit var choosePhotoHelper: ChoosePhotoHelper\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        choosePhotoHelper = ChoosePhotoHelper.with(this)\n            .asFilePath()\n            .withState(savedInstanceState)\n            .build {\n                Glide.with(this)\n                    .load(it)\n                    .into(imageView)\n            }\n\n        button.setOnClickListener {\n            choosePhotoHelper.showChooser()\n        }\n    }\n\n    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {\n        super.onActivityResult(requestCode, resultCode, data)\n        choosePhotoHelper.onActivityResult(requestCode, resultCode, data)\n    }\n\n    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array\u003cString\u003e, grantResults: IntArray) {\n        super.onRequestPermissionsResult(requestCode, permissions, grantResults)\n        choosePhotoHelper.onRequestPermissionsResult(requestCode, permissions, grantResults)\n    }\n\n    override fun onSaveInstanceState(outState: Bundle) {\n        super.onSaveInstanceState(outState)\n        choosePhotoHelper.onSaveInstanceState(outState)\n    }\n\n}\n```\n\n\u003cbr/\u003e\n\nChange Log\n----------\n### Version 1.3.0\n- Migrating to Kotlin 1.4.0.\n\n### Version 1.2.1\n- Some minor improvements.\n- Adding ability to always show remove photo option.\n\n### Version 1.2.0\n- File path problem targeting api 29 is fixed.\n\n### Version 1.1.0\n- Migrating to AndroidX.\n- Adding `onSaveInstanceState` to save and restore state.\n\n\u003cbr/\u003e\n\nLicense\n--------\n```\nCopyright 2019 Mohammad Amin Hassani.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminography%2FChoosePhotoHelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faminography%2FChoosePhotoHelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminography%2FChoosePhotoHelper/lists"}