diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/BackupHelperTest.java b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/BackupHelperTest.java
index 82fcbf7ac..977e30dc2 100644
--- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/BackupHelperTest.java
+++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/BackupHelperTest.java
@@ -89,7 +89,8 @@ public void exportNotes_nothingToExport() throws IOException {
BackupHelper.exportNotes(backupDir);
assertTrue(backupDir.exists());
- assertEquals(0, backupDir.listFiles().size());
+ assertTrue(backupDir.findFile(".nomedia").exists());
+ assertEquals(1, backupDir.listFiles().size());
}
@Test
@@ -101,7 +102,8 @@ public void exportNotes() throws IOException {
BackupHelper.exportNotes(backupDir);
assertTrue(backupDir.exists());
- assertEquals(4, backupDir.listFiles().size());
+ assertTrue(backupDir.findFile(".nomedia").exists());
+ assertEquals(5, backupDir.listFiles().size());
}
@Test
@@ -109,6 +111,7 @@ public void exportNote() {
Note note = createTestNote("test title", "test content", 0);
BackupHelper.exportNote(backupDir, note);
+
var noteFiles = from(backupDir.listFiles())
.filter(f -> f.getName().matches("\\d{13}.json")).toList().toBlocking().single();
assertEquals(1, noteFiles.size());
diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BackupHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BackupHelper.java
index 827bb0904..47a96158c 100644
--- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BackupHelper.java
+++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BackupHelper.java
@@ -66,6 +66,7 @@
public final class BackupHelper {
public static void exportNotes(DocumentFileCompat backupDir) {
+ backupDir.createFile("", ".nomedia");
for (Note note : DbHelper.getInstance(true).getAllNotes(false)) {
exportNote(backupDir, note);
}
diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/utils/StorageHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/utils/StorageHelper.java
index e068032c3..c00fecb0f 100644
--- a/omniNotes/src/main/java/it/feio/android/omninotes/utils/StorageHelper.java
+++ b/omniNotes/src/main/java/it/feio/android/omninotes/utils/StorageHelper.java
@@ -299,26 +299,6 @@ public static File getExternalStoragePublicDir() {
+ File.separator + Constants.EXTERNAL_STORAGE_FOLDER + File.separator);
}
- public static File getOrCreateBackupDir(String backupName) {
- File backupDir = new File(getOrCreateExternalStoragePublicDir(), backupName);
- if (!backupDir.exists() && backupDir.mkdirs()) {
- createNoMediaFile(backupDir);
- }
- return backupDir;
- }
-
-
- private static void createNoMediaFile(File folder) {
- try {
- boolean created = new File(folder, ".nomedia").createNewFile();
- if (!created) {
- LogDelegate.w("File .nomedia already existing into " + folder.getAbsolutePath());
- }
- } catch (IOException e) {
- LogDelegate.e("Error creating .nomedia file into backup folder");
- }
- }
-
public static File getSharedPreferencesFile(Context mContext) {
File appData = mContext.getFilesDir().getParentFile();
diff --git a/omniNotes/src/test/java/it/feio/android/omninotes/utils/StorageHelperTest.java b/omniNotes/src/test/java/it/feio/android/omninotes/utils/StorageHelperTest.java
deleted file mode 100644
index 9d5762634..000000000
--- a/omniNotes/src/test/java/it/feio/android/omninotes/utils/StorageHelperTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package it.feio.android.omninotes.utils;
-
-import static org.junit.Assert.*;
-
-import android.os.Environment;
-import it.feio.android.omninotes.BaseUnitTest;
-import java.io.File;
-import org.junit.After;
-import org.junit.Test;
-import org.mockito.MockedStatic;
-import org.mockito.Mockito;
-
-public class StorageHelperTest extends BaseUnitTest {
-
- private static final File EXTERNAL_STORAGE_DIRECTORY = new File("/tmp/" + StorageHelperTest.class.getSimpleName());
-
- @After
- public void tearDown() {
- EXTERNAL_STORAGE_DIRECTORY.deleteOnExit();
- }
-
- @Test
- public void getOrCreateBackupDir() {
- try (MockedStatic env = Mockito.mockStatic(Environment.class)) {
- env.when(Environment::getExternalStorageDirectory).thenReturn(EXTERNAL_STORAGE_DIRECTORY);
-
- var backupDir = StorageHelper.getOrCreateBackupDir("backup");
-
- assertTrue(backupDir.exists());
- }
- }
-
-
-
-}
\ No newline at end of file