A fully customazible gallery and media picker for android thats built on kotlin.
- Select media(photo, video) from android media store, custom offline gallery or custom online gallery
- Backward compatible with android API level 14
- Enable or disable content observer
- Filter medias based on types(Photos, videos, both)
- Modern user interface with the capability to add new theme and languages
- Select media with a caption
- Taking photo from the camera with the intent
- Showing bucket list in two different UI(grid and linear) which user can switches between them in runtime
- You can choose max selectable media by user
- Support orientation
- Set custom edit text layout (for emoji compatibility, etc)
- Enable or disable media count
- Set view pager scroll orientation (Vertical, Horizontal)
- Set view pager transformer
- Set custom onClick for video toggle in the video preview
- Automatic grant external storage permissions (You can disable it)
- Nice DSL for starting fallery from fragment, activity and extract the result from an output intent
- and many other features
Step 1. Add it in your root build.gradle
at the end of repositories:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.mehdiyari:Fallery:{latest_version}'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.mehdiyari</groupId>
<artifactId>Fallery</artifactId>
<version>{latest_version}</version>
</dependency>
Kotlin
class MainActivity : AppCompatActivity(R.layout.activity_main) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val falleryOptions = FalleryBuilder()
.setImageLoader(YourImageLoader())
.build()
falleryButton.setOnClickListener {
startFalleryWithOptions(requestCode = 1, falleryOptions = falleryOptions)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 1 && resultCode == RESULT_OK && data != null) {
handleResultWithCaption(
result = data?.getFalleryResultMediasFromIntent(),
caption = data?.getFalleryCaptionFromIntent()
)
}
}
private fun handleResultWithCaption(result: Array<String>?, caption: String?) {
TODO("handle result and caption")
}
}
Java
public class MainActivity extends AppCompatActivity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final FalleryOptions falleryOptions = new FalleryBuilder()
.setImageLoader(YourImageLoader())
.build();
this.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Fallery.startFalleryFromActivityWithOptions(
MainActivity.this, 1, falleryOptions
);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK && data != null) {
String[] result = Fallery.getResultMediasFromIntent(data);
String caption = Fallery.getCaptionFromIntent(data);
handleResultWithCaption(result, caption);
}
}
private void handleResultWithCaption(String[] result, String caption) {
// todo: handle result and caption
}
}
For more details about how to using Fallery please checkout example module or checkout Fallery blog post.
If you have free time I would very much appreciate your contributions.
Copyright 2020 Mehdi Yari
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.