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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies {
implementation("com.google.code.gson:gson:2.8.9")
implementation("com.squareup.okhttp3:okhttp:4.9.3")
implementation("com.squareup.okio:okio:3.4.0")
testImplementation("junit:junit:4.12")
testImplementation("junit:junit:4.13.1")
}

tasks {
Expand Down
12 changes: 5 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.6
# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion=17
# Gradle JVM settings
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
kotlin.code.style=official
# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
Expand All @@ -15,13 +13,13 @@ platformType=AI
#TODO: set to 2025.1.1.2
platformVersion=2024.3.1.7
pluginGroup=com.github.grishberg.android
pluginName=android-layout-inspector-plugin
pluginName=YALI
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
#TODO: set to 252.*
sinceBuild=243.22562.145
pluginVersion=25.08.04.0
pluginVersion=25.08.05.0
# Use the latest of Android plugin versionAdd commentMore actions
# see https://github.com/JetBrains/intellij-platform-gradle-plugin/releases
androidPluginVersion=243.22562.218
studioCompilePath=/Applications/Android Studio Preview.app/Contents
#localASVersion=/Applications/Android Studio.app/Contents
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package com.github.grishberg.android.layoutinspector.domain
import com.android.layoutinspector.model.LayoutFileData

interface LayoutResultOutput {

/**
* Show hierarchy and screenshot
*/
fun showResult(resultOutput: LayoutFileData, label: String? = null)
fun showResult(resultOutput: LayoutFileData, label: String? = null, isRefresh: Boolean = false)

fun showError(error: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import com.github.grishberg.android.layoutinspector.process.LayoutFileSystem
import com.github.grishberg.android.layoutinspector.process.LayoutInspectorCaptureTask
import com.github.grishberg.android.layoutinspector.process.RecordingConfig
import com.github.grishberg.android.layoutinspector.process.providers.ScreenSizeProvider
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.Date
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.Date

private const val TAG = "Logic"

Expand All @@ -33,6 +33,7 @@ class Logic(
private val coroutineScope: CoroutineScope,
private val dispatchers: CoroutinesDispatchers
) {

private val screenSizeProvider = ScreenSizeProvider(dispatchers)
private var recordingJob: Job? = null
private var isOpenedLayout = false
Expand Down Expand Up @@ -88,7 +89,6 @@ class Logic(
val dpPerPixels = (density / 160.0)
logger.d("$TAG: dp per pixels = $dpPerPixels")


val config = RecordingConfig(
recordOptions.client,
window,
Expand All @@ -114,7 +114,7 @@ class Logic(
}
val windowList: List<ClientWindow> = windows.await()
if (windowList.any { it.displayName == config.clientWindow.displayName }) {
captureLayouts(config)
captureLayouts(config, isRefresh = true)
} else {
recodLayoutFromNewDevice()
}
Expand All @@ -123,7 +123,7 @@ class Logic(
}

private suspend fun captureLayouts(
config: RecordingConfig,
config: RecordingConfig, isRefresh: Boolean = false
) {
val task = LayoutInspectorCaptureTask(layoutFileSystem, coroutineScope, logger, dispatchers)

Expand All @@ -134,13 +134,12 @@ class Logic(
if (liResult.data == null || liResult.root == null) {
output.showError(liResult.error)
} else {
onSuccessCaptured(config, liResult)
onSuccessCaptured(config, liResult, isRefresh)
}
}

private fun onSuccessCaptured(
config: RecordingConfig,
liResult: LayoutInspectorResult,
config: RecordingConfig, liResult: LayoutInspectorResult, isRefresh: Boolean = false
) {
val dpPerPixels = config.dpPerPixels
val fileNamePrefix = config.recordOptions.fileNamePrefix
Expand All @@ -158,7 +157,7 @@ class Logic(
metaRepository.serialize()

logger.d("$TAG: Received result")
output.showResult(LayoutFileData.fromLayoutInspectorResult(liResult), config.recordOptions.label)
output.showResult(LayoutFileData.fromLayoutInspectorResult(liResult), config.recordOptions.label, isRefresh)
isOpenedLayout = true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.github.grishberg.android.layoutinspector.ui

import java.awt.Dimension
import java.awt.geom.AffineTransform

data class LayoutsPreviewConfiguration(val size: Dimension, val transform: AffineTransform)
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ class Main(
copyScreenShot.addActionListener { copyScreenshotToClipboard() }
toolsMenu.add(copyScreenShot)

val syncLayoutsScaleMenuItem = JMenuItem("Sync scale from other layouts panel")
syncLayoutsScaleMenuItem.addActionListener { copyLayoutsConfiguration() }
toolsMenu.add(syncLayoutsScaleMenuItem)

return toolsMenu
}

Expand Down Expand Up @@ -494,15 +498,15 @@ class Main(
logic.openFile()
}

override fun showResult(resultOutput: LayoutFileData, label: String?) {
override fun showResult(resultOutput: LayoutFileData, label: String?, isRefresh: Boolean) {
val trimmedLabel = label?.trim()
if (!trimmedLabel.isNullOrEmpty()) {
this.title = trimmedLabel
} else {
this.title = TITLE
}

layoutPanel.showLayoutResult(resultOutput)
layoutPanel.showLayoutResult(resultOutput, isRefresh)
treePanel.showLayoutResult(resultOutput)
findDialog.updateRootNode(resultOutput.node)
splitPane1.invalidate()
Expand Down Expand Up @@ -671,6 +675,17 @@ class Main(
layoutPanel.repaint()
}

fun copyLayoutsConfiguration() {
windowsManager.getLayoutsPreviewConfiguration(this)?.let {
layoutPanel.setLayoutsConfigurationIfNeeded(it)
layoutPanel.repaint()
}
}

fun getLayoutsPreviewConfiguration(): LayoutsPreviewConfiguration {
return layoutPanel.getLayoutsPreviewConfiguration()
}

private companion object {
private const val TITLE = "Yet Another Android Layout Inspector."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class WindowsManager(
windows.remove(window)
}

fun getLayoutsPreviewConfiguration(currentWindow: Main): LayoutsPreviewConfiguration? {
if (windows.size != 2) {
logger.d("getLayoutsPreviewConfiguration: there is ${windows.size} windows")
return null
}

val referenceWindow = windows.first { it != currentWindow }
return referenceWindow.getLayoutsPreviewConfiguration()
}

fun startScreenshotTest(comparableWindow: Main): Boolean {
if (windows.size != 2) {
logger.d("startScreenshotTest: there is ${windows.size} windows")
Expand Down Expand Up @@ -62,4 +72,4 @@ class WindowsManager(
)
return true
}
}
}
Loading
Loading