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. 42
      core/src/org/transdroid/core/gui/search/FilePickerHelper.java
  2. 1
      core/src/org/transdroid/core/gui/search/SearchActivity.java

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

@ -42,23 +42,31 @@ public class FilePickerHelper {
@SuppressLint("ValidFragment") @SuppressLint("ValidFragment")
public static void startFilePicker(final SherlockFragmentActivity activity) { public static void startFilePicker(final SherlockFragmentActivity activity) {
try { try {
// Start a file manager that can handle the PICK_FILE intent (specifically IO File Manager) // Start a file manager that can handle the file/* file/* intents
activity.startActivityForResult(new Intent("org.openintents.action.PICK_FILE"), ACTIVITY_FILEPICKER); activity.startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("file/*"),
} catch (Exception e) { ACTIVITY_FILEPICKER);
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not present } catch (Exception e1) {
new DialogFragment() { try {
public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) { // Start a file manager that can handle the PICK_FILE intent (specifically IO File Manager)
return new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) activity.startActivityForResult(new Intent("org.openintents.action.PICK_FILE"), ACTIVITY_FILEPICKER);
.setMessage(activity.getString(R.string.search_filemanagernotfound)) } catch (Exception e2) {
.setPositiveButton(android.R.string.yes, new OnClickListener() { // Can't start the file manager, for example with a SecurityException or when IO File Manager is not
@Override // present
public void onClick(DialogInterface dialog, int which) { new DialogFragment() {
if (activity != null) public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI)); return new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert)
} .setMessage(activity.getString(R.string.search_filemanagernotfound))
}).setNegativeButton(android.R.string.no, null).create(); .setPositiveButton(android.R.string.yes, new OnClickListener() {
}; @Override
}.show(activity.getSupportFragmentManager(), "installfilemanager"); public void onClick(DialogInterface dialog, int which) {
if (activity != null)
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
} else if (intent.getAction().equals(Intent.ACTION_SEND)) { } else if (intent.getAction().equals(Intent.ACTION_SEND)) {
query = SendIntentHelper.cleanUpText(intent); query = SendIntentHelper.cleanUpText(intent);
} }
query = query.trim();
if (query != null && query.length() > 0) { if (query != null && query.length() > 0) {
// Remember this search query to later show as a suggestion // Remember this search query to later show as a suggestion

Loading…
Cancel
Save