Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #12 from mustafa-nimir/master
Browse files Browse the repository at this point in the history
use FileProvider to be compatible with android N API 24
  • Loading branch information
alhazmy13 authored Sep 11, 2016
2 parents c59af6a + a46f643 commit c6be482
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
29 changes: 14 additions & 15 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.daemon=true

# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

android.useDeprecatedNdk=true
# org.gradle.parallel=true
#Sat Sep 10 13:03:48 EAT 2016
libVersion=2.2.2
systemProp.http.proxyHost=127.0.0.1
isDubgMode=true
org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
org.gradle.daemon=true
org.gradle.parallel=true
systemProp.http.proxyPort=9050
android.useDeprecatedNdk=true
9 changes: 9 additions & 0 deletions libary/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<activity android:name="net.alhazmy13.mediapicker.Video.VideoActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Translucent"/>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;
Expand Down Expand Up @@ -145,7 +146,7 @@ private void startActivityFromGalleryMultiImg() {
private void startActivityFromCamera() {
mImgConfig.isImgFromCamera = true;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
mImageUri = Uri.fromFile(destination);
mImageUri = FileProvider.getUriForFile(this, this.getApplicationContext().getPackageName() + ".provider", destination);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), ImageTags.IntentCode.CAMERA_REQUEST);
if (mImgConfig.debug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;
Expand Down Expand Up @@ -109,7 +110,7 @@ private void startActivityFromGallery() {

private void startActivityFromCamera() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
mVideoUri = Uri.fromFile(destination);
mVideoUri = FileProvider.getUriForFile(this, this.getApplicationContext().getPackageName() + ".provider", destination);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
startActivityForResult(intent, CAMERA_REQUEST);
}
Expand Down
4 changes: 4 additions & 0 deletions libary/src/main/res/xml/provider_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<path xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</path>

0 comments on commit c6be482

Please sign in to comment.