From e754a98314bbc380ee2c1325b70209a7cdbc0bdf Mon Sep 17 00:00:00 2001 From: Raghav Satyadev Date: Thu, 19 Dec 2024 18:46:29 +0530 Subject: [PATCH 1/4] Compatibility with 2024.3.1.6 - Updated the IDE version to 2024.3.1.6. -> gradle.properties - added JVM Args and Kotlin Code Style. -> gradle.properties - Updated Gradle Wrapper to 8.12-rc-2. -> gradle-wrapper.properties - Updated Java compatibility to version 21. -> build.gradle.kts - Updated notification groups to use the NotificationGroupManager API. -> NotificationHelper.kt - Removed deprecation in ReflectKt.kt - Added Gradle Script file to run "buildPlugin runIde" commands directly without creating a configuration manually. -> BuildRun.run.xml - Updated .gitignore to exclude .kotlin folder --- .gitignore | 4 +- .run/BuildRun.run.xml | 26 +++ build.gradle.kts | 4 +- gradle.properties | 6 +- gradle/wrapper/gradle-wrapper.properties | 3 +- .../com/developerphil/adbidea/ReflectKt.kt | 2 +- .../adbidea/ui/NotificationHelper.kt | 50 ++++- src/main/resources/META-INF/plugin.xml | 192 ++++++++---------- 8 files changed, 170 insertions(+), 117 deletions(-) create mode 100644 .run/BuildRun.run.xml diff --git a/.gitignore b/.gitignore index ce09f24e..84856089 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ build/ *.iml *.iws -.intellijPlatform/ \ No newline at end of file +.intellijPlatform/ + +.kotlin \ No newline at end of file diff --git a/.run/BuildRun.run.xml b/.run/BuildRun.run.xml new file mode 100644 index 00000000..1fbe39ee --- /dev/null +++ b/.run/BuildRun.run.xml @@ -0,0 +1,26 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 438e76b2..4e2389d7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,8 +56,8 @@ reckon { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.runIde { diff --git a/gradle.properties b/gradle.properties index 941ec88a..b79809f0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Android Studio Version # Get it from `list-studio-versions.sh` -ideVersion=2024.3.1.2 +ideVersion=2024.3.1.6 # Minimum Intellij PLatform version supported by this plugin # see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html @@ -16,4 +16,6 @@ sinceBuild=242.23339 kotlin.stdlib.default.dependency = false org.gradle.parallel=true -org.gradle.caching=true \ No newline at end of file +org.gradle.caching=true +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" -XX\:+UseParallelGC +kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 171d8761..d7f5d570 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ +#Wed Dec 18 03:18:23 IST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-rc-2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/com/developerphil/adbidea/ReflectKt.kt b/src/main/kotlin/com/developerphil/adbidea/ReflectKt.kt index de7e7cf3..317ac497 100644 --- a/src/main/kotlin/com/developerphil/adbidea/ReflectKt.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ReflectKt.kt @@ -2,5 +2,5 @@ package com.developerphil.adbidea import org.joor.Reflect -inline fun on() = Reflect.on(T::class.java) +inline fun on() = Reflect.onClass(T::class.java) inline fun Reflect.asType() = this.`as`(T::class.java) \ No newline at end of file diff --git a/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt b/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt index 5b3492b8..a048f3bd 100644 --- a/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt @@ -1,20 +1,54 @@ package com.developerphil.adbidea.ui -import com.intellij.notification.NotificationDisplayType import com.intellij.notification.NotificationGroup +import com.intellij.notification.NotificationGroupManager +import com.intellij.notification.NotificationListener import com.intellij.notification.NotificationType object NotificationHelper { - private val INFO = NotificationGroup("ADB Idea (Logging)", NotificationDisplayType.NONE, true, null, null) - private val ERRORS = NotificationGroup("ADB Idea (Errors)", NotificationDisplayType.BALLOON, true, null, null) + fun info(message: String) { + sendNotification( + message, + NotificationType.INFORMATION, + NotificationGroupManager + .getInstance() + .getNotificationGroup("ADB Idea (Logging)") + ) + } + + // Function to send an error notification + fun error(message: String) { + sendNotification( + message, + NotificationType.ERROR, + NotificationGroupManager + .getInstance() + .getNotificationGroup("ADB Idea (Errors)") + ) + } - fun info(message: String) = sendNotification(message, NotificationType.INFORMATION, INFO) + // Helper function to create and display a notification + private fun sendNotification( + message: String, + notificationType: NotificationType, + notificationGroup: NotificationGroup, + ) { + // Create the notification without a listener + val notification = notificationGroup.createNotification( + "ADB IDEA", + escapeString(message), + notificationType + ) - fun error(message: String) = sendNotification(message, NotificationType.ERROR, ERRORS) + // Set the listener separately, if needed + notification.setListener(NotificationListener.URL_OPENING_LISTENER) - private fun sendNotification(message: String, notificationType: NotificationType, notificationGroup: NotificationGroup) { - notificationGroup.createNotification("ADB IDEA", escapeString(message), notificationType, null).notify(null) + // Display the notification + notification.notify(null) } - private fun escapeString(string: String) = string.replace("\n".toRegex(), "\n
") + private fun escapeString(string: String) = string.replace( + "\n".toRegex(), + "\n
" + ) } \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 12d0a789..1c5416da 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -2,7 +2,13 @@ com.developerphil.adbidea ADB Idea Philippe Breault + + + + + +
    @@ -31,108 +37,90 @@ org.jetbrains.android - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5d07d0c9d5151913ac1b0fa7b3b847f697918dd6 Mon Sep 17 00:00:00 2001 From: Raghav Satyadev Date: Fri, 20 Dec 2024 16:30:15 +0530 Subject: [PATCH 2/4] - removed unused imports - analyzed the project and fixed some suggestions from the studio analyzer -> DeviceResultFetcher.kt, UseSameDevicesHelper.kt, Debugger.kt, MyDeviceChooser.kt, ObjectGraph.kt - Updated run configurations to removed buildPlugin and make 2 separate configurations for runIde and runLocalIde - gradle-wrapper.properties downgraded to 8.11.1 - Removed listener from NotificationHelper.kt - Updated Application.kt to use @Service instead of Android Components API, removed from -> plugin.xml - Added temporary logo - Updated org.jetbrains.kotlin.jvm to 2.1.0 - Updated org.jetbrains.changelog to 2.2.1 - replaced sourceCompatibility with jvmToolchain - Updated sinceBuild to 243.22562.145 -> gradle.properties --- .run/BuildRun.run.xml | 26 ---------------- .run/Run.run.xml | 24 +++++++++++++++ .run/RunLocal.run.xml | 24 +++++++++++++++ build.gradle.kts | 11 ++++--- gradle.properties | 4 +-- gradle/wrapper/gradle-wrapper.properties | 4 +-- .../com/developerphil/adbidea/Application.kt | 30 ++++++++++++------- .../com/developerphil/adbidea/ObjectGraph.kt | 4 +-- .../adbidea/action/QuickListAction.kt | 1 - .../com/developerphil/adbidea/adb/AdbUtil.kt | 1 - .../adbidea/adb/DeviceResultFetcher.kt | 6 ++-- .../adbidea/adb/UseSameDevicesHelper.kt | 2 +- .../adbidea/debugger/Debugger.kt | 6 ++-- .../adbidea/ui/ModuleChooserDialogHelper.kt | 2 -- .../adbidea/ui/MyDeviceChooser.kt | 29 ++++++++++-------- .../adbidea/ui/NotificationHelper.kt | 6 +--- src/main/resources/META-INF/plugin.xml | 6 ---- src/main/resources/META-INF/pluginIcon.svg | 13 ++++++++ .../developerphil/adbidea/adb/FakeDevice.kt | 5 ---- .../adbidea/adb/UseSameDevicesHelperTest.kt | 7 ++--- 20 files changed, 117 insertions(+), 94 deletions(-) delete mode 100644 .run/BuildRun.run.xml create mode 100644 .run/Run.run.xml create mode 100644 .run/RunLocal.run.xml create mode 100644 src/main/resources/META-INF/pluginIcon.svg diff --git a/.run/BuildRun.run.xml b/.run/BuildRun.run.xml deleted file mode 100644 index 1fbe39ee..00000000 --- a/.run/BuildRun.run.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - true - true - false - false - - - \ No newline at end of file diff --git a/.run/Run.run.xml b/.run/Run.run.xml new file mode 100644 index 00000000..4c81fef7 --- /dev/null +++ b/.run/Run.run.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/.run/RunLocal.run.xml b/.run/RunLocal.run.xml new file mode 100644 index 00000000..ff03938a --- /dev/null +++ b/.run/RunLocal.run.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 4e2389d7..867a825f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { // Must match the Kotlin version bundled with the IDE // https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library // https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html - id("org.jetbrains.kotlin.jvm") version "2.0.21" + id("org.jetbrains.kotlin.jvm") version "2.1.0" // https://github.com/JetBrains/intellij-platform-gradle-plugin id("org.jetbrains.intellij.platform") version "2.1.0" @@ -18,7 +18,7 @@ plugins { id("com.github.b3er.local.properties") version "1.1" // https://github.com/JetBrains/gradle-changelog-plugin - id("org.jetbrains.changelog") version "2.0.0" + id("org.jetbrains.changelog") version "2.2.1" } @@ -55,9 +55,8 @@ reckon { snapshotFromProp() } -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 +kotlin { + jvmToolchain(21) } tasks.runIde { @@ -89,7 +88,7 @@ dependencies { } - implementation("org.jooq:joor-java-8:0.9.14") + implementation("org.jooq:joor:0.9.15") testImplementation("junit:junit:4.13.2") testImplementation("org.mockito:mockito-core:4.7.0") diff --git a/gradle.properties b/gradle.properties index b79809f0..36bf2c64 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ ideVersion=2024.3.1.6 # Minimum Intellij PLatform version supported by this plugin # see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html -sinceBuild=242.23339 +sinceBuild=243.22562.145 # The path to a local Android Studio installation. # This will enable the `runLocalIde` task. @@ -17,5 +17,5 @@ kotlin.stdlib.default.dependency = false org.gradle.parallel=true org.gradle.caching=true -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" -XX\:+UseParallelGC +org.gradle.jvmargs=-Xmx3072m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\\="-Xmx3072M" -XX\\:+UseParallelGC -XX:ReservedCodeCacheSize=512m kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d7f5d570..e62a8796 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ -#Wed Dec 18 03:18:23 IST 2024 +#Fri Dec 20 13:14:15 IST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-rc-2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/com/developerphil/adbidea/Application.kt b/src/main/kotlin/com/developerphil/adbidea/Application.kt index fcac65c1..73680bd1 100644 --- a/src/main/kotlin/com/developerphil/adbidea/Application.kt +++ b/src/main/kotlin/com/developerphil/adbidea/Application.kt @@ -1,29 +1,37 @@ package com.developerphil.adbidea -import com.developerphil.adbidea.preference.accessor.PreferenceAccessorImpl import com.developerphil.adbidea.preference.ApplicationPreferences +import com.developerphil.adbidea.preference.accessor.PreferenceAccessorImpl import com.developerphil.adbidea.ui.NotificationHelper -import com.intellij.ide.plugins.PluginManager +import com.intellij.ide.plugins.PluginManagerCore import com.intellij.ide.util.PropertiesComponent -import com.intellij.openapi.components.ApplicationComponent +import com.intellij.openapi.components.Service +import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.extensions.PluginId import com.intellij.util.text.SemVer - -private val pluginPackage = "com.developerphil.adbidea" - // This is more of a service locator than a proper DI framework. // It's not used often enough in the codebase to warrant the complexity of a DI solution like dagger. -class Application : ApplicationComponent { +@Service +class Application { + + private val logger = Logger.getInstance(Application::class.java) + private val pluginPackage = "com.developerphil.adbidea" private val applicationPreferencesAccessor = PreferenceAccessorImpl(PropertiesComponent.getInstance()) private val applicationPreferences = ApplicationPreferences(applicationPreferencesAccessor) - override fun initComponent() { + init { try { - val version = PluginManager.getPlugin(PluginId.getId(pluginPackage))!!.version!! - applicationPreferences.savePreviousPluginVersion(SemVer.parseFromText(version)!!) + val pluginId = PluginId.getId(pluginPackage) + val pluginDescriptor = PluginManagerCore.getPlugin(pluginId) + val version = pluginDescriptor?.version + if (version != null) { + applicationPreferences.savePreviousPluginVersion(SemVer.parseFromText(version)!!) + } else { + logger.error("Plugin version is null for plugin ID: $pluginId") + } } catch (e: Exception) { NotificationHelper.error("Couldn't initialize ADB Idea: ${e.message}") } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/developerphil/adbidea/ObjectGraph.kt b/src/main/kotlin/com/developerphil/adbidea/ObjectGraph.kt index ef2c34f7..9d69c9a3 100644 --- a/src/main/kotlin/com/developerphil/adbidea/ObjectGraph.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ObjectGraph.kt @@ -1,10 +1,10 @@ package com.developerphil.adbidea -import com.developerphil.adbidea.preference.accessor.PreferenceAccessorImpl import com.developerphil.adbidea.adb.BridgeImpl import com.developerphil.adbidea.adb.DeviceResultFetcher import com.developerphil.adbidea.adb.UseSameDevicesHelper import com.developerphil.adbidea.preference.ProjectPreferences +import com.developerphil.adbidea.preference.accessor.PreferenceAccessorImpl import com.intellij.ide.util.PropertiesComponent import com.intellij.openapi.components.Service import com.intellij.openapi.project.Project @@ -13,7 +13,7 @@ import kotlinx.coroutines.CoroutineScope // This is more of a service locator than a proper DI framework. // It's not used often enough in the codebase to warrant the complexity of a DI solution like dagger. @Service(Service.Level.PROJECT) -class ObjectGraph(private val project: Project, private val coroutineScope: CoroutineScope) { +class ObjectGraph(private val project: Project, coroutineScope: CoroutineScope) { val deviceResultFetcher by lazy { DeviceResultFetcher(project, useSameDevicesHelper, bridge) } val projectPreferences: ProjectPreferences by lazy { ProjectPreferences(projectPreferenceAccessor) } diff --git a/src/main/kotlin/com/developerphil/adbidea/action/QuickListAction.kt b/src/main/kotlin/com/developerphil/adbidea/action/QuickListAction.kt index daca1884..aca3080f 100644 --- a/src/main/kotlin/com/developerphil/adbidea/action/QuickListAction.kt +++ b/src/main/kotlin/com/developerphil/adbidea/action/QuickListAction.kt @@ -1,6 +1,5 @@ package com.developerphil.adbidea.action -import com.developerphil.adbidea.adb.AdbUtil import com.intellij.ide.actions.QuickSwitchSchemeAction import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.AnActionEvent diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/AdbUtil.kt b/src/main/kotlin/com/developerphil/adbidea/adb/AdbUtil.kt index f658fd01..ab74d2be 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/AdbUtil.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/AdbUtil.kt @@ -8,7 +8,6 @@ import com.android.tools.idea.gradle.project.sync.GradleSyncState import com.developerphil.adbidea.adb.command.receiver.GenericReceiver import com.developerphil.adbidea.ui.NotificationHelper.info import com.intellij.openapi.project.Project -import org.joor.Reflect import java.io.IOException import java.util.concurrent.TimeUnit diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt index c71770bd..d2104f71 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt @@ -20,7 +20,7 @@ import org.jetbrains.android.facet.AndroidFacet import org.joor.Reflect -class DeviceResultFetcher constructor( +class DeviceResultFetcher( private val project: Project, private val useSameDevicesHelper: UseSameDevicesHelper, private val bridge: Bridge @@ -113,6 +113,6 @@ sealed class DeviceResult { val packageName: String ) : DeviceResult() - object Cancelled : DeviceResult() - object DeviceNotFound : DeviceResult() + data object Cancelled : DeviceResult() + data object DeviceNotFound : DeviceResult() } diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelper.kt b/src/main/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelper.kt index 279e9293..ae002316 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelper.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelper.kt @@ -3,7 +3,7 @@ package com.developerphil.adbidea.adb import com.android.ddmlib.IDevice import com.developerphil.adbidea.preference.ProjectPreferences -class UseSameDevicesHelper constructor(private val projectPreferences: ProjectPreferences, private val bridge: Bridge) { +class UseSameDevicesHelper(private val projectPreferences: ProjectPreferences, private val bridge: Bridge) { var previouslyConnectedDevices: List? = null diff --git a/src/main/kotlin/com/developerphil/adbidea/debugger/Debugger.kt b/src/main/kotlin/com/developerphil/adbidea/debugger/Debugger.kt index 45b03081..e86480b3 100644 --- a/src/main/kotlin/com/developerphil/adbidea/debugger/Debugger.kt +++ b/src/main/kotlin/com/developerphil/adbidea/debugger/Debugger.kt @@ -2,10 +2,10 @@ package com.developerphil.adbidea.debugger import com.android.ddmlib.Client import com.android.ddmlib.IDevice -import com.android.tools.idea.execution.common.processhandler.AndroidProcessHandler import com.android.tools.idea.execution.common.debug.AndroidDebugger import com.android.tools.idea.execution.common.debug.AndroidDebuggerState import com.android.tools.idea.execution.common.debug.DebugSessionStarter +import com.android.tools.idea.execution.common.processhandler.AndroidProcessHandler import com.developerphil.adbidea.compatibility.BackwardCompatibleGetter import com.developerphil.adbidea.on import com.developerphil.adbidea.waitUntil @@ -45,7 +45,7 @@ class Debugger( terminateRunSessions(client) coroutineScope.launch { - DebugSessionStarter.attachDebuggerToClientAndShowTab( + DebugSessionStarter.attachDebuggerToClientAndShowTab( project, client, androidDebugger, @@ -107,6 +107,6 @@ private class RunningProcessesGetter( } override fun getPreviousImplementation(): Array { - return on().call("getInstance", project).call("getRunningProcesses").get>() + return on().call("getInstance", project).call("getRunningProcesses").get() } } diff --git a/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt b/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt index 3116993e..bd82eb67 100644 --- a/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ui/ModuleChooserDialogHelper.kt @@ -4,12 +4,10 @@ import com.intellij.ide.util.PropertiesComponent import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog -import com.intellij.ui.table.JBTable import com.intellij.util.ui.UIUtil import org.jetbrains.android.facet.AndroidFacet import java.awt.Component import java.awt.Dimension -import java.awt.geom.Dimension2D import javax.swing.JTable object ModuleChooserDialogHelper { diff --git a/src/main/kotlin/com/developerphil/adbidea/ui/MyDeviceChooser.kt b/src/main/kotlin/com/developerphil/adbidea/ui/MyDeviceChooser.kt index b2f5b1c2..49f61826 100755 --- a/src/main/kotlin/com/developerphil/adbidea/ui/MyDeviceChooser.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ui/MyDeviceChooser.kt @@ -74,7 +74,7 @@ class MyDeviceChooser( private val myRefreshingAlarm: Alarm private val myBridge: AndroidDebugBridge? private val myMinSdkVersion: ListenableFuture = - StudioAndroidModuleInfo.getInstance(myFacet).runtimeMinSdkVersion; + StudioAndroidModuleInfo.getInstance(myFacet).runtimeMinSdkVersion private val myProjectTarget: IAndroidTarget = getInstance(myFacet.module)?.target ?: error("Module [${myFacet.module.name}] already disposed") @@ -95,7 +95,7 @@ class MyDeviceChooser( */ private val myDetectedDevicesRef = AtomicReference(EMPTY_DEVICE_ARRAY) private val myPanel: JComponent - private val myDeviceTable: JBTable + private val myDeviceTable = JBTable() private var mySelectedRows: IntArray? = null private var hadUserInteraction = false private var previouslySelectedSerials: Array? = null @@ -180,7 +180,7 @@ class MyDeviceChooser( } }) } - if (!Arrays.equals(myDisplayedDevices, devices)) { + if (!myDisplayedDevices.contentEquals(devices)) { myDetectedDevicesRef.set(devices) ApplicationManager.getApplication() .invokeLater({ refreshTable() }, ModalityState.stateForComponent(myDeviceTable)) @@ -198,8 +198,8 @@ class MyDeviceChooser( } } myProcessSelectionFlag = false - myDeviceTable.setModel(MyDeviceTableModel(devices)) - if (selectedRows.size() == 0 && devices.size > 0) { + myDeviceTable.model = MyDeviceTableModel(devices) + if (selectedRows.size() == 0 && devices.isNotEmpty()) { myDeviceTable.selectionModel.setSelectionInterval(0, 0) } for (selectedRow in selectedRows.toNativeArray()) { @@ -219,7 +219,7 @@ class MyDeviceChooser( val preferredFocusComponent: JComponent get() = myDeviceTable - val panel: JComponent? + val panel: JComponent get() = myPanel val selectedDevices: Array @@ -336,12 +336,16 @@ class MyDeviceChooser( } override fun getColumnClass(columnIndex: Int): Class<*> { - return if (columnIndex == COMPATIBILITY_COLUMN_INDEX) { - LaunchCompatibility::class.java - } else if (columnIndex == DEVICE_NAME_COLUMN_INDEX) { - IDevice::class.java - } else { - String::class.java + return when (columnIndex) { + COMPATIBILITY_COLUMN_INDEX -> { + LaunchCompatibility::class.java + } + DEVICE_NAME_COLUMN_INDEX -> { + IDevice::class.java + } + else -> { + String::class.java + } } } @@ -409,7 +413,6 @@ class MyDeviceChooser( } init { - myDeviceTable = JBTable() myPanel = ScrollPaneFactory.createScrollPane(myDeviceTable) myPanel.preferredSize = Dimension(450, 220) myDeviceTable.model = MyDeviceTableModel(EMPTY_DEVICE_ARRAY) diff --git a/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt b/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt index a048f3bd..d541fb06 100644 --- a/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt +++ b/src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt @@ -2,7 +2,6 @@ package com.developerphil.adbidea.ui import com.intellij.notification.NotificationGroup import com.intellij.notification.NotificationGroupManager -import com.intellij.notification.NotificationListener import com.intellij.notification.NotificationType object NotificationHelper { @@ -37,12 +36,9 @@ object NotificationHelper { val notification = notificationGroup.createNotification( "ADB IDEA", escapeString(message), - notificationType + notificationType, ) - // Set the listener separately, if needed - notification.setListener(NotificationListener.URL_OPENING_LISTENER) - // Display the notification notification.notify(null) } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 1c5416da..8233f91e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -124,10 +124,4 @@ - - - - com.developerphil.adbidea.Application - - diff --git a/src/main/resources/META-INF/pluginIcon.svg b/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 00000000..74aa891b --- /dev/null +++ b/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/kotlin/com/developerphil/adbidea/adb/FakeDevice.kt b/src/test/kotlin/com/developerphil/adbidea/adb/FakeDevice.kt index 62e4318e..dfa2b46e 100644 --- a/src/test/kotlin/com/developerphil/adbidea/adb/FakeDevice.kt +++ b/src/test/kotlin/com/developerphil/adbidea/adb/FakeDevice.kt @@ -1,12 +1,7 @@ package com.developerphil.adbidea.adb import com.android.ddmlib.* -import com.android.ddmlib.log.LogReceiver -import com.android.sdklib.AndroidVersion -import java.io.File import java.lang.reflect.Proxy -import java.util.concurrent.Future -import java.util.concurrent.TimeUnit data class FakeDevice(private val serialNumber: String) : IDevice by stub() { override fun getSerialNumber(): String { diff --git a/src/test/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelperTest.kt b/src/test/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelperTest.kt index 19f68b4f..69880110 100644 --- a/src/test/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelperTest.kt +++ b/src/test/kotlin/com/developerphil/adbidea/adb/UseSameDevicesHelperTest.kt @@ -1,11 +1,8 @@ -package com.developerphil.adbidea +package com.developerphil.adbidea.adb import com.android.ddmlib.IDevice -import com.developerphil.adbidea.preference.accessor.InMemoryPreferenceAccessor -import com.developerphil.adbidea.adb.Bridge -import com.developerphil.adbidea.adb.FakeDevice -import com.developerphil.adbidea.adb.UseSameDevicesHelper import com.developerphil.adbidea.preference.ProjectPreferences +import com.developerphil.adbidea.preference.accessor.InMemoryPreferenceAccessor import com.google.common.truth.Truth.assertThat import org.junit.Test From c45ee9618a15e90e3b4d6ed48dd8f9eabc3f5311 Mon Sep 17 00:00:00 2001 From: Raghav Satyadev Date: Wed, 25 Dec 2024 17:03:08 +0530 Subject: [PATCH 3/4] - updated android studio compability to 2024.3.1.7 - updated gradle wrapper to 8.12 - readying the code for org.jetbrains.intellij.platform : 2.2.1 --- build.gradle.kts | 8 +++++++- gradle.properties | 8 ++++++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- .../com/developerphil/adbidea/adb/DeviceResultFetcher.kt | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 867a825f..7a3c8f92 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,10 @@ plugins { id("org.jetbrains.changelog") version "2.2.1" } - +// Readying the code for org.jetbrains.intellij.platform : 2.2.1 +//project.configurations.all { +// exclude(Constants.Configurations.Dependencies.BUNDLED_MODULE_GROUP, "com.jetbrains.performancePlugin") +//} repositories { mavenCentral() intellijPlatform { @@ -80,6 +83,9 @@ dependencies { intellijPlatform { bundledPlugin("org.jetbrains.android") instrumentationTools() +// Readying the code for org.jetbrains.intellij.platform : 2.2.1 +// plugin("org.jetbrains.android", property("androidPluginVersion").toString()) +// plugin("com.android.tools.design", property("androidPluginVersion").toString()) if (project.hasProperty("localIdeOverride")) { local(property("localIdeOverride").toString()) } else { diff --git a/gradle.properties b/gradle.properties index 36bf2c64..2c92c66d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,15 @@ # Android Studio Version # Get it from `list-studio-versions.sh` -ideVersion=2024.3.1.6 +ideVersion=2024.3.1.7 # Minimum Intellij PLatform version supported by this plugin # see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html sinceBuild=243.22562.145 +# Use the latest of Android plugin version +# see https://github.com/JetBrains/intellij-platform-gradle-plugin/releases +androidPluginVersion=243.22562.218 + # The path to a local Android Studio installation. # This will enable the `runLocalIde` task. # Should provide this either as a command line argument or in your home gradle.properties @@ -17,5 +21,5 @@ kotlin.stdlib.default.dependency = false org.gradle.parallel=true org.gradle.caching=true -org.gradle.jvmargs=-Xmx3072m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\\="-Xmx3072M" -XX\\:+UseParallelGC -XX:ReservedCodeCacheSize=512m +org.gradle.jvmargs=-Xmx3072m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\\="-Xmx3072M" -XX\\:+UseParallelGC -XX:ReservedCodeCacheSize=512m kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e62a8796..c4c9271a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ -#Fri Dec 20 13:14:15 IST 2024 +#Wed Dec 25 15:42:43 IST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt index d2104f71..3436ae75 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt @@ -116,3 +116,6 @@ sealed class DeviceResult { data object Cancelled : DeviceResult() data object DeviceNotFound : DeviceResult() } +// +//val Module.isAndroidApp: Boolean +// get() = AndroidFacet.getInstance(this)?.configuration?.isAppProject ?: false \ No newline at end of file From 8b4dbb5d4b36f24d96abdc125ccda157988233fb Mon Sep 17 00:00:00 2001 From: Raghav Satyadev Date: Sat, 4 Jan 2025 01:34:06 +0530 Subject: [PATCH 4/4] - Changes done as requested - removed plugin icon - removed commented code that was going to be used when upgrading org.jetbrains.intellij.platform to latest version --- build.gradle.kts | 7 ------- gradle.properties | 4 ---- .../adbidea/adb/DeviceResultFetcher.kt | 5 +---- src/main/resources/META-INF/pluginIcon.svg | 13 ------------- 4 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 src/main/resources/META-INF/pluginIcon.svg diff --git a/build.gradle.kts b/build.gradle.kts index 7a3c8f92..286a3932 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,10 +21,6 @@ plugins { id("org.jetbrains.changelog") version "2.2.1" } -// Readying the code for org.jetbrains.intellij.platform : 2.2.1 -//project.configurations.all { -// exclude(Constants.Configurations.Dependencies.BUNDLED_MODULE_GROUP, "com.jetbrains.performancePlugin") -//} repositories { mavenCentral() intellijPlatform { @@ -83,9 +79,6 @@ dependencies { intellijPlatform { bundledPlugin("org.jetbrains.android") instrumentationTools() -// Readying the code for org.jetbrains.intellij.platform : 2.2.1 -// plugin("org.jetbrains.android", property("androidPluginVersion").toString()) -// plugin("com.android.tools.design", property("androidPluginVersion").toString()) if (project.hasProperty("localIdeOverride")) { local(property("localIdeOverride").toString()) } else { diff --git a/gradle.properties b/gradle.properties index 2c92c66d..444e8adb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,10 +6,6 @@ ideVersion=2024.3.1.7 # see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html sinceBuild=243.22562.145 -# Use the latest of Android plugin version -# see https://github.com/JetBrains/intellij-platform-gradle-plugin/releases -androidPluginVersion=243.22562.218 - # The path to a local Android Studio installation. # This will enable the `runLocalIde` task. # Should provide this either as a command line argument or in your home gradle.properties diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt index 3436ae75..ee43fcec 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt @@ -115,7 +115,4 @@ sealed class DeviceResult { data object Cancelled : DeviceResult() data object DeviceNotFound : DeviceResult() -} -// -//val Module.isAndroidApp: Boolean -// get() = AndroidFacet.getInstance(this)?.configuration?.isAppProject ?: false \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/resources/META-INF/pluginIcon.svg b/src/main/resources/META-INF/pluginIcon.svg deleted file mode 100644 index 74aa891b..00000000 --- a/src/main/resources/META-INF/pluginIcon.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file