Merge pull request #39 from ckin-it/master

Adding Android constants
This commit is contained in:
cjdell 2016-01-05 12:29:15 +00:00
commit 88515c13bc
3 changed files with 7 additions and 1 deletions

View File

@ -177,7 +177,8 @@ var RNFS = {
MainBundlePath: RNFSManager.MainBundlePath,
CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath,
DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath,
LibraryDirectoryPath: RNFSManager.NSLibraryDirectoryPath
LibraryDirectoryPath: RNFSManager.NSLibraryDirectoryPath,
PicturesDirectoryPath: RNFSManager.NSPicturesDirectoryPath
};
module.exports = RNFS;

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rnfs" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

View File

@ -38,6 +38,8 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
public class RNFSManager extends ReactContextBaseJavaModule {
private static final String NSDocumentDirectoryPath = "NSDocumentDirectoryPath";
private static final String NSPicturesDirectoryPath = "NSPicturesDirectoryPath";
private static final String NSCachesDirectoryPath = "NSCachesDirectoryPath";
private static final String NSDocumentDirectory = "NSDocumentDirectory";
private static final String NSFileTypeRegular = "NSFileTypeRegular";
@ -281,6 +283,8 @@ public class RNFSManager extends ReactContextBaseJavaModule {
final Map<String, Object> constants = new HashMap<>();
constants.put(NSDocumentDirectory, 0);
constants.put(NSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath());
constants.put(NSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
constants.put(NSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath());
constants.put(NSFileTypeRegular, 0);
constants.put(NSFileTypeDirectory, 1);
return constants;