Skip to content

Commit 441c4b0

Browse files
braver-toolHariharan
authored andcommitted
1.Library migrated to kotlin
2.App supports android 12 3.Implemented Android 12 Splash screen API 4.Access non-media files without MANAGE_EXTERNAL_STORAGE permission
1 parent 8dabffb commit 441c4b0

File tree

64 files changed

+1212
-1151
lines changed

Some content is hidden

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

64 files changed

+1212
-1151
lines changed

.gitignore

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

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
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.
66
For using this library, you need to migrate your project to AndroidX(If your project is not migrated to AndroidX).
77

8+
This works without MANAGE_EXTERNAL_STORAGE permission Since it's very useful when you publish the app on Google Play Store.
89

9-
<img src="app_demo_b.jpg" width="30%" height="30%"/>
10+
11+
<img src="app_demo_pic.jpg" width="30%" height="30%"/>
1012

1113

1214
# Getting Started
@@ -25,28 +27,31 @@ allprojects {
2527
buildscript {
2628
repositories {
2729
maven { url "https://www.jitpack.io" }
28-
}
30+
}
2931
}
3032
```
3133

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

34-
add implementation 'implementation 'com.github.braver-tool:Android11FilePicker:0.1.1' to your build.gradle dependencies block.
35-
36+
add implementation 'implementation 'com.github.braver-tool:Android11FilePicker:1.0.0' to your build.gradle dependencies block.
37+
3638
for example:
37-
39+
3840
```
3941
dependencies {
40-
implementation 'com.github.braver-tool:Android11FilePicker:0.1.1'
42+
implementation 'com.github.braver-tool:Android11FilePicker:1.0.0'
4143
}
4244
```
4345

4446
# Key Features :
4547

48+
- Kotlin language supported
4649
- Fully Handled Android's Dangerous Permissions
4750
- Compressing option for selected images included,
4851
- To Preview your selected images using 'PhotoView'
4952
- To Preview your selected videos using exoplayer
53+
- Can pick any non-media files like PDF,Doc,Txt files without using MANAGE_EXTERNAL_STORAGE permission
54+
- Supports up to Android 12 and SplashScreen API
5055

5156
This library compatible with Android 6 and above
5257

@@ -118,4 +123,4 @@ Sample project is here(https://github.com/braver-tool/Android11FilePicker)
118123
## Usage
119124

120125
* Photoview - ImageView for Android that supports zooming, by various touch gestures.
121-
https://github.com/Baseflow/PhotoView
126+
https://github.com/Baseflow/PhotoView

app/build.gradle

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
*
33
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
44
* * Copyright (c) 2021 . All rights reserved.
5-
* * Last modified 15/11/21, 05:50 PM
5+
* * Last modified 23/03/22, 09:45 AM
66
*
77
*/
88

99
apply plugin: 'com.android.application'
1010
android {
11-
compileSdkVersion 30
11+
compileSdkVersion 31
1212
defaultConfig {
1313
applicationId "com.braver.tool.filepicker"
1414
minSdkVersion 23
15-
targetSdkVersion 30
15+
targetSdkVersion 31
1616
versionCode 1
1717
versionName "1.0"
1818

@@ -32,16 +32,16 @@ android {
3232
}
3333

3434
dependencies {
35-
implementation 'androidx.appcompat:appcompat:1.3.1'
36-
implementation 'com.google.android.material:material:1.4.0'
37-
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
38-
//implementation 'androidx.core:core:1.7.0'
39-
testImplementation 'junit:junit:4.+'
35+
implementation 'androidx.appcompat:appcompat:1.4.1'
36+
implementation 'com.google.android.material:material:1.5.0'
37+
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
38+
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'
39+
testImplementation 'junit:junit:4.13.2'
4040
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
4141
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
4242
implementation 'com.intuit.sdp:sdp-android:1.0.6'
43-
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
43+
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
4444
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
45-
//implementation project(':picker')
46-
implementation 'com.github.braver-tool:Android11FilePicker:0.1.0'
45+
implementation project(':picker')
46+
//implementation 'com.github.braver-tool:Android11FilePicker:1.1.0'
4747
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
44
* * Copyright (c) 2021 . All rights reserved.
5-
* * Last modified 15/11/21, 05:50 PM
5+
* * Last modified 23/03/22, 09:45 AM
66
*
77
*/
88

app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ /*
43
~ * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
54
~ * Copyright (c) 2021 . All rights reserved.
6-
~ * Last modified 15/11/21, 05:50 PM
5+
~ * Last modified 23/03/22, 09:45 AM
76
~ */
87
-->
98

@@ -14,9 +13,6 @@
1413
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
1514
<uses-permission android:name="android.permission.CAMERA" />
1615
<uses-permission android:name="android.permission.RECORD_AUDIO" />
17-
<uses-permission
18-
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
19-
tools:ignore="ScopedStorage" />
2016

2117
<application
2218
android:allowBackup="true"
@@ -25,22 +21,22 @@
2521
android:requestLegacyExternalStorage="true"
2622
android:roundIcon="@mipmap/ic_app_logo"
2723
android:supportsRtl="true"
28-
android:theme="@style/Theme.FilePicker">
24+
android:theme="@style/Theme.App.Starting">
2925
<activity
30-
android:name=".LaunchActivity"
31-
android:exported="true"
32-
android:theme="@style/SplashTheme">
26+
android:name=".PickerActivity"
27+
android:exported="true">
3328
<intent-filter>
3429
<action android:name="android.intent.action.MAIN" />
3530

3631
<category android:name="android.intent.category.LAUNCHER" />
3732
</intent-filter>
3833
</activity>
3934
<activity
40-
android:name=".PickerActivity"
41-
android:exported="true" />
42-
<activity android:name="com.braver.tool.picker.CameraActivity" />
43-
<activity android:name=".PreviewActivity" />
35+
android:name="com.braver.tool.picker.CameraActivity"
36+
android:theme="@style/Theme.FilePicker" />
37+
<activity
38+
android:name=".PreviewActivity"
39+
android:theme="@style/Theme.FilePicker" />
4440

4541
<provider
4642
android:name="androidx.core.content.FileProvider"

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-
/* * * * 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()); } }}
1+
/* * * * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM * * Copyright (c) 2021 . All rights reserved. * * Last modified 23/03/22, 09:45 AM * */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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* * Created by https://github.com/braver-tool on 12/10/21, 08:30 PM
44
* * Copyright (c) 2021 . All rights reserved.
5-
* * Last modified 15/11/21, 05:50 PM
5+
* * Last modified 23/03/22, 09:45 AM
66
*
77
*/
88

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

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)