From 078c9dd704b2057cf9f9b5f6cf8fea04a9dba162 Mon Sep 17 00:00:00 2001 From: Albert Beade Date: Wed, 30 Apr 2025 18:49:24 +0200 Subject: [PATCH 1/6] Update run android studio task to use meerkat version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b660c6c..eb7a514 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -153,7 +153,7 @@ tasks { val runAndroidStudio by intellijPlatformTesting.runIde.registering { type = IntelliJPlatformType.AndroidStudio - version = "2024.2.1.9" + version = "2024.3.1.2" } tasks.withType(RunIdeTask::class) { From c01a6dc26cea1f953a46f31e2982da0c97aa2a70 Mon Sep 17 00:00:00 2001 From: Albert Beade Date: Wed, 30 Apr 2025 18:50:51 +0200 Subject: [PATCH 2/6] Add action update thread override to use BGT --- src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt b/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt index 75e6978..928bc5c 100644 --- a/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt +++ b/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt @@ -5,6 +5,7 @@ import com.android.tools.idea.rendering.webp.ConvertToWebpAction import com.intellij.ide.util.PropertiesComponent import com.intellij.notification.NotificationGroupManager import com.intellij.notification.NotificationType +import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.PlatformDataKeys @@ -24,12 +25,14 @@ class ImportAction : AnAction() { private lateinit var virtualFileRes: VirtualFile + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT + override fun update(anActionEvent: AnActionEvent) { val project = anActionEvent.project val psiElement: PsiElement? = anActionEvent.dataContext.getData(PlatformDataKeys.PSI_ELEMENT) val isValid = project != null && psiElement != null && (psiElement as? PsiDirectoryImpl)?.isDirectory == true && - (psiElement as? PsiDirectoryImpl)?.name == RES_DIRECTORY + psiElement.name == RES_DIRECTORY anActionEvent.presentation.isEnabledAndVisible = isValid if (isValid) { virtualFileRes = (psiElement as PsiDirectoryImpl).virtualFile From 105c651b7b0e348c47278bd41c57e979680584a2 Mon Sep 17 00:00:00 2001 From: Albert Beade Date: Wed, 30 Apr 2025 18:53:06 +0200 Subject: [PATCH 3/6] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82c49b7..538c2d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ ### Fixed +- Plugin not working on AS Meerkat due to missing action update thread + ## 1.4.0 - 2025-01-05 ### Added From a7a4d404059ad1046b02e0ad324ebc732cc51c0b Mon Sep 17 00:00:00 2001 From: Albert Beade Date: Wed, 30 Apr 2025 18:55:00 +0200 Subject: [PATCH 4/6] Bump up plugin version --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 538c2d2..f47b3da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ ### Fixed +## 1.4.1 - 2025-04-30 + +### Fixed + - Plugin not working on AS Meerkat due to missing action update thread ## 1.4.0 - 2025-01-05 diff --git a/gradle.properties b/gradle.properties index aac1828..a674dbc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.abeade.plugin.figma pluginName = Import Figma Resources pluginRepositoryUrl = https://github.com/abeade/figma-import-plugin # SemVer format -> https://semver.org -pluginVersion = 1.4.0 +pluginVersion = 1.4.1 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 233 From 8d7340a5053060ceb3075e57770a05aba949108f Mon Sep 17 00:00:00 2001 From: Albert Beade Date: Wed, 30 Apr 2025 19:19:57 +0200 Subject: [PATCH 5/6] Change getMinSdkVersion function to avoid usage of deprecated API --- CHANGELOG.md | 4 ++++ .../figma/utils/AnActionEventExtensions.kt | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f47b3da..eeaebfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ ## 1.4.1 - 2025-04-30 +### Changed + +- Updated getMinSdkVersion function to avoid usage of deprecated API + ### Fixed - Plugin not working on AS Meerkat due to missing action update thread diff --git a/src/main/kotlin/com/abeade/plugin/figma/utils/AnActionEventExtensions.kt b/src/main/kotlin/com/abeade/plugin/figma/utils/AnActionEventExtensions.kt index 2dcdb82..2991596 100644 --- a/src/main/kotlin/com/abeade/plugin/figma/utils/AnActionEventExtensions.kt +++ b/src/main/kotlin/com/abeade/plugin/figma/utils/AnActionEventExtensions.kt @@ -7,8 +7,10 @@ import com.android.tools.idea.model.queryMinSdkAndTargetSdkFromManifestIndex import com.android.tools.idea.util.CommonAndroidUtil import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.LangDataKeys +import com.intellij.openapi.application.ReadAction import com.intellij.openapi.module.Module -import com.intellij.openapi.project.DumbService +import com.intellij.openapi.progress.ProcessCanceledException +import com.intellij.openapi.project.Project import org.jetbrains.android.facet.AndroidFacet fun AnActionEvent.getMinSdkVersion(): Int { @@ -17,17 +19,21 @@ fun AnActionEvent.getMinSdkVersion(): Int { if (module != null && CommonAndroidUtil.getInstance().isAndroidProject(module.project)) { val facet = AndroidFacet.getInstance(module) if (facet != null) { - val minSdk = getMinSdkVersion(facet) + val minSdk = getMinSdkVersion(facet, module.project) minSdkVersion = minSdk?.featureLevel ?: Int.MAX_VALUE } } return minSdkVersion } -private fun getMinSdkVersion(facet: AndroidFacet): AndroidVersion? = AndroidModel.get(facet)?.minSdkVersion +private fun getMinSdkVersion(facet: AndroidFacet, project: Project): AndroidVersion? = AndroidModel.get(facet)?.minSdkVersion ?: try { - DumbService.getInstance(facet.module.project) - .runReadActionInSmartMode { facet.queryMinSdkAndTargetSdkFromManifestIndex().minSdk } + ReadAction + .nonBlocking { facet.queryMinSdkAndTargetSdkFromManifestIndex().minSdk } + .inSmartMode(project) + .executeSynchronously() + } catch (e: ProcessCanceledException) { + throw e } catch (_: Exception) { try { MergedManifestManager.getMergedManifestSupplier(facet.module).get().get().minSdkVersion From de02c6f63cf48c0cd7052e7cef6142f1bff31e48 Mon Sep 17 00:00:00 2001 From: Albert Beade Date: Wed, 30 Apr 2025 19:31:19 +0200 Subject: [PATCH 6/6] Reduce redundant casting --- src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt b/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt index 928bc5c..0804dfd 100644 --- a/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt +++ b/src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt @@ -29,13 +29,12 @@ class ImportAction : AnAction() { override fun update(anActionEvent: AnActionEvent) { val project = anActionEvent.project - val psiElement: PsiElement? = anActionEvent.dataContext.getData(PlatformDataKeys.PSI_ELEMENT) - val isValid = project != null && psiElement != null && - (psiElement as? PsiDirectoryImpl)?.isDirectory == true && - psiElement.name == RES_DIRECTORY + val psiElement = anActionEvent.getData(PlatformDataKeys.PSI_ELEMENT) + val resDirectory = psiElement as? PsiDirectoryImpl + val isValid = project != null && resDirectory?.isDirectory == true && resDirectory.name == RES_DIRECTORY anActionEvent.presentation.isEnabledAndVisible = isValid if (isValid) { - virtualFileRes = (psiElement as PsiDirectoryImpl).virtualFile + virtualFileRes = resDirectory!!.virtualFile } }