diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/catrobattestrunner/CatrobatTestRunner.kt b/catroid/src/androidTest/java/org/catrobat/catroid/catrobattestrunner/CatrobatTestRunner.kt index 8345914afc9..498f1f0ce9d 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/catrobattestrunner/CatrobatTestRunner.kt +++ b/catroid/src/androidTest/java/org/catrobat/catroid/catrobattestrunner/CatrobatTestRunner.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -106,11 +106,11 @@ class CatrobatTestRunner { val projectName = assetName.replace(Constants.CATROBAT_EXTENSION, "") TestUtils.deleteProjects(projectName) FlavoredConstants.DEFAULT_ROOT_DIRECTORY.mkdir() - Constants.CACHE_DIR.mkdir() + Constants.CACHE_DIRECTORY.mkdir() val inputStream = InstrumentationRegistry.getInstrumentation().context.assets .open("$assetPath/$assetName") val projectArchive = StorageOperations - .copyStreamToDir(inputStream, Constants.CACHE_DIR, assetName) + .copyStreamToDir(inputStream, Constants.CACHE_DIRECTORY, assetName) Assert.assertTrue(unzipAndImportProjects(arrayOf(projectArchive))) val projectDir = File(FlavoredConstants.DEFAULT_ROOT_DIRECTORY, projectName) Assert.assertTrue( @@ -121,7 +121,7 @@ class CatrobatTestRunner { @After @Throws(IOException::class) fun tearDown() { - StorageOperations.deleteDir(Constants.CACHE_DIR) + StorageOperations.deleteDir(Constants.CACHE_DIRECTORY) TestUtils.deleteProjects(assetName.replace(Constants.CATROBAT_EXTENSION, "")) } diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectFromContextMenu.kt b/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectFromContextMenu.kt index 9e4e82c0769..e5c4c641a32 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectFromContextMenu.kt +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectFromContextMenu.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -74,7 +74,7 @@ class ImportObjectIntoProjectFromContextMenu { @Before fun setUp() { try { - Constants.MEDIA_LIBRARY_CACHE_DIR.mkdirs() + Constants.MEDIA_LIBRARY_CACHE_DIRECTORY.mkdirs() } catch (e: Exception) { Log.e(TAG, Log.getStackTraceString(e)) } @@ -100,7 +100,7 @@ class ImportObjectIntoProjectFromContextMenu { XstreamSerializer.getInstance().saveProject(importedProject) val projectZip = File( - Constants.MEDIA_LIBRARY_CACHE_DIR, + Constants.MEDIA_LIBRARY_CACHE_DIRECTORY, importedProject?.name + Constants.CATROBAT_EXTENSION ) diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectTest.kt b/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectTest.kt index ab27c0bd3a7..f558f08f634 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectTest.kt +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/content/sprite/ImportObjectIntoProjectTest.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -38,7 +38,7 @@ import junit.framework.Assert.assertEquals import org.catrobat.catroid.ProjectManager import org.catrobat.catroid.R import org.catrobat.catroid.common.Constants -import org.catrobat.catroid.common.Constants.MEDIA_LIBRARY_CACHE_DIR +import org.catrobat.catroid.common.Constants.MEDIA_LIBRARY_CACHE_DIRECTORY import org.catrobat.catroid.common.DefaultProjectHandler import org.catrobat.catroid.content.Project import org.catrobat.catroid.content.Script @@ -78,7 +78,7 @@ class ImportObjectIntoProjectTest { @Before fun setUp() { try { - MEDIA_LIBRARY_CACHE_DIR.mkdirs() + MEDIA_LIBRARY_CACHE_DIRECTORY.mkdirs() } catch (e: Exception) { Log.e(TAG, Log.getStackTraceString(e)) } @@ -104,7 +104,7 @@ class ImportObjectIntoProjectTest { XstreamSerializer.getInstance().saveProject(importedProject) val projectZip = File( - Constants.MEDIA_LIBRARY_CACHE_DIR, + Constants.MEDIA_LIBRARY_CACHE_DIRECTORY, importedProject?.name + Constants.CATROBAT_EXTENSION ) diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/DSTFileGeneratorTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/DSTFileGeneratorTest.java index 49715b23e79..535d5cbfce8 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/DSTFileGeneratorTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/DSTFileGeneratorTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -60,12 +60,12 @@ public void setUp() throws IOException { Project project = new Project(ApplicationProvider.getApplicationContext(), projectName); ProjectManager.getInstance().setCurrentProject(project); - dstFile = new File(Constants.CACHE_DIR, projectName + ".dst"); + dstFile = new File(Constants.CACHE_DIRECTORY, projectName + ".dst"); if (dstFile.exists()) { dstFile.delete(); } - if (!Constants.CACHE_DIR.exists()) { - Constants.CACHE_DIR.mkdirs(); + if (!Constants.CACHE_DIRECTORY.exists()) { + Constants.CACHE_DIRECTORY.mkdirs(); } dstFile.createNewFile(); } @@ -87,7 +87,7 @@ public void testWriteToSampleDSTFile() throws IOException { InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(org.catrobat .catroid.test.R.raw.sample_dst_file); - File compareFile = StorageOperations.copyStreamToDir(inputStream, Constants.CACHE_DIR, "sample_dst_file.dst"); + File compareFile = StorageOperations.copyStreamToDir(inputStream, Constants.CACHE_DIRECTORY, "sample_dst_file.dst"); assertEquals(compareFile.length(), dstFile.length()); @@ -125,7 +125,7 @@ public void testWriteToComplexSampleDSTFile() throws IOException { InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(org.catrobat .catroid.test.R.raw.complex_sample_dst_file); - File compareFile = StorageOperations.copyStreamToDir(inputStream, Constants.CACHE_DIR, + File compareFile = StorageOperations.copyStreamToDir(inputStream, Constants.CACHE_DIRECTORY, "complex_sample_dst_file.dst"); assertEquals(compareFile.length(), dstFile.length()); diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/EmbroideryFileExporterTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/EmbroideryFileExporterTest.java index 13a4a2a7f51..6d13f4e56b1 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/EmbroideryFileExporterTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/embroidery/EmbroideryFileExporterTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -58,7 +58,7 @@ public void setUp() { @Test public void testShareSimpleFile() { - File dstFile = new File(Constants.CACHE_DIR, filename); + File dstFile = new File(Constants.CACHE_DIRECTORY, filename); Uri uriForFile = FileProvider.getUriForFile(stageActivity, stageActivity.getPackageName() + ".fileProvider", dstFile); new ExportEmbroideryFileLauncher(stageActivity, dstFile).startActivity(); diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectExportTaskTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectExportTaskTest.java index fb1d2c39863..c3290bcdbd6 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectExportTaskTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectExportTaskTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -99,7 +99,7 @@ public void exportProjectTest() { String fileName = project.getDirectory().getName() + "_destination" + CATROBAT_EXTENSION; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - projectZip = new File(Constants.CACHE_DIR, fileName); + projectZip = new File(Constants.CACHE_DIRECTORY, fileName); } else { projectZip = new File(EXTERNAL_STORAGE_ROOT_EXPORT_DIRECTORY, fileName); } diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectUnZipperAndImporterTest.kt b/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectUnZipperAndImporterTest.kt index e3ee9d35fc7..bddbaf0ceba 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectUnZipperAndImporterTest.kt +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/io/asynctask/ProjectUnZipperAndImporterTest.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -25,7 +25,7 @@ package org.catrobat.catroid.test.io.asynctask import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import junit.framework.TestCase -import org.catrobat.catroid.common.Constants.CACHE_DIR +import org.catrobat.catroid.common.Constants.CACHE_DIRECTORY import org.catrobat.catroid.common.Constants.CODE_XML_FILE_NAME import org.catrobat.catroid.common.FlavoredConstants.DEFAULT_ROOT_DIRECTORY import org.catrobat.catroid.content.backwardcompatibility.ProjectMetaDataParser @@ -57,21 +57,21 @@ class ProjectUnZipperAndImporterTest { fun setUp() { TestUtils.deleteProjects(AIR_FIGHT_0_5, AIR_FIGHT_0_5_1, FALLING_BALLS) DEFAULT_ROOT_DIRECTORY.mkdir() - CACHE_DIR.mkdir() + CACHE_DIRECTORY.mkdir() var assetName = "Air_fight_0.5.catrobat" var inputStream = InstrumentationRegistry.getInstrumentation().context.assets.open(assetName) - projectAirFightFile = StorageOperations.copyStreamToDir(inputStream, CACHE_DIR, assetName) + projectAirFightFile = StorageOperations.copyStreamToDir(inputStream, CACHE_DIRECTORY, assetName) assetName = "Falling_balls.catrobat" inputStream = InstrumentationRegistry.getInstrumentation().context.assets.open(assetName) projectFallingBallsFile = - StorageOperations.copyStreamToDir(inputStream, CACHE_DIR, assetName) + StorageOperations.copyStreamToDir(inputStream, CACHE_DIRECTORY, assetName) } @After @Throws(IOException::class) fun tearDown() { - StorageOperations.deleteDir(CACHE_DIR) + StorageOperations.deleteDir(CACHE_DIRECTORY) TestUtils.deleteProjects(AIR_FIGHT_0_5, AIR_FIGHT_0_5_1, FALLING_BALLS) } diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/io/filepicker/ListProjectFilesTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/test/io/filepicker/ListProjectFilesTest.java index b1f8ca83980..1a2c020439c 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/io/filepicker/ListProjectFilesTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/io/filepicker/ListProjectFilesTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -42,7 +42,7 @@ import static junit.framework.Assert.assertTrue; import static org.catrobat.catroid.common.Constants.CODE_XML_FILE_NAME; -import static org.catrobat.catroid.common.Constants.TMP_DIR_NAME; +import static org.catrobat.catroid.common.Constants.TMP_DIRECTORY_NAME; import static org.catrobat.catroid.common.FlavoredConstants.EXTERNAL_STORAGE_ROOT_DIRECTORY; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; @@ -114,7 +114,7 @@ public void testListProjectsOnExternalStorage() throws IOException { File backpackFolder = new File(EXTERNAL_STORAGE_ROOT_DIRECTORY, "backpack"); assertTrue(backpackFolder.mkdirs()); - File tempFolder = new File(EXTERNAL_STORAGE_ROOT_DIRECTORY, TMP_DIR_NAME); + File tempFolder = new File(EXTERNAL_STORAGE_ROOT_DIRECTORY, TMP_DIRECTORY_NAME); assertTrue(tempFolder.mkdirs()); File projectFolder1 = new File(EXTERNAL_STORAGE_ROOT_DIRECTORY, "projectFolder1"); diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/LookFromGalleryIntentTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/LookFromGalleryIntentTest.java index d900f6bc986..6f8e35d02fc 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/LookFromGalleryIntentTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/LookFromGalleryIntentTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -85,7 +85,7 @@ public class LookFromGalleryIntentTest { private final String lookFileName = "catroid_sunglasses.png"; private final String projectName = getClass().getSimpleName(); private final File tmpPath = new File( - Constants.CACHE_DIR.getAbsolutePath(), "Pocket Code Test Temp"); + Constants.CACHE_DIRECTORY.getAbsolutePath(), "Pocket Code Test Temp"); @Rule public FragmentActivityTestRule baseActivityTestRule = new diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/SpriteFromGalleryIntentTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/SpriteFromGalleryIntentTest.java index 0704fded06c..135535e4fc3 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/SpriteFromGalleryIntentTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/looks/gallery/SpriteFromGalleryIntentTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -87,7 +87,7 @@ public class SpriteFromGalleryIntentTest { private final String lookFileName = "catroid_sunglasses.png"; private final String projectName = getClass().getSimpleName(); private final File tmpPath = new File( - Constants.CACHE_DIR.getAbsolutePath(), "Pocket Code Test Temp"); + Constants.CACHE_DIRECTORY.getAbsolutePath(), "Pocket Code Test Temp"); @Rule public FragmentActivityTestRule baseActivityTestRule = new diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/sounds/gallery/SoundFromGalleryIntentTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/sounds/gallery/SoundFromGalleryIntentTest.java index af698508635..a36c4a4f10d 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/sounds/gallery/SoundFromGalleryIntentTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/intents/sounds/gallery/SoundFromGalleryIntentTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -85,7 +85,7 @@ public class SoundFromGalleryIntentTest { private final String soundFileName = "longsound.mp3"; private final String projectName = getClass().getSimpleName(); private final File tmpPath = new File( - Constants.CACHE_DIR.getAbsolutePath(), "Pocket Code Test Temp"); + Constants.CACHE_DIRECTORY.getAbsolutePath(), "Pocket Code Test Temp"); @Rule public FragmentActivityTestRule baseActivityTestRule = new diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/fragment/ProjectOptionsTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/fragment/ProjectOptionsTest.java index b63c7f7951d..a1de589d7a5 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/fragment/ProjectOptionsTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/fragment/ProjectOptionsTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -186,7 +186,7 @@ public void changeProjectName() throws IOException { } private Matcher createLookFromPaintroid() throws IOException { - File tmpDir = new File(Constants.CACHE_DIR.getAbsolutePath(), "Pocket Code Test Temp"); + File tmpDir = new File(Constants.CACHE_DIRECTORY.getAbsolutePath(), "Pocket Code Test Temp"); String lookFileName = "catroid_sunglasses.png"; Intents.init(); diff --git a/catroid/src/main/java/org/catrobat/catroid/common/Constants.java b/catroid/src/main/java/org/catrobat/catroid/common/Constants.java index 886b0775359..051f1eee3b4 100644 --- a/catroid/src/main/java/org/catrobat/catroid/common/Constants.java +++ b/catroid/src/main/java/org/catrobat/catroid/common/Constants.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -56,12 +56,12 @@ public final class Constants { public static final String TMP_CODE_XML_FILE_NAME = "tmp_" + CODE_XML_FILE_NAME; public static final String UNDO_CODE_XML_FILE_NAME = "undo_" + CODE_XML_FILE_NAME; - public static final String DEVICE_VARIABLE_JSON_FILENAME = "DeviceVariables.json"; - public static final String DEVICE_LIST_JSON_FILENAME = "DeviceLists.json"; + public static final String DEVICE_VARIABLE_JSON_FILE_NAME = "DeviceVariables.json"; + public static final String DEVICE_LIST_JSON_FILE_NAME = "DeviceLists.json"; - public static final String POCKET_CODE_EXTERNAL_EXPORT_STORAGE_FOLDER_NAME = "Catrobat"; + public static final String POCKET_CODE_EXTERNAL_EXPORT_STORAGE_DIRECTORY_NAME = "Catrobat"; public static final File EXTERNAL_STORAGE_ROOT_EXPORT_DIRECTORY = new File( - Environment.getExternalStorageDirectory(), POCKET_CODE_EXTERNAL_EXPORT_STORAGE_FOLDER_NAME); + Environment.getExternalStorageDirectory(), POCKET_CODE_EXTERNAL_EXPORT_STORAGE_DIRECTORY_NAME); public static final String CATROBAT_EXTENSION = ".catrobat"; public static final String ZIP_EXTENSION = ".zip"; @@ -84,7 +84,7 @@ public final class Constants { public static final String SOUND_DIRECTORY_NAME = "sounds"; public static final String SCREENSHOT_AUTOMATIC_FILE_NAME = "automatic_screenshot" + DEFAULT_IMAGE_EXTENSION; public static final String SCREENSHOT_MANUAL_FILE_NAME = "manual_screenshot" + DEFAULT_IMAGE_EXTENSION; - public static final File TEMP_LOOK_FILE = + public static final File TMP_LOOK_FILE = new File(DEFAULT_ROOT_DIRECTORY, "temporary_look_file" + DEFAULT_IMAGE_EXTENSION); // Recent Bricks Directory @@ -106,19 +106,19 @@ public final class Constants { public static final int JSON_INDENTATION = 4; // Temporary Files and Directories: - public static final File CACHE_DIR = CatroidApplication.getAppContext().getCacheDir(); + public static final File CACHE_DIRECTORY = CatroidApplication.getAppContext().getCacheDir(); public static final String CACHED_PROJECT_ZIP_FILE_NAME = "projectImportCache.zip"; - public static final File POCKET_PAINT_CACHE_DIR = new File(CACHE_DIR, "pocketPaint"); - public static final File CAMERA_CACHE_DIR = new File(CACHE_DIR, "camera"); - public static final File SOUND_RECORDER_CACHE_DIR = new File(CACHE_DIR, "soundRecorder"); - public static final File MEDIA_LIBRARY_CACHE_DIR = new File(CACHE_DIR, "mediaLibrary"); + public static final File POCKET_PAINT_CACHE_DIRECTORY = new File(CACHE_DIRECTORY, "pocketPaint"); + public static final File CAMERA_CACHE_DIRECTORY = new File(CACHE_DIRECTORY, "camera"); + public static final File SOUND_RECORDER_CACHE_DIRECTORY = new File(CACHE_DIRECTORY, "soundRecorder"); + public static final File MEDIA_LIBRARY_CACHE_DIRECTORY = new File(CACHE_DIRECTORY, "mediaLibrary"); public static final String TMP_IMAGE_FILE_NAME = "image"; - public static final String TMP_DIR_NAME = "tmp"; - public static final String TMP_PATH = CACHE_DIR.getAbsolutePath() + "/" + TMP_DIR_NAME; + public static final String TMP_DIRECTORY_NAME = "tmp"; + public static final String TMP_PATH = CACHE_DIRECTORY.getAbsolutePath() + "/" + TMP_DIRECTORY_NAME; public static final String TEXT_TO_SPEECH_TMP_PATH = TMP_PATH + "/textToSpeech"; // Web: @@ -217,7 +217,7 @@ public final class Constants { public static final int SCRATCH_SECOND_RELEASE_PUBLISHED_DATE_MONTH = Calendar.MAY; public static final int SCRATCH_SECOND_RELEASE_PUBLISHED_DATE_DAY = 9; public static final int SCRATCH_HTTP_REQUEST_MIN_TIMEOUT = 1_000; // in ms - public static final int SCRATCH_HTTP_REQUEST_MAX_NUM_OF_RETRIES = 2; + public static final int SCRATCH_HTTP_REQUEST_MAX_NUMBER_OF_RETRIES = 2; public static final int SCRATCH_IMAGE_DEFAULT_WIDTH = 480; public static final int SCRATCH_IMAGE_DEFAULT_HEIGHT = 360; public static final String DATE_FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss"; diff --git a/catroid/src/main/java/org/catrobat/catroid/content/actions/PaintNewLookAction.kt b/catroid/src/main/java/org/catrobat/catroid/content/actions/PaintNewLookAction.kt index b46666a3204..9fba0966776 100644 --- a/catroid/src/main/java/org/catrobat/catroid/content/actions/PaintNewLookAction.kt +++ b/catroid/src/main/java/org/catrobat/catroid/content/actions/PaintNewLookAction.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -67,8 +67,8 @@ class PaintNewLookAction : PocketPaintAction() { private fun createEmptyImageFile(): File { val pocketPaintImageFileName = Constants.TMP_IMAGE_FILE_NAME + Constants.DEFAULT_IMAGE_EXTENSION - Constants.POCKET_PAINT_CACHE_DIR.mkdirs() - if (!Constants.POCKET_PAINT_CACHE_DIR.isDirectory) { + Constants.POCKET_PAINT_CACHE_DIRECTORY.mkdirs() + if (!Constants.POCKET_PAINT_CACHE_DIRECTORY.isDirectory) { Log.e(TAG, "Failed to create directory!") } val currentProject = ProjectManager.getInstance().currentProject @@ -77,7 +77,7 @@ class PaintNewLookAction : PocketPaintAction() { currentProject.xmlHeader.virtualScreenHeight, Bitmap.Config.ARGB_8888 ) return StorageOperations.compressBitmapToPng( - bitmap, File(Constants.POCKET_PAINT_CACHE_DIR, pocketPaintImageFileName)) + bitmap, File(Constants.POCKET_PAINT_CACHE_DIRECTORY, pocketPaintImageFileName)) } override fun onIntentResult(resultCode: Int, data: Intent?) { @@ -134,7 +134,7 @@ object LookRequester { val currentScene = ProjectManager.getInstance().currentlyPlayingScene val imageDirectory = File(currentScene.directory, Constants.IMAGE_DIRECTORY_NAME) val pocketPaintImageFileName = Constants.TMP_IMAGE_FILE_NAME + Constants.DEFAULT_IMAGE_EXTENSION - val pocketPaintFile = File(Constants.POCKET_PAINT_CACHE_DIR, pocketPaintImageFileName) + val pocketPaintFile = File(Constants.POCKET_PAINT_CACHE_DIRECTORY, pocketPaintImageFileName) file = StorageOperations.copyFileToDir(pocketPaintFile, imageDirectory) } catch (e: IOException) { Log.e(TAG, Log.getStackTraceString(e)) diff --git a/catroid/src/main/java/org/catrobat/catroid/content/actions/WriteEmbroideryToFileAction.kt b/catroid/src/main/java/org/catrobat/catroid/content/actions/WriteEmbroideryToFileAction.kt index 6f2ef5e5717..0aef7e2b57b 100644 --- a/catroid/src/main/java/org/catrobat/catroid/content/actions/WriteEmbroideryToFileAction.kt +++ b/catroid/src/main/java/org/catrobat/catroid/content/actions/WriteEmbroideryToFileAction.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -123,7 +123,7 @@ class WriteEmbroideryToFileAction : Action(), IntentListener { val fileName = StorageOperations.resolveFileName(contentResolver, uri) ?: return var message = context.getString(R.string.brick_write_variable_to_file_success, fileName) try { - val cacheFile = File(Constants.CACHE_DIR, fileName) + val cacheFile = File(Constants.CACHE_DIRECTORY, fileName) if (!cacheFile.exists()) { cacheFile.createNewFile() } diff --git a/catroid/src/main/java/org/catrobat/catroid/io/DeviceListAccessor.java b/catroid/src/main/java/org/catrobat/catroid/io/DeviceListAccessor.java index e749083415b..3f5c980c9fd 100644 --- a/catroid/src/main/java/org/catrobat/catroid/io/DeviceListAccessor.java +++ b/catroid/src/main/java/org/catrobat/catroid/io/DeviceListAccessor.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ import java.io.File; import java.util.List; -import static org.catrobat.catroid.common.Constants.DEVICE_LIST_JSON_FILENAME; +import static org.catrobat.catroid.common.Constants.DEVICE_LIST_JSON_FILE_NAME; public class DeviceListAccessor extends DeviceUserDataAccessor { @@ -47,7 +47,7 @@ protected Object getLock() { @Override protected String getDeviceFileName() { - return DEVICE_LIST_JSON_FILENAME; + return DEVICE_LIST_JSON_FILE_NAME; } @Override diff --git a/catroid/src/main/java/org/catrobat/catroid/io/DeviceVariableAccessor.java b/catroid/src/main/java/org/catrobat/catroid/io/DeviceVariableAccessor.java index ec8bb7e14fb..92786123517 100644 --- a/catroid/src/main/java/org/catrobat/catroid/io/DeviceVariableAccessor.java +++ b/catroid/src/main/java/org/catrobat/catroid/io/DeviceVariableAccessor.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.List; -import static org.catrobat.catroid.common.Constants.DEVICE_VARIABLE_JSON_FILENAME; +import static org.catrobat.catroid.common.Constants.DEVICE_VARIABLE_JSON_FILE_NAME; public final class DeviceVariableAccessor extends DeviceUserDataAccessor { @@ -48,7 +48,7 @@ protected Object getLock() { @Override protected String getDeviceFileName() { - return DEVICE_VARIABLE_JSON_FILENAME; + return DEVICE_VARIABLE_JSON_FILE_NAME; } @Override diff --git a/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectExportTask.kt b/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectExportTask.kt index 1c56df4b658..0eacac044d9 100644 --- a/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectExportTask.kt +++ b/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectExportTask.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -55,7 +55,7 @@ class ProjectExportTask( deleteUndoFile() val projectFileName = projectDir.name + Constants.ZIP_EXTENSION - val cacheFile = File(Constants.CACHE_DIR, projectFileName) + val cacheFile = File(Constants.CACHE_DIRECTORY, projectFileName) if (cacheFile.exists()) { cacheFile.delete() } diff --git a/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectUnZipperAndImporter.kt b/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectUnZipperAndImporter.kt index 7133a53f150..39d6fc038c8 100644 --- a/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectUnZipperAndImporter.kt +++ b/catroid/src/main/java/org/catrobat/catroid/io/asynctask/ProjectUnZipperAndImporter.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -27,7 +27,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import org.catrobat.catroid.common.Constants.CACHE_DIR +import org.catrobat.catroid.common.Constants.CACHE_DIRECTORY import org.catrobat.catroid.io.StorageOperations import org.catrobat.catroid.io.ZipArchiver import java.io.File @@ -58,7 +58,7 @@ fun unzipAndImportProjects(files: Array): Boolean { } private fun unzipAndImportProject(projectDir: File): Boolean = try { - val cachedProjectDir = File(CACHE_DIR, StorageOperations.getSanitizedFileName(projectDir.name)) + val cachedProjectDir = File(CACHE_DIRECTORY, StorageOperations.getSanitizedFileName(projectDir.name)) if (cachedProjectDir.isDirectory) { StorageOperations.deleteDir(cachedProjectDir) } diff --git a/catroid/src/main/java/org/catrobat/catroid/merge/ImportProjectHelper.kt b/catroid/src/main/java/org/catrobat/catroid/merge/ImportProjectHelper.kt index 92142a1304b..26129ef7c71 100644 --- a/catroid/src/main/java/org/catrobat/catroid/merge/ImportProjectHelper.kt +++ b/catroid/src/main/java/org/catrobat/catroid/merge/ImportProjectHelper.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -179,9 +179,9 @@ class ImportProjectHelper( fun getNewProject(resolvedName: String): Project? { try { val cachedProjectDir = - File(Constants.MEDIA_LIBRARY_CACHE_DIR, resolvedName) + File(Constants.MEDIA_LIBRARY_CACHE_DIRECTORY, resolvedName) val cachedProject = - File(Constants.MEDIA_LIBRARY_CACHE_DIR, lookFileName) + File(Constants.MEDIA_LIBRARY_CACHE_DIRECTORY, lookFileName) ZipArchiver().unzip(cachedProject, cachedProjectDir) return XstreamSerializer.getInstance() diff --git a/catroid/src/main/java/org/catrobat/catroid/soundrecorder/SoundRecorderActivity.java b/catroid/src/main/java/org/catrobat/catroid/soundrecorder/SoundRecorderActivity.java index 706c0e6cc82..1bf5f75e4d5 100644 --- a/catroid/src/main/java/org/catrobat/catroid/soundrecorder/SoundRecorderActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/soundrecorder/SoundRecorderActivity.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -47,7 +47,7 @@ import static android.Manifest.permission.RECORD_AUDIO; -import static org.catrobat.catroid.common.Constants.SOUND_RECORDER_CACHE_DIR; +import static org.catrobat.catroid.common.Constants.SOUND_RECORDER_CACHE_DIRECTORY; public class SoundRecorderActivity extends BaseActivity implements OnClickListener { @@ -108,11 +108,11 @@ private synchronized void startRecording() { soundRecorder.stop(); } - SOUND_RECORDER_CACHE_DIR.mkdirs(); - if (!SOUND_RECORDER_CACHE_DIR.isDirectory()) { - throw new IOException("Cannot create " + SOUND_RECORDER_CACHE_DIR); + SOUND_RECORDER_CACHE_DIRECTORY.mkdirs(); + if (!SOUND_RECORDER_CACHE_DIRECTORY.isDirectory()) { + throw new IOException("Cannot create " + SOUND_RECORDER_CACHE_DIRECTORY); } - File soundFile = new File(SOUND_RECORDER_CACHE_DIR, getString(R.string.soundrecorder_recorded_filename)); + File soundFile = new File(SOUND_RECORDER_CACHE_DIRECTORY, getString(R.string.soundrecorder_recorded_filename)); soundRecorder = new SoundRecorder(soundFile.getAbsolutePath()); soundRecorder.start(); setViewsToRecordingState(); diff --git a/catroid/src/main/java/org/catrobat/catroid/transfers/FetchScratchProgramDetailsTask.java b/catroid/src/main/java/org/catrobat/catroid/transfers/FetchScratchProgramDetailsTask.java index 8d62e600565..c821efdec65 100644 --- a/catroid/src/main/java/org/catrobat/catroid/transfers/FetchScratchProgramDetailsTask.java +++ b/catroid/src/main/java/org/catrobat/catroid/transfers/FetchScratchProgramDetailsTask.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -94,7 +94,7 @@ protected ScratchProgramData doInBackground(Long... params) { public ScratchProgramData fetchProjectData(final long projectID) throws InterruptedIOException { // exponential backoff final int minTimeout = Constants.SCRATCH_HTTP_REQUEST_MIN_TIMEOUT; - final int maxNumRetries = Constants.SCRATCH_HTTP_REQUEST_MAX_NUM_OF_RETRIES; + final int maxNumRetries = Constants.SCRATCH_HTTP_REQUEST_MAX_NUMBER_OF_RETRIES; int delay; diff --git a/catroid/src/main/java/org/catrobat/catroid/transfers/SearchScratchProgramsTask.java b/catroid/src/main/java/org/catrobat/catroid/transfers/SearchScratchProgramsTask.java index 425a4c52ded..a2ae517db85 100644 --- a/catroid/src/main/java/org/catrobat/catroid/transfers/SearchScratchProgramsTask.java +++ b/catroid/src/main/java/org/catrobat/catroid/transfers/SearchScratchProgramsTask.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -78,7 +78,7 @@ protected ScratchSearchResult doInBackground(String... params) { public ScratchSearchResult fetchProgramList(String query) throws InterruptedIOException { final int minTimeout = Constants.SCRATCH_HTTP_REQUEST_MIN_TIMEOUT; - final int maxNumRetries = Constants.SCRATCH_HTTP_REQUEST_MAX_NUM_OF_RETRIES; + final int maxNumRetries = Constants.SCRATCH_HTTP_REQUEST_MAX_NUMBER_OF_RETRIES; int delay; diff --git a/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectDownloadService.kt b/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectDownloadService.kt index ba00f8c2275..2c6dc8d10a7 100644 --- a/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectDownloadService.kt +++ b/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectDownloadService.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -33,11 +33,11 @@ import android.util.Log import org.catrobat.catroid.ProjectManager import org.catrobat.catroid.R import org.catrobat.catroid.common.Constants -import org.catrobat.catroid.common.Constants.CACHE_DIR +import org.catrobat.catroid.common.Constants.CACHE_DIRECTORY import org.catrobat.catroid.common.Constants.CATROBAT_EXTENSION import org.catrobat.catroid.common.Constants.EXTRA_PROJECT_NAME import org.catrobat.catroid.common.Constants.MAX_PERCENT -import org.catrobat.catroid.common.Constants.TMP_DIR_NAME +import org.catrobat.catroid.common.Constants.TMP_DIRECTORY_NAME import org.catrobat.catroid.common.FlavoredConstants import org.catrobat.catroid.io.XstreamSerializer import org.catrobat.catroid.io.ZipArchiver @@ -82,7 +82,7 @@ class ProjectDownloadService : IntentService("ProjectDownloadService") { val resultReceiver = downloadIntent.getParcelableExtra(EXTRA_RESULT_RECEIVER) ?: return logWarning("Called ProjectDownloadService without url - aborting") - val zipFileString = File(File(CACHE_DIR, TMP_DIR_NAME), DOWNLOAD_FILE_NAME).absolutePath + val zipFileString = File(File(CACHE_DIRECTORY, TMP_DIRECTORY_NAME), DOWNLOAD_FILE_NAME).absolutePath val destinationFile = File(zipFileString) if ((destinationFile.parentFile.isDirectory or destinationFile.parentFile.mkdirs()).not()) { diff --git a/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectUpload.kt b/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectUpload.kt index 32e38d92273..ba60b2d060b 100644 --- a/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectUpload.kt +++ b/catroid/src/main/java/org/catrobat/catroid/transfers/project/ProjectUpload.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2019 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ package org.catrobat.catroid.transfers.project import android.content.SharedPreferences import android.util.Log import org.catrobat.catroid.common.Constants -import org.catrobat.catroid.common.Constants.DEVICE_VARIABLE_JSON_FILENAME +import org.catrobat.catroid.common.Constants.DEVICE_VARIABLE_JSON_FILE_NAME import org.catrobat.catroid.common.Constants.UPLOAD_IMAGE_SCALE_HEIGHT import org.catrobat.catroid.common.Constants.UPLOAD_IMAGE_SCALE_WIDTH import org.catrobat.catroid.io.ProjectAndSceneScreenshotLoader @@ -118,7 +118,7 @@ class ProjectUpload( private fun zipProjectToArchive(projectDirectory: File, archiveDirectory: File): File? { return try { val fileList = projectDirectory.listFiles() - val filteredFileList = fileList.filter { file -> file.name != DEVICE_VARIABLE_JSON_FILENAME } + val filteredFileList = fileList.filter { file -> file.name != DEVICE_VARIABLE_JSON_FILE_NAME } zipArchiver.zip(archiveDirectory, filteredFileList.toTypedArray()) archiveDirectory diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/ImportLaunchers.kt b/catroid/src/main/java/org/catrobat/catroid/ui/ImportLaunchers.kt index ff92bacded3..214a891a338 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/ImportLaunchers.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/ImportLaunchers.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -38,10 +38,10 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.FileProvider import org.catrobat.catroid.ProjectManager import org.catrobat.catroid.R -import org.catrobat.catroid.common.Constants.CAMERA_CACHE_DIR +import org.catrobat.catroid.common.Constants.CAMERA_CACHE_DIRECTORY import org.catrobat.catroid.common.Constants.DEFAULT_IMAGE_EXTENSION import org.catrobat.catroid.common.Constants.EXTRA_PICTURE_PATH_POCKET_PAINT -import org.catrobat.catroid.common.Constants.POCKET_PAINT_CACHE_DIR +import org.catrobat.catroid.common.Constants.POCKET_PAINT_CACHE_DIRECTORY import org.catrobat.catroid.common.Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME import org.catrobat.catroid.common.Constants.TMP_IMAGE_FILE_NAME import org.catrobat.catroid.io.StorageOperations @@ -63,14 +63,14 @@ class ImportFromPocketPaintLauncher(private val activity: Activity) : ImportLaun return FileProvider.getUriForFile( activity, activity.applicationContext.packageName + ".fileProvider", - File(POCKET_PAINT_CACHE_DIR, pocketPaintImageFileName) + File(POCKET_PAINT_CACHE_DIRECTORY, pocketPaintImageFileName) ) } private fun createEmptyImageFile(): File { - POCKET_PAINT_CACHE_DIR.mkdirs() - if (!POCKET_PAINT_CACHE_DIR.isDirectory) { - throw IOException("Cannot create ${POCKET_PAINT_CACHE_DIR.absolutePath}.") + POCKET_PAINT_CACHE_DIRECTORY.mkdirs() + if (!POCKET_PAINT_CACHE_DIRECTORY.isDirectory) { + throw IOException("Cannot create ${POCKET_PAINT_CACHE_DIRECTORY.absolutePath}.") } val currentProject = ProjectManager.getInstance().currentProject @@ -78,7 +78,7 @@ class ImportFromPocketPaintLauncher(private val activity: Activity) : ImportLaun currentProject.xmlHeader.virtualScreenWidth, currentProject.xmlHeader.virtualScreenHeight, Bitmap.Config.ARGB_8888 ) - return StorageOperations.compressBitmapToPng(bitmap, File(POCKET_PAINT_CACHE_DIR, pocketPaintImageFileName)) + return StorageOperations.compressBitmapToPng(bitmap, File(POCKET_PAINT_CACHE_DIRECTORY, pocketPaintImageFileName)) } override fun startActivityForResult(requestCode: Int) { @@ -127,14 +127,14 @@ class ImportFromCameraLauncher(private val activity: AppCompatActivity) : Import return FileProvider.getUriForFile( activity, activity.applicationContext.packageName + ".fileProvider", - File(CAMERA_CACHE_DIR, cameraImageFileName) + File(CAMERA_CACHE_DIRECTORY, cameraImageFileName) ) } fun createCameraCacheDir() { - CAMERA_CACHE_DIR.mkdirs() - if (!CAMERA_CACHE_DIR.isDirectory) { - throw IOException("Cannot create ${CAMERA_CACHE_DIR.absolutePath}.") + CAMERA_CACHE_DIRECTORY.mkdirs() + if (!CAMERA_CACHE_DIRECTORY.isDirectory) { + throw IOException("Cannot create ${CAMERA_CACHE_DIRECTORY.absolutePath}.") } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java b/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java index 0d0651bd0ec..c074ca4f33c 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -87,7 +87,7 @@ import static org.catrobat.catroid.common.Constants.DEFAULT_SOUND_EXTENSION; import static org.catrobat.catroid.common.Constants.IMAGE_DIRECTORY_NAME; import static org.catrobat.catroid.common.Constants.JPEG_IMAGE_EXTENSION; -import static org.catrobat.catroid.common.Constants.MEDIA_LIBRARY_CACHE_DIR; +import static org.catrobat.catroid.common.Constants.MEDIA_LIBRARY_CACHE_DIRECTORY; import static org.catrobat.catroid.common.Constants.SOUND_DIRECTORY_NAME; import static org.catrobat.catroid.common.Constants.TMP_IMAGE_FILE_NAME; import static org.catrobat.catroid.common.FlavoredConstants.LIBRARY_BACKGROUNDS_URL_LANDSCAPE; @@ -498,8 +498,8 @@ private void addSpriteFromUri(final Uri uri, String imageExtension) { builder.setTitle(R.string.new_sprite_dialog_title) .setNegativeButton(R.string.cancel, (dialog, which) -> { try { - if (MEDIA_LIBRARY_CACHE_DIR.exists()) { - StorageOperations.deleteDir(MEDIA_LIBRARY_CACHE_DIR); + if (MEDIA_LIBRARY_CACHE_DIRECTORY.exists()) { + StorageOperations.deleteDir(MEDIA_LIBRARY_CACHE_DIRECTORY); } } catch (IOException e) { Log.e(TAG, Log.getStackTraceString(e)); diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/WebViewActivity.java b/catroid/src/main/java/org/catrobat/catroid/ui/WebViewActivity.java index 4badf844db7..0f43e3280d0 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/WebViewActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/WebViewActivity.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -63,7 +63,7 @@ import androidx.core.content.res.ResourcesCompat; import static org.catrobat.catroid.common.Constants.MAIN_URL_HTTPS; -import static org.catrobat.catroid.common.Constants.MEDIA_LIBRARY_CACHE_DIR; +import static org.catrobat.catroid.common.Constants.MEDIA_LIBRARY_CACHE_DIRECTORY; import static org.catrobat.catroid.common.FlavoredConstants.CATROBAT_HELP_URL; import static org.catrobat.catroid.common.FlavoredConstants.LIBRARY_BASE_URL; import static org.catrobat.catroid.ui.MainMenuActivity.surveyCampaign; @@ -121,13 +121,13 @@ protected void onCreate(Bundle savedInstanceState) { } else if (downloadUrl.contains(LIBRARY_BASE_URL)) { String fileName = URLUtil.guessFileName(downloadUrl, contentDisposition, mimetype); - MEDIA_LIBRARY_CACHE_DIR.mkdirs(); - if (!MEDIA_LIBRARY_CACHE_DIR.isDirectory()) { - Log.e(TAG, "Cannot create " + MEDIA_LIBRARY_CACHE_DIR); + MEDIA_LIBRARY_CACHE_DIRECTORY.mkdirs(); + if (!MEDIA_LIBRARY_CACHE_DIRECTORY.isDirectory()) { + Log.e(TAG, "Cannot create " + MEDIA_LIBRARY_CACHE_DIRECTORY); return; } - File file = new File(MEDIA_LIBRARY_CACHE_DIR, fileName); + File file = new File(MEDIA_LIBRARY_CACHE_DIRECTORY, fileName); resultIntent.putExtra(MEDIA_FILE_PATH, file.getAbsolutePath()); new MediaDownloader(this) .startDownload(this, downloadUrl, fileName, file.getAbsolutePath()); diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/StageDialog.java b/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/StageDialog.java index 069b2fef48c..236804091a4 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/StageDialog.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/StageDialog.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -148,7 +148,7 @@ private void shareEmbroideryFile() { String filename = FileMetaDataExtractor.encodeSpecialCharsForFileSystem(ProjectManager.getInstance().getCurrentProject().getName()); DSTFileGenerator dstFileGenerator = new DSTFileGenerator(stageListener.embroideryPatternManager.getEmbroideryStream()); - File dstFile = new File(Constants.CACHE_DIR, filename + Constants.EMBROIDERY_FILE_EXTENSION); + File dstFile = new File(Constants.CACHE_DIRECTORY, filename + Constants.EMBROIDERY_FILE_EXTENSION); if (dstFile.exists()) { dstFile.delete(); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/filepicker/ListProjectFilesTask.java b/catroid/src/main/java/org/catrobat/catroid/ui/filepicker/ListProjectFilesTask.java index f2670e5fe35..09db58d18d4 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/filepicker/ListProjectFilesTask.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/filepicker/ListProjectFilesTask.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ import static org.catrobat.catroid.common.Constants.BACKPACK_DIRECTORY_NAME; import static org.catrobat.catroid.common.Constants.CATROBAT_EXTENSION; import static org.catrobat.catroid.common.Constants.CODE_XML_FILE_NAME; -import static org.catrobat.catroid.common.Constants.TMP_DIR_NAME; +import static org.catrobat.catroid.common.Constants.TMP_DIRECTORY_NAME; import static org.catrobat.catroid.common.FlavoredConstants.EXTERNAL_STORAGE_ROOT_DIRECTORY; public class ListProjectFilesTask extends AsyncTask> { @@ -74,7 +74,7 @@ public static void getAllProjectsFromPocketCodeFolder(List projectFiles) { } for (File dir : EXTERNAL_STORAGE_ROOT_DIRECTORY.listFiles()) { if (!dir.getName().equals(BACKPACK_DIRECTORY_NAME) - && !dir.getName().equals(TMP_DIR_NAME) + && !dir.getName().equals(TMP_DIRECTORY_NAME) && dir.isDirectory() && new File(dir, CODE_XML_FILE_NAME).exists()) { projectFiles.add(dir); diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/NewSpriteDialogFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/NewSpriteDialogFragment.kt index 003af5839ba..fc7e7a5bc25 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/NewSpriteDialogFragment.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/NewSpriteDialogFragment.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -147,8 +147,8 @@ class NewSpriteDialogFragment( private fun handleNegativeButton() { try { - if (Constants.MEDIA_LIBRARY_CACHE_DIR.exists()) { - StorageOperations.deleteDir(Constants.MEDIA_LIBRARY_CACHE_DIR) + if (Constants.MEDIA_LIBRARY_CACHE_DIRECTORY.exists()) { + StorageOperations.deleteDir(Constants.MEDIA_LIBRARY_CACHE_DIRECTORY) } } catch (exception: IOException) { Log.e(TAG, Log.getStackTraceString(exception)) diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.kt index 2b770801af5..ab0d0f48ae3 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -136,8 +136,8 @@ class LookListFragment : RecyclerViewFragment() { } private fun disposeItem() { - if (Constants.TEMP_LOOK_FILE.exists()) { - Constants.TEMP_LOOK_FILE.delete() + if (Constants.TMP_LOOK_FILE.exists()) { + Constants.TMP_LOOK_FILE.delete() currentItem = null } } @@ -193,7 +193,7 @@ class LookListFragment : RecyclerViewFragment() { fun undo(): Boolean { currentItem?.let { try { - StorageOperations.copyFile(Constants.TEMP_LOOK_FILE, it.file) + StorageOperations.copyFile(Constants.TMP_LOOK_FILE, it.file) } catch (e: IOException) { Log.e(TAG, Log.getStackTraceString(e)) } @@ -221,7 +221,7 @@ class LookListFragment : RecyclerViewFragment() { item?.invalidateThumbnailBitmap() item?.clearCollisionInformation() try { - StorageOperations.copyFile(currentItem?.file, Constants.TEMP_LOOK_FILE) + StorageOperations.copyFile(currentItem?.file, Constants.TMP_LOOK_FILE) } catch (e: IOException) { Log.e(TAG, Log.getStackTraceString(e)) } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.kt index f7848c05c02..16db1644329 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -341,7 +341,7 @@ class ProjectListFragment : RecyclerViewFragment(), ProjectLoadLis private fun copyFileContentToCacheFile(uri: Uri, fileName: String) { val projectFile = StorageOperations.copyUriToDir( requireActivity().contentResolver, uri, - Constants.CACHE_DIR, fileName + Constants.CACHE_DIRECTORY, fileName ) filesForUnzipAndImportTask?.add(projectFile) hasUnzipAndImportTaskFinished = false diff --git a/catroid/src/test/java/org/catrobat/catroid/test/transfers/ProjectUploadTest.kt b/catroid/src/test/java/org/catrobat/catroid/test/transfers/ProjectUploadTest.kt index 622a850854a..c292955d186 100644 --- a/catroid/src/test/java/org/catrobat/catroid/test/transfers/ProjectUploadTest.kt +++ b/catroid/src/test/java/org/catrobat/catroid/test/transfers/ProjectUploadTest.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2019 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -79,7 +79,7 @@ class ProjectUploadTest { screenshotLoader = mock(ProjectAndSceneScreenshotLoader::class.java) projectDirectory = mock(File::class.java) val deviceVariableFile = mock(File::class.java) - `when`(deviceVariableFile.getName()).thenReturn(Constants.DEVICE_VARIABLE_JSON_FILENAME) + `when`(deviceVariableFile.getName()).thenReturn(Constants.DEVICE_VARIABLE_JSON_FILE_NAME) projectDirectoryFilesFiltered = arrayOf(mock(File::class.java), mock(File::class.java), mock(File::class.java)) projectDirectoryFiles = projectDirectoryFilesFiltered + arrayOf(deviceVariableFile) archiveDirectory = mock(File::class.java)