4k
This commit is contained in:
@@ -11,8 +11,8 @@ android {
|
|||||||
applicationId = "com.tv.browser"
|
applicationId = "com.tv.browser"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 11
|
versionCode = 12
|
||||||
versionName = "4.5.0"
|
versionName = "5.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -565,7 +565,10 @@ class BrowserActivity : AppCompatActivity(), RemoteControlCallback {
|
|||||||
cursorOverlay?.post { initCursorPosition() }
|
cursorOverlay?.post { initCursorPosition() }
|
||||||
// 不监听 overlay 的 layout 变化,避免底部左右移动时 webView.scrollBy 触发布局导致 clampCursorToBounds 错误改动 cursorY;全屏切换等时由调用方主动 clamp
|
// 不监听 overlay 的 layout 变化,避免底部左右移动时 webView.scrollBy 触发布局导致 clampCursorToBounds 错误改动 cursorY;全屏切换等时由调用方主动 clamp
|
||||||
|
|
||||||
webView.setOnFocusChangeListener { _, hasFocus -> if (hasFocus) hideKeyboard() }
|
// 仅当焦点切到网页非输入区域时收起地址栏残留的软键盘;若用户直接点击网页内的输入框(onCheckIsTextEditor=true),不能收起键盘
|
||||||
|
webView.setOnFocusChangeListener { _, hasFocus ->
|
||||||
|
if (hasFocus && !webView.onCheckIsTextEditor()) hideKeyboard()
|
||||||
|
}
|
||||||
|
|
||||||
// 弹窗(DialogFragment)显示时隐藏光标、销毁时恢复,避免弹窗遮挡光标(按弹窗对象去重,重复回调也不会累积)
|
// 弹窗(DialogFragment)显示时隐藏光标、销毁时恢复,避免弹窗遮挡光标(按弹窗对象去重,重复回调也不会累积)
|
||||||
dialogCursorLifecycleCallbacks = object : FragmentManager.FragmentLifecycleCallbacks() {
|
dialogCursorLifecycleCallbacks = object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import android.util.AttributeSet
|
|||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TV 场景专用 WebView:
|
* 自定义 WebView:
|
||||||
* - 不作为文本编辑器,避免系统软键盘在网页输入框获得焦点时弹出
|
* - 保留系统默认的 onCheckIsTextEditor() 行为(仅在网页内 input/textarea 等可编辑元素聚焦时返回 true,以正常唤起手机/系统输入法)
|
||||||
* - 文字输入统一通过遥控网页转发
|
|
||||||
* - 暴露滚动监听,支持向下滚动自动收起工具栏,向上滚动自动唤出
|
* - 暴露滚动监听,支持向下滚动自动收起工具栏,向上滚动自动唤出
|
||||||
*/
|
*/
|
||||||
class RemoteWebView @JvmOverloads constructor(
|
class RemoteWebView @JvmOverloads constructor(
|
||||||
@@ -19,11 +18,6 @@ class RemoteWebView @JvmOverloads constructor(
|
|||||||
/** 滚动变化监听:(scrollX, scrollY, oldScrollX, oldScrollY) */
|
/** 滚动变化监听:(scrollX, scrollY, oldScrollX, oldScrollY) */
|
||||||
var onScrollChangeListener: ((Int, Int, Int, Int) -> Unit)? = null
|
var onScrollChangeListener: ((Int, Int, Int, Int) -> Unit)? = null
|
||||||
|
|
||||||
override fun onCheckIsTextEditor(): Boolean {
|
|
||||||
// 告诉系统这不是文本编辑控件,避免为网页内的 input/textarea 弹出软键盘
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
|
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
|
||||||
super.onScrollChanged(l, t, oldl, oldt)
|
super.onScrollChanged(l, t, oldl, oldt)
|
||||||
onScrollChangeListener?.invoke(l, t, oldl, oldt)
|
onScrollChangeListener?.invoke(l, t, oldl, oldt)
|
||||||
|
|||||||
@@ -283,6 +283,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
android:nextFocusUp="@id/urlBar" />
|
android:nextFocusUp="@id/urlBar" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
|||||||
Reference in New Issue
Block a user