Browse Source

Added (preferred) support for file managers that support file picking vai the GET_CONTENT action adn file/* mime type.

pull/148/merge
Eric Kok 11 years ago
parent
commit
f5bb381dff
  1. 14
      core/src/org/transdroid/core/gui/search/FilePickerHelper.java
  2. 1
      core/src/org/transdroid/core/gui/search/SearchActivity.java

14
core/src/org/transdroid/core/gui/search/FilePickerHelper.java

@ -41,11 +41,17 @@ public class FilePickerHelper { @@ -41,11 +41,17 @@ public class FilePickerHelper {
*/
@SuppressLint("ValidFragment")
public static void startFilePicker(final SherlockFragmentActivity activity) {
try {
// Start a file manager that can handle the file/* file/* intents
activity.startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("file/*"),
ACTIVITY_FILEPICKER);
} catch (Exception e1) {
try {
// Start a file manager that can handle the PICK_FILE intent (specifically IO File Manager)
activity.startActivityForResult(new Intent("org.openintents.action.PICK_FILE"), ACTIVITY_FILEPICKER);
} catch (Exception e) {
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not present
} catch (Exception e2) {
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not
// present
new DialogFragment() {
public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
return new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert)
@ -54,12 +60,14 @@ public class FilePickerHelper { @@ -54,12 +60,14 @@ public class FilePickerHelper {
@Override
public void onClick(DialogInterface dialog, int which) {
if (activity != null)
activity.startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI));
activity.startActivity(new Intent(Intent.ACTION_VIEW,
FILEMANAGER_MARKET_URI));
}
}).setNegativeButton(android.R.string.no, null).create();
};
}.show(activity.getSupportFragmentManager(), "installfilemanager");
}
}
}
}

1
core/src/org/transdroid/core/gui/search/SearchActivity.java

@ -242,6 +242,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga @@ -242,6 +242,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
} else if (intent.getAction().equals(Intent.ACTION_SEND)) {
query = SendIntentHelper.cleanUpText(intent);
}
query = query.trim();
if (query != null && query.length() > 0) {
// Remember this search query to later show as a suggestion

Loading…
Cancel
Save