Add ability to select OPML export folder
Instead of exporting a OPML file to a predefined folder the user can choose the folder (but not the filename) the file will be exported
This commit is contained in:
parent
66121d606e
commit
a411135931
|
@ -5,7 +5,6 @@ import android.app.AlertDialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.FileObserver;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
@ -158,7 +157,7 @@ public class DirectoryChooserActivity extends ActionBarActivity {
|
|||
listDirectoriesAdapter = new ArrayAdapter<String>(this,
|
||||
android.R.layout.simple_list_item_1, filenames);
|
||||
listDirectories.setAdapter(listDirectoriesAdapter);
|
||||
changeDirectory(Environment.getExternalStorageDirectory());
|
||||
changeDirectory(UserPreferences.getDataFolder(this, null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,10 +24,10 @@ import de.danoeh.antennapod.core.util.LangUtils;
|
|||
*/
|
||||
public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
|
||||
private static final String TAG = "OpmlExportWorker";
|
||||
private static final String DEFAULT_OUTPUT_NAME = "antennapod-feeds.opml";
|
||||
public static final String DEFAULT_OUTPUT_NAME = "antennapod-feeds.opml";
|
||||
public static final String EXPORT_DIR = "export/";
|
||||
|
||||
private Context context;
|
||||
private final Context context;
|
||||
private File output;
|
||||
|
||||
private ProgressDialog progDialog;
|
||||
|
|
|
@ -61,6 +61,8 @@ public class PreferenceController {
|
|||
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
|
||||
|
||||
private static final int REQUEST_CHOOSE_DATA_DIR = 1;
|
||||
private static final int REQUEST_CHOOSE_OMPL_EXPORT_DIR = 2;
|
||||
|
||||
private final PreferenceUI ui;
|
||||
|
||||
|
@ -150,9 +152,12 @@ public class PreferenceController {
|
|||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
new OpmlExportWorker(activity)
|
||||
.executeAsync();
|
||||
|
||||
Intent intent = new Intent(activity,
|
||||
DirectoryChooserActivity.class);
|
||||
intent.putExtra(DirectoryChooserActivity.NON_EMPTY_DIRECTORY_WARNING, false);
|
||||
activity.startActivityForResult(intent,
|
||||
REQUEST_CHOOSE_OMPL_EXPORT_DIR
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +172,7 @@ public class PreferenceController {
|
|||
DirectoryChooserActivity.class);
|
||||
intent.putExtra(DirectoryChooserActivity.NON_EMPTY_DIRECTORY_WARNING, true);
|
||||
activity.startActivityForResult(intent,
|
||||
DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED
|
||||
REQUEST_CHOOSE_DATA_DIR
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
@ -312,9 +317,18 @@ public class PreferenceController {
|
|||
if (resultCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) {
|
||||
String dir = data
|
||||
.getStringExtra(DirectoryChooserActivity.RESULT_SELECTED_DIR);
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Setting data folder");
|
||||
UserPreferences.setDataFolder(dir);
|
||||
switch(requestCode) {
|
||||
case REQUEST_CHOOSE_DATA_DIR:
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Setting data folder");
|
||||
UserPreferences.setDataFolder(dir);
|
||||
break;
|
||||
case REQUEST_CHOOSE_OMPL_EXPORT_DIR:
|
||||
File path = new File(dir, OpmlExportWorker.DEFAULT_OUTPUT_NAME);
|
||||
new OpmlExportWorker(ui.getActivity(), path)
|
||||
.executeAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue