File tree Expand file tree Collapse file tree
plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,16 +130,21 @@ class IdeProjectServiceImpl(
130130 }
131131
132132 return allowedPaths.any { allowedPath ->
133- canonicalPath.startsWith(allowedPath)
133+ canonicalPath == allowedPath || canonicalPath .startsWith(allowedPath + File .separator )
134134 }
135135 }
136136
137137 private fun getDefaultAllowedPaths (): List <String > {
138- return listOf (
139- " /storage/emulated/0/AndroidIDEProjects" ,
140- " /sdcard/AndroidIDEProjects" ,
141- System .getProperty(" user.home" , " /" ) + " /AndroidIDEProjects" ,
142- " /tmp/AndroidIDEProject" // Allow temporary project for demo purposes
143- )
138+ // Derive allowed roots from the official project API (IdeProjectService /
139+ // ProjectProvider) rather than hardcoding a projects-directory name. CodeOnTheGo
140+ // stores projects under CodeOnTheGoProjects and a project
141+ // can live anywhere the user opened it, so the open project's rootDir is the source
142+ // of truth for what this plugin may read.
143+ val roots = mutableListOf<File >()
144+ runCatching {
145+ projectProvider.getCurrentProject()?.rootDir?.let { roots.add(it) }
146+ projectProvider.getAllProjects().forEach { roots.add(it.rootDir) }
147+ }
148+ return roots.mapNotNull { root -> runCatching { root.canonicalPath }.getOrNull() }
144149 }
145150}
You can’t perform that action at this time.
0 commit comments