Skip to content

Commit

Permalink
CATROID-1286 Improve constants names
Browse files Browse the repository at this point in the history
  • Loading branch information
l-ilma committed Apr 18, 2022
1 parent a4d6482 commit 169be3d
Show file tree
Hide file tree
Showing 34 changed files with 125 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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(
Expand All @@ -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, ""))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ImportObjectIntoProjectFromContextMenuTest {
@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))
}
Expand All @@ -101,7 +101,7 @@ class ImportObjectIntoProjectFromContextMenuTest {
XstreamSerializer.getInstance().saveProject(importedProject)

val projectZip = File(
Constants.MEDIA_LIBRARY_CACHE_DIR,
Constants.MEDIA_LIBRARY_CACHE_DIRECTORY,
importedProject?.name + Constants.CATROBAT_EXTENSION
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand All @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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();
}
Expand All @@ -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());

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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<SpriteActivity> baseActivityTestRule = new
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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<ProjectActivity> baseActivityTestRule = new
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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<SpriteActivity> baseActivityTestRule = new
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -186,7 +186,7 @@ public void changeProjectName() throws IOException {
}

private Matcher<Intent> 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();
Expand Down
28 changes: 14 additions & 14 deletions catroid/src/main/java/org/catrobat/catroid/common/Constants.java
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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";
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 169be3d

Please sign in to comment.