mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Added 'set to default folder' menu button
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<item android:id="@+id/new_folder_item" android:title="@string/create_folder_label" android:showAsAction="ifRoom|withText"></item>
|
<item android:id="@+id/new_folder_item" android:title="@string/create_folder_label" android:showAsAction="ifRoom|withText"></item>
|
||||||
|
<item android:id="@+id/set_to_default_folder_item" android:showAsAction="collapseActionView" android:title="@string/set_to_default_folder"></item>
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@ -226,5 +226,6 @@
|
|||||||
<string name="create_folder_error">Could not create folder</string>
|
<string name="create_folder_error">Could not create folder</string>
|
||||||
<string name="folder_not_empty_dialog_title">Folder is not empty</string>
|
<string name="folder_not_empty_dialog_title">Folder is not empty</string>
|
||||||
<string name="folder_not_empty_dialog_msg">The folder you have selected is not empty. Media downloads and other data will be placed directly in this folder. Continue anyway?</string>
|
<string name="folder_not_empty_dialog_msg">The folder you have selected is not empty. Media downloads and other data will be placed directly in this folder. Continue anyway?</string>
|
||||||
|
<string name="set_to_default_folder">Set to default folder</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@ -158,13 +158,19 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
|||||||
changeDirectory(Environment.getExternalStorageDirectory());
|
changeDirectory(Environment.getExternalStorageDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Finishes the activity and returns the selected folder as a result. */
|
/**
|
||||||
|
* Finishes the activity and returns the selected folder as a result. The
|
||||||
|
* selected folder can also be null.
|
||||||
|
*/
|
||||||
private void returnSelectedFolder() {
|
private void returnSelectedFolder() {
|
||||||
if (AppConfig.DEBUG)
|
if (selectedDir != null && AppConfig.DEBUG)
|
||||||
Log.d(TAG, "Returning " + selectedDir.getAbsolutePath()
|
Log.d(TAG, "Returning " + selectedDir.getAbsolutePath()
|
||||||
+ " as result");
|
+ " as result");
|
||||||
Intent resultData = new Intent();
|
Intent resultData = new Intent();
|
||||||
resultData.putExtra(RESULT_SELECTED_DIR, selectedDir.getAbsolutePath());
|
if (selectedDir != null) {
|
||||||
|
resultData.putExtra(RESULT_SELECTED_DIR,
|
||||||
|
selectedDir.getAbsolutePath());
|
||||||
|
}
|
||||||
setResult(RESULT_CODE_DIR_SELECTED, resultData);
|
setResult(RESULT_CODE_DIR_SELECTED, resultData);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -299,6 +305,10 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
|||||||
case R.id.new_folder_item:
|
case R.id.new_folder_item:
|
||||||
openNewFolderDialog();
|
openNewFolderDialog();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.set_to_default_folder_item:
|
||||||
|
selectedDir = null;
|
||||||
|
returnSelectedFolder();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -177,14 +177,9 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
|
|||||||
if (resultCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) {
|
if (resultCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) {
|
||||||
String dir = data
|
String dir = data
|
||||||
.getStringExtra(DirectoryChooserActivity.RESULT_SELECTED_DIR);
|
.getStringExtra(DirectoryChooserActivity.RESULT_SELECTED_DIR);
|
||||||
if (dir != null) {
|
if (AppConfig.DEBUG)
|
||||||
if (AppConfig.DEBUG)
|
Log.d(TAG, "Setting data folder");
|
||||||
Log.d(TAG, "Setting data folder");
|
PodcastApp.getInstance().setDataFolder(dir);
|
||||||
PodcastApp.getInstance().setDataFolder(dir);
|
|
||||||
} else {
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Result from DirectoryChooser was null");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user