|
|
@ -21,12 +21,14 @@ import org.transdroid.R; |
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.app.DialogFragment; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.DialogInterface.OnClickListener; |
|
|
|
import android.content.DialogInterface.OnClickListener; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.Intent; |
|
|
|
import android.net.Uri; |
|
|
|
import android.net.Uri; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.ref.WeakReference; |
|
|
|
|
|
|
|
|
|
|
|
public class FilePickerHelper { |
|
|
|
public class FilePickerHelper { |
|
|
|
|
|
|
|
|
|
|
|
public static final int ACTIVITY_FILEPICKER = 0x0000c0df; // A 'random' ID to identify file picker intents
|
|
|
|
public static final int ACTIVITY_FILEPICKER = 0x0000c0df; // A 'random' ID to identify file picker intents
|
|
|
@ -49,22 +51,17 @@ public class FilePickerHelper { |
|
|
|
// Start a file manager that can handle the PICK_FILE intent (specifically IO File Manager)
|
|
|
|
// 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); |
|
|
|
activity.startActivityForResult(new Intent("org.openintents.action.PICK_FILE"), ACTIVITY_FILEPICKER); |
|
|
|
} catch (Exception e2) { |
|
|
|
} catch (Exception e2) { |
|
|
|
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not
|
|
|
|
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not present
|
|
|
|
// present
|
|
|
|
final WeakReference<Context> intentStartContext = new WeakReference<Context>(activity); |
|
|
|
new DialogFragment() { |
|
|
|
new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) |
|
|
|
public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) { |
|
|
|
.setMessage(activity.getString(R.string.search_filemanagernotfound)) |
|
|
|
return new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) |
|
|
|
.setPositiveButton(android.R.string.yes, new OnClickListener() { |
|
|
|
.setMessage(activity.getString(R.string.search_filemanagernotfound)) |
|
|
|
@Override |
|
|
|
.setPositiveButton(android.R.string.yes, new OnClickListener() { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
@Override |
|
|
|
if (intentStartContext.get() != null) |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI)); |
|
|
|
if (activity != null) |
|
|
|
} |
|
|
|
activity.startActivity(new Intent(Intent.ACTION_VIEW, |
|
|
|
}).setNegativeButton(android.R.string.no, null).show(); |
|
|
|
FILEMANAGER_MARKET_URI)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).setNegativeButton(android.R.string.no, null).create(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}.show(activity.getFragmentManager(), "installfilemanager"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|