当前位置: 首页 > 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~

http://www.lryc.cn/news/431982.html

相关文章:

  • 【Hot100算法刷题集】哈希-02-字母异位词分组(含排序构造键、自定义键、自定义哈希函数法)
  • 用华为智驾,开启MPV的下半场
  • 发烧时眼睛胀痛的多种原因
  • 用ACF和PACF计算出一堆数据的周期个数以及周期时长,数据分析python
  • 生活方式对人健康影响非常大 第三篇
  • ubuntu22.04 qemu 安装windows on arm虚拟机
  • 前端框架的演变与选择
  • Oracle(109)如何管理用户密码策略?
  • 【重学MySQL】十三、基本的 select 语句
  • vue3.5新特性整理
  • RK3588 系列之3—rknn使用过程中遇到的bug
  • Java中的强引用、软引用、弱引用和虚引用于JVM的垃圾回收机制
  • 网络协议的基础知识
  • Java高级Day37-UDP网络编程
  • 如何利用ChatGPT提升学术论文讨论部分的撰写质量和效率
  • 谷歌seo网址如何快速被收录?
  • 自动驾驶---什么是Frenet坐标系?
  • 如何编写Linux PCI设备驱动器 之一
  • 梯度弥散问题及解决方法
  • Python中pickle文件操作及案例-学习篇
  • 微服务日常总结
  • C和C++内存管理
  • axios取消请求
  • 阿里中间件——diamond
  • pyenv -- 一款macos下开源的多版本python环境安装管理工具 国内加速版安装 + 项目venv虚拟环境 pip加速 使用与总结
  • VitePress 自定义 CSS 指南
  • 【舍入,取整,取小数,取余数丨Excel 函数】
  • 无线信道中ph和ph^2的场景
  • HCIA--实验五:静态路由综合实验
  • 不同vlan之间的通信方法