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

商业网站开发模式国内最新新闻

商业网站开发模式,国内最新新闻,wordpress postid,行业网站建设公司外界实体物理键盘,需要选择键盘布局,不然会对应输入不正确,某些平台是这样的。 实体键盘在插入设备中后会自动设置一个布局,但是可能不是我们想要的。 修改两个功能: 根据系统语言设置默认的键盘。 默认添加两个键盘…

外界实体物理键盘,需要选择键盘布局,不然会对应输入不正确,某些平台是这样的。

实体键盘在插入设备中后会自动设置一个布局,但是可能不是我们想要的。

修改两个功能:
根据系统语言设置默认的键盘。

默认添加两个键盘布局到'选择键盘布局' 的dialog界面

键盘的布局文件apk位置:  

frameworks/base/packages/InputDevices/res/raw/

frameworks/base/packages/InputDevices/res/xml/keyboard_layouts.xml

追查设置中的布局找到这里,选择键盘布局的Dialog,packages/apps/Settings/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java

点击设置键盘布局,会走到  packages/apps/Settings/src/com/android/settings/inputmethod/KeyboardLayoutPickerController.java

查看到 addKeyboardLayoutForInputDevice 设置键盘布局,所以利用这里我们添加。

@Overridepublic boolean handlePreferenceTreeClick(Preference preference) {if(DEBUG)Log.d("testkeyboard","----handlePreferenceTreeClick---");if (!(preference instanceof SwitchPreference)) {return false;}final SwitchPreference switchPref = (SwitchPreference) preference;final KeyboardLayout layout = mPreferenceMap.get(switchPref);if (layout != null) {final boolean checked = switchPref.isChecked();if (checked) {mIm.addKeyboardLayoutForInputDevice(mInputDeviceIdentifier,layout.getDescriptor());if(DEBUG)Log.d("testkeyboard","layout.getDescriptor() = " + layout.getDescriptor());} else {mIm.removeKeyboardLayoutForInputDevice(mInputDeviceIdentifier,layout.getDescriptor());}}return true;}

主要修改 frameworks/base/services/core/java/com/android/server/input/InputManagerService.java 

addKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,String keyboardLayoutDescriptor)

如下修改:

diff --git a/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java b/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
index 5fc3712d221..1bc1ee6cef7 100755
--- a/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
@@ -1101,6 +1101,7 @@ public class InputManagerService extends IInputManager.StubString layout =getCurrentKeyboardLayoutForInputDevice(inputDevice.getIdentifier());if (layout == null) {
+                    if(DEBUG) Slog.d("testkeyboard", "---goto--getDefaultKeyboardLayout");layout = getDefaultKeyboardLayout(inputDevice);if (layout != null) {setCurrentKeyboardLayoutForInputDevice(
@@ -1134,6 +1135,20 @@ public class InputManagerService extends IInputManager.Stubfinal Locale systemLocale = mContext.getResources().getConfiguration().locale;// If our locale doesn't have a language for some reason, then we don't really have a// reasonable default.
+
+        if(DEBUG) Slog.d("testkeyboard", "---getDefaultKeyboardLayout---getLanguage="+systemLocale.getLanguage());
+        String russuan = "com.android.inputdevices/com.android.inputdevices.InputDeviceReceiver/keyboard_layout_russian";
+        String english_us = "com.android.inputdevices/com.android.inputdevices.InputDeviceReceiver/keyboard_layout_english_us";//根据语言设置当前键盘
+        if(systemLocale.getLanguage().equals("en")){
+            return english_us;
+        }
+        if(systemLocale.getLanguage().equals("ru")){
+            return russuan;
+        }
+        //这里就是添加的两个键盘
+        addKeyboardLayoutForInputDevice(d.getIdentifier(),russuan);
+        addKeyboardLayoutForInputDevice(d.getIdentifier(),english_us);
+if (TextUtils.isEmpty(systemLocale.getLanguage())) {return null;}
@@ -1150,6 +1165,7 @@ public class InputManagerService extends IInputManager.Stubfor (int localeIndex = 0; localeIndex < numLocales; ++localeIndex) {if (isCompatibleLocale(systemLocale, locales.get(localeIndex))) {layouts.add(layout);
+                    if(DEBUG) Slog.d("testkeyboard", "---getDefaultKeyboardLayout---for--getLanguage="+systemLocale.getLanguage());break;}}
@@ -1386,10 +1402,12 @@ public class InputManagerService extends IInputManager.Stub@Override // Binder callpublic KeyboardLayout[] getKeyboardLayoutsForInputDevice(final InputDeviceIdentifier identifier) {
+        if(DEBUG) Slog.d("testkeyboard", "---getKeyboardLayoutsForInputDevice---");final String[] enabledLayoutDescriptors =getEnabledKeyboardLayoutsForInputDevice(identifier);final ArrayList<KeyboardLayout> enabledLayouts =new ArrayList<>(enabledLayoutDescriptors.length);
+        if(DEBUG) Slog.d("testkeyboard", "---ArrayList enabledLayouts---");final ArrayList<KeyboardLayout> potentialLayouts = new ArrayList<>();visitAllKeyboardLayouts(new KeyboardLayoutVisitor() {boolean mHasSeenDeviceSpecificLayout;
@@ -1402,6 +1420,7 @@ public class InputManagerService extends IInputManager.Stubfor (String s : enabledLayoutDescriptors) {if (s != null && s.equals(layout.getDescriptor())) {enabledLayouts.add(layout);
+                        if(DEBUG) Slog.d("testkeyboard", "---ArrayList enabledLayouts.add---");return;}}
@@ -1436,8 +1455,10 @@ public class InputManagerService extends IInputManager.Stubpublic KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor) {Objects.requireNonNull(keyboardLayoutDescriptor,"keyboardLayoutDescriptor must not be null");
+        if(DEBUG) Slog.d("testkeyboard", "---getKeyboardLayout---keyboardLayoutDescriptor="+keyboardLayoutDescriptor);final KeyboardLayout[] result = new KeyboardLayout[1];
+        if(result!=null) Slog.d("testkeyboard", "---getKeyboardLayout---result.length="+result.length);visitKeyboardLayout(keyboardLayoutDescriptor,(resources, keyboardLayoutResId, layout) -> result[0] = layout);if (result[0] == null) {
@@ -1632,12 +1653,15 @@ public class InputManagerService extends IInputManager.Stub@Override // Binder callpublic String[] getEnabledKeyboardLayoutsForInputDevice(InputDeviceIdentifier identifier) {String key = getLayoutDescriptor(identifier);
+        if(DEBUG) Slog.d("testkeyboard", "---getEnabledKeyboardLayoutsForInputDevice---key="+key);synchronized (mDataStore) {String[] layouts = mDataStore.getKeyboardLayouts(key);
+            if(DEBUG) Slog.d("testkeyboard", "---getEnabledKeyboardLayoutsForInputDevice---getDescriptor="+identifier.getDescriptor());if ((layouts == null || layouts.length == 0)&& !key.equals(identifier.getDescriptor())) {layouts = mDataStore.getKeyboardLayouts(identifier.getDescriptor());}
+            if(DEBUG) Slog.d("testkeyboard", "---getEnabledKeyboardLayoutsForInputDevice---length="+layouts.length);return layouts;}}
@@ -1645,6 +1669,7 @@ public class InputManagerService extends IInputManager.Stub@Override // Binder callpublic void addKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,String keyboardLayoutDescriptor) {
+        if(DEBUG) Slog.d("testkeyboard", "---addKeyboardLayoutForInputDevice---keyboardLayoutDescriptor="+keyboardLayoutDescriptor);if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT,"addKeyboardLayoutForInputDevice()")) {throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
@@ -1653,6 +1678,7 @@ public class InputManagerService extends IInputManager.Stub"keyboardLayoutDescriptor must not be null");String key = getLayoutDescriptor(identifier);
+        if(DEBUG) Slog.d("testkeyboard", "---addKeyboardLayoutForInputDevice---key="+key);synchronized (mDataStore) {try {String oldLayout = mDataStore.getCurrentKeyboardLayout(key);

http://www.ds6.com.cn/news/65654.html

相关文章:

  • 网站建设网站软件有哪些内容专业网站优化推广
  • c2c网站开发毕业设计网站开发需要的技术
  • 做旅游的网站的目的和意义公司网站如何seo
  • 网站只做内容 不做外链重庆森林百度云
  • 做面食视频网站seo含义
  • 济宁市环保局建设项目审批网站什么是网站推广优化
  • 三九手机网官网武汉seo培训
  • 网页设计板式要求前端seo搜索引擎优化
  • u盘搭建网站开发环境方法郑州seo培训
  • b2b网站开发报价在百度上怎么发布信息
  • sae wordpress 4.3seo主要做什么工作
  • 做网站怎么友情链接的作用有哪些
  • 网站地址栏图标文字中国免费网站服务器主机域名
  • 网站建设有哪些软件有哪些方面杭州百度公司在哪里
  • 网店推广软文范例seo做的好的网站
  • 做数据表格的网站深圳网络推广引流
  • 做分销网站多少钱个人网站制作流程
  • 深圳网站建设吗网站快速排名优化价格
  • 怎样做才能让网站有排名网络推广公司介绍
  • 如何做优酷网站赚钱企业网站模板html
  • 做视频网站需要什么地推团队接单平台
  • 用ps做招生网站seo优化入门教程
  • 用ps做简单的网页设计seo排名快速
  • 杭州网站设计网站seo优化方式包括
  • 成都网站建设木子网络培训学校管理制度大全
  • wordpress 钩子百度搜索seo优化技巧
  • 福建漳州网站建设费用seo搜索引擎优化主要做什么
  • 做网站店铺图片用什么软件教育机构退费纠纷找谁
  • 自己公司做公益网站怎么弄收录好的网站有哪些
  • 无锡高端网站建设咨询搜索量用什么工具查询