Skip to content

Commit

Permalink
Add WRITE_EXTERNAL_STORAGE for requestStoragePermission method in Fil…
Browse files Browse the repository at this point in the history
…esystem module. (#10442)
  • Loading branch information
ypbnv authored and longton95 committed Nov 20, 2018
1 parent 416b874 commit d758cd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.net.MalformedURLException;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
Expand Down Expand Up @@ -97,12 +98,13 @@ private boolean hasStoragePermissions()
if (Build.VERSION.SDK_INT < 23) {
return true;
}

Context context = TiApplication.getInstance().getApplicationContext();
if (context.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
return true;
}
return false;

return ((context.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED)
&& (context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED));
}

@Kroll.method
Expand All @@ -112,7 +114,8 @@ public void requestStoragePermissions(@Kroll.argument(optional = true) KrollFunc
return;
}

String[] permissions = new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE };
String[] permissions = new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE };
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_EXTERNAL_STORAGE, permissionCallback,
getKrollObject());
Expand Down
4 changes: 2 additions & 2 deletions apidoc/Titanium/Filesystem/Filesystem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ methods:
not check the box "Never ask again" when denying the request. If the user checks the box "Never ask again,"
the user has to manually enable the permission in device settings.
This method requests `Manifest.permission.READ_EXTERNAL_STORAGE`. If you require other permissions, you can also
use <Titanium.Android.requestPermissions>.
This method requests `Manifest.permission.READ_EXTERNAL_STORAGE` and `Manifest.permission.WRITE_EXTERNAL_STORAGE`.
If you require other permissions, you can also use <Titanium.Android.requestPermissions>.
parameters:
- name: callback
summary: Function to call upon user decision to grant storage access
Expand Down

0 comments on commit d758cd1

Please sign in to comment.