6.7.0 - Alpha23 - 修复 floaty.rawWindow 因传入错误的上下文导致部分控件显示异常的问题

This commit is contained in:
SuperMonster003
2026-03-14 20:55:01 +08:00
parent 36b4a02f55
commit 6ffa12165d
4 changed files with 14 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
package org.autojs.autojs.core.floaty
import android.content.Context
import android.graphics.PixelFormat
import android.view.Gravity
import android.view.View
@@ -18,7 +19,10 @@ import org.autojs.autojs6.R
* Modified by SuperMonster003 as of Mar 27, 2022.
* Transformed by SuperMonster003 on Mar 27, 2022.
*/
class RawWindow(private val supplier: BaseResizableFloatyWindow.ViewSupplier) : FloatyWindow() {
class RawWindow(
private val context: Context,
private val supplier: BaseResizableFloatyWindow.ViewSupplier,
) : FloatyWindow() {
private val mInflateException = VolatileDispose<RuntimeException>()
@@ -35,8 +39,8 @@ class RawWindow(private val supplier: BaseResizableFloatyWindow.ViewSupplier) :
}
override fun onCreateView(floatyService: FloatyService): View {
val windowView = View.inflate(floatyService, R.layout.raw_window, null) as ViewGroup
contentView = supplier.inflate(floatyService, windowView)
val windowView = View.inflate(context, R.layout.raw_window, null) as ViewGroup
contentView = supplier.inflate(context, windowView)
return windowView
}
@@ -83,4 +87,4 @@ class RawWindow(private val supplier: BaseResizableFloatyWindow.ViewSupplier) :
updateWindowLayoutParams(this)
}
}
}
}

View File

@@ -177,7 +177,7 @@ class Floaty(private val uiHandler: UiHandler, private val scriptRuntime: Script
init {
val context = uiHandler.applicationContext
val window = RawWindow(supplier).also { mWindow = it }
val window = RawWindow(mContext, supplier).also { mWindow = it }
val r = Runnable {
context.startService(Intent(context, FloatyService::class.java))
FloatyService.addWindow(window)
@@ -332,5 +332,4 @@ class Floaty(private val uiHandler: UiHandler, private val scriptRuntime: Script
}
}
}
}
}