Skip to content

Commit fdaf2a8

Browse files
author
Hariharan
committed
Added CopyRights and Update ReadME File
1 parent 397ebf1 commit fdaf2a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+484
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.iml
22
.gradle
3+
.idea
34
/local.properties
45
/.idea/caches
56
/.idea/libraries

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
1-
# Android11FilePicker
1+
# Android FilePicker
2+
3+
# Description
4+
5+
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.
6+
For using this library, you need to migrate your project to AndroidX(If your project is not migrated to AndroidX).
7+
8+
9+
<img src="app_demo_a.jpg" width="30%" height="30%"/>
10+
11+
12+
# Getting Started
13+
14+
To add this library to your project, please follow below steps
15+
16+
Add this in your root `build.gradle` file (project level gradle file):
17+
18+
```gradle
19+
allprojects {
20+
repositories {
21+
maven { url "https://www.jitpack.io" }
22+
}
23+
}
24+
25+
buildscript {
26+
repositories {
27+
maven { url "https://www.jitpack.io" }
28+
}
29+
}
30+
```
31+
32+
Then, Add this in your root `build.gradle` file (app level gradle file):
33+
34+
add implementation 'implementation 'com.github.braver-tool:Android11FilePicker:0.1.1' to your build.gradle dependencies block.
35+
36+
for example:
37+
38+
```
39+
dependencies {
40+
implementation 'com.github.braver-tool:Android11FilePicker:0.1.1'
41+
}
42+
```
43+
44+
# Key Features :
45+
46+
- Fully Handled Android's Dangerous Permissions
47+
- Compressing option for selected images included,
48+
- To Preview your selected images using 'PhotoView'
49+
- To Preview your selected videos using exoplayer
50+
51+
This library compatible with Android 6 and above
52+
53+
54+
## Version Compatibility
55+
It depends on your targetAPI:
56+
- `targetAPI <= 28`, you are fine ;)
57+
- `targetAPI >= 29`, please enable `requestLegacyExternalStorage` on your Manifest.xml file
58+
59+
## Permissions Needed :
60+
61+
* android.permission.READ_EXTERNAL_STORAGE
62+
* android.permission.CAMERA
63+
* android.permission.RECORD_AUDIO

app/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
*
3+
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
4+
* * Copyright (c) 2021 . All rights reserved.
5+
* * Last modified 15/11/21, 05:50 PM
6+
*
7+
*/
8+
19
apply plugin: 'com.android.application'
210
android {
311
compileSdkVersion 30
@@ -34,5 +42,6 @@ dependencies {
3442
implementation 'com.intuit.sdp:sdp-android:1.0.6'
3543
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
3644
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
37-
implementation project(':picker')
45+
//implementation project(':picker')
46+
implementation 'com.github.braver-tool:Android11FilePicker:0.1.0'
3847
}

app/src/androidTest/java/com/braver/tool/filepicker/ExampleInstrumentedTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
*
3+
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
4+
* * Copyright (c) 2021 . All rights reserved.
5+
* * Last modified 15/11/21, 05:50 PM
6+
*
7+
*/
8+
19
package com.braver.tool.filepicker;
210

311
import android.content.Context;

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ /*
4+
~ * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
5+
~ * Copyright (c) 2021 . All rights reserved.
6+
~ * Last modified 15/11/21, 05:50 PM
7+
~ */
8+
-->
9+
210
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
311
xmlns:tools="http://schemas.android.com/tools"
412
package="com.braver.tool.filepicker">

app/src/main/java/com/braver/tool/filepicker/AppUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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()); } }}
1+
/* * * * 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()); } }}

app/src/main/java/com/braver/tool/filepicker/CustomPreferencesManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
*
3+
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
4+
* * Copyright (c) 2021 . All rights reserved.
5+
* * Last modified 15/11/21, 05:50 PM
6+
*
7+
*/
8+
19
package com.braver.tool.filepicker;
210

311

app/src/main/java/com/braver/tool/filepicker/LaunchActivity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
*
3+
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
4+
* * Copyright (c) 2021 . All rights reserved.
5+
* * Last modified 15/11/21, 05:50 PM
6+
*
7+
*/
8+
19
package com.braver.tool.filepicker;
210

311
import android.content.Intent;

0 commit comments

Comments
 (0)