当前位置: 首页 > news >正文

Android TvSettings Bug: 密码框无法点击唤起输入法

概述

       Android 10 的Box方案, 默认使用的是TvSettings作为系统设置,输入操作的习惯上是使用鼠标,键盘,遥控,日常的场景是没有问题,也不会出现本文中提及的问题。当外接的USB触摸屏后,出现无法点击WIFI密码框换出输入法进行输入密码操作。

问题:
在这里插入图片描述
在这里插入图片描述
从图1开始添加WIFI,并准备输入密码时,外接的USB触摸屏没有办法点击唤起输入法。

正常的情况应该如下图所示:
在这里插入图片描述

过程

     在前面的一些文章中,对于无法点击或响应按键操作的问题,一般可以先查查焦点的问题:

View Hierarchy:DecorView@661bdd7[WifiConnectionActivity]android.widget.LinearLayout{abf86c4 V.E...... ........ 0,0-1920,1080}android.view.ViewStub{e3449ad G.E...... ......I. 0,0-0,0 #10201a2 android:id/action_mode_bar_stub}android.widget.FrameLayout{38444e2 V.E...... ........ 0,0-1920,1080 #1020002 android:id/content}android.widget.FrameLayout{51a6073 V.E...... ........ 0,0-1920,1080 #7f0a0229 app:id/wifi_container}androidx.leanback.app.GuidedStepRootLayout{1904b30 V.E...... ........ 0,0-1920,1080 #7f0a0105 app:id/guidedstep_root}android.widget.FrameLayout{878d3a9 V.E...... ........ 0,0-1920,1080 #7f0a0104 app:id/guidedstep_background_view_root}androidx.leanback.widget.NonOverlappingView{9a5cd2e V.ED..... ........ 0,0-1920,1080 #7f0a0103 app:id/guidedstep_background}android.widget.LinearLayout{fb090cf V.E...... ........ 0,0-1920,1080 #7f0a00a0 app:id/content_frame}androidx.leanback.widget.NonOverlappingFrameLayout{966ea5c V.E...... ........ 0,0-1231,1080 #7f0a009f app:id/content_fragment}com.android.tv.settings.connectivity.setup.GuidanceRelativeLayout{b620165 V.E...... ........ 0,0-1231,1080}android.widget.TextView{e458e3a V.ED..... ........ 168,374-1147,447 #7f0a00f1 app:id/guidance_title}android.widget.TextView{fcf6aeb V.ED..... ........ 168,474-1147,503 #7f0a00ef app:id/guidance_description}androidx.leanback.widget.NonOverlappingFrameLayout{aa65048 V.E...... ........ 1231,0-1919,1080 #7f0a0044 app:id/action_fragment_root}androidx.leanback.widget.NonOverlappingView{4f64ee1 V.ED..... ........ 0,0-688,1080 #7f0a0043 app:id/action_fragment_background}androidx.leanback.widget.NonOverlappingLinearLayout{bee5406 VFE...... ........ 0,0-688,1080 #7f0a0042 app:id/action_fragment}android.widget.RelativeLayout{4b7cac7 V.E...... ........ 0,0-688,1080 #7f0a00ff app:id/guidedactions_root}androidx.leanback.widget.NonOverlappingView{ef428f4 G.ED..... ......ID 0,0-0,0 #7f0a00fd app:id/guidedactions_list_background}androidx.leanback.widget.GuidedActionsRelativeLayout{327f81d V.E...... ........ 0,0-688,1080 #7f0a00f3 app:id/guidedactions_content}androidx.leanback.widget.VerticalGridView{90baa92 V.E...... ........ 0,0-348,1080 #7f0a00fb app:id/guidedactions_list}android.widget.LinearLayout{6dc4c63 VFE...C.. ........ 0,103-348,528}android.widget.FrameLayout{2a4e060 V.E...... ........ 0,293-348,365 #7f0a020f app:id/text_input_wrapper}android.widget.EditText{6d0f919 VFED..... ........ 24,0-324,72 #7f0a00fa app:id/guidedactions_item_title}android.widget.CheckBox{535ddde VFED..C.. ........ 14,377-146,425 #7f0a01ac app:id/password_checkbox}androidx.leanback.widget.NonOverlappingView{93d4bbf G.ED..... ......ID 0,0-0,0 #7f0a0102 app:id/guidedactions_sub_list_background}androidx.leanback.widget.VerticalGridView{e7a28c IFE...... ......I. 0,432-688,432 #7f0a0101 app:id/guidedactions_sub_list}android.widget.RelativeLayout{a6f0dd5 V.E...... ........ 688,0-688,1080 #7f0a0100 app:id/guidedactions_root2}androidx.leanback.widget.NonOverlappingView{f3df9ea V.ED..... ......ID 0,0-0,1080 #7f0a00fe app:id/guidedactions_list_background2}androidx.leanback.widget.NonOverlappingFrameLayout{484e4db V.E...... ......ID 0,0-0,1080 #7f0a00f4 app:id/guidedactions_content2}androidx.leanback.widget.VerticalGridView{6b25b78 V.E...... ......ID 0,0-0,1080 #7f0a00fc app:id/guidedactions_list2}

很明显android.widget.EditText{6d0f919 VFED… … 24,0-324,72 #7f0a00fa app:id/guidedactions_item_title} 不可点击.

通过ID找到相关的代码:

$ grep -r "guidedactions_item_title" packages/apps/TvSettings/Settings
packages/apps/TvSettings/Settings/res/layout/setup_text_input_item.xml:            android:id="@+id/guidedactions_item_title"
packages/apps/TvSettings/Settings/res/layout/setup_password_item.xml:            android:id="@+id/guidedactions_item_title"
packages/apps/TvSettings/Settings/src/com/android/tv/settings/connectivity/util/GuidedActionsAlignUtil.java:                        androidx.leanback.R.id.guidedactions_item_title);
packages/apps/TvSettings/Settings/src/com/android/tv/settings/util/GuidedActionsAlignUtil.java:                        androidx.leanback.R.id.guidedactions_item_title);

packages/apps/TvSettings/Settings/res/layout/setup_password_item.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:clipChildren="false"android:clipToPadding="false"android:orientation="vertical"><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/text_input_wrapper"android:layout_width="match_parent"android:layout_height="@dimen/setup_list_item_height"android:layout_alignParentStart="true"android:layout_marginTop="@dimen/setup_action_vertical_offset"android:background="@drawable/setup_text_input_background"android:elevation="@dimen/setup_elevation"android:gravity="start|center_vertical"android:paddingEnd="@dimen/setup_list_item_padding"android:paddingStart="@dimen/setup_list_item_padding"><EditTextandroid:id="@+id/guidedactions_item_title"style="@style/Setup.Action.TextInput"android:layout_width="match_parent"android:layout_height="match_parent"android:focusable="true"android:gravity="center_vertical"android:imeOptions="actionNext|flagNoExtractUi"android:inputType="text"></EditText></FrameLayout><CheckBoxandroid:id="@+id/password_checkbox"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="@dimen/setup_obfuscation_margin_start"android:layout_marginTop="@dimen/setup_obfuscation_margin_top"android:buttonTint="@color/setup_list_item_background_focused"android:buttonTintMode="src_in"android:text="@string/text_obfuscation_toggle_caption" />
</LinearLayout>
        @Overridepublic GuidedActionsStylist onCreateActionsStylist() {return new GuidedActionsStylist() {@Overridepublic void onBindViewHolder(ViewHolder vh, GuidedAction action) {super.onBindViewHolder(vh, action);if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {PasswordViewHolder viewHolder = (PasswordViewHolder) vh;mTextInput = (EditText) viewHolder.getTitleView();mTextInput.setClickable(true);mTextInput.setFocusableInTouchMode(true);mCheckBox = viewHolder.mCheckbox;mCheckBox.setOnClickListener(view -> {updatePasswordInputObfuscation();EnterPasswordFragment.this.openInEditMode(action);});mCheckBox.setChecked(mUserChoiceInfo.isPasswordHidden());updatePasswordInputObfuscation();openInEditMode(action);}}}@Overridepublic int onProvideItemLayoutId() {return R.layout.setup_password_item;}}

增加
mTextInput.setClickable(true);
mTextInput.setFocusableInTouchMode(true);

编译,解决!


另一种尝试
在这之前,尝试过在XML中设置:

        <EditTextandroid:clickable="true"android:focusableInTouchMode="true">

结果:无效??
反复确认了layout文件的正确性无果。
从代码中去一个个追查并不现实,取了个巧,自定一个EditText替换了默认的,并重写了setClickable函数,从中打印出调用的堆栈得知,在GuidedActionsStylist.onBindViewHolder中确实调用了。

GuidedActionsStylist 位于androidx中,

packages/apps/TvSettings/Settings/Android.mk

LOCAL_PACKAGE_NAME := TvSettings
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
LOCAL_PROGUARD_ENABLED := disabledLOCAL_PRIVILEGED_MODULE := trueLOCAL_STATIC_ANDROID_LIBRARIES := \androidx.recyclerview_recyclerview \androidx.preference_preference \androidx.appcompat_appcompat \androidx.legacy_legacy-preference-v14 \androidx.leanback_leanback-preference \androidx.leanback_leanback \androidx.lifecycle_lifecycle-extensions \androidx-constraintlayout_constraintlayout \

对应的jar包路径:

out/target/common/obj/JAVA_LIBRARIES/androidx.leanback_leanback_intermediates/classes.jar

顺便看下源码:

GuidedActionsStylist.java

		public ViewHolder(@NonNull View v, boolean isSubAction) {super(v);mContentView = v.findViewById(R.id.guidedactions_item_content);mTitleView = (TextView) v.findViewById(R.id.guidedactions_item_title);mActivatorView = v.findViewById(R.id.guidedactions_activator_item);mDescriptionView = (TextView) v.findViewById(R.id.guidedactions_item_description);mIconView = (ImageView) v.findViewById(R.id.guidedactions_item_icon);mCheckmarkView = (ImageView) v.findViewById(R.id.guidedactions_item_checkmark);mChevronView = (ImageView) v.findViewById(R.id.guidedactions_item_chevron);mIsSubAction = isSubAction;v.setAccessibilityDelegate(mDelegate);}/*** Binds a {@link ViewHolder} to a particular {@link GuidedAction}.* @param vh The view holder to be associated with the given action.* @param action The guided action to be displayed by the view holder's view.* @return The view to be added to the caller's view hierarchy.*/public void onBindViewHolder(ViewHolder vh, GuidedAction action) {vh.mAction = action;if (vh.mTitleView != null) {vh.mTitleView.setInputType(action.getInputType());vh.mTitleView.setText(action.getTitle());vh.mTitleView.setAlpha(action.isEnabled() ? mEnabledTextAlpha : mDisabledTextAlpha);vh.mTitleView.setFocusable(false);vh.mTitleView.setClickable(false);vh.mTitleView.setLongClickable(false);if (BuildCompat.isAtLeastP()) {if (action.isEditable()) {vh.mTitleView.setAutofillHints(action.getAutofillHints());} else {vh.mTitleView.setAutofillHints((String[]) null);}} else if (VERSION.SDK_INT >= 26) {// disable autofill below P as dpad/keyboard is not supportedvh.mTitleView.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);}}//....}

从上面的代码可以看出,使用了GuidedActionsStylist后,guidedactions_item_title这个ID的控件会被置为不可点击。
刚好就是前面提及的文本输入框,对头!

引用

android:focusable和android:focusableInTouchMode的区别
GuidedActionsStylist
AndroidX GitHub
AOSP AndroidX Contribution Guide

相关文章:

Android TvSettings Bug: 密码框无法点击唤起输入法

概述 Android 10 的Box方案&#xff0c; 默认使用的是TvSettings作为系统设置&#xff0c;输入操作的习惯上是使用鼠标&#xff0c;键盘&#xff0c;遥控&#xff0c;日常的场景是没有问题&#xff0c;也不会出现本文中提及的问题。当外接的USB触摸屏后&#xff0c;出现无法点击…...

Windows, MacOS还是Linux好?

今天我们来聊一个小话题&#xff1a;选操作系统&#xff0c;是哪个好&#xff1f;今天&#xff0c;我以一个介绍者的身份给大家推荐&#xff0c;我就不出什么点子了。 Windows Windows&#xff0c;是一个老牌的操作系统。他的优处和短处和有很多&#xff0c;我们来介绍一下 优…...

Gateway自定义过滤器——全局过滤器

一、什么是全局过滤器&#x1f349; 首先&#xff0c;我们要知道全局过滤器其实是特殊路由过滤器(特殊的GatewayFilter)&#xff0c;会有条件地作用于所有路由。 为什么要自定义全局过滤器&#xff1f;就好比是看大门的保安大叔&#xff0c;平时主要是做好进出大门外来人员登记…...

Android App的几个核心概念

Application启动 点击桌面图标启动App(如下流程图) 针对以上流程图示&#xff1a; ActivityManagerService#startProcessLocked()Process#start()ActivityThread#main()&#xff0c;入口分析的地方ActivityThread#attach()&#xff0c;这个里面的逻辑很核心 ActivityManagerS…...

window10安装telnet

1、打开控制面板 2、点击程序和功能 3、点击启用或关闭Windows功能 4、选中Telnet客户端&#xff0c;然后点击确定&#xff0c;然后就可以使用telnent 主机 端口来查看本地是否能连通该主机的该端口。...

大厂sql真题讲解(黑马)

2023 http://yun.itheima.com/open/853.html | 面试宝典-如何备战大厂SQL真题 http://yun.itheima.com/open/858.html | 面试宝典–大厂必考知识开窗函数 http://yun.itheima.com/open/864.html | 面试宝典-详解美团SQL真题 http://yun.itheima.com/open/868.html | 图解大…...

SpringBoot整合EasyExcel实现读操作

&#x1f60a; 作者&#xff1a; 一恍过去 &#x1f496; 主页&#xff1a; https://blog.csdn.net/zhuocailing3390 &#x1f38a; 社区&#xff1a; Java技术栈交流 &#x1f389; 主题&#xff1a; SpringBoot整合EasyExcel实现读操作 ⏱️ 创作时间&#xff1a; 2023年…...

go mod 设置国内源 windows 环境 win10

启用 go module 功能 go env -w GO111MODULEon 配置 goproxy 变量 go env -w GOPROXYhttps://goproxy.cn,direct 下载包就行了&#xff0c;速度飞快 go mod tidy 检测 goproxy 是否配置好 运行 go env | findstr goproxy 查看 goproxy Go module 从 Go v1.12 版本开始存在&a…...

智能决策支持系统实现的关键技术分析

1.模 型 中 的 关 键 因 素 。 在 按 本 模 型 研 究 开 发 系 统 时 ,应 当 着 重 考 虑 以 下 几 个 因 素 : (1)设 备 保 护 需 求 计 划 。 保 护 需 求 包 括 了 人 员 、 物 质 、 财 务 等 各项 因 素 ; (2)考 虑 设 备 运行 及维修的 历史数据。 这是进 行 模 型 选 择…...

OSS对象存储后端实现+Vue实现图片上传【基于若依管理系统开发】

文章目录 基本介绍术语介绍图片上传方式介绍普通上传用户直传应用服务器签名后直传 OSS对象存储后端实现maven配置文件配置类ServiceController 图片上传前端图片上传组件api页面使用组件组件效果 基本介绍 术语介绍 Bucket&#xff08;存储空间&#xff09;&#xff1a;用于…...

人工智能学习目录

1、人工智能-电脑如何像人一样思考&#xff1f; 从发展历史到人工智能的应用案例&#xff0c;再到人工智能本质是数学问题&#xff0c;从房价预测问题提出损失函数由参数导致&#xff0c;再由损失函数的最优值入手引入梯度下降法&#xff0c;最后到多参数方程的最优求解。 人工…...

Vue单页面实现el-tree el-breadcrumb功能、el-tree右键点击树节点展示菜单功能、树节点编辑节点字段名称功能

(1) 点击el-tree节点 使用el-breadcrumb展示选中树节点及父项数据 重点&#xff1a;handleNodeClick方法、getTreeNode方法 (2) 选择el-breadcrumb-item设置el-tree节点选中 必须设置属性: current-node-key"currentNodeKey" 、 node-key"id" 重点: 设置…...

C++核心编程之函数高级使用

目录 一、函数的默认参数 二、函数占位参数 三、函数重载 四、函数重载-注意事项 一、函数的默认参数 在C中&#xff0c;函数的形参列表中的形参是可以有默认值的 语法&#xff1a;返回值类型 函数名 &#xff08;参数默认值&#xff09;{} 示例1&#xff1a; #includ…...

如何创建智能合约游戏系统

区块技术的发展&#xff0c;智能合约成为了一个热门话题。智能合约是一种基于区块技术的自动化合约&#xff0c;它可以自动执行合同中规定的条款&#xff0c;从而实现去中心化的信任和价值传递。在游戏领域&#xff0c;智能合约可以让玩家在游戏中实现各种交易和交互&#xff0…...

如何用rust实现一个异步channel

目录 前言思路实现功能代码实现 测试先引测试版包测试代码结果与分析思考 尾语 前言 使用通信来共享内存&#xff0c;而不是通过共享内存来通信 上面这句话&#xff0c;是每个go开发者在 处理多线程通信时 的座右铭&#xff0c;go甚至把实现这个理念的channel直接焊在编译器里&…...

gitee上传项目到仓库

目录 一些常用的Git命令切换到其他盘符&#xff1a;列出目录下的所有文件&#xff1a;以树状图的形式显示目录下的文件和子目录:返回上一层目录&#xff1a;写的C#代码文件上传到新建的Git仓库中&#xff0c;可以按照以下步骤进行操作&#xff1a;出现的错误&#xff1a; 一些常…...

day27 贪心算法

1.什么是贪心&#xff1f; 比如10张钞票&#xff0c;有1&#xff0c;5&#xff0c;20&#xff0c;100等面额&#xff0c;取五张&#xff0c;如何取得到数额最多的钱&#xff1f;每次取面额最大的那张钞票&#xff1b;就是每个阶段的局部最优&#xff1b;全局最优就是最后拿到的…...

Java实现字符串反转

起因 自己在刷题的过程中&#xff0c;想把一个字符串翻转一下&#xff0c;便写了下面的代码&#xff1a; String str "abcd";str str.reverse();发现行不通&#xff0c;这是为什么呢&#xff1f; 分析 在Java中&#xff0c;字符串是不可变的对象&#xff0c;这意…...

vue - 常见的性能优化

文章目录 vue使用中常见的性能优化1&#xff0c; v-for 遍历避免同时使用 v-if2&#xff0c; 如果需要使用v-for给每项元素绑定事件时 可以使用事件代理**3&#xff0c; 一些数据不做响应式4&#xff0c;一些页面采用keep-alive缓存组件5&#xff0c;第三方UI库按需导入6&#…...

微服务系列文章 之 Nginx服务状态监控的方法

在Nginx的插件模块中有一个模块stub_status可以监控Nginx的一些状态信息&#xff0c;默认安装可能没有这个模块&#xff0c;手动编译的时候加一下即可。 1. 模块安装 先使用命令查看是否已经安装这个模块&#xff1a; [rootihxb123Z nginx]# ./nginx -V (V大写会显示版本号和…...

设计模式和设计原则回顾

设计模式和设计原则回顾 23种设计模式是设计原则的完美体现,设计原则设计原则是设计模式的理论基石, 设计模式 在经典的设计模式分类中(如《设计模式:可复用面向对象软件的基础》一书中),总共有23种设计模式,分为三大类: 一、创建型模式(5种) 1. 单例模式(Sing…...

鸿蒙中用HarmonyOS SDK应用服务 HarmonyOS5开发一个生活电费的缴纳和查询小程序

一、项目初始化与配置 1. 创建项目 ohpm init harmony/utility-payment-app 2. 配置权限 // module.json5 {"requestPermissions": [{"name": "ohos.permission.INTERNET"},{"name": "ohos.permission.GET_NETWORK_INFO"…...

CMake 从 GitHub 下载第三方库并使用

有时我们希望直接使用 GitHub 上的开源库,而不想手动下载、编译和安装。 可以利用 CMake 提供的 FetchContent 模块来实现自动下载、构建和链接第三方库。 FetchContent 命令官方文档✅ 示例代码 我们将以 fmt 这个流行的格式化库为例,演示如何: 使用 FetchContent 从 GitH…...

Python ROS2【机器人中间件框架】 简介

销量过万TEEIS德国护膝夏天用薄款 优惠券冠生园 百花蜂蜜428g 挤压瓶纯蜂蜜巨奇严选 鞋子除臭剂360ml 多芬身体磨砂膏280g健70%-75%酒精消毒棉片湿巾1418cm 80片/袋3袋大包清洁食品用消毒 优惠券AIMORNY52朵红玫瑰永生香皂花同城配送非鲜花七夕情人节生日礼物送女友 热卖妙洁棉…...

Yolov8 目标检测蒸馏学习记录

yolov8系列模型蒸馏基本流程&#xff0c;代码下载&#xff1a;这里本人提交了一个demo:djdll/Yolov8_Distillation: Yolov8轻量化_蒸馏代码实现 在轻量化模型设计中&#xff0c;**知识蒸馏&#xff08;Knowledge Distillation&#xff09;**被广泛应用&#xff0c;作为提升模型…...

初探Service服务发现机制

1.Service简介 Service是将运行在一组Pod上的应用程序发布为网络服务的抽象方法。 主要功能&#xff1a;服务发现和负载均衡。 Service类型的包括ClusterIP类型、NodePort类型、LoadBalancer类型、ExternalName类型 2.Endpoints简介 Endpoints是一种Kubernetes资源&#xf…...

return this;返回的是谁

一个审批系统的示例来演示责任链模式的实现。假设公司需要处理不同金额的采购申请&#xff0c;不同级别的经理有不同的审批权限&#xff1a; // 抽象处理者&#xff1a;审批者 abstract class Approver {protected Approver successor; // 下一个处理者// 设置下一个处理者pub…...

Java编程之桥接模式

定义 桥接模式&#xff08;Bridge Pattern&#xff09;属于结构型设计模式&#xff0c;它的核心意图是将抽象部分与实现部分分离&#xff0c;使它们可以独立地变化。这种模式通过组合关系来替代继承关系&#xff0c;从而降低了抽象和实现这两个可变维度之间的耦合度。 用例子…...

基于SpringBoot在线拍卖系统的设计和实现

摘 要 随着社会的发展&#xff0c;社会的各行各业都在利用信息化时代的优势。计算机的优势和普及使得各种信息系统的开发成为必需。 在线拍卖系统&#xff0c;主要的模块包括管理员&#xff1b;首页、个人中心、用户管理、商品类型管理、拍卖商品管理、历史竞拍管理、竞拍订单…...

RSS 2025|从说明书学习复杂机器人操作任务:NUS邵林团队提出全新机器人装配技能学习框架Manual2Skill

视觉语言模型&#xff08;Vision-Language Models, VLMs&#xff09;&#xff0c;为真实环境中的机器人操作任务提供了极具潜力的解决方案。 尽管 VLMs 取得了显著进展&#xff0c;机器人仍难以胜任复杂的长时程任务&#xff08;如家具装配&#xff09;&#xff0c;主要受限于人…...