├── .gitignore
├── .travis.yml
├── LICENSE.md
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── resource-file-provider
├── .gitignore
├── build.gradle
├── distribution.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── it
│ │ └── federicoboschini
│ │ └── resourcefileprovider
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── it
│ │ │ └── federicoboschini
│ │ │ └── resourcefileprovider
│ │ │ └── ResourceFileProvider.java
│ └── res
│ │ ├── values
│ │ └── strings.xml
│ │ └── xml
│ │ └── file_provider_paths.xml
│ └── test
│ └── java
│ └── it
│ └── federicoboschini
│ └── resourcefileprovider
│ └── ExampleUnitTest.java
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── it
│ │ └── federicoboschini
│ │ └── fileprovidersample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── loremipsum.pdf
│ │ ├── pokeflute.png
│ │ ├── yee.mp3
│ │ └── yee_video.mp4
│ ├── java
│ │ └── it
│ │ │ └── federicoboschini
│ │ │ └── fileprovidersample
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ └── pokeflute.png
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── 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
│ │ ├── raw
│ │ ├── loremipsum.pdf
│ │ ├── pokeflute.png
│ │ ├── yee.mp3
│ │ └── yee_video.mp4
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── it
│ └── federicoboschini
│ └── fileprovidersample
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Log Files
26 | *.log
27 |
28 | # Android Studio Navigation editor temp files
29 | .navigation/
30 |
31 | # Android Studio captures folder
32 | captures/
33 |
34 | \.idea/
35 |
36 | *.iml
37 |
38 | resource-file-provider/secrets\.properties
39 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | env:
3 | - BINTRAY_USER=xxxxUSERxxxx BINTRAY_APIKEY=xxxxAPIKEYxxxx
4 | android:
5 | components:
6 | - platform-tools
7 | - build-tools-28.0.3
8 | - android-28
9 | - extra-android-m2repository
10 | before_script:
11 | - mkdir "$ANDROID_HOME/licenses" || true
12 | - echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
13 | script:
14 | - ./gradlew resource-file-provider:check
15 | before_install:
16 | - chmod +x gradlew
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 |
2 | The MIT License (MIT)
3 |
4 | Copyright (c) 2018
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android Resource File Provider
2 |
3 | [](https://developer.android.com/about/dashboards/index.html#Platform)
4 | [](LICENSE.md)
5 | [](https://android-arsenal.com/details/1/7485)
6 | [](https://travis-ci.org/federicoboschini/Android-Resource-File-Provider)
7 |
8 | Easily share audio, video, image and document files from `raw`, `assets` and `drawable` folders **without any specific permission**.
9 |
10 | ## Installation
11 |
12 | Include the dependency in your app `build.gradle` file:
13 |
14 | ```groovy
15 | implementation 'it.federicoboschini:resource-file-provider:1.0.0'
16 | ```
17 |
18 | If you are experiencing any issue with resource merging or support-library compatibility add the dependency excluding `com.android.support`:
19 |
20 | ```groovy
21 | implementation('it.federicoboschini:resource-file-provider:1.0.0') {
22 | exclude group: 'com.android.support'
23 | }
24 | ```
25 |
26 | ## Configuration
27 |
28 | Add this to your app `AndroidManifest.xml`:
29 |
30 | ```xml
31 |
32 |
33 |
38 |
41 |
42 |
43 |
44 | ```
45 |
46 | **Optional** Add this (provider authority) to your app `strings.xml`:
47 |
48 | ```xml
49 |
50 |
51 | it.my_company.my_app.my_authority
52 |
53 |
54 | ```
55 |
56 | **Optional** Define custom file paths by creating a `file_provider_paths` in `res/xml`:
57 |
58 | ```xml
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | ```
68 |
69 | ## Example: share a mp3 file
70 |
71 | ```java
72 | try {
73 | ResourceFileProvider.Builder
74 | .from(this)
75 | .setDirectory(FOLDER_RAW)
76 | .setFileName("my_sound")
77 | .setFileExtension("mp3")
78 | .setFileType(TYPE_AUDIO)
79 | .build()
80 | .shareFile();
81 | } catch (FileNotFoundException e) {
82 | e.printStackTrace();
83 | }
84 | ```
85 |
86 | ***Note:*** `setFileName` parameter is **without** the extension.
87 |
88 | ### Current supported and tested extensions:
89 |
90 | * `.mp3`
91 | * `.jpg`
92 | * `.png`
93 | * `.pdf`
94 | * `.mp4`
95 |
96 | ### Current supported and tested folders:
97 |
98 | * `drawable`
99 | * `raw`
100 | * `assets`
101 |
102 | ***Note:*** if your project contains density-dependent drawables, the nearest to the device density will be selected.
103 |
104 | ### Known issues:
105 |
106 | * Can't get images from `mipmap` folder.
107 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.3.0'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
12 |
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | maven {
24 | url "https://dl.bintray.com/boschini/android-libraries"
25 | }
26 | }
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jan 22 22:09:02 CET 2019
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-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/resource-file-provider/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/resource-file-provider/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.jfrog.bintray' version '1.7.3'
3 | id 'com.novoda.build-properties' version '0.4.1'
4 | }
5 |
6 | apply plugin: 'com.android.library'
7 | apply plugin: 'com.jfrog.bintray'
8 | apply plugin: 'com.github.dcendents.android-maven'
9 | apply plugin: 'com.novoda.build-properties'
10 | apply from: 'distribution.gradle'
11 |
12 | android {
13 | compileSdkVersion 28
14 |
15 | defaultConfig {
16 | minSdkVersion 14
17 | targetSdkVersion 28
18 | versionCode 0
19 | versionName version
20 |
21 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
22 |
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 |
32 | }
33 |
34 | dependencies {
35 | implementation fileTree(dir: 'libs', include: ['*.jar'])
36 |
37 | api 'com.android.support:appcompat-v7:28.0.0'
38 |
39 | testImplementation 'junit:junit:4.12'
40 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
41 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
42 | }
43 |
--------------------------------------------------------------------------------
/resource-file-provider/distribution.gradle:
--------------------------------------------------------------------------------
1 | buildProperties {
2 | secrets {
3 | using project.file('secrets.properties')
4 | }
5 | env {
6 | using System.getenv()
7 | }
8 | }
9 |
10 | /*
11 | * Gets the version name from the latest Git tag
12 | */
13 | def getVersionName = {
14 | def stdout = new ByteArrayOutputStream()
15 | try {
16 | exec {
17 | commandLine 'git', 'describe', '--tags', '--abbrev=0'
18 | standardOutput = stdout
19 | }
20 | return stdout.toString().trim()
21 | }
22 | catch (e) {
23 | println("Can't get version from git: " + e)
24 | return "adhoc"
25 | }
26 | }
27 | allprojects {
28 | version = "${getVersionName()}"
29 | }
30 |
31 | /*
32 | * Performs clean, build, maven install and publish on Bintray
33 | */
34 | task cleanBuildInstallPublish {
35 | dependsOn 'clean'
36 | dependsOn 'build'
37 | dependsOn 'install'
38 | dependsOn 'bintrayUpload'
39 | tasks.findByName('build').mustRunAfter 'clean'
40 | tasks.findByName('install').mustRunAfter 'build'
41 | tasks.findByName('bintrayUpload').mustRunAfter 'install'
42 | }
43 | configure(cleanBuildInstallPublish) {
44 | group = 'Publishing'
45 | description = 'Cleans, builds, creates artifact and uploads to bintray'
46 | }
47 |
48 | /*
49 | * Upload to Bintray
50 | */
51 | task sourcesJar(type: Jar) {
52 | from android.sourceSets.main.java.srcDirs
53 | classifier = 'sources'
54 | }
55 | artifacts {
56 | archives sourcesJar
57 | }
58 |
59 | group = 'it.federicoboschini'
60 |
61 | bintray {
62 | user = (buildProperties.secrets['bintray.user'] | buildProperties.env['BINTRAY_USER']).string
63 | key = (buildProperties.secrets['bintray.apikey'] | buildProperties.env['BINTRAY_APIKEY']).string
64 | configurations = ['archives']
65 |
66 | pkg {
67 | repo = 'android-libraries'
68 | name = 'it.federicoboschini:resource-file-provider'
69 | vcsUrl = 'https://github.com/federicoboschini/Android-Resource-File-Provider'
70 | websiteUrl = 'https://federicoboschini.it'
71 | licenses = ['MIT']
72 | publish = true
73 | }
74 | }
--------------------------------------------------------------------------------
/resource-file-provider/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/resource-file-provider/src/androidTest/java/it/federicoboschini/resourcefileprovider/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package it.federicoboschini.resourcefileprovider;
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 | * Instrumented 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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("it.federicoboschini.androidresourcefileprovider.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/resource-file-provider/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/resource-file-provider/src/main/java/it/federicoboschini/resourcefileprovider/ResourceFileProvider.java:
--------------------------------------------------------------------------------
1 | package it.federicoboschini.resourcefileprovider;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.res.AssetManager;
7 | import android.net.Uri;
8 | import android.support.annotation.NonNull;
9 | import android.support.v4.app.ShareCompat;
10 | import android.support.v4.content.FileProvider;
11 | import android.util.Log;
12 |
13 | import java.io.File;
14 | import java.io.FileNotFoundException;
15 | import java.io.FileOutputStream;
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.util.IllegalFormatException;
19 |
20 | import it.federicoboschini.androidresourcefileprovider.R;
21 |
22 | /**
23 | * @author Federico Boschini
24 | */
25 | public class ResourceFileProvider {
26 |
27 | private static final String TAG = "ResourceFileProvider";
28 |
29 | private static final String ANDROID_RES_URI = "android.resource://%1$s/%2$s";
30 |
31 | public static final String FOLDER_RAW = "raw";
32 | public static final String FOLDER_DRAWABLE = "drawable";
33 | public static final String FOLDER_MIPMAP = "mipmap";
34 | public static final String FOLDER_ASSETS = "assets";
35 |
36 | public static final String TYPE_AUDIO = "audio/*";
37 | public static final String TYPE_IMAGE = "image/*";
38 | public static final String TYPE_VIDEO = "video/*";
39 | public static final String TYPE_PDF = "application/pdf";
40 |
41 | private final Activity activity;
42 | private final String directory;
43 | private final String fileName;
44 | private final String fileExtension;
45 | private final String fileType;
46 |
47 | private ResourceFileProvider(@NonNull Activity activity, @NonNull String directory, @NonNull String fileName, @NonNull String fileExtension, @NonNull String fileType) {
48 | this.activity = activity;
49 | this.directory = directory;
50 | this.fileName = fileName;
51 | this.fileExtension = fileExtension;
52 | this.fileType = fileType;
53 | }
54 |
55 | /**
56 | * Given the {@link Builder} parameters, retrieves the file. Automatically starts a "share" Intent.
57 | * @throws FileNotFoundException if can't find the file.
58 | */
59 | public void shareFile() throws FileNotFoundException {
60 | int resId = activity.getResources().getIdentifier(fileName, directory, activity.getPackageName());
61 | InputStream inputStream = null;
62 | if (isValidResId(resId)) {
63 | switch (directory) {
64 | case FOLDER_RAW:
65 | inputStream = activity.getResources().openRawResource(resId);
66 | break;
67 | case FOLDER_MIPMAP:
68 | case FOLDER_DRAWABLE:
69 | Uri fileUri;
70 | try {
71 | fileUri = Uri.parse(String.format(ANDROID_RES_URI, activity.getPackageName(), resId));
72 | } catch (IllegalFormatException e) {
73 | throw new FileNotFoundException();
74 | }
75 | if (fileUri != null) {
76 | inputStream = activity.getContentResolver().openInputStream(fileUri);
77 | }
78 | break;
79 | default:
80 | inputStream = activity.getResources().openRawResource(resId);
81 | break;
82 | }
83 | prepareAndShare(inputStream);
84 | } else {
85 | if (directory.equals(FOLDER_ASSETS)) {
86 | AssetManager assetManager = activity.getAssets();
87 | try {
88 | inputStream = assetManager.open(fileName.concat(".").concat(fileExtension));
89 | } catch (IOException e) {
90 | e.printStackTrace();
91 | throw new FileNotFoundException();
92 | }
93 | prepareAndShare(inputStream);
94 | } else {
95 | throw new FileNotFoundException();
96 | }
97 | }
98 | }
99 |
100 | private void prepareAndShare(InputStream inputStream) {
101 | try {
102 | byte[] buff = new byte[1024];
103 | int len;
104 | FileOutputStream outputStream = activity.openFileOutput(fileName.concat(".").concat(fileExtension), Context.MODE_PRIVATE);
105 | if (inputStream != null) {
106 | while ((len = inputStream.read(buff)) > 0) {
107 | outputStream.write(buff, 0, len);
108 | }
109 | inputStream.close();
110 | }
111 | outputStream.close();
112 | } catch (IOException e) {
113 | Log.e(TAG, e.getLocalizedMessage());
114 | }
115 |
116 | Uri uri = FileProvider.getUriForFile(activity, activity.getResources().getString(R.string.rfp_provider_authority), new File(activity.getFilesDir(), fileName.concat(".").concat(fileExtension)));
117 |
118 | Intent intent = ShareCompat.IntentBuilder.from(activity).getIntent();
119 | intent.setAction(Intent.ACTION_SEND);
120 | intent.setType(fileType);
121 | intent.putExtra(Intent.EXTRA_STREAM, uri);
122 | intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
123 |
124 | if (intent.resolveActivity(activity.getPackageManager()) != null) {
125 | activity.startActivity(intent);
126 | }
127 | }
128 |
129 | private boolean isValidResId(int resId) {
130 | return resId != 0;
131 | }
132 |
133 | /**
134 | * Builder class: the entry point of this tool.
135 | */
136 | public static class Builder {
137 | private final Activity activity;
138 | private String directory;
139 | private String fileName;
140 | private String fileExtension;
141 | private String fileType;
142 |
143 | private Builder(Activity activity) {
144 | this.activity = activity;
145 | }
146 |
147 | /**
148 | * @param activity a valid Activity used as Context and to start the "share" Intent
149 | * @return the Builder itself.
150 | */
151 | public static Builder from(@NonNull Activity activity) {
152 | return new Builder(activity);
153 | }
154 |
155 | /**
156 | * Set the directory where the file is stored.
157 | * @param directory a String representing the directory. Consider using one of the following
158 | * {@link ResourceFileProvider#FOLDER_ASSETS}
159 | * {@link ResourceFileProvider#FOLDER_RAW}
160 | * {@link ResourceFileProvider#FOLDER_DRAWABLE}
161 | * @return the Builder itself.
162 | */
163 | public Builder setDirectory(@NonNull String directory) {
164 | this.directory = directory;
165 | return this;
166 | }
167 |
168 | /**
169 | * Set the file name.
170 | * @param fileName the filename as a String, WITHOUT any extension, see {@link Builder#setFileExtension(String)}.
171 | * @return the Builder itself.
172 | */
173 | public Builder setFileName(@NonNull String fileName) {
174 | this.fileName = fileName;
175 | return this;
176 | }
177 |
178 | /**
179 | * Set the file extension.
180 | * @param fileExtension the extension as a String, WITHOUT the point.
181 | * @return the Builder itself.
182 | */
183 | public Builder setFileExtension(@NonNull String fileExtension) {
184 | this.fileExtension = fileExtension;
185 | return this;
186 | }
187 |
188 | /**
189 | * Set the file type. Used for the "share" intent.
190 | * @param fileType the file type as a String (MIME type). Consider using one of the following
191 | * {@link ResourceFileProvider#TYPE_AUDIO}
192 | * {@link ResourceFileProvider#TYPE_VIDEO}
193 | * {@link ResourceFileProvider#TYPE_IMAGE}
194 | * {@link ResourceFileProvider#TYPE_PDF}
195 | * @return the Builder itself.
196 | */
197 | public Builder setFileType(@NonNull String fileType) {
198 | this.fileType = fileType;
199 | return this;
200 | }
201 |
202 | /**
203 | * Builds the ResourceFileProvider.
204 | * @return the ResourceFileProvider.
205 | */
206 | public ResourceFileProvider build() {
207 | return new ResourceFileProvider(activity, directory, fileName, fileExtension, fileType);
208 | }
209 | }
210 |
211 |
212 | }
213 |
--------------------------------------------------------------------------------
/resource-file-provider/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | it.federicoboschini.fileprovider
3 |
4 |
--------------------------------------------------------------------------------
/resource-file-provider/src/main/res/xml/file_provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/resource-file-provider/src/test/java/it/federicoboschini/resourcefileprovider/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package it.federicoboschini.resourcefileprovider;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "it.federicoboschini.arfp.sample"
7 | minSdkVersion 14
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 |
24 | //implementation 'it.federicoboschini:resource-file-provider:1.0.0'
25 | implementation project(':resource-file-provider')
26 |
27 | implementation 'com.android.support:appcompat-v7:28.0.0'
28 |
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33 | }
34 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/it/federicoboschini/fileprovidersample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package it.federicoboschini.fileprovidersample;
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 | * Instrumented 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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("it.federicoboschini.androidresourcefileprovider", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
27 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/assets/loremipsum.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/assets/loremipsum.pdf
--------------------------------------------------------------------------------
/sample/src/main/assets/pokeflute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/assets/pokeflute.png
--------------------------------------------------------------------------------
/sample/src/main/assets/yee.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/assets/yee.mp3
--------------------------------------------------------------------------------
/sample/src/main/assets/yee_video.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/assets/yee_video.mp4
--------------------------------------------------------------------------------
/sample/src/main/java/it/federicoboschini/fileprovidersample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package it.federicoboschini.fileprovidersample;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import java.io.FileNotFoundException;
8 |
9 | import it.federicoboschini.resourcefileprovider.ResourceFileProvider;
10 | import it.federicoboschini.arfp.sample.R;
11 |
12 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.FOLDER_ASSETS;
13 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.FOLDER_DRAWABLE;
14 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.FOLDER_MIPMAP;
15 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.FOLDER_RAW;
16 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.TYPE_AUDIO;
17 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.TYPE_IMAGE;
18 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.TYPE_PDF;
19 | import static it.federicoboschini.resourcefileprovider.ResourceFileProvider.TYPE_VIDEO;
20 |
21 | public class MainActivity extends AppCompatActivity {
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | }
28 |
29 | public void shareRawSoundFile(View view) {
30 | try {
31 | ResourceFileProvider.Builder
32 | .from(this)
33 | .setDirectory(FOLDER_RAW)
34 | .setFileName("yee")
35 | .setFileExtension("mp3")
36 | .setFileType(TYPE_AUDIO)
37 | .build()
38 | .shareFile();
39 | } catch (FileNotFoundException e) {
40 | e.printStackTrace();
41 | }
42 | }
43 |
44 | public void shareAssetsSoundFile(View view) {
45 | try {
46 | ResourceFileProvider.Builder
47 | .from(this)
48 | .setDirectory(FOLDER_ASSETS)
49 | .setFileName("yee")
50 | .setFileExtension("mp3")
51 | .setFileType(TYPE_AUDIO)
52 | .build()
53 | .shareFile();
54 | } catch (FileNotFoundException e) {
55 | e.printStackTrace();
56 | }
57 | }
58 |
59 | public void shareAssetsPdfFile(View view) {
60 | try {
61 | ResourceFileProvider.Builder
62 | .from(this)
63 | .setDirectory(FOLDER_ASSETS)
64 | .setFileName("loremipsum")
65 | .setFileExtension("pdf")
66 | .setFileType(TYPE_PDF)
67 | .build()
68 | .shareFile();
69 | } catch (FileNotFoundException e) {
70 | e.printStackTrace();
71 | }
72 | }
73 |
74 | public void shareRawPdfFile(View view) {
75 | try {
76 | ResourceFileProvider.Builder
77 | .from(this)
78 | .setDirectory(FOLDER_RAW)
79 | .setFileName("loremipsum")
80 | .setFileExtension("pdf")
81 | .setFileType(TYPE_PDF)
82 | .build()
83 | .shareFile();
84 | } catch (FileNotFoundException e) {
85 | e.printStackTrace();
86 | }
87 | }
88 |
89 | public void shareRawVideoFile(View view) {
90 | try {
91 | ResourceFileProvider.Builder
92 | .from(this)
93 | .setDirectory(FOLDER_RAW)
94 | .setFileName("yee_video")
95 | .setFileExtension("mp4")
96 | .setFileType(TYPE_VIDEO)
97 | .build()
98 | .shareFile();
99 | } catch (FileNotFoundException e) {
100 | e.printStackTrace();
101 | }
102 | }
103 |
104 | public void shareAssetsVideoFile(View view) {
105 | try {
106 | ResourceFileProvider.Builder
107 | .from(this)
108 | .setDirectory(FOLDER_ASSETS)
109 | .setFileName("yee_video")
110 | .setFileExtension("mp4")
111 | .setFileType(TYPE_VIDEO)
112 | .build()
113 | .shareFile();
114 | } catch (FileNotFoundException e) {
115 | e.printStackTrace();
116 | }
117 | }
118 |
119 | public void shareImageAssets(View view) {
120 | try {
121 | ResourceFileProvider.Builder
122 | .from(this)
123 | .setDirectory(FOLDER_ASSETS)
124 | .setFileName("pokeflute")
125 | .setFileExtension("png")
126 | .setFileType(TYPE_IMAGE)
127 | .build()
128 | .shareFile();
129 | } catch (FileNotFoundException e) {
130 | e.printStackTrace();
131 | }
132 | }
133 |
134 | public void shareImageRaw(View view) {
135 | try {
136 | ResourceFileProvider.Builder
137 | .from(this)
138 | .setDirectory(FOLDER_RAW)
139 | .setFileName("pokeflute")
140 | .setFileExtension("png")
141 | .setFileType(TYPE_IMAGE)
142 | .build()
143 | .shareFile();
144 | } catch (FileNotFoundException e) {
145 | e.printStackTrace();
146 | }
147 | }
148 |
149 | public void shareDrawableFile(View view) {
150 | try {
151 | ResourceFileProvider.Builder
152 | .from(this)
153 | .setDirectory(FOLDER_DRAWABLE)
154 | .setFileName("pokeflute")
155 | .setFileExtension("png")
156 | .setFileType(TYPE_IMAGE)
157 | .build()
158 | .shareFile();
159 | } catch (FileNotFoundException e) {
160 | e.printStackTrace();
161 | }
162 | }
163 |
164 | }
165 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/pokeflute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/drawable/pokeflute.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
21 |
22 |
31 |
32 |
41 |
42 |
51 |
52 |
61 |
62 |
71 |
72 |
81 |
82 |
91 |
92 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/raw/loremipsum.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/raw/loremipsum.pdf
--------------------------------------------------------------------------------
/sample/src/main/res/raw/pokeflute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/raw/pokeflute.png
--------------------------------------------------------------------------------
/sample/src/main/res/raw/yee.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/raw/yee.mp3
--------------------------------------------------------------------------------
/sample/src/main/res/raw/yee_video.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/federicoboschini/Android-Resource-File-Provider/f584432d7d8603c5e7d8514fe84624e818982766/sample/src/main/res/raw/yee_video.mp4
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Resource File Provider Sample
3 | it.my_company.my_app.my_authority
4 | Share sound file (raw)
5 | Share PDF file (raw)
6 | Share video file (raw)
7 | Share sound file (assets)
8 | Share PDF file (assets)
9 | Share video file (assets)
10 | Share image file (assets)
11 | Share image file (raw)
12 | Share image file (drawable)
13 |
14 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/test/java/it/federicoboschini/fileprovidersample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package it.federicoboschini.fileprovidersample;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':resource-file-provider'
2 |
--------------------------------------------------------------------------------