Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

### Fixed

## 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

## 1.4.0 - 2025-01-05

### Added
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/com/abeade/plugin/figma/ImportAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,15 +25,16 @@ 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
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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<AndroidVersion> { facet.queryMinSdkAndTargetSdkFromManifestIndex().minSdk }
ReadAction
.nonBlocking<AndroidVersion> { facet.queryMinSdkAndTargetSdkFromManifestIndex().minSdk }
.inSmartMode(project)
.executeSynchronously()
} catch (e: ProcessCanceledException) {
throw e
} catch (_: Exception) {
try {
MergedManifestManager.getMergedManifestSupplier(facet.module).get().get().minSdkVersion
Expand Down
Loading