|
@@ -233,18 +233,17 @@ object FileUtils {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- fun changeProjectName(oldName: String, newName: String): Boolean {
|
|
|
|
|
|
+ fun changeProjectName(oldName: String, newName: String): Project {
|
|
val oldProjectFile = File("${Config.PROJECTS_FOLDER}/$oldName/${Config.PROJECT_FILE_NAME}")
|
|
val oldProjectFile = File("${Config.PROJECTS_FOLDER}/$oldName/${Config.PROJECT_FILE_NAME}")
|
|
- if (!oldProjectFile.exists())
|
|
|
|
- return false
|
|
|
|
var oldProject = Gson().fromJson<Project>(readFileToString(oldProjectFile), Project::class.java)
|
|
var oldProject = Gson().fromJson<Project>(readFileToString(oldProjectFile), Project::class.java)
|
|
|
|
|
|
val oldProjectFolder = File(Config.PROJECTS_FOLDER, oldName)
|
|
val oldProjectFolder = File(Config.PROJECTS_FOLDER, oldName)
|
|
val newProjectFolder = File(Config.PROJECTS_FOLDER, newName)
|
|
val newProjectFolder = File(Config.PROJECTS_FOLDER, newName)
|
|
- val result = oldProjectFolder.renameTo(newProjectFolder)
|
|
|
|
-
|
|
|
|
- if (result) {
|
|
|
|
|
|
+ val success = oldProjectFolder.renameTo(newProjectFolder)
|
|
|
|
|
|
|
|
+ if (!success) {
|
|
|
|
+ return oldProject
|
|
|
|
+ } else {
|
|
val newProjectFile = File("${Config.PROJECTS_FOLDER}/$newName/${Config.PROJECT_FILE_NAME}")
|
|
val newProjectFile = File("${Config.PROJECTS_FOLDER}/$newName/${Config.PROJECT_FILE_NAME}")
|
|
var oldProjectPath = File(Config.PROJECTS_FOLDER, oldName).absolutePath
|
|
var oldProjectPath = File(Config.PROJECTS_FOLDER, oldName).absolutePath
|
|
var newProjectPath = File(Config.PROJECTS_FOLDER, newName).absolutePath
|
|
var newProjectPath = File(Config.PROJECTS_FOLDER, newName).absolutePath
|
|
@@ -287,17 +286,17 @@ object FileUtils {
|
|
}
|
|
}
|
|
println("count = $count")
|
|
println("count = $count")
|
|
}
|
|
}
|
|
|
|
+ return newProject
|
|
|
|
|
|
- try {
|
|
|
|
- val fileWriter = FileWriter(newProjectFile)
|
|
|
|
- fileWriter.write(Gson().toJson(newProject))
|
|
|
|
- fileWriter.flush()
|
|
|
|
- fileWriter.close()
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
- e.printStackTrace()
|
|
|
|
- }
|
|
|
|
|
|
+// try {
|
|
|
|
+// val fileWriter = FileWriter(newProjectFile)
|
|
|
|
+// fileWriter.write(Gson().toJson(newProject))
|
|
|
|
+// fileWriter.flush()
|
|
|
|
+// fileWriter.close()
|
|
|
|
+// } catch (e: Exception) {
|
|
|
|
+// e.printStackTrace()
|
|
|
|
+// }
|
|
}
|
|
}
|
|
- return result
|
|
|
|
}
|
|
}
|
|
|
|
|
|
fun saveProject(context: Context, project: Project, scaleWidth: Int, scaleHeight: Int): Completable {
|
|
fun saveProject(context: Context, project: Project, scaleWidth: Int, scaleHeight: Int): Completable {
|