Skip to content

Commit

Permalink
v21.12.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigory-Rylov committed Dec 10, 2021
1 parent ff76366 commit e33a55a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Allows you to switch between displaying dimensions in **PX** and **DP** (only fo
![Searching mode](assets/find.png)

## Download
![GitHub All Releases](https://img.shields.io/github/downloads/Grigory-Rylov/android-layout-inspector-plugin/total?color=%234caf50&style=for-the-badge)
![GitHub All Releases](https://img.shields.io/github/downloads/Grigory-Rylov/android-layout-inspector/total?color=%234caf50&style=for-the-badge)

Find [YALI](https://plugins.jetbrains.com/plugin/15227-yali) in AS plugins repository.

OR

1) [Download latest release](https://github.com/Grigory-Rylov/android-layout-inspector-plugin/releases)
1) [Download latest release](https://github.com/Grigory-Rylov/android-layout-inspector/releases)
2) Preferences -> Plugins -> Install plugin from Disk...
3) Select android-layout-inspector-plugin-{VERSION}.jar

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ patchPluginXml {
Fixed screenshot offset in landscape on phones with cutouts.<br>
Fix propertie panel invalidation.<br>
Copy id by ctrl(cmd) + c.<br>
Clear selection after capture new layout.<br>
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Logic(

val task = LayoutInspectorCaptureTask(logger)

val liResult = task.capture(window, recordOptions.timeoutInSeconds)
val liResult = task.capture(recordOptions.client, window, recordOptions.timeoutInSeconds)

output.hideLoading()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
package com.github.grishberg.android.layoutinspector.process

import com.android.ddmlib.Client
import com.android.layoutinspector.LayoutInspectorBridge
import com.android.layoutinspector.LayoutInspectorBridge.V2_MIN_API
import com.android.layoutinspector.LayoutInspectorCaptureOptions
import com.android.layoutinspector.LayoutInspectorResult
import com.android.layoutinspector.ProtocolVersion
import com.android.layoutinspector.common.AppLogger
import com.android.layoutinspector.model.ClientWindow
import com.android.tools.idea.flags.StudioFlags
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async


private const val TAG = "LayoutInspectorCaptureTask"

class LayoutInspectorCaptureTask(
private val logger: AppLogger
) {
suspend fun capture(clientWindow: ClientWindow, timeoutInSeconds: Int): LayoutInspectorResult {
suspend fun capture(client: Client, clientWindow: ClientWindow, timeoutInSeconds: Int): LayoutInspectorResult {
val result = GlobalScope.async(Dispatchers.IO) {
logger.d("$TAG: start capture view timeout = $timeoutInSeconds")

try {
val version: ProtocolVersion = determineProtocolVersion(
client.device.version.apiLevel,
StudioFlags.LAYOUT_INSPECTOR_V2_PROTOCOL_ENABLED.get()
)
val options = LayoutInspectorCaptureOptions()
options.version = version

val captureView = LayoutInspectorBridge.captureView(
logger,
clientWindow,
LayoutInspectorCaptureOptions(),
options,
timeoutInSeconds.toLong()
)
return@async captureView
Expand All @@ -35,4 +47,8 @@ class LayoutInspectorCaptureTask(
logger.d("$TAG: capturing is done, error: ${await.error}")
return await
}

private fun determineProtocolVersion(apiVersion: Int, v2Enabled: Boolean): ProtocolVersion {
return if (apiVersion >= V2_MIN_API && v2Enabled) ProtocolVersion.Version2 else ProtocolVersion.Version1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class LayoutLogic(
}

fun showLayoutResult(layoutData: LayoutFileData) {
removeSelection()

root = layoutData.node

layoutData.bufferedImage?.let {
Expand Down

0 comments on commit e33a55a

Please sign in to comment.