|
|
@ -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"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|