Skip to content

Commit 02ce76b

Browse files
Merge pull request #57 from Grigory-Rylov/fix/dialog-processes-refresh
Fix: Auto-refresh device list in Select Layout recording dialog
2 parents f8d1f97 + eade15d commit 02ce76b

7 files changed

Lines changed: 87 additions & 38 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ on:
44
push:
55
branches:
66
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
710

811
jobs:
912
build-artifact:
1013
runs-on: ubuntu-latest
1114
outputs:
1215
plugin_version: ${{ steps.get_version.outputs.plugin_version }}
16+
is_master: ${{ steps.check_branch.outputs.is_master }}
1317
steps:
1418
- name: Checkout code
1519
uses: actions/checkout@v4
@@ -21,7 +25,10 @@ jobs:
2125
java-version: '21'
2226

2327
- name: Set up Gradle
24-
uses: gradle/gradle-build-action@v3
28+
uses: gradle/actions/setup-gradle@v4
29+
with:
30+
gradle-version: '8.13'
31+
cache-disabled: true
2532

2633
- name: Extract plugin version
2734
id: get_version
@@ -30,6 +37,15 @@ jobs:
3037
echo "$version" > plugin-version.txt
3138
echo "plugin_version=$version" >> $GITHUB_OUTPUT
3239
40+
- name: Check if master branch
41+
id: check_branch
42+
run: |
43+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
44+
echo "is_master=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "is_master=false" >> $GITHUB_OUTPUT
47+
fi
48+
3349
- name: Build plugin
3450
run: ./gradlew buildPlugin
3551

@@ -50,7 +66,7 @@ jobs:
5066
path: plugin-version.txt
5167

5268
release:
53-
if: github.ref == 'refs/heads/master'
69+
if: needs.build-artifact.outputs.is_master == 'true'
5470
needs: build-artifact
5571
runs-on: ubuntu-latest
5672
steps:

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ plugins {
44
// Java support
55
id("java")
66
// Kotlin support
7-
id("org.jetbrains.kotlin.jvm") version "2.1.0"
7+
id("org.jetbrains.kotlin.jvm") version "2.2.20"
88
// https://github.com/JetBrains/intellij-platform-gradle-plugin
9-
id("org.jetbrains.intellij.platform") version "2.6.0"
9+
id("org.jetbrains.intellij.platform") version "2.10.5"
1010
// https://github.com/JetBrains/gradle-changelog-plugin
1111
id("org.jetbrains.changelog") version "2.2.1"
1212
}

gradle.properties

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Gradle JVM settings
2-
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
2+
org.gradle.jvmargs=-Xmx4096m
33
kotlin.code.style=official
4+
org.gradle.parallel=true
45
# Opt-out flag for bundling Kotlin standard library.
56
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
67
# suppress inspection "UnusedProperty"
@@ -10,16 +11,14 @@ kotlin.stdlib.default.dependency=false
1011
platformPlugins=android
1112
# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
1213
platformType=AI
13-
#TODO: set to 2025.1.1.2
14-
platformVersion=2024.3.1.7
14+
platformVersion=2025.3.1.1
1515
pluginGroup=com.github.grishberg.android
1616
pluginName=YALI
1717
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1818
# for insight into build numbers and IntelliJ Platform versions.
19-
#TODO: set to 252.*
20-
sinceBuild=243.22562.145
21-
pluginVersion=25.08.05.0
19+
sinceBuild=253.28294.334
20+
pluginVersion=26.04.12.0
2221
# Use the latest of Android plugin versionAdd commentMore actions
2322
# see https://github.com/JetBrains/intellij-platform-gradle-plugin/releases
24-
androidPluginVersion=243.22562.218
23+
# androidPluginVersion=251.25410.109
2524
#localASVersion=/Applications/Android Studio.app/Contents
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/main/kotlin/com/android/layoutinspector/model/TreePathUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object TreePathUtils {
2222
var node: AbstractViewNode? = node
2323
val nodes = Lists.newArrayList<Any>()
2424
do {
25-
nodes.add(0, node)
25+
nodes.add(0, node!!)
2626
node = node?.parent as AbstractViewNode?
2727
} while (node != null && node !== root)
2828
if (root != null && node === root) {

src/main/kotlin/com/github/grishberg/android/layoutinspector/ui/dialogs/NewLayoutDialog.kt

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class NewLayoutDialog(
4545
private val resetConnectionButton: JButton
4646
private val clientsList: JBList<ClientWrapper>
4747
private val deviceChangedAction = DeviceChangedActions()
48+
private var processesRefreshJob: Job? = null
4849
var result: LayoutRecordOptions? = null
4950
private set
5051

@@ -73,6 +74,7 @@ class NewLayoutDialog(
7374
}
7475

7576
showAllProcesses = JCheckBox("any processes")
77+
showAllProcesses.isSelected = true
7678
showAllProcesses.addActionListener {
7779
val deviceWrapper = devicesComboBox.selectedItem as DeviceWrapper?
7880

@@ -81,6 +83,27 @@ class NewLayoutDialog(
8183
}
8284
}
8385

86+
// Start processes refresh timer when dialog is shown
87+
addWindowListener(object : java.awt.event.WindowAdapter() {
88+
override fun windowOpened(e: java.awt.event.WindowEvent?) {
89+
logger.d("$TAG: windowOpened() - Starting process auto-refresh")
90+
// Immediately populate clients for the selected device
91+
val deviceWrapper = devicesComboBox.selectedItem as DeviceWrapper?
92+
if (deviceWrapper != null) {
93+
logger.d("$TAG: windowOpened() - Populating clients for device: ${deviceWrapper.device}")
94+
populateWithClients(deviceWrapper.device)
95+
} else {
96+
logger.w("$TAG: windowOpened() - No device selected")
97+
}
98+
startProcessesRefreshTimer()
99+
}
100+
101+
override fun windowClosed(e: java.awt.event.WindowEvent?) {
102+
logger.d("$TAG: windowClosed() - Stopping process auto-refresh")
103+
stopProcessesRefreshTimer()
104+
}
105+
})
106+
84107
clientsList = JBList(clientListModel)
85108
val listScroll = JBScrollPane(clientsList)
86109
setupClientsList(clientsList)
@@ -237,24 +260,31 @@ class NewLayoutDialog(
237260
}
238261

239262
fun showDialog() {
263+
logger.d("$TAG: showDialog() - Opening dialog")
240264
deviceProvider.deviceChangedActions.add(deviceChangedAction)
241265
setLocationRelativeTo(owner)
242266
result = null
243267
populateWithDevices()
244268
isVisible = true
269+
logger.d("$TAG: showDialog() - Dialog closed, result: ${result != null}")
245270
}
246271

247272
private fun populateWithDevices() {
273+
logger.d("$TAG: populateWithDevices() - Requesting devices from provider")
248274
GlobalScope.launch(Dispatchers.EDT) {
249275
val devices = deviceProvider.requestDevices()
250-
logger.d("$TAG: received ${devices.size} devices")
276+
logger.d("$TAG: populateWithDevices() - received ${devices.size} devices")
251277
devicesComboBox.removeAllItems()
252278
for (device in devices) {
253279
devicesComboBox.addItem(RealDeviceWrapper(device))
280+
logger.d("$TAG: populateWithDevices() - added device: ${device}")
254281
}
255282

256283
if (devicesComboBox.itemCount > 0) {
257284
devicesComboBox.selectedIndex = 0
285+
// Immediately populate clients for the first device
286+
logger.d("$TAG: populateWithDevices() - selecting first device and populating clients")
287+
populateWithClients((devicesComboBox.selectedItem as DeviceWrapper).device)
258288
}
259289
if (devicesComboBox.itemCount == 1) {
260290
clientsList.requestFocus()
@@ -263,6 +293,7 @@ class NewLayoutDialog(
263293
}
264294

265295
private fun populateWithClients(device: IDevice) {
296+
logger.d("$TAG: populateWithClients() called for device: ${device}")
266297
GlobalScope.launch(Dispatchers.EDT) {
267298
val clients = getClientsWithWindow(device, showAllProcesses.isSelected)
268299
clientListModel.clear()
@@ -280,6 +311,7 @@ class NewLayoutDialog(
280311
}
281312
pack()
282313
repaint()
314+
logger.d("$TAG: populateWithClients() completed, clients count: ${clients.size}")
283315
}
284316
}
285317

@@ -340,6 +372,32 @@ class NewLayoutDialog(
340372
}
341373
}
342374

375+
private fun startProcessesRefreshTimer() {
376+
logger.d("$TAG: startProcessesRefreshTimer() - Starting 3-second refresh timer")
377+
processesRefreshJob = GlobalScope.launch(Dispatchers.Default) {
378+
while (isActive) {
379+
delay(3000) // 3 seconds
380+
withContext(Dispatchers.EDT) {
381+
val deviceWrapper = devicesComboBox.selectedItem as DeviceWrapper?
382+
if (deviceWrapper != null) {
383+
logger.d("$TAG: timer tick - populating clients for device: ${deviceWrapper.device}")
384+
populateWithClients(deviceWrapper.device)
385+
} else {
386+
logger.w("$TAG: timer tick - no device selected, skipping refresh")
387+
}
388+
}
389+
}
390+
}
391+
logger.d("$TAG: startProcessesRefreshTimer() - Timer job started: ${processesRefreshJob?.hashCode()}")
392+
}
393+
394+
private fun stopProcessesRefreshTimer() {
395+
logger.d("$TAG: stopProcessesRefreshTimer() - Cancelling timer job: ${processesRefreshJob?.hashCode()}")
396+
processesRefreshJob?.cancel()
397+
processesRefreshJob = null
398+
logger.d("$TAG: stopProcessesRefreshTimer() - Timer stopped")
399+
}
400+
343401
private inner class FocusPolicy : FocusTraversalPolicy() {
344402
override fun getComponentAfter(aContainer: Container, aComponent: Component): Component {
345403
return when (aComponent) {

src/main/resources/META-INF/pluginIcon.svg

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)