Skip to content

Commit

Permalink
Added CopyRights and Update ReadME File
Browse files Browse the repository at this point in the history
  • Loading branch information
Hariharan committed Nov 15, 2021
1 parent 397ebf1 commit fdaf2a8
Show file tree
Hide file tree
Showing 56 changed files with 484 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
.gradle
.idea
/local.properties
/.idea/caches
/.idea/libraries
Expand Down
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# Android11FilePicker
# Android FilePicker

# Description

This app can make the file picking process easy, which allows you to select Pictures, Videos, and Documents. Also, that has Capturing Photo/Video option.
For using this library, you need to migrate your project to AndroidX(If your project is not migrated to AndroidX).


<img src="app_demo_a.jpg" width="30%" height="30%"/>


# Getting Started

To add this library to your project, please follow below steps

Add this in your root `build.gradle` file (project level gradle file):

```gradle
allprojects {
repositories {
maven { url "https://www.jitpack.io" }
}
}
buildscript {
repositories {
maven { url "https://www.jitpack.io" }
}
}
```

Then, Add this in your root `build.gradle` file (app level gradle file):

add implementation 'implementation 'com.github.braver-tool:Android11FilePicker:0.1.1' to your build.gradle dependencies block.

for example:

```
dependencies {
implementation 'com.github.braver-tool:Android11FilePicker:0.1.1'
}
```

# Key Features :

- Fully Handled Android's Dangerous Permissions
- Compressing option for selected images included,
- To Preview your selected images using 'PhotoView'
- To Preview your selected videos using exoplayer

This library compatible with Android 6 and above


## Version Compatibility
It depends on your targetAPI:
- `targetAPI <= 28`, you are fine ;)
- `targetAPI >= 29`, please enable `requestLegacyExternalStorage` on your Manifest.xml file

## Permissions Needed :

* android.permission.READ_EXTERNAL_STORAGE
* android.permission.CAMERA
* android.permission.RECORD_AUDIO
11 changes: 10 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
*
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
* * Copyright (c) 2021 . All rights reserved.
* * Last modified 15/11/21, 05:50 PM
*
*/

apply plugin: 'com.android.application'
android {
compileSdkVersion 30
Expand Down Expand Up @@ -34,5 +42,6 @@ dependencies {
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation project(':picker')
//implementation project(':picker')
implementation 'com.github.braver-tool:Android11FilePicker:0.1.0'
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
*
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
* * Copyright (c) 2021 . All rights reserved.
* * Last modified 15/11/21, 05:50 PM
*
*/

package com.braver.tool.filepicker;

import android.content.Context;
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ /*
~ * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
~ * Copyright (c) 2021 . All rights reserved.
~ * Last modified 15/11/21, 05:50 PM
~ */
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.braver.tool.filepicker">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/braver/tool/filepicker/AppUtils.java
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package com.braver.tool.filepicker;import android.content.Context;import android.content.Intent;import android.net.Uri;import android.util.Log;import androidx.core.content.FileProvider;import java.io.File;import java.util.Random;public class AppUtils { private static final boolean IS_DEBUG = false; public static final String DOC_ALERT_MSG = "You have to allow permission to access this feature"; public static final String START_POINT = "Source file path is \n ***/***/"; public static String getRandomImageFileName(Context context) { File mediaStorageDir = context.getFilesDir(); int random = new Random().nextInt(8997); String mImageName = "Braver_Img".concat("_") + random + ".jpg"; return new File(mediaStorageDir.getPath() + "/" + mImageName).getAbsolutePath(); } /** * @param tag - Contains class name * @param msg - Log message as String * Method used to print log in console for development */ public static void printLogConsole(String tag, String msg) { if (IS_DEBUG) { Log.d("##@" + tag, msg); } } /** * This method is a string return method * Method used get file name from local file path */ public static String getFileNameFromPath(String filePath) { String fileName = ""; try { fileName = filePath.substring(filePath.lastIndexOf('/') + 1); } catch (Exception e) { AppUtils.printLogConsole("getFileNameFromPath", "Exception-------->" + e.getMessage()); } return fileName; } public static void openDocument(Context context, String filePath) { try { Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", new File(filePath)); Intent intent = new Intent(Intent.ACTION_VIEW); if (filePath.contains(".doc") || filePath.contains(".docx")) { intent.setDataAndType(uri, "application/msword"); } else if (filePath.contains(".pdf")) { intent.setDataAndType(uri, "application/pdf"); } else if (filePath.contains(".ppt") || filePath.contains(".pptx")) { intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (filePath.contains(".xls") || filePath.contains(".xlsx")) { intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (filePath.contains(".zip") || filePath.contains(".rar")) { intent.setDataAndType(uri, "application/x-wav"); } else if (filePath.contains(".rtf")) { intent.setDataAndType(uri, "application/rtf"); } else if (filePath.contains(".wav") || filePath.contains(".mp3")) { intent.setDataAndType(uri, "audio/x-wav"); } else if (filePath.contains(".gif")) { intent.setDataAndType(uri, "image/gif"); } else if (filePath.contains(".jpg") || filePath.contains(".jpeg") || filePath.contains(".png")) { intent.setDataAndType(uri, "image/jpeg"); } else if (filePath.contains(".txt")) { intent.setDataAndType(uri, "text/plain"); } else if (filePath.contains(".3gp") || filePath.contains(".mpg") || filePath.contains(".mpeg") || filePath.contains(".mpe") || filePath.contains(".mp4") || filePath.contains(".avi")) { intent.setDataAndType(uri, "video/*"); } else { intent.setDataAndType(uri, "*/*"); } intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (Exception e) { AppUtils.printLogConsole("openDocument", "Exception-------->" + e.getMessage()); } }}
/* * * * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM * * Copyright (c) 2021 . All rights reserved. * * Last modified 15/11/21, 05:50 PM * */package com.braver.tool.filepicker;import android.content.Context;import android.content.Intent;import android.net.Uri;import android.util.Log;import androidx.core.content.FileProvider;import java.io.File;import java.util.Random;public class AppUtils { private static final boolean IS_DEBUG = false; public static final String DOC_ALERT_MSG = "You have to allow permission to access this feature"; public static final String START_POINT = "Source file path is \n ***/***/"; public static String getRandomImageFileName(Context context) { File mediaStorageDir = context.getFilesDir(); int random = new Random().nextInt(8997); String mImageName = "Braver_Img".concat("_") + random + ".jpg"; return new File(mediaStorageDir.getPath() + "/" + mImageName).getAbsolutePath(); } /** * @param tag - Contains class name * @param msg - Log message as String * Method used to print log in console for development */ public static void printLogConsole(String tag, String msg) { if (IS_DEBUG) { Log.d("##@" + tag, msg); } } /** * This method is a string return method * Method used get file name from local file path */ public static String getFileNameFromPath(String filePath) { String fileName = ""; try { fileName = filePath.substring(filePath.lastIndexOf('/') + 1); } catch (Exception e) { AppUtils.printLogConsole("getFileNameFromPath", "Exception-------->" + e.getMessage()); } return fileName; } public static void openDocument(Context context, String filePath) { try { Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", new File(filePath)); Intent intent = new Intent(Intent.ACTION_VIEW); if (filePath.contains(".doc") || filePath.contains(".docx")) { intent.setDataAndType(uri, "application/msword"); } else if (filePath.contains(".pdf")) { intent.setDataAndType(uri, "application/pdf"); } else if (filePath.contains(".ppt") || filePath.contains(".pptx")) { intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (filePath.contains(".xls") || filePath.contains(".xlsx")) { intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (filePath.contains(".zip") || filePath.contains(".rar")) { intent.setDataAndType(uri, "application/x-wav"); } else if (filePath.contains(".rtf")) { intent.setDataAndType(uri, "application/rtf"); } else if (filePath.contains(".wav") || filePath.contains(".mp3")) { intent.setDataAndType(uri, "audio/x-wav"); } else if (filePath.contains(".gif")) { intent.setDataAndType(uri, "image/gif"); } else if (filePath.contains(".jpg") || filePath.contains(".jpeg") || filePath.contains(".png")) { intent.setDataAndType(uri, "image/jpeg"); } else if (filePath.contains(".txt")) { intent.setDataAndType(uri, "text/plain"); } else if (filePath.contains(".3gp") || filePath.contains(".mpg") || filePath.contains(".mpeg") || filePath.contains(".mpe") || filePath.contains(".mp4") || filePath.contains(".avi")) { intent.setDataAndType(uri, "video/*"); } else { intent.setDataAndType(uri, "*/*"); } intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (Exception e) { AppUtils.printLogConsole("openDocument", "Exception-------->" + e.getMessage()); } }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
*
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
* * Copyright (c) 2021 . All rights reserved.
* * Last modified 15/11/21, 05:50 PM
*
*/

package com.braver.tool.filepicker;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
*
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
* * Copyright (c) 2021 . All rights reserved.
* * Last modified 15/11/21, 05:50 PM
*
*/

package com.braver.tool.filepicker;

import android.content.Intent;
Expand Down
Loading

0 comments on commit fdaf2a8

Please sign in to comment.