do not allow renaming the root folder of a storage

This commit is contained in:
tibbi 2016-11-13 11:40:12 +01:00
parent 9b8420e9d1
commit e013cc02a4
10 changed files with 18 additions and 0 deletions

View file

@ -304,6 +304,11 @@ public class MainActivity extends SimpleActivity
private void renameDir(final String path) { private void renameDir(final String path) {
final File dir = new File(path); final File dir = new File(path);
if (Utils.Companion.isAStorageRootFolder(this, path)) {
Utils.Companion.showToast(this, R.string.rename_folder_root);
return;
}
new RenameDirectoryDialog(this, dir, new RenameDirectoryDialog.OnRenameDirListener() { new RenameDirectoryDialog(this, dir, new RenameDirectoryDialog.OnRenameDirListener() {
@Override @Override
public void onRenameDirSuccess(@NotNull String[] changedFiles) { public void onRenameDirSuccess(@NotNull String[] changedFiles) {

View file

@ -111,6 +111,11 @@ class Utils {
} }
} }
fun isAStorageRootFolder(context: Context, path: String): Boolean {
val trimmed = path.trimEnd('/')
return trimmed.isEmpty() || trimmed == context.getInternalStoragePath() || trimmed == context.getSDCardPath()
}
fun isPhotoVideo(file: File) = file.isPhotoVideo() fun isPhotoVideo(file: File) = file.isPhotoVideo()
fun needsStupidWritePermissions(context: Context, path: String) = context.needsStupidWritePermissions(path) fun needsStupidWritePermissions(context: Context, path: String) = context.needsStupidWritePermissions(path)

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">Konnte den Ordner nicht umbenennen</string> <string name="rename_folder_error">Konnte den Ordner nicht umbenennen</string>
<string name="rename_folder_empty">Ordnername darf nicht leer sein</string> <string name="rename_folder_empty">Ordnername darf nicht leer sein</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">Ordner erfolgreich umbenannt</string> <string name="rename_folder_ok">Ordner erfolgreich umbenannt</string>
<string name="renaming_folder">Benenne Ordner um</string> <string name="renaming_folder">Benenne Ordner um</string>
<string name="filename_cannot_be_empty">Dateiname darf nicht leer sein</string> <string name="filename_cannot_be_empty">Dateiname darf nicht leer sein</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">No se pudo renombrar la carpeta</string> <string name="rename_folder_error">No se pudo renombrar la carpeta</string>
<string name="rename_folder_empty">El nombre de carpeta no puede estar vacío</string> <string name="rename_folder_empty">El nombre de carpeta no puede estar vacío</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">Carpeta renombrada correctamente</string> <string name="rename_folder_ok">Carpeta renombrada correctamente</string>
<string name="renaming_folder">Renombrando carpeta</string> <string name="renaming_folder">Renombrando carpeta</string>
<string name="filename_cannot_be_empty">El nombre de archivo no puede estar vacío</string> <string name="filename_cannot_be_empty">El nombre de archivo no puede estar vacío</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">Impossibile rinominare la cartella</string> <string name="rename_folder_error">Impossibile rinominare la cartella</string>
<string name="rename_folder_empty">Il nome della cartella non deve essere vuoto</string> <string name="rename_folder_empty">Il nome della cartella non deve essere vuoto</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">Cartella rinominata correttamente</string> <string name="rename_folder_ok">Cartella rinominata correttamente</string>
<string name="renaming_folder">Rinominazione cartella</string> <string name="renaming_folder">Rinominazione cartella</string>
<string name="filename_cannot_be_empty">Il nome del file non deve essere vuoto</string> <string name="filename_cannot_be_empty">Il nome del file non deve essere vuoto</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">フォルダーの名前を変更できませんでした</string> <string name="rename_folder_error">フォルダーの名前を変更できませんでした</string>
<string name="rename_folder_empty">フォルダー名は空にできません</string> <string name="rename_folder_empty">フォルダー名は空にできません</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">フォルダーの名前を正常に変更しました</string> <string name="rename_folder_ok">フォルダーの名前を正常に変更しました</string>
<string name="renaming_folder">フォルダーの名前を変更中</string> <string name="renaming_folder">フォルダーの名前を変更中</string>
<string name="filename_cannot_be_empty">ファイル名は空にできません</string> <string name="filename_cannot_be_empty">ファイル名は空にできません</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">Não foi possível renomear a pasta</string> <string name="rename_folder_error">Não foi possível renomear a pasta</string>
<string name="rename_folder_empty">O nome da pasta não pode estar vazio</string> <string name="rename_folder_empty">O nome da pasta não pode estar vazio</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">A pasta foi renomeada com sucesso</string> <string name="rename_folder_ok">A pasta foi renomeada com sucesso</string>
<string name="renaming_folder">A renomear pasta</string> <string name="renaming_folder">A renomear pasta</string>
<string name="filename_cannot_be_empty">O nome do ficheiro não pode estar vazio</string> <string name="filename_cannot_be_empty">O nome do ficheiro não pode estar vazio</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">Det gick inte att döpa om mappen</string> <string name="rename_folder_error">Det gick inte att döpa om mappen</string>
<string name="rename_folder_empty">Du måste ange ett mappnamn</string> <string name="rename_folder_empty">Du måste ange ett mappnamn</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">Mappen döptes om</string> <string name="rename_folder_ok">Mappen döptes om</string>
<string name="renaming_folder">Döper om mappen</string> <string name="renaming_folder">Döper om mappen</string>
<string name="filename_cannot_be_empty">Du måste ange ett filnamn</string> <string name="filename_cannot_be_empty">Du måste ange ett filnamn</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder">重命名文件夹</string> <string name="rename_folder">重命名文件夹</string>
<string name="rename_folder_empty">文件夹名不能为空</string> <string name="rename_folder_empty">文件夹名不能为空</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_error">文件夹不能重命名</string> <string name="rename_folder_error">文件夹不能重命名</string>
<string name="rename_folder_ok">文件夹重命名成功</string> <string name="rename_folder_ok">文件夹重命名成功</string>
<string name="renaming_folder">重命名中..</string> <string name="renaming_folder">重命名中..</string>

View file

@ -16,6 +16,7 @@
<string name="rename_folder_error">Could not rename the folder</string> <string name="rename_folder_error">Could not rename the folder</string>
<string name="rename_folder_empty">Folder name must not be empty</string> <string name="rename_folder_empty">Folder name must not be empty</string>
<string name="rename_folder_exists">A folder with that name already exists</string> <string name="rename_folder_exists">A folder with that name already exists</string>
<string name="rename_folder_root">Cannot rename the root folder of a storage</string>
<string name="rename_folder_ok">Folder renamed successfully</string> <string name="rename_folder_ok">Folder renamed successfully</string>
<string name="renaming_folder">Renaming folder</string> <string name="renaming_folder">Renaming folder</string>
<string name="filename_cannot_be_empty">Filename cannot be empty</string> <string name="filename_cannot_be_empty">Filename cannot be empty</string>