mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Added 'empty directory' warning
This commit is contained in:
@ -214,14 +214,17 @@
|
|||||||
<string name="best_rating_label">Best rating</string>
|
<string name="best_rating_label">Best rating</string>
|
||||||
<string name="add_feed_label">Add feed</string>
|
<string name="add_feed_label">Add feed</string>
|
||||||
<string name="miro_feed_added">Feed is being added</string>
|
<string name="miro_feed_added">Feed is being added</string>
|
||||||
|
|
||||||
<!-- Directory chooser -->
|
<!-- Directory chooser -->
|
||||||
<string name="selected_folder_label">Selected folder:</string>
|
<string name="selected_folder_label">Selected folder:</string>
|
||||||
<string name="create_folder_label">Create folder</string>
|
<string name="create_folder_label">Create folder</string>
|
||||||
<string name="choose_data_directory">Choose data folder</string>
|
<string name="choose_data_directory">Choose data folder</string>
|
||||||
<string name="create_folder_msg">Create new folder with name "%1$s"?</string>
|
<string name="create_folder_msg">Create new folder with name "%1$s"?</string>
|
||||||
<string name="create_folder_success">Created new folder</string>
|
<string name="create_folder_success">Created new folder</string>
|
||||||
<string name="create_folder_error_no_write_access">Cannot write to this folder</string>
|
<string name="create_folder_error_no_write_access">Cannot write to this folder</string>
|
||||||
<string name="create_folder_error_already_exists">Folder already exists</string>
|
<string name="create_folder_error_already_exists">Folder already exists</string>
|
||||||
<string name="create_folder_error">Could not create folder</string>
|
<string name="create_folder_error">Could not create folder</string>
|
||||||
</resources>
|
<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>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@ -5,8 +5,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -76,14 +79,40 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (AppConfig.DEBUG)
|
if (isValidFile(selectedDir)) {
|
||||||
Log.d(TAG, "Returning " + selectedDir.getAbsolutePath()
|
if (selectedDir.list().length == 0) {
|
||||||
+ " as result");
|
returnSelectedFolder();
|
||||||
Intent resultData = new Intent();
|
} else {
|
||||||
resultData.putExtra(RESULT_SELECTED_DIR,
|
showNonEmptyDirectoryWarning();
|
||||||
selectedDir.getAbsolutePath());
|
}
|
||||||
setResult(RESULT_CODE_DIR_SELECTED, resultData);
|
}
|
||||||
finish();
|
}
|
||||||
|
|
||||||
|
private void showNonEmptyDirectoryWarning() {
|
||||||
|
AlertDialog.Builder adb = new AlertDialog.Builder(
|
||||||
|
DirectoryChooserActivity.this);
|
||||||
|
adb.setTitle(R.string.folder_not_empty_dialog_title);
|
||||||
|
adb.setMessage(R.string.folder_not_empty_dialog_msg);
|
||||||
|
adb.setNegativeButton(R.string.cancel_label,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
adb.setPositiveButton(R.string.confirm_label,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
returnSelectedFolder();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
adb.create().show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -129,6 +158,17 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
|||||||
changeDirectory(Environment.getExternalStorageDirectory());
|
changeDirectory(Environment.getExternalStorageDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Finishes the activity and returns the selected folder as a result. */
|
||||||
|
private void returnSelectedFolder() {
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Returning " + selectedDir.getAbsolutePath()
|
||||||
|
+ " as result");
|
||||||
|
Intent resultData = new Intent();
|
||||||
|
resultData.putExtra(RESULT_SELECTED_DIR, selectedDir.getAbsolutePath());
|
||||||
|
setResult(RESULT_CODE_DIR_SELECTED, resultData);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
@ -205,6 +245,7 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
|||||||
private void refreshButtonState() {
|
private void refreshButtonState() {
|
||||||
if (selectedDir != null) {
|
if (selectedDir != null) {
|
||||||
butConfirm.setEnabled(isValidFile(selectedDir));
|
butConfirm.setEnabled(isValidFile(selectedDir));
|
||||||
|
supportInvalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +276,13 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
|
menu.findItem(R.id.new_folder_item)
|
||||||
|
.setVisible(isValidFile(selectedDir));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = new MenuInflater(this);
|
MenuInflater inflater = new MenuInflater(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user