├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── appsample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── necistudio
│ │ └── filepickerdocumentlibrary
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── necistudio
│ │ │ └── filepickerdocumentlibrary
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── github.png
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── necistudio
│ └── filepickerdocumentlibrary
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_create-web.png
│ ├── java
│ └── com
│ │ └── necistudio
│ │ └── libarary
│ │ ├── FilePickerActivity.java
│ │ ├── adapter
│ │ ├── FilePickerAdapter.java
│ │ └── FilterAdapter.java
│ │ ├── cursors
│ │ ├── DocScannerTask.java
│ │ └── loadercallback
│ │ │ └── FileResultCallback.java
│ │ ├── item
│ │ ├── BaseFile.java
│ │ └── Document.java
│ │ ├── utils
│ │ ├── FilePickerConst.java
│ │ ├── MediaStoreHelper.java
│ │ ├── PermissionUtils.java
│ │ └── Utils.java
│ │ └── view
│ │ └── FilterFragment.java
│ └── res
│ ├── drawable
│ ├── ic_excel.png
│ ├── ic_pdf.png
│ ├── ic_ppt.png
│ ├── ic_txt.png
│ └── ic_word.png
│ ├── layout
│ ├── activitymain.xml
│ ├── fragmentfilter.xml
│ ├── item_document.xml
│ └── item_filter.xml
│ ├── mipmap-hdpi
│ └── ic_create.png
│ ├── mipmap-mdpi
│ └── ic_create.png
│ ├── mipmap-xhdpi
│ └── ic_create.png
│ ├── mipmap-xxhdpi
│ └── ic_create.png
│ ├── mipmap-xxxhdpi
│ └── ic_create.png
│ └── values
│ ├── colors.xml
│ ├── layout.xml
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android - FilePickerFilter Library
2 |
3 |
4 |
5 |
6 |
7 | ```
8 | repositories {
9 | jcenter()
10 | maven { url 'https://jitpack.io' }
11 | }
12 | ```
13 | ```
14 | dependencies {
15 | compile 'com.github.aerdy:Android-FilePickerFilterLibrary:-SNAPSHOT'
16 | }
17 |
18 | ```
19 | ### Support Android Version
20 | ```
21 | minSdkVersion 15
22 | ```
23 |
24 | ```
25 | Intent intent = new Intent(getApplicationContext(),FilePickerActivity.class);
26 | startActivityForResult(intent, idresult);
27 | ```
28 | ```
29 | @Override
30 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
31 | super.onActivityResult(requestCode, resultCode, data);
32 | if (requestCode == 1) {
33 | if (resultCode == Activity.RESULT_OK) {
34 | String path = data.getStringExtra("path");
35 | txtPath.setText(path);
36 | Log.e("data",path);
37 | }else{
38 | Log.e("data","cance");
39 | }
40 | }
41 | }
42 | ```
43 | # Screenshot
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | ##License
56 | ```
57 | Copyright 2020 Necis Studio
58 |
59 | Licensed under the Apache License, Version 2.0 (the "License");
60 | you may not use this file except in compliance with the License.
61 | You may obtain a copy of the License at
62 |
63 | http://www.apache.org/licenses/LICENSE-2.0
64 |
65 | Unless required by applicable law or agreed to in writing, software
66 | distributed under the License is distributed on an "AS IS" BASIS,
67 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
68 | See the License for the specific language governing permissions and
69 | limitations under the License.
70 | ```
71 |
--------------------------------------------------------------------------------
/appsample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/appsample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.necistudio.filepickerdocumentlibrary"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.2.0'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
29 | testCompile 'junit:junit:4.12'
30 | compile project(':library')
31 | }
32 |
--------------------------------------------------------------------------------
/appsample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/vim/sdk-linux/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/appsample/src/androidTest/java/com/necistudio/filepickerdocumentlibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.filepickerdocumentlibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.necistudio.filepickerdocumentlibrary", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/appsample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/appsample/src/main/java/com/necistudio/filepickerdocumentlibrary/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.filepickerdocumentlibrary;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.TextView;
11 |
12 | import com.necistudio.libarary.FilePickerActivity;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | private Button btnPick;
17 | private TextView txtPath;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | btnPick = (Button) findViewById(R.id.btnPick);
24 | txtPath = (TextView)findViewById(R.id.txtPath);
25 | btnPick.setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View v) {
28 | Intent intent = new Intent(getApplicationContext(),FilePickerActivity.class);
29 | startActivityForResult(intent, 1);
30 | }
31 | });
32 | }
33 |
34 | @Override
35 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
36 | super.onActivityResult(requestCode, resultCode, data);
37 | if (requestCode == 1) {
38 | if (resultCode == Activity.RESULT_OK) {
39 | String path = data.getStringExtra("path");
40 | txtPath.setText(path);
41 | Log.e("data",path);
42 | }else{
43 | Log.e("data","cance");
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/appsample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
23 |
31 |
38 |
39 |
47 |
48 |
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xhdpi/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xhdpi/github.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/appsample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/appsample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/appsample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #9100ca
4 | #5d0081
5 | #47c100
6 |
7 |
--------------------------------------------------------------------------------
/appsample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FilePickerDocumentLibrary
3 |
4 |
--------------------------------------------------------------------------------
/appsample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/appsample/src/test/java/com/necistudio/filepickerdocumentlibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.filepickerdocumentlibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0-rc1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Mar 01 11:40:20 WIB 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:25.2.0'
26 | compile 'com.android.support:support-v4:25.2.0'
27 | compile 'com.android.support:design:25.2.0'
28 | compile 'com.android.support:cardview-v7:25.2.0'
29 | compile 'com.android.support:recyclerview-v7:25.2.0'
30 | }
31 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/vim/sdk-linux/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/library/src/main/ic_create-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/ic_create-web.png
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/FilePickerActivity.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary;
2 |
3 | import android.Manifest;
4 | import android.app.Activity;
5 | import android.app.DialogFragment;
6 | import android.content.Intent;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.support.annotation.NonNull;
10 | import android.support.annotation.Nullable;
11 | import android.support.design.widget.FloatingActionButton;
12 | import android.support.v7.app.AppCompatActivity;
13 | import android.support.v7.widget.LinearLayoutManager;
14 | import android.support.v7.widget.RecyclerView;
15 | import android.support.v7.widget.Toolbar;
16 | import android.util.Log;
17 | import android.view.View;
18 | import android.view.Window;
19 | import android.view.WindowManager;
20 | import android.widget.TextView;
21 |
22 | import com.necistudio.libarary.adapter.FilePickerAdapter;
23 | import com.necistudio.libarary.cursors.loadercallback.FileResultCallback;
24 | import com.necistudio.libarary.item.Document;
25 | import com.necistudio.libarary.utils.MediaStoreHelper;
26 | import com.necistudio.libarary.utils.PermissionUtils;
27 | import com.necistudio.libarary.view.FilterFragment;
28 |
29 | import java.util.ArrayList;
30 | import java.util.List;
31 |
32 | /**
33 | * Created by vim on 01/03/17.
34 | */
35 |
36 | public class FilePickerActivity extends AppCompatActivity {
37 | private RecyclerView recyclerView;
38 | private FilePickerAdapter adapter;
39 | private Toolbar toolbar;
40 | private TextView txtNull;
41 | private FloatingActionButton btnFilter;
42 | private List itemfilter;
43 |
44 | @Override
45 | protected void onCreate(@Nullable Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
48 | Window window = getWindow();
49 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
50 | window.setStatusBarColor(getResources().getColor(R.color.clrPrimaryDrakLib));
51 | }
52 | setContentView(R.layout.activitymain);
53 | toolbar = (Toolbar) findViewById(R.id.toolbar);
54 | txtNull = (TextView) findViewById(R.id.txtNull);
55 | btnFilter = (FloatingActionButton) findViewById(R.id.btnFilter);
56 | setSupportActionBar(toolbar);
57 | itemfilter = new ArrayList<>();
58 | itemfilter.add(".pdf");
59 | itemfilter.add(".txt");
60 | itemfilter.add(".docx");
61 | itemfilter.add(".doc");
62 | if (PermissionUtils.requestPermission(this, 1, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
63 | getDocument();
64 | }
65 |
66 | btnFilter.setOnClickListener(new View.OnClickListener() {
67 | @Override
68 | public void onClick(View v) {
69 | DialogFragment dialogFragment = FilterFragment.newInstance((ArrayList) itemfilter);
70 | dialogFragment.show(getFragmentManager(), "filter");
71 | }
72 | });
73 | }
74 |
75 | public void finishData(String path) {
76 | Intent returnIntent = new Intent();
77 | returnIntent.putExtra("result", "ok");
78 | returnIntent.putExtra("path", path);
79 | setResult(Activity.RESULT_OK, returnIntent);
80 | finish();
81 | }
82 |
83 | public void getDocument() {
84 | MediaStoreHelper mediaStoreHelper = new MediaStoreHelper();
85 | mediaStoreHelper.getDocs(this,itemfilter, new FileResultCallback() {
86 | @Override
87 | public void onResultCallback(List files) {
88 | recyclerView = (RecyclerView) findViewById(R.id.recycleMain);
89 | recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
90 | adapter = new FilePickerAdapter(getApplicationContext(), FilePickerActivity.this, files);
91 | recyclerView.setAdapter(adapter);
92 | if (files.isEmpty()) {
93 | txtNull.setVisibility(View.VISIBLE);
94 | }
95 | Log.e("data","loadagain");
96 | }
97 | });
98 |
99 | }
100 |
101 | @Override
102 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
103 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
104 | if (PermissionUtils.permissionGranted(requestCode, 1, grantResults)) {
105 | getDocument();
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/adapter/FilePickerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.text.format.Formatter;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.RelativeLayout;
11 | import android.widget.TextView;
12 |
13 | import com.necistudio.libarary.FilePickerActivity;
14 | import com.necistudio.libarary.R;
15 | import com.necistudio.libarary.item.Document;
16 |
17 | import java.util.List;
18 |
19 | /**
20 | * Created by vim on 01/03/17.
21 | */
22 |
23 | public class FilePickerAdapter extends RecyclerView.Adapter {
24 | private Context context;
25 | private List feedlist;
26 | private FilePickerActivity activity;
27 | public FilePickerAdapter(Context context, FilePickerActivity activity,Listfeedlist){
28 | this.context = context;
29 | this.activity = activity;
30 | this.feedlist = feedlist;
31 | }
32 | @Override
33 | public FilePickerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
34 | View itemView = LayoutInflater.from(context).inflate(R.layout.item_document, parent, false);
35 | return new FilePickerHolder(itemView);
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(FilePickerHolder holder, int position) {
40 | final Document document = feedlist.get(position);
41 | holder.imgIcon.setImageResource(document.getTypeDrawable());
42 | holder.txtName.setText(document.getTitle());
43 | holder.txtSize.setText(Formatter.formatShortFileSize(context, Long.parseLong(document.getSize())));
44 | holder.txtPath.setText(document.getPath());
45 |
46 | holder.relativeMain.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View v) {
49 | activity.finishData(document.getPath());
50 | }
51 | });
52 | }
53 |
54 | @Override
55 | public int getItemCount() {
56 | return feedlist.size();
57 | }
58 |
59 | public class FilePickerHolder extends RecyclerView.ViewHolder {
60 | ImageView imgIcon;
61 | TextView txtName,txtSize,txtPath;
62 | RelativeLayout relativeMain;
63 | public FilePickerHolder(View itemView) {
64 | super(itemView);
65 | imgIcon = (ImageView) itemView.findViewById(R.id.imgIcon);
66 | txtName = (TextView) itemView.findViewById(R.id.txtName);
67 | txtSize = (TextView) itemView.findViewById(R.id.txtSize);
68 | txtPath = (TextView) itemView.findViewById(R.id.txtPath);
69 | relativeMain = (RelativeLayout)itemView.findViewById(R.id.relativeMain);
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/adapter/FilterAdapter.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.necistudio.libarary.R;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * Created by vim on 01/03/17.
16 | */
17 |
18 | public class FilterAdapter extends RecyclerView.Adapter{
19 | private Context context;
20 | private List itemlist;
21 | public FilterAdapter(Context context,List itemlist){
22 | this.context=context;
23 | this.itemlist=itemlist;
24 | }
25 | @Override
26 | public FilterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
27 | View itemView = LayoutInflater.from(context).inflate(R.layout.item_filter, parent, false);
28 | return new FilterHolder(itemView);
29 | }
30 |
31 | @Override
32 | public void onBindViewHolder(FilterHolder holder, int position) {
33 | String filter = itemlist.get(position);
34 | holder.txtName.setText(filter);
35 | }
36 |
37 | @Override
38 | public int getItemCount() {
39 | return itemlist.size();
40 | }
41 |
42 | public class FilterHolder extends RecyclerView.ViewHolder{
43 | TextView txtName;
44 | public FilterHolder(View itemView) {
45 | super(itemView);
46 | txtName = (TextView)itemView.findViewById(R.id.txtName);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/cursors/DocScannerTask.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.cursors;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 | import android.os.AsyncTask;
6 | import android.provider.MediaStore;
7 | import android.text.TextUtils;
8 | import android.util.Log;
9 |
10 | import com.necistudio.libarary.cursors.loadercallback.FileResultCallback;
11 | import com.necistudio.libarary.item.Document;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import static android.provider.BaseColumns._ID;
17 | import static android.provider.MediaStore.MediaColumns.DATA;
18 |
19 | /**
20 | * Created by droidNinja on 01/08/16.
21 | */
22 | public class DocScannerTask extends AsyncTask> {
23 |
24 | final String[] DOC_PROJECTION = {
25 | MediaStore.Images.Media._ID,
26 | MediaStore.Images.Media.DATA,
27 | MediaStore.Files.FileColumns.MIME_TYPE,
28 | MediaStore.Files.FileColumns.SIZE,
29 | MediaStore.Images.Media.DATE_ADDED,
30 | MediaStore.Files.FileColumns.TITLE
31 | };
32 | private final FileResultCallback resultCallback;
33 | List itemfilter;
34 | String[] selectionArgs ;
35 |
36 | private final Context context;
37 |
38 | public DocScannerTask(Context context, FileResultCallback fileResultCallback,List itemfilter)
39 | {
40 | this.context = context;
41 | this.resultCallback = fileResultCallback;
42 | this.itemfilter = itemfilter;
43 | }
44 |
45 | @Override
46 | protected void onPreExecute() {
47 | super.onPreExecute();
48 | if(itemfilter.isEmpty()){
49 | selectionArgs = new String[0];
50 | }else {
51 | selectionArgs = new String[itemfilter.size()-1];
52 | for(int a=0;a doInBackground(Void... voids) {
60 | ArrayList documents = new ArrayList<>();
61 | final String[] projection = DOC_PROJECTION;
62 | final Cursor cursor = context.getContentResolver().query(MediaStore.Files.getContentUri("external"),
63 | projection,
64 | null,
65 | null,
66 | MediaStore.Files.FileColumns.DATE_ADDED + " DESC");
67 |
68 | if(cursor!=null) {
69 | documents = getDocumentFromCursor(cursor);
70 | cursor.close();
71 | }
72 |
73 |
74 | return documents;
75 | }
76 |
77 | @Override
78 | protected void onPostExecute(List documents) {
79 | super.onPostExecute(documents);
80 | if (resultCallback != null) {
81 | resultCallback.onResultCallback(documents);
82 | }
83 | }
84 |
85 | private ArrayList getDocumentFromCursor(Cursor data)
86 | {
87 | ArrayList documents = new ArrayList<>();
88 | while (data.moveToNext()) {
89 |
90 | int imageId = data.getInt(data.getColumnIndexOrThrow(_ID));
91 | String path = data.getString(data.getColumnIndexOrThrow(DATA));
92 | String title = data.getString(data.getColumnIndexOrThrow(MediaStore.Files.FileColumns.TITLE));
93 |
94 | if(path!=null && contains(selectionArgs,path)) {
95 | Document document = new Document(imageId, title, path);
96 |
97 | String mimeType = data.getString(data.getColumnIndexOrThrow(MediaStore.Files.FileColumns.MIME_TYPE));
98 | if (mimeType != null && !TextUtils.isEmpty(mimeType))
99 | document.setMimeType(mimeType);
100 | else
101 | {
102 | document.setMimeType("");
103 | }
104 |
105 | document.setSize(data.getString(data.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE)));
106 |
107 | if (!documents.contains(document))
108 | documents.add(document);
109 | }
110 | }
111 |
112 | return documents;
113 | }
114 |
115 | boolean contains(String[] types, String path) {
116 | for (String string : types) {
117 | if (path.endsWith(string)) return true;
118 | }
119 | return false;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/cursors/loadercallback/FileResultCallback.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.cursors.loadercallback;
2 |
3 | import java.util.List;
4 |
5 | public interface FileResultCallback {
6 | void onResultCallback(List files);
7 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/item/BaseFile.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.item;
2 |
3 |
4 | import com.necistudio.libarary.utils.Utils;
5 |
6 | /**
7 | * Created by droidNinja on 29/07/16.
8 | */
9 | public class BaseFile {
10 | protected int id;
11 | protected String name;
12 | protected String path;
13 |
14 | public BaseFile(int id, String name, String path) {
15 | this.id = id;
16 | this.name = name;
17 | this.path = path;
18 | }
19 |
20 |
21 | @Override
22 | public boolean equals(Object o) {
23 | if (this == o) return true;
24 | if (!(o instanceof BaseFile)) return false;
25 |
26 | BaseFile baseFile = (BaseFile) o;
27 |
28 | return id == baseFile.id;
29 | }
30 |
31 | public String getPath() {
32 | return path;
33 | }
34 |
35 | public void setPath(String path) {
36 | this.path = path;
37 | }
38 |
39 | public int getId() {
40 | return id;
41 | }
42 |
43 | public void setId(int id) {
44 | this.id = id;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/item/Document.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.item;
2 |
3 | import android.text.TextUtils;
4 |
5 | import com.necistudio.libarary.R;
6 | import com.necistudio.libarary.utils.FilePickerConst;
7 | import com.necistudio.libarary.utils.Utils;
8 |
9 | import java.io.File;
10 |
11 |
12 | /**
13 | * Created by droidNinja on 29/07/16.
14 | */
15 | public class Document extends BaseFile {
16 | private String mimeType;
17 | private String size;
18 |
19 | public Document(int id, String title, String path) {
20 | super(id,title,path);
21 | }
22 |
23 | public Document() {
24 | super(0,null,null);
25 | }
26 |
27 | @Override
28 | public boolean equals(Object o) {
29 | if (this == o) return true;
30 | if (!(o instanceof Document)) return false;
31 |
32 | Document document = (Document) o;
33 |
34 | return id == document.id;
35 | }
36 |
37 | @Override
38 | public int hashCode() {
39 | return id;
40 | }
41 |
42 | public String getPath() {
43 | return path;
44 | }
45 |
46 | public void setPath(String path) {
47 | this.path = path;
48 | }
49 |
50 | public int getId() {
51 | return id;
52 | }
53 |
54 | public void setId(int id) {
55 | this.id = id;
56 | }
57 |
58 | public String getMimeType() {
59 | return mimeType;
60 | }
61 |
62 | public void setMimeType(String mimeType) {
63 | this.mimeType = mimeType;
64 | }
65 |
66 | public String getSize() {
67 | return size;
68 | }
69 |
70 | public void setSize(String size) {
71 | this.size = size;
72 | }
73 |
74 | public String getTitle() {
75 | return new File(this.path).getName();
76 | }
77 |
78 | public void setTitle(String title) {
79 | this.name = title;
80 | }
81 |
82 | public int getTypeDrawable()
83 | {
84 | if(getFileType()== FilePickerConst.FILE_TYPE.EXCEL)
85 | return R.drawable.ic_excel;
86 | if(getFileType()== FilePickerConst.FILE_TYPE.WORD)
87 | return R.drawable.ic_word;
88 | if(getFileType()== FilePickerConst.FILE_TYPE.PPT)
89 | return R.drawable.ic_ppt;
90 | if(getFileType()== FilePickerConst.FILE_TYPE.PDF)
91 | return R.drawable.ic_pdf;
92 | if(getFileType()== FilePickerConst.FILE_TYPE.TXT)
93 | return R.drawable.ic_txt;
94 | else
95 | return R.drawable.ic_txt;
96 | }
97 |
98 | public boolean isThisType(FilePickerConst.FILE_TYPE type)
99 | {
100 | if(getFileType() == type)
101 | return true;
102 |
103 | return false;
104 | }
105 |
106 | public FilePickerConst.FILE_TYPE getFileType()
107 | {
108 | String fileExtension = Utils.getFileExtension(new File(this.path));
109 | if(TextUtils.isEmpty(fileExtension))
110 | return FilePickerConst.FILE_TYPE.UNKNOWN;
111 | if(isExcelFile())
112 | return FilePickerConst.FILE_TYPE.EXCEL;
113 | if(isDocFile())
114 | return FilePickerConst.FILE_TYPE.WORD;
115 | if(isPPTFile())
116 | return FilePickerConst.FILE_TYPE.PPT;
117 | if(isPDFFile())
118 | return FilePickerConst.FILE_TYPE.PDF;
119 | if(isTxtFile())
120 | return FilePickerConst.FILE_TYPE.TXT;
121 | else
122 | return FilePickerConst.FILE_TYPE.UNKNOWN;
123 | }
124 |
125 | public boolean isExcelFile()
126 | {
127 | String[] types = {"xls","xlsx"};
128 | return Utils.contains(types, this.path);
129 | }
130 |
131 | public boolean isDocFile()
132 | {
133 | String[] types = {"doc","docx", "dot","dotx"};
134 | return Utils.contains(types, this.path);
135 | }
136 |
137 | public boolean isPPTFile()
138 | {
139 | String[] types = {"ppt","pptx"};
140 | return Utils.contains(types, this.path);
141 | }
142 |
143 | public boolean isPDFFile()
144 | {
145 | String[] types = {"pdf"};
146 | return Utils.contains(types, this.path);
147 | }
148 |
149 | public boolean isTxtFile()
150 | {
151 | String[] types = {"txt"};
152 | return Utils.contains(types, this.path);
153 | }
154 |
155 | }
156 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/utils/FilePickerConst.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.utils;
2 |
3 | /**
4 | * Created by droidNinja on 28/07/16.
5 | */
6 | public class FilePickerConst {
7 | public static final int REQUEST_CODE_PHOTO = 233;
8 | public static final int REQUEST_CODE_DOC = 234;
9 |
10 |
11 | public final static int DEFAULT_MAX_COUNT = 9;
12 | public final static int DEFAULT_COLUMN_NUMBER = 3;
13 |
14 | public final static int PHOTO_PICKER = 0x11;
15 | public final static int DOC_PICKER = 0x12;
16 |
17 | public final static String KEY_SELECTED_PHOTOS = "SELECTED_PHOTOS";
18 | public final static String KEY_SELECTED_DOCS = "SELECTED_DOCS";
19 |
20 | public final static String EXTRA_PICKER_TYPE = "EXTRA_PICKER_TYPE";
21 | public final static String EXTRA_SHOW_GIF = "SHOW_GIF";
22 | public final static String PPT_MIME_TYPE = "application/mspowerpoint";
23 |
24 |
25 |
26 | public enum FILE_TYPE{
27 | PDF,
28 | WORD,
29 | EXCEL,
30 | PPT,
31 | TXT,
32 | UNKNOWN
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/utils/MediaStoreHelper.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.utils;
2 |
3 | import android.support.v4.app.FragmentActivity;
4 |
5 | import com.necistudio.libarary.cursors.DocScannerTask;
6 | import com.necistudio.libarary.cursors.loadercallback.FileResultCallback;
7 | import com.necistudio.libarary.item.Document;
8 |
9 | import java.util.List;
10 |
11 | public class MediaStoreHelper {
12 |
13 | public static void getDocs(FragmentActivity activity, List itemfilter, FileResultCallback fileResultCallback)
14 | {
15 | new DocScannerTask(activity,fileResultCallback,itemfilter).execute();
16 | }
17 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/utils/PermissionUtils.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.utils;
2 |
3 | /**
4 | * Created by Jarcode on 2016-02-24.
5 | */
6 | import android.app.Activity;
7 | import android.content.pm.PackageManager;
8 | import android.support.v4.app.ActivityCompat;
9 | import android.support.v4.content.ContextCompat;
10 |
11 | import java.util.ArrayList;
12 |
13 | public class PermissionUtils {
14 | public static boolean requestPermission(Activity activity, int requestCode, String... permissions) {
15 | boolean granted = true;
16 | ArrayList permissionsNeeded = new ArrayList<>();
17 |
18 | for (String s : permissions) {
19 | int permissionCheck = ContextCompat.checkSelfPermission(activity, s);
20 | boolean hasPermission = (permissionCheck == PackageManager.PERMISSION_GRANTED);
21 | granted &= hasPermission;
22 | if (!hasPermission) {
23 | permissionsNeeded.add(s);
24 | }
25 | }
26 |
27 | if (granted) {
28 | return true;
29 | } else {
30 | ActivityCompat.requestPermissions(activity,
31 | permissionsNeeded.toArray(new String[permissionsNeeded.size()]),
32 | requestCode);
33 | return false;
34 | }
35 | }
36 |
37 |
38 | public static boolean permissionGranted(int requestCode, int permissionCode, int[] grantResults) {
39 | if (requestCode == permissionCode) {
40 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
41 | return true;
42 | } else {
43 | return false;
44 | }
45 | }
46 | return false;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.utils;
2 |
3 | import com.android.internal.util.Predicate;
4 |
5 | import java.io.File;
6 | import java.util.ArrayList;
7 | import java.util.Collection;
8 |
9 | /**
10 | * Created by droidNinja on 29/07/16.
11 | */
12 | public class Utils {
13 |
14 | public static Collection filter(Collection target, Predicate predicate) {
15 | Collection result = new ArrayList();
16 | for (T element: target) {
17 | if (predicate.apply(element)) {
18 | result.add(element);
19 | }
20 | }
21 | return result;
22 | }
23 |
24 | public static String getFileExtension(File file) {
25 | String name = file.getName();
26 | try {
27 | return name.substring(name.lastIndexOf(".") + 1);
28 | } catch (Exception e) {
29 | return "";
30 | }
31 | }
32 |
33 | public static boolean contains(String[] types, String path) {
34 | for (String string : types) {
35 | if (path.toLowerCase().endsWith(string)) return true;
36 | }
37 | return false;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/com/necistudio/libarary/view/FilterFragment.java:
--------------------------------------------------------------------------------
1 | package com.necistudio.libarary.view;
2 |
3 | import android.app.DialogFragment;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.Gravity;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.view.Window;
15 | import android.view.WindowManager;
16 | import android.widget.Button;
17 | import android.widget.EditText;
18 |
19 | import com.necistudio.libarary.FilePickerActivity;
20 | import com.necistudio.libarary.R;
21 | import com.necistudio.libarary.adapter.FilterAdapter;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | /**
27 | * Created by vim on 01/03/17.
28 | */
29 |
30 | public class FilterFragment extends DialogFragment {
31 | private Button btnAdd, btnClear;
32 | private EditText editAdd;
33 | private RecyclerView recyclerView;
34 | private FilterAdapter adapter;
35 | private List itemfilter;
36 |
37 | public static FilterFragment newInstance(ArrayList itemfilter) {
38 | Bundle args = new Bundle();
39 | args.putStringArrayList("filter", itemfilter);
40 | FilterFragment fragment = new FilterFragment();
41 | fragment.setArguments(args);
42 | return fragment;
43 | }
44 |
45 | @Override
46 | public void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | itemfilter = getArguments().getStringArrayList("filter");
49 |
50 | }
51 |
52 | @Override
53 | public void onStart() {
54 | super.onStart();
55 | getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
56 | getDialog().setCanceledOnTouchOutside(true);
57 | }
58 |
59 | @Override
60 | public void onActivityCreated(Bundle savedInstanceState) {
61 | super.onActivityCreated(savedInstanceState);
62 | WindowManager.LayoutParams params = getDialog().getWindow()
63 | .getAttributes();
64 | params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
65 | Window window = getDialog().getWindow();
66 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
67 | getDialog().getWindow().setAttributes(params);
68 | }
69 |
70 | @Nullable
71 | @Override
72 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
73 | View view = inflater.inflate(R.layout.fragmentfilter, container, false);
74 | btnAdd = (Button) view.findViewById(R.id.btnAdd);
75 | editAdd = (EditText) view.findViewById(R.id.editAdd);
76 | recyclerView = (RecyclerView) view.findViewById(R.id.recycleMain);
77 | btnClear = (Button) view.findViewById(R.id.btnClear);
78 | return view;
79 | }
80 |
81 | @Override
82 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
83 | super.onViewCreated(view, savedInstanceState);
84 | adapter = new FilterAdapter(getActivity(), itemfilter);
85 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
86 | recyclerView.setAdapter(adapter);
87 |
88 | btnAdd.setOnClickListener(new View.OnClickListener() {
89 | @Override
90 | public void onClick(View v) {
91 | if (!editAdd.getText().toString().matches("")) {
92 | itemfilter.add("." + editAdd.getText().toString());
93 | adapter.notifyDataSetChanged();
94 | ((FilePickerActivity) getActivity()).getDocument();
95 | getDialog().dismiss();
96 | } else {
97 | editAdd.setError("Empty Filter");
98 | }
99 | }
100 | });
101 | btnClear.setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View v) {
104 | itemfilter.clear();
105 | ((FilePickerActivity) getActivity()).getDocument();
106 | getDialog().dismiss();
107 | }
108 | });
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_excel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/drawable/ic_excel.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_pdf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/drawable/ic_pdf.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_ppt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/drawable/ic_ppt.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_txt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/drawable/ic_txt.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_word.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/drawable/ic_word.png
--------------------------------------------------------------------------------
/library/src/main/res/layout/activitymain.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
21 |
22 |
23 |
24 |
28 |
29 |
37 |
38 |
42 |
43 |
44 |
52 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/fragmentfilter.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
17 |
18 |
25 |
32 |
33 |
34 |
38 |
39 |
45 |
46 |
47 |
51 |
52 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/item_document.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
28 |
29 |
39 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/item_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-hdpi/ic_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/mipmap-hdpi/ic_create.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-mdpi/ic_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/mipmap-mdpi/ic_create.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xhdpi/ic_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/mipmap-xhdpi/ic_create.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxhdpi/ic_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/mipmap-xxhdpi/ic_create.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxxhdpi/ic_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aerdy/Android-FilePickerFilterLibrary/625edfb82be6c2787b3e159ad25d141d5c964b52/library/src/main/res/mipmap-xxxhdpi/ic_create.png
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #9100ca
4 | #5d0081
5 | #47c100
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/values/layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | \
14 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | libarary
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':appsample', ':library'
2 |
--------------------------------------------------------------------------------