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

validationtools中按键测试选项光标移除


最近处理一个问题,设备有方向键盘,做cit中的按键测试,发现按方向键第一次按键不能触发该键值,而是让屏幕第一个按钮获取焦点,然后再次按键,则其他正常。问题:进入界面第一次按键就要响应对应按键逻辑,不需要焦点。该问题查找了很久,最后找到了答案!

布局中的按键测试布局中按钮是button或imagebutton。这布局进入时,初次会相应方向键(原理未知),解决方案:设置所有按钮clickable=false(防止触屏幕激发),主要的是将所有按钮设置

enable=false(imagebutton在xml中设置无效,需要在代码中设置)

修改如下

Date:   Wed Aug 28 18:38:33 2024 +0800处理按键测试按钮获取焦点问题Change-Id: I6f317fec43c213761573fb793bc057fd14da71aediff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8e8eb03..23abed9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -87,7 +87,7 @@<dataandroid:host="83789"android:scheme="unisoc_secret_code" />
-            </intent-filter>
+            </intent-filter>    </receiver><receiverandroid:name="com.sprd.validationtools.PhaseCheckBroadcastReceiver"
diff --git a/res/layout/key_test.xml b/res/layout/key_test.xml
index 53eba2e..16f2164 100644
--- a/res/layout/key_test.xml
+++ b/res/layout/key_test.xml
@@ -3,12 +3,6 @@android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" >
-     <Button
-        android:id="@+id/focus_button"
-        android:layout_width="0dp"
-        android:layout_height="0dp"
-        android:clickable="false" >
-    </Button><LinearLayoutandroid:layout_width="fill_parent"
@@ -21,6 +15,7 @@android:layout_height="wrap_content"android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+            android:enabled="false"                                                                                android:src="@drawable/voice_up" />                                                                    <ImageButton                                                                                               
@@ -28,6 +23,7 @@                                                                                                   android:layout_width="0dip"                                                                            android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              
+            android:enabled="false"                                                                                android:clickable="false"                                                                              android:src="@drawable/voice_down" />                                                                  <ImageButton                                                                                               
@@ -36,6 +32,7 @@                                                                                                   android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+            android:enabled="false"                                                                                android:src="@drawable/power_off" />                                                                   </LinearLayout>                                                                                                
@@ -69,6 +66,7 @@                                                                                                   android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+            android:enabled="false"                                                                                android:gravity="center"                                                                               android:text="CALL" />                                                                                 @@ -78,6 +76,8 @@                                                                                                   android:layout_height="wrap_content"                                                                       android:layout_weight="1"                                                                                  android:gravity="center"                                                                                   
+        android:enabled="false"                                                                                    
+        android:clickable="false"                                                                                  android:src="@drawable/menu"                                                                               android:visibility="visible" />                                                                            @@ -87,6 +87,7 @@                                                                                                   android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+            android:enabled="false"                                                                                android:src="@drawable/camera" />                                                                      <ImageButton                                                                                           android:id="@+id/home_button"                                                                          
@@ -95,6 +96,7 @@                                                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              android:gravity="center"                                                                               
+            android:enabled="false"                                                                                android:src="@drawable/home" />                                                                        </LinearLayout>                                                                                                
@@ -110,6 +112,9 @@                                                                                                 android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+            android:enabled="false"                                                                                
+                                                                                                                   
+                                                                                                                   android:text="PTT" />                                                                                  <Button                                                                                                    
@@ -118,6 +123,8 @@                                                                                                 android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+            android:enabled="false"                                                                                
+                                                                                                                   android:text="SOS" />                                                                                  <ImageButton                                                                                               android:id="@+id/back_button"                                                                  
@@ -125,6 +132,7 @@                                                                                                 android:layout_height="wrap_content"                                                           android:layout_weight="1"                                                                      android:clickable="false"                                                                      
+                    android:enabled="false"                                                                        android:gravity="center"                                                                       android:src="@drawable/back"                                                                   android:visibility="visible" />                                                                
@@ -134,6 +142,7 @@                                                                                                 android:layout_weight="1"                                                                          android:layout_height="wrap_content"                                                               android:clickable="false"                                                                          
+                android:enabled="false"                                                                            android:gravity="center"                                                                           android:text="Fn"                                                                                  android:visibility="visible" />                                                                    
@@ -150,6 +159,9 @@                                                                                                 android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+                android:enabled="false"                                                                            
+                                                                                                                   
+                                                                                                                   android:text="VIDEO" />                                                                                <Button                                                                                                    
@@ -158,6 +170,8 @@                                                                                                 android:layout_height="wrap_content"                                                                   android:layout_weight="1"                                                                              android:clickable="false"                                                                              
+                android:enabled="false"                                                                            
+                                                                                                                   android:text="LIGHT" />                                                                                </LinearLayout>                                                                                                
@@ -181,6 +195,9 @@                                                                                                 android:layout_width="wrap_content"                                                            android:layout_height="wrap_content"                                                           android:clickable="false"                                                                      
+                     android:focusable="false"                                                                     
+                     android:enabled="false"                                                                       
+                    android:focusableInTouchMode="false"                                                           android:src="@drawable/up" />                                                                  <LinearLayout                                                                                      
@@ -199,6 +216,9 @@                                                                                                 android:layout_width="wrap_content"                                                        android:layout_height="wrap_content"                                                       android:clickable="false"                                                                  
+                        android:enabled="false"                                                                    
+                         android:focusable="false"                                                                 
+                    android:focusableInTouchMode="false"                                                           android:src="@drawable/left" />                                                            <ImageButton                                                                                   
@@ -206,6 +226,9 @@                                                                                                 android:layout_width="wrap_content"                                                        android:layout_height="wrap_content"                                                       android:clickable="false"                                                                  
+                         android:focusable="false"                                                                 
+                         android:enabled="false"                                                                   
+                         android:focusableInTouchMode="false"                                                      android:src="@drawable/center" />                                                          <ImageButton                                                                                   
@@ -213,6 +236,9 @@                                                                                                 android:layout_width="wrap_content"                                                        android:layout_height="wrap_content"                                                       android:clickable="false"                                                                  
+                        android:focusable="false"                                                                  
+                        android:enabled="false"                                                                    
+                        android:focusableInTouchMode="false"                                                       android:src="@drawable/right" />                                                           </LinearLayout>                                                                                    @@ -227,6 +253,9 @@                                                                                                 android:layout_width="wrap_content"                                                        android:layout_height="wrap_content"                                                       android:clickable="false"                                                                  
+                         android:focusable="false"                                                                 
+                         android:enabled="false"                                                                   
+                        android:focusableInTouchMode="false"                                                       android:src="@drawable/down" />                                                            </LinearLayout>                                                                                    </LinearLayout>                                                                                            
@@ -249,6 +278,7 @@                                                                                                 android:layout_width="180dip"                                                                  android:layout_height="wrap_content"                                                           android:clickable="false"                                                                      
+                android:enabled="false"                                                                            android:text="@string/ai_key_test" />                                                          </LinearLayout>                                                                                            </LinearLayout>                                                                                                
diff --git a/src/com/sprd/validationtools/itemstest/audio/PhoneLoopBackTest.java b/src/com/sprd/validationtools/itemstest/audio/PhoneLoopBackTest.java                                                                                  
index d45d9b8..7b8696c 100644                                                                                       
--- a/src/com/sprd/validationtools/itemstest/audio/PhoneLoopBackTest.java                                           
+++ b/src/com/sprd/validationtools/itemstest/audio/PhoneLoopBackTest.java                                           
@@ -83,17 +83,21 @@ public class PhoneLoopBackTest extends BaseActivity {                                           mRadioSpeaker.setOnClickListener(new View.OnClickListener() {                                              public void onClick(View v) {                                                                          
+                Log.d(TAG, "mRadioSpeaker click---");                                                              
+                                                                                                                   switchLoopback(LOOPBACK_SPEAKER);                                                                  }                                                                                                      });                                                                                                        mRadioReceiver.setOnClickListener(new View.OnClickListener() {                                             public void onClick(View v) {                                                                          
+                Log.d(TAG, "mRadioReceiver click---");                                                             switchLoopback(LOOPBACK_RECEIVER);                                                                 }                                                                                                      });                                                                                                        mRadioEarpiece.setOnClickListener(new View.OnClickListener() {                                             public void onClick(View v) {                                                                          
+                Log.d(TAG, "mRadioEarpiece click---");                                                             switchLoopback(LOOPBACK_MIC_EARPIECE);                                                             }                                                                                                      });                                                                                                        
diff --git a/src/com/sprd/validationtools/itemstest/keypad/KeyTestActivity.java b/src/com/sprd/validationtools/itemstest/keypad/KeyTestActivity.java                                                                                    
index 0139c4e..06f5bd1 100644                                                                                       
--- a/src/com/sprd/validationtools/itemstest/keypad/KeyTestActivity.java                                            
+++ b/src/com/sprd/validationtools/itemstest/keypad/KeyTestActivity.java                                            
@@ -19,6 +19,7 @@ import android.widget.Button;                                                                     import android.widget.GridLayout;                                                                                  import android.widget.ImageButton;                                                                                 import android.widget.Toast;                                                                                       
+import android.view.WindowManager;                                                                                 import com.sprd.validationtools.BaseActivity;                                                                      import com.sprd.validationtools.Const;                                                                             
@@ -118,13 +119,20 @@ public class KeyTestActivity extends BaseActivity {                                           setContentView(R.layout.key_test);                                                                     setTitle(R.string.key_test);                                                                           mHomeButton = (ImageButton) findViewById(R.id.home_button);                                            
+            mHomeButton.setEnabled(false);                                                                         //            mMenuButton = (ImageButton) findViewById(R.id.menu_button);                                          mCallButton = (Button) findViewById(R.id.call_button);                                                 mVolumeUpButton = (ImageButton) findViewById(R.id.volume_up_button);                                   mVolumeDownButton = (ImageButton) findViewById(R.id.volume_down_button);                               mCameraButton = (ImageButton) findViewById(R.id.camera_button);                                        
+            mVolumeUpButton.setEnabled(false);                                                                     
+            mVolumeDownButton.setEnabled(false);                                                                   
+            mCameraButton.setEnabled(false);                                                                       
+                                                                                                                   mPowerButton = (ImageButton) findViewById(R.id.power_button);                                          
+            mPowerButton.setEnabled(false);                                                                        
+                                                                                                                   mPTTButton = (Button)findViewById(R.id.ptt_button);                                                    mSOSButton = (Button)findViewById(R.id.sos_button);                                                    @@ -154,10 +162,9 @@ public class KeyTestActivity extends BaseActivity {                                            mVideoButton.setVisibility(View.GONE);                                                                 mCallButton.setVisibility(View.GONE);                                                                  -            findViewById(R.id.focus_button).requestFocus();                                                        
-                                                                                                                   mFnButton = (Button)findViewById(R.id.fn_button);                                                      mMenuButton = (ImageButton)findViewById(R.id.menu_button);                                             
+            mMenuButton.setEnabled(false);                                                                         mUpButton = (ImageButton)findViewById(R.id.up_button);                                                 mDownButton = (ImageButton)findViewById(R.id.down_button);                                             
@@ -165,7 +172,14 @@ public class KeyTestActivity extends BaseActivity {                                            mRightButton = (ImageButton)findViewById(R.id.right_button);                                           mCenterButton = (ImageButton)findViewById(R.id.center_button);                                         mBackButton = (ImageButton)findViewById(R.id.back_button);                                             
-                                                                                                                   
+            mUpButton.setEnabled(false);                                                                           
+            mDownButton.setEnabled(false);                                                                         
+            mLeftButton.setEnabled(false);                                                                         
+            mRightButton.setEnabled(false);                                                                        
+            mCenterButton.setEnabled(false);                                                                       
+            mBackButton.setEnabled(false);                                                                         
+                                                                                                                   
+            // mVolumeUpButton.requestFocus();                                                                     initSupport();                                                                                         }                                                                                                          }  

over~

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • Spring Boot集成Stripe快速入门demo
  • 使用dx工具将jar和class打包成dex
  • 注解的生命周期
  • 粘包、半包和Netty中的自定义帧解码器间的关系
  • 【Java设计模式】脏标记模式:通过变更跟踪优化性能
  • HTTP/3
  • 453.最小操作次数使数组元素相等
  • 产品概述Tektronix泰克TCP0030A电流探头TCP0030原装二手
  • 自然语言处理与深度学习的结合
  • pyinstaller 打包发布flask 应用
  • C++奇迹之旅:深度解析list的模拟实现
  • 【时时三省】(C语言基础)指针进阶6qsort函数的使用
  • BCC软译码和硬译码之间的性能差别
  • CAN协议通信 学习笔记
  • Linux启动流程和内核管理
  • 【css3】浏览器内核及其兼容性
  • 2017届校招提前批面试回顾
  • codis proxy处理流程
  • Fundebug计费标准解释:事件数是如何定义的?
  • gitlab-ci配置详解(一)
  • Java 23种设计模式 之单例模式 7种实现方式
  • Lucene解析 - 基本概念
  • SpiderData 2019年2月25日 DApp数据排行榜
  • Vue 重置组件到初始状态
  • vue-router的history模式发布配置
  • 解析 Webpack中import、require、按需加载的执行过程
  • 配置 PM2 实现代码自动发布
  • 前端面试之CSS3新特性
  • 使用 Xcode 的 Target 区分开发和生产环境
  • 算法-插入排序
  • 《天龙八部3D》Unity技术方案揭秘
  • SAP CRM里Lead通过工作流自动创建Opportunity的原理讲解 ...
  • Spark2.4.0源码分析之WorldCount 默认shuffling并行度为200(九) ...
  • 选择阿里云数据库HBase版十大理由
  • 资深实践篇 | 基于Kubernetes 1.61的Kubernetes Scheduler 调度详解 ...
  • ​学习一下,什么是预包装食品?​
  • # Maven错误Error executing Maven
  • #基础#使用Jupyter进行Notebook的转换 .ipynb文件导出为.md文件
  • $$$$GB2312-80区位编码表$$$$
  • (2022版)一套教程搞定k8s安装到实战 | RBAC
  • (39)STM32——FLASH闪存
  • (C语言)输入自定义个数的整数,打印出最大值和最小值
  • (delphi11最新学习资料) Object Pascal 学习笔记---第5章第5节(delphi中的指针)
  • (DenseNet)Densely Connected Convolutional Networks--Gao Huang
  • (Matlab)使用竞争神经网络实现数据聚类
  • (第27天)Oracle 数据泵转换分区表
  • (二)测试工具
  • (每日持续更新)jdk api之StringBufferInputStream基础、应用、实战
  • (一)模式识别——基于SVM的道路分割实验(附资源)
  • *算法训练(leetcode)第四十五天 | 101. 孤岛的总面积、102. 沉没孤岛、103. 水流问题、104. 建造最大岛屿
  • .apk 成为历史!
  • .gitignore文件_Git:.gitignore
  • .net core Swagger 过滤部分Api
  • .NET Core 发展历程和版本迭代
  • .NET Core 项目指定SDK版本