properly URI-decode file:// URIs, so the files can be found

Fixes issues 63
This commit is contained in:
Thialfihar 2010-08-17 12:50:42 +00:00
parent 6e9146c91a
commit 96162b6608
4 changed files with 4 additions and 4 deletions

View File

@ -50,7 +50,7 @@ public class DataSource {
if (mContentUri != null) { if (mContentUri != null) {
if (mContentUri.getScheme().equals("file")) { if (mContentUri.getScheme().equals("file")) {
// get the rest after "file://" // get the rest after "file://"
String path = mContentUri.toString().substring(6); String path = Uri.decode(mContentUri.toString().substring(7));
if (path.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath())) { if (path.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath())) {
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
throw new GeneralException(context.getString(R.string.error_externalStorageNotReady)); throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));

View File

@ -217,7 +217,7 @@ public class DecryptActivity extends BaseActivity {
} else if (Apg.Intent.DECRYPT_FILE.equals(mIntent.getAction())) { } else if (Apg.Intent.DECRYPT_FILE.equals(mIntent.getAction())) {
mInputFilename = mIntent.getDataString(); mInputFilename = mIntent.getDataString();
if ("file".equals(mIntent.getScheme())) { if ("file".equals(mIntent.getScheme())) {
mInputFilename = mInputFilename.substring(6); mInputFilename = Uri.decode(mInputFilename.substring(7));
} }
mFilename.setText(mInputFilename); mFilename.setText(mInputFilename);
guessOutputFilename(); guessOutputFilename();

View File

@ -349,7 +349,7 @@ public class EncryptActivity extends BaseActivity {
} }
} else if (Apg.Intent.ENCRYPT_FILE.equals(mIntent.getAction())) { } else if (Apg.Intent.ENCRYPT_FILE.equals(mIntent.getAction())) {
if ("file".equals(mIntent.getScheme())) { if ("file".equals(mIntent.getScheme())) {
mInputFilename = mIntent.getDataString().replace("file://", ""); mInputFilename = Uri.decode(mIntent.getDataString().replace("file://", ""));
mFilename.setText(mInputFilename); mFilename.setText(mInputFilename);
guessOutputFilename(); guessOutputFilename();
} }

View File

@ -102,7 +102,7 @@ public class KeyListActivity extends BaseActivity {
Intent intent = getIntent(); Intent intent = getIntent();
if (Apg.Intent.IMPORT.equals(intent.getAction())) { if (Apg.Intent.IMPORT.equals(intent.getAction())) {
if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
mImportFilename = intent.getDataString().replace("file://", ""); mImportFilename = Uri.decode(intent.getDataString().replace("file://", ""));
} else { } else {
mImportData = intent.getStringExtra(Apg.EXTRA_TEXT); mImportData = intent.getStringExtra(Apg.EXTRA_TEXT);
} }