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

news2025/6/24 21:14:38

概述

       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 Project

     Licensed 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 at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed 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 and
     limitations 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">

        <EditText
            android: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>

    <CheckBox
        android: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>

        @Override
        public GuidedActionsStylist onCreateActionsStylist() {
            return new GuidedActionsStylist() {
                @Override
                public 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);
                    }
                }
             }
			@Override
            public int onProvideItemLayoutId() {
                return R.layout.setup_password_item;
            }
         }

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

编译,解决!


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

        <EditText
            android: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 := disabled

LOCAL_PRIVILEGED_MODULE := true

LOCAL_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 supported
                vh.mTitleView.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
            }
        }
		//....
    }

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

引用

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/755048.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

华润燃气牵手腾讯云 数字技术助力燃气行业高质量发展

7月13日&#xff0c;华润燃气与腾讯云正式签署战略合作协议。双方将充分发挥各自优势&#xff0c;探索AI大模型在燃气行业的深度应用&#xff0c;并深耕分布式计算、连接和客户运营等领域&#xff0c;不断提升燃气民生服务的效率、质量&#xff0c;共同推动行业数字化转型和高质…

echarts3D地图+3D柱状图+3D飞线图

echarts版本&#xff1a;5.4.0 echarts-gl版本&#xff1a;2.0.8 示例代码&#xff1a; <template><div><div ref"chinaMap" id"chinaMap" style"width: 90vw;height: 90vh;"></div></div> </template>&l…

【ArcGIS Pro二次开发】(49):村规数据入库【福建省】

之前用Arcpy脚本工具做了一个村规数据入库和主要图纸生成工具。 在使用过程中&#xff0c;感觉对电脑环境比较高&#xff0c;换电脑用经常会一些莫名其妙的错误&#xff0c;bug修得很累。近来随着ArcGIS Pro SDK的熟悉&#xff0c;就有了移植的想法。 这里先把村规数据入库工…

【量化课程】02_2.货币金融学基础概念

2.2_货币金融学基础概念 文章目录 2.2_货币金融学基础概念概述金融体系货币利率利率的风险结构与期限结构货币供给过程中国货币政策工具货币政策效果货币数量论、通货膨胀与货币需求总需求与总供给分析货币政策理论货币政策传导机制 概述 金融市场&#xff1a;资金从剩余方转向…

解决git每次提交都需要输入用户密码

一、背景 在github上贴上了服务器ssh的公钥后&#xff0c;在服务器上推送代码仍旧提示需要输入git的账号和密码。 二、原因 这是因为此时的仓库是http协议下载的&#xff0c;此时的链接并不是通过ssh的&#xff0c;因此在推送代码时&#xff0c;会提示输入git的账号和密码。…

基于Python编写一个B站全自动抽奖的小程序

本文将利用Python编写一个B站全自动抽奖的小程序&#xff0c;可以实时监控自己关注的UP主&#xff0c;如果关注的UP主中有人发布了抽奖的动态&#xff0c;就自动参与这个抽奖。这样就能不错过任何一个可以暴富的机会了。需要的可以参考一下 导语 应好友邀请&#xff0c;帮他写…

i.MX6ULL(十五) 根文件系统

Linux“三巨头”已经完成了 2 个了&#xff0c;就剩最后一个 rootfs( 根文件系统 ) 了&#xff0c;本章我们就来学 习一下根文件系统的组成以及如何构建根文件系统。这是 Linux 移植的最后一步&#xff0c;根文件系统 构建好以后就意味着我们已经拥有了一个完整的、可以运…

Python isdigit()函数使用详解

「作者主页」&#xff1a;士别三日wyx 「作者简介」&#xff1a;CSDN top100、阿里云博客专家、华为云享专家、网络安全领域优质创作者 「推荐专栏」&#xff1a;小白零基础《Python入门到精通》 isdigit函数使用详解 1、包含负数的情况2、包含小数的情况3、带圈的数字4、数字上…

重封装Ehcache与Redis模板以便于一二级缓存同步数据(二)

参考: 一级缓存二级缓存的获取与更新顺序&#xff08;一) 简单封装Ehcache与RedisTemplate模版 通常使用一二级缓存时,必须保持一二级缓存数据数据与数据库中数据保持一致 &#xff1b;此时可以简单封装下,一二级缓存的相关接口,便于我…

数据结构(王道)——线性表的存储结构之链表存储

线性表的链表存储&#xff1a; 一、单链表定义&#xff1a; 用代码定义一个单链表&#xff1a; 不带头结点的单链表定义&#xff1a; 带头结点的单链表定义&#xff1a; 单链表定义总结&#xff1a; 二、单链表的基本操作&#xff08;插入删除查找&#xff09; 1、插入 如何在…

手机图片怎么转pdf格式?这几个图片转换方式了解一下

手机图片怎么转pdf格式&#xff1f;将图片转换为PDF的应用场景非常广泛。例如&#xff0c;你可以将多张照片转换为PDF&#xff0c;然后将其作为一本电子相册保存。你也可以将多张图片转换为PDF&#xff0c;然后将其作为一份报告或文档的附件发送给他人。此外&#xff0c;许多人…

⌈C++⌋深度剖析构造、拷贝构造与赋值运算符重载——深浅拷贝、explicit、类型转换等

目录 一、认识拷贝构造函数 1、什么是拷贝构造 2、深拷贝与浅拷贝 3、编译器可以绕过拷贝构造函数&#xff08;C Primer P442&#xff09; 4、explicit修饰 二、认识赋值运算符重载 1、赋值运算符重载格式 2、默认赋值运算符重载 3、赋值运算符都必须定义为成员函数 …

内网使用JRebel及踩坑点

目录 前言外网正常使用JRebel下载安装插件授权 内网授权方式搭建本地授权服务器安装JRebel的电脑网络切换为手机热点 设置脱机离线模式设置自动重新部署时间间隔使用JRebel之前需要的配置项勾选compiler -> build project automatically设置代码热部署配置JRebel热部署的项目…

979.在二叉树中分配硬币

979.在二叉树中分配硬币 给定一个有 N 个结点的二叉树的根结点 root&#xff0c;树中的每个结点上都对应有 node.val 枚硬币&#xff0c;并且总共有 N 枚硬币。 在一次移动中&#xff0c;我们可以选择两个相邻的结点&#xff0c;然后将一枚硬币从其中一个结点移动到另一个结点…

Ubuntu新版静态IP设置

cd /etc/netplan直接编辑 sudo vi /etc/netplan/00-installer-config.yaml#network: # ethernets: # ens160: # dhcp4: true # version: 2network:version: 2ethernets:ens160:dhcp4: noaddresses: [172.17.10.23/24]optional: truegateway4: 172.17.10.1nameservers…

【Linux】无法连外网,只能用压缩包,环境搭建流程

【Linux】无法连外网&#xff0c;只能用压缩包&#xff0c;环境搭建流程 【一】JDK&#xff08;1&#xff09;下载jdk安装包&#xff08;2&#xff09;解压安装包&#xff08;3&#xff09;修改环境变量&#xff08;4&#xff09;测试是否安装成功 【二】安装mysql【1】5.7版本…

Prometheus、Grafana使用

文章目录 系统性能监控相关命令lscputopfreehtopdstatglancesiftopiptrafnethogs 监控软件Prometheus安装、使用将promethues做成服务监控其他机器 exportergrafana配置、使用 系统性能监控 相关命令 lscpu lscpu 是一个 Linux 命令&#xff0c;用于显示关于 CPU&#xff08…

使用git克隆非自己账号的项目

在地址的中https://或者http://后添加要使用的 账号名项目地址&#xff0c;就会提示输入对应账号的密码&#xff0c;进行克隆。 如果克隆别人的项目&#xff0c;你将别人给你的项目地址克隆&#xff0c;此时身份验证是别人的用户名&#xff0c;这时你输入自己的密码就会验证失败…

Centos 8 / TencentOS Server 3.1 安装 docker-ce

目录 前言安装 docker-ce设置Docker Hub 镜像缓存参考 前言 TencentOS Server 3.1(与 CentOS 8用户态完全兼容&#xff0c;配套基于社区5.4 LTS 内核深度优化的 tkernel4版本) 安装 docker-ce 先卸载老版本&#xff0c;没有老版本的跳过 yum remove docker \docker-client \d…

DBeaver连接华为高斯数据库 DBeaver连接Gaussdb数据库 DBeaver connect Gaussdb

DBeaver连接华为高斯数据库 DBeaver连接Gaussdb数据库 DBeaver connect Gaussdb 一、概述 华为GaussDB出来已经有一段时间&#xff0c;最近工作中刚到Gauss数据库。作为coder&#xff0c;那么如何通过可视化工具来操作Gauss呢&#xff1f; 本文将记录使用免费、开源的DBeaver来…