Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Android Studio Meerkat | 2024.3.1 Canary 7 (2024.3.1.7) #173

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ build/
*.iml
*.iws

.intellijPlatform/
.intellijPlatform/

.kotlin
24 changes: 24 additions & 0 deletions .run/Run.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="runIde" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/RunLocal.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="RunLocal" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="runLocalIde" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
19 changes: 12 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -18,10 +18,13 @@ 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"

}

// 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 {
Expand Down Expand Up @@ -55,9 +58,8 @@ reckon {
snapshotFromProp()
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
kotlin {
jvmToolchain(21)
}

tasks.runIde {
Expand All @@ -81,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 {
Expand All @@ -89,7 +94,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")
Expand Down
12 changes: 9 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Android Studio Version
# Get it from `list-studio-versions.sh`
ideVersion=2024.3.1.2
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=242.23339
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.
Expand All @@ -16,4 +20,6 @@ sinceBuild=242.23339
kotlin.stdlib.default.dependency = false

org.gradle.parallel=true
org.gradle.caching=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx3072m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\\="-Xmx3072M" -XX\\:+UseParallelGC -XX:ReservedCodeCacheSize=512m
kotlin.code.style=official
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Wed Dec 25 15:42:43 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-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
30 changes: 19 additions & 11 deletions src/main/kotlin/com/developerphil/adbidea/Application.kt
Original file line number Diff line number Diff line change
@@ -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}")
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/developerphil/adbidea/ObjectGraph.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/developerphil/adbidea/ReflectKt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.developerphil.adbidea

import org.joor.Reflect

inline fun <reified T> on() = Reflect.on(T::class.java)
inline fun <reified T> on() = Reflect.onClass(T::class.java)
inline fun <reified T> Reflect.asType() = this.`as`(T::class.java)
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/com/developerphil/adbidea/adb/AdbUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,6 +113,9 @@ sealed class DeviceResult {
val packageName: String
) : DeviceResult()

object Cancelled : DeviceResult()
object DeviceNotFound : DeviceResult()
data object Cancelled : DeviceResult()
data object DeviceNotFound : DeviceResult()
}
//
//val Module.isAndroidApp: Boolean
// get() = AndroidFacet.getInstance(this)?.configuration?.isAppProject ?: false
Original file line number Diff line number Diff line change
Expand Up @@ -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<IDevice>? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,7 +45,7 @@ class Debugger(
terminateRunSessions(client)

coroutineScope.launch {
DebugSessionStarter.attachDebuggerToClientAndShowTab<AndroidDebuggerState>(
DebugSessionStarter.attachDebuggerToClientAndShowTab(
project,
client,
androidDebugger,
Expand Down Expand Up @@ -107,6 +107,6 @@ private class RunningProcessesGetter(
}

override fun getPreviousImplementation(): Array<ProcessHandler> {
return on<ExecutionManager>().call("getInstance", project).call("getRunningProcesses").get<Array<ProcessHandler>>()
return on<ExecutionManager>().call("getInstance", project).call("getRunningProcesses").get()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 16 additions & 13 deletions src/main/kotlin/com/developerphil/adbidea/ui/MyDeviceChooser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MyDeviceChooser(
private val myRefreshingAlarm: Alarm
private val myBridge: AndroidDebugBridge?
private val myMinSdkVersion: ListenableFuture<AndroidVersion> =
StudioAndroidModuleInfo.getInstance(myFacet).runtimeMinSdkVersion;
StudioAndroidModuleInfo.getInstance(myFacet).runtimeMinSdkVersion

private val myProjectTarget: IAndroidTarget =
getInstance(myFacet.module)?.target ?: error("Module [${myFacet.module.name}] already disposed")
Expand All @@ -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<String>? = null
Expand Down Expand Up @@ -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))
Expand All @@ -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()) {
Expand All @@ -219,7 +219,7 @@ class MyDeviceChooser(
val preferredFocusComponent: JComponent
get() = myDeviceTable

val panel: JComponent?
val panel: JComponent
get() = myPanel

val selectedDevices: Array<IDevice>
Expand Down Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -409,7 +413,6 @@ class MyDeviceChooser(
}

init {
myDeviceTable = JBTable()
myPanel = ScrollPaneFactory.createScrollPane(myDeviceTable)
myPanel.preferredSize = Dimension(450, 220)
myDeviceTable.model = MyDeviceTableModel(EMPTY_DEVICE_ARRAY)
Expand Down
Loading