From 9c44895155ef48da1438b62464a3a941fa9e432b Mon Sep 17 00:00:00 2001 From: Philippe Breault Date: Sun, 17 Mar 2024 13:45:33 -0400 Subject: [PATCH] Fix #162- Bug (v1.6.11): for a project with multiple modules, it always asks on which to perform any operation --- CHANGELOG.md | 6 +++++- gradle.properties | 2 +- .../adbidea/adb/DeviceResultFetcher.kt | 21 +++++++++---------- .../adbidea/ui/ModuleChooserDialogHelper.kt | 7 +++---- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c7ee7..557058e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [[Unreleased]] +## [1.6.14] - 2024-03-17 +- Fix [#162](https://github.com/pbreault/adb-idea/issues/162) : Bug (v1.6.11): for a project with multiple modules, it always asks on which to perform any operation + ## [1.6.13] - 2023-12-05 - Compatibility with AS Iguana Canary 16 @@ -196,7 +199,8 @@ - Command to clear data - Command to clear data and restart -[Unreleased]: https://github.com/pbreault/adb-idea/compare/1.6.13...HEAD +[Unreleased]: https://github.com/pbreault/adb-idea/compare/1.6.14...HEAD +[1.6.14]: https://github.com/pbreault/adb-idea/compare/1.6.13...1.6.14 [1.6.13]: https://github.com/pbreault/adb-idea/compare/1.6.12...1.6.13 [1.6.12]: https://github.com/pbreault/adb-idea/compare/1.6.11...1.6.12 [1.6.11]: https://github.com/pbreault/adb-idea/compare/1.6.10...1.6.11 diff --git a/gradle.properties b/gradle.properties index b151fe9..588a818 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Android Studio Version # Get it from `list-studio-versions.sh` -ideVersion=2023.2.1.16 +ideVersion=2023.2.1.23 # Minimum Intellij PLatform version supported by this plugin # see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt index 07fb920..4a62817 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt @@ -1,6 +1,7 @@ package com.developerphil.adbidea.adb import com.android.ddmlib.IDevice +import com.android.tools.idea.insights.isAndroidApp import com.android.tools.idea.model.AndroidModel import com.android.tools.idea.util.androidFacet import com.developerphil.adbidea.adb.DeviceResult.DeviceNotFound @@ -49,19 +50,17 @@ class DeviceResultFetcher constructor( return null } - private fun getFacet(_facets: List): AndroidFacet? { - val facets = _facets.mapNotNull { it.holderModule.androidFacet }.distinct() - val facet: AndroidFacet? - if (facets.size > 1) { - facet = ModuleChooserDialogHelper.showDialogForFacets(project, facets) - if (facet == null) { - return null - } + private fun getFacet(facets: List): AndroidFacet? { + val appFacets = facets + .filter { it.holderModule.isAndroidApp } + .mapNotNull { it.holderModule.androidFacet } + .distinct() + + return if (appFacets.size > 1) { + ModuleChooserDialogHelper.showDialogForFacets(project, appFacets) } else { - facet = facets[0] + appFacets[0] } - - return facet } private fun showDeviceChooserDialog(facet: AndroidFacet, packageName: String): DeviceResult { diff --git a/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt b/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt index b54ec14..3116993 100644 --- a/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt @@ -28,7 +28,8 @@ object ModuleChooserDialogHelper { with(ChooseModulesDialog(project, modules, "Choose Module", "")) { setSingleSelectionMode() getSizeForTableContainer(preferredFocusedComponent)?.let { - setSize(it.width, it.height) + // Set the height to 0 to allow the dialog to resize itself to fit the content. + setSize(it.width, 0) } previousSelectedModule?.let { selectElements(listOf(it)) } return showAndGetResult().firstOrNull() @@ -45,10 +46,8 @@ object ModuleChooserDialogHelper { for (table in tables) { val tableSize = table.preferredSize size.width = size.width.coerceAtLeast(tableSize.width) - size.height = size.height.coerceAtLeast(tableSize.height + size.height - table.parent.height) } - size.width = 1000.coerceAtMost(600.coerceAtLeast(size.width)) - size.height = 800.coerceAtMost(size.height) + size.width = size.width.coerceIn(600, 1000) return size }