6.6.2 - Alpha7 - 新增 ui.statusBarHeight 属性 (getter) (issue #357)
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
"released_date": "2025/04/16",
|
"released_date": "2025/04/16",
|
||||||
"feature": [
|
"feature": [
|
||||||
"ui.statusBarAppearanceLight/statusBarAppearanceLightBy/navigationBarColor 等方法",
|
"ui.statusBarAppearanceLight/statusBarAppearanceLightBy/navigationBarColor 等方法",
|
||||||
|
"ui.statusBarHeight 属性 (getter), 用于获取状态栏高度 _[`issue #357`](http://issues.autojs6.com/357)_",
|
||||||
"images.flip 方法, 用于图像翻转 _[`issue #349`](http://issues.autojs6.com/349)_",
|
"images.flip 方法, 用于图像翻转 _[`issue #349`](http://issues.autojs6.com/349)_",
|
||||||
"设置页面增加 \"文件扩展名\" 设置选项",
|
"设置页面增加 \"文件扩展名\" 设置选项",
|
||||||
"主题色设置页面增加新布局支持 (分组/定位/搜索/历史记录/调色盘增强等)"
|
"主题色设置页面增加新布局支持 (分组/定位/搜索/历史记录/调色盘增强等)"
|
||||||
@@ -148,7 +149,7 @@
|
|||||||
"text/button/input 元素的文本内容包含半角双引号时无法正常解析的问题",
|
"text/button/input 元素的文本内容包含半角双引号时无法正常解析的问题",
|
||||||
"text/textswitcher 元素的 autoLink 属性功能失效的问题",
|
"text/textswitcher 元素的 autoLink 属性功能失效的问题",
|
||||||
"不同脚本可能错误地共享同一个 ScriptRuntime 对象的问题",
|
"不同脚本可能错误地共享同一个 ScriptRuntime 对象的问题",
|
||||||
"全局变量 HEIGHT 及 WIDTH 丢失 Getter 动态属性的问题",
|
"全局变量 HEIGHT 及 WIDTH 丢失 getter 动态属性的问题",
|
||||||
"脚本启动时 RootShell 随即加载可能导致启动高延迟的问题",
|
"脚本启动时 RootShell 随即加载可能导致启动高延迟的问题",
|
||||||
"控制台浮动窗口设置背景颜色导致矩形圆角样式丢失的问题",
|
"控制台浮动窗口设置背景颜色导致矩形圆角样式丢失的问题",
|
||||||
"无障碍服务自动启动可能出现的服务异常问题 (试修)",
|
"无障碍服务自动启动可能出现的服务异常问题 (试修)",
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import android.view.MenuItem
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.graphics.drawable.toDrawable
|
||||||
|
import androidx.core.view.isNotEmpty
|
||||||
import org.autojs.autojs.AbstractAutoJs.Companion.isInrt
|
import org.autojs.autojs.AbstractAutoJs.Companion.isInrt
|
||||||
import org.autojs.autojs.annotation.ScriptInterface
|
import org.autojs.autojs.annotation.ScriptInterface
|
||||||
import org.autojs.autojs.core.eventloop.EventEmitter
|
import org.autojs.autojs.core.eventloop.EventEmitter
|
||||||
@@ -65,7 +67,7 @@ class ScriptExecuteActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
val windowBackground: Drawable = window.decorView.background
|
val windowBackground: Drawable = window.decorView.background
|
||||||
?: ColorDrawable(getColor(R.color.md_gray_50)).also { window.setBackgroundDrawable(it) }
|
?: getColor(R.color.md_gray_50).toDrawable().also { window.setBackgroundDrawable(it) }
|
||||||
|
|
||||||
if (windowBackground is ColorDrawable) windowBackground.color.let { backgroundColor ->
|
if (windowBackground is ColorDrawable) windowBackground.color.let { backgroundColor ->
|
||||||
val isLightColor = ViewUtils.isLuminanceDark(backgroundColor)
|
val isLightColor = ViewUtils.isLuminanceDark(backgroundColor)
|
||||||
@@ -220,7 +222,7 @@ class ScriptExecuteActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
emit("create_options_menu", menu)
|
emit("create_options_menu", menu)
|
||||||
return menu.size() > 0
|
return menu.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package org.autojs.autojs.runtime.api.augment.ui
|
package org.autojs.autojs.runtime.api.augment.ui
|
||||||
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.graphics.drawable.toDrawable
|
||||||
import org.autojs.autojs.annotation.RhinoFunctionBody
|
import org.autojs.autojs.annotation.RhinoFunctionBody
|
||||||
import org.autojs.autojs.annotation.RhinoRuntimeFunctionInterface
|
import org.autojs.autojs.annotation.RhinoRuntimeFunctionInterface
|
||||||
import org.autojs.autojs.core.ui.JsViewHelper
|
import org.autojs.autojs.core.ui.JsViewHelper
|
||||||
@@ -131,6 +131,9 @@ class UI(private val scriptRuntime: ScriptRuntime) : AugmentableProxy(scriptRunt
|
|||||||
val activity = getActivity(scriptRuntime)
|
val activity = getActivity(scriptRuntime)
|
||||||
(activity as? ScriptExecuteActivity)?.eventEmitter
|
(activity as? ScriptExecuteActivity)?.eventEmitter
|
||||||
},
|
},
|
||||||
|
"statusBarHeight" to Supplier {
|
||||||
|
ViewUtils.getStatusBarHeightByDimen(globalContext)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -555,7 +558,7 @@ class UI(private val scriptRuntime: ScriptRuntime) : AugmentableProxy(scriptRunt
|
|||||||
ensureActivity(scriptRuntime) { activity ->
|
ensureActivity(scriptRuntime) { activity ->
|
||||||
runRhinoRuntime(scriptRuntime, newBaseFunction("action", {
|
runRhinoRuntime(scriptRuntime, newBaseFunction("action", {
|
||||||
Colors.toIntRhino(Colors.setAlphaRhino(color, 1.0)).also {
|
Colors.toIntRhino(Colors.setAlphaRhino(color, 1.0)).also {
|
||||||
activity.window.setBackgroundDrawable(ColorDrawable(it))
|
activity.window.setBackgroundDrawable(it.toDrawable())
|
||||||
}
|
}
|
||||||
}, NOT_CONSTRUCTABLE))
|
}, NOT_CONSTRUCTABLE))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ open class LayoutBoundsView : View {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
this.setWillNotDraw(false)
|
this.setWillNotDraw(false)
|
||||||
statusBarHeight = ViewUtils.getStatusBarHeight(context)
|
statusBarHeight = ViewUtils.getStatusBarHeightByWindow(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setOnNodeInfoSelectListener(onNodeInfoSelectListener: OnNodeInfoSelectListener?) {
|
fun setOnNodeInfoSelectListener(onNodeInfoSelectListener: OnNodeInfoSelectListener?) {
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class LayoutHierarchyView extends MultiLevelListView {
|
|||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
mPaint.setStrokeWidth(3);
|
mPaint.setStrokeWidth(3);
|
||||||
mStatusBarHeight = ViewUtils.getStatusBarHeight(getContext());
|
mStatusBarHeight = ViewUtils.getStatusBarHeightByWindow(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Paint getBoundsPaint() {
|
public Paint getBoundsPaint() {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.marginBottom
|
import androidx.core.view.marginBottom
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
@@ -50,8 +48,6 @@ class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListen
|
|||||||
private var mFloatingActionMenu: FloatingActionMenu? = null
|
private var mFloatingActionMenu: FloatingActionMenu? = null
|
||||||
private var mIsCurrentPageFiles = false
|
private var mIsCurrentPageFiles = false
|
||||||
|
|
||||||
private var mBottomInset: Int = 0
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
EventBus.getDefault().register(this)
|
EventBus.getDefault().register(this)
|
||||||
@@ -63,10 +59,6 @@ class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListen
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(view) { _, insets ->
|
|
||||||
mBottomInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom
|
|
||||||
insets
|
|
||||||
}
|
|
||||||
mExplorerView = binding.itemList.also { explorerView ->
|
mExplorerView = binding.itemList.also { explorerView ->
|
||||||
explorerView.setOnItemClickListener(object : ExplorerView.OnItemClickListener {
|
explorerView.setOnItemClickListener(object : ExplorerView.OnItemClickListener {
|
||||||
override fun onItemClick(view: View?, item: ExplorerItem) {
|
override fun onItemClick(view: View?, item: ExplorerItem) {
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ import org.autojs.autojs.theme.ThemeColorManager
|
|||||||
import org.autojs.autojs.util.StringUtils.key
|
import org.autojs.autojs.util.StringUtils.key
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
import androidx.core.view.size
|
||||||
|
import androidx.core.view.get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on Jan 24, 2017.
|
* Created by Stardust on Jan 24, 2017.
|
||||||
@@ -100,29 +102,40 @@ object ViewUtils {
|
|||||||
// ! 在一些设备上无法正常获取结果.
|
// ! 在一些设备上无法正常获取结果.
|
||||||
// ! 参阅: https://github.com/hyb1996/Auto.js/issues/268
|
// ! 参阅: https://github.com/hyb1996/Auto.js/issues/268
|
||||||
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
||||||
fun getStatusBarHeightLegacy(context: Context): Int {
|
@JvmStatic
|
||||||
return context.resources.getIdentifier("status_bar_height", "dimen", "android").let { resourceId ->
|
@JvmOverloads
|
||||||
when (resourceId > 0) {
|
fun getStatusBarHeightByDimen(context: Context, withFallback: Boolean = true): Int {
|
||||||
true -> context.resources.getDimensionPixelSize(resourceId)
|
val resourceId = context.resources.getIdentifier("status_bar_height", "dimen", "android")
|
||||||
else -> 0
|
val dimenStatusBarHeight = when (resourceId > 0) {
|
||||||
}
|
true -> context.resources.getDimensionPixelSize(resourceId)
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
return when {
|
||||||
|
dimenStatusBarHeight > 0 -> dimenStatusBarHeight
|
||||||
|
withFallback -> TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, context.resources.displayMetrics).toInt()
|
||||||
|
else -> 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getStatusBarHeight(context: Context): Int {
|
@JvmOverloads
|
||||||
return getWindowForContext(context)?.let { window ->
|
fun getStatusBarHeightByWindow(context: Context, withFallback: Boolean = true): Int {
|
||||||
Rect().let { rect ->
|
val windowStatusBarHeight = getWindowForContext(context)?.decorView?.let { decorView ->
|
||||||
window.decorView.getWindowVisibleDisplayFrame(rect)
|
Rect().also { rect ->
|
||||||
rect.top.takeIf { it >= 0 }
|
decorView.getWindowVisibleDisplayFrame(rect)
|
||||||
}
|
}.top
|
||||||
} ?: TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, context.resources.displayMetrics).toInt()
|
} ?: 0
|
||||||
|
return when {
|
||||||
|
windowStatusBarHeight > 0 -> windowStatusBarHeight
|
||||||
|
withFallback -> TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, context.resources.displayMetrics).toInt()
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTitleBarHeight(context: Context): Int {
|
fun getTitleBarHeight(context: Context): Int {
|
||||||
val window = getWindowForContext(context)
|
val window = getWindowForContext(context)
|
||||||
val contentViewTop = window?.findViewById<View>(Window.ID_ANDROID_CONTENT)?.top ?: 0
|
val contentViewTop = window?.findViewById<View>(Window.ID_ANDROID_CONTENT)?.top ?: 0
|
||||||
return contentViewTop - getStatusBarHeight(context)
|
return contentViewTop - getStatusBarHeightByWindow(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getScreenHeight(activity: Activity) = DisplayMetrics().let { metrics ->
|
fun getScreenHeight(activity: Activity) = DisplayMetrics().let { metrics ->
|
||||||
@@ -415,8 +428,8 @@ object ViewUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Menu.setItemsColor(color: Int) {
|
fun Menu.setItemsColor(color: Int) {
|
||||||
for (i in 0 until size()) {
|
for (i in 0 until size) {
|
||||||
val menuItem = getItem(i)
|
val menuItem = this[i]
|
||||||
menuItem.icon = menuItem.icon?.applyColorFilterWith(color)
|
menuItem.icon = menuItem.icon?.applyColorFilterWith(color)
|
||||||
menuItem.subMenu?.setItemsColor(color)
|
menuItem.subMenu?.setItemsColor(color)
|
||||||
}
|
}
|
||||||
@@ -471,11 +484,7 @@ object ViewUtils {
|
|||||||
val view = this
|
val view = this
|
||||||
val viewTreeObserver = view.viewTreeObserver
|
val viewTreeObserver = view.viewTreeObserver
|
||||||
if (viewTreeObserver.isAlive) {
|
if (viewTreeObserver.isAlive) {
|
||||||
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
viewTreeObserver.addOnGlobalLayoutListener { listener.invoke() }
|
||||||
override fun onGlobalLayout() {
|
|
||||||
listener.invoke()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +517,7 @@ object ViewUtils {
|
|||||||
val fullColor = context.getColor(if (isAimColorLight) R.color.day_full else R.color.night_full)
|
val fullColor = context.getColor(if (isAimColorLight) R.color.day_full else R.color.night_full)
|
||||||
val hintColor = context.getColor(if (isAimColorLight) R.color.day_alpha_70 else R.color.night_alpha_70)
|
val hintColor = context.getColor(if (isAimColorLight) R.color.day_alpha_70 else R.color.night_alpha_70)
|
||||||
|
|
||||||
findViewById<EditText?>(androidx.appcompat.R.id.search_src_text).apply {
|
findViewById<EditText?>(androidx.appcompat.R.id.search_src_text)?.apply {
|
||||||
setTextColor(fullColor)
|
setTextColor(fullColor)
|
||||||
setHintTextColor(hintColor)
|
setHintTextColor(hintColor)
|
||||||
setLinkTextColor(fullColor)
|
setLinkTextColor(fullColor)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Wed Apr 16 14:34:09 CST 2025
|
#Wed Apr 16 16:02:18 CST 2025
|
||||||
BUILD_TIME=1744785249350
|
BUILD_TIME=1744790538995
|
||||||
COMPILE_SDK_VERSION=35
|
COMPILE_SDK_VERSION=35
|
||||||
JAVA_VERSION=23
|
JAVA_VERSION=23
|
||||||
JAVA_VERSION_MIN_RADICAL=0
|
JAVA_VERSION_MIN_RADICAL=0
|
||||||
|
|||||||
Reference in New Issue
Block a user