Skip to content

Commit

Permalink
Merge remote-tracking branch 'maikalms/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bpellin committed Jan 21, 2017
2 parents 480e02f + a5fe606 commit e5f16f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package com.keepassdroid.fileselect;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
Expand Down Expand Up @@ -212,6 +213,7 @@ public void onClick(View v) {
Intent i = new Intent(StorageAF.ACTION_OPEN_DOCUMENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION|Intent.FLAG_GRANT_WRITE_URI_PERMISSION|Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
startActivityForResult(i, OPEN_DOC);
}
else {
Expand Down Expand Up @@ -356,6 +358,7 @@ protected void onPostExecute(Void v) {
}.execute(position);
}

@SuppressLint("NewApi")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand All @@ -378,6 +381,15 @@ else if ((requestCode == GET_CONTENT || requestCode == OPEN_DOC) && resultCode =
if (data != null) {
Uri uri = data.getData();
if (uri != null) {
if (StorageAF.useStorageFramework(this)) {
try {
// try to persist read and write permissions
getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
} catch (Exception e) {
// nop
}
}
if (requestCode == GET_CONTENT) {
uri = UriUtil.translate(this, uri);
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-v19/donottranslate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="saf_default">true</bool>
</resources>

0 comments on commit e5f16f5

Please sign in to comment.