mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-13 03:51:10 +00:00
test(dual-screen): log the Steam chat page's layout structure
Temporary, for the next device test only: 4 s and 12 s after the chat page loads, log the element chain at the top, at the friends list and at the bottom of the page, plus the body's children (tag, id, classes, position, height; no text, long digit runs masked). Steam's header is not #global_header there and the friends list stops short of the bottom, so the real elements are needed before fixing it. To be removed with that fix.
This commit is contained in:
1 parent
80d954d24e
commit
083bdc0560
1 file changed
+23
@@ -74,6 +74,26 @@ internal fun steamChatFitScript(cssWidth: Int, scale: Float): String {
|
||||
"window.dispatchEvent(new Event('resize'));})()"
|
||||
}
|
||||
|
||||
// Test builds only: logs the chat page's element structure (tags, ids, classes, sizes; no text) to find what
|
||||
// holds the header and limits the friends list height. Remove once the layout is fixed.
|
||||
private const val CHAT_LAYOUT_PROBE = "(function(){" +
|
||||
"function m(v){return String(v).replace(/\\d{6,}/g,'#');}" +
|
||||
"function d(e){if(!e||!e.tagName)return null;var r=e.getBoundingClientRect(),c=getComputedStyle(e);" +
|
||||
"var k=typeof e.className==='string'&&e.className.trim()?'.'+e.className.trim().split(/\\s+/).slice(0,4).join('.'):'';" +
|
||||
"return m(e.tagName.toLowerCase()+(e.id?'#'+e.id:'')+k)+' y='+Math.round(r.top)+' h='+Math.round(r.height)+" +
|
||||
"' css='+c.height+' pos='+c.position+' disp='+c.display;}" +
|
||||
"function ch(e){var o=[];while(e&&e!==document.documentElement&&o.length<16){o.push(d(e));e=e.parentElement;}return o;}" +
|
||||
"var w=innerWidth,h=innerHeight;" +
|
||||
"return JSON.stringify({w:w,h:h,dpr:devicePixelRatio,vp:(document.querySelector('meta[name=viewport]')||{}).content," +
|
||||
"top:ch(document.elementFromPoint(w/2,8)),list:ch(document.elementFromPoint(40,h*0.6))," +
|
||||
"bottom:ch(document.elementFromPoint(40,h-6)),body:[].slice.call(document.body.children,0,16).map(d)});})()"
|
||||
|
||||
private fun logChatLayout(view: WebView, round: Int) {
|
||||
view.evaluateJavascript(CHAT_LAYOUT_PROBE) { json ->
|
||||
json.orEmpty().chunked(3000).forEachIndexed { i, part -> android.util.Log.i("BottomChatLayout", "r$round p$i $part") }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BottomChatPage() {
|
||||
val context = LocalContext.current
|
||||
@@ -159,6 +179,9 @@ private fun SteamChatView() {
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
val scale = view.resources.displayMetrics.density * CHAT_PAGE_SCALE
|
||||
if (view.width > 0) view.evaluateJavascript(steamChatFitScript((view.width / scale).roundToInt(), CHAT_PAGE_SCALE), null)
|
||||
android.util.Log.i("BottomChatLayout", "page finished ${url.substringBefore('?')} view ${view.width}x${view.height}")
|
||||
view.postDelayed({ logChatLayout(view, 1) }, 4_000L)
|
||||
view.postDelayed({ logChatLayout(view, 2) }, 12_000L)
|
||||
}
|
||||
}
|
||||
loadUrl(STEAM_CHAT)
|
||||
|
||||
Reference in new issue
Block a user