搜狗输入法短信界面点击Enter键不能换行

搜狗输入法MMs界面不换行;

  1. 定位改问题问题的UI界面点
    grep -r “键入信息” packages/apps/Mms/
    packages/apps/Mms/res/values-zh-rCN/strings.xml: “键入信息”

可以知道字符串为:type_to_compose_text_enter_to_send,继续通过命令查找:
packages/apps/Mms/res/layout/compose_message_activity.xml: android:hint="@string/type_to_compose_text_enter_to_send"
可以知道对应的布局问题:

                    <EditText
                        android:id="@+id/embedded_text_editor"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dip"
                        android:paddingBottom="14dip"
                        android:autoText="true"
                        android:capitalize="sentences"
                        android:hint="@string/type_to_compose_text_enter_to_send"
                        android:imeOptions="actionSend|flagNoEnterAction"
                        android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
                        android:maxLines="3"
                        android:background="#ffffff"
                        android:minHeight="@dimen/input_text_height"
                        android:nextFocusRight="@+id/send_button"
                        android:textColor="@color/embedded_text_color"
                        android:textColorHint="@color/embedded_hint_text_color"
                        android:textSize="16sp"
                        />

同步布局文件,有两个怀疑点:
1)android:imeOptions="actionSend|flagNoEnterAction"属性相关
2)在Activity中有对该EditText有键值定义处
查找对应的Activity: packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java
找到对应key值embedded_text_editor 的定义处:

mTextEditor = (EditText) findViewById(R.id.embedded_text_editor);
...
//此处即为函数的按键处理点:
mTextEditor.setOnEditorActionListener(this);

找到按键对应的文件函数:
其函数名一般是:注册函数的中间部分:即OnEditorAction,搜索果然如此:

@Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (event != null) {
            // if shift key is down, then we want to insert the '\n' char in the TextView;
            // otherwise, the default action is to send the message.
            /*if (!event.isShiftPressed() && event.getAction() == KeyEvent.ACTION_DOWN) {
                if (isPreparedForSending()) {
                    confirmSendMessageIfNeeded();
                }
                return true;
            }*/
            return false;
        }

        if (isPreparedForSending()) {
            confirmSendMessageIfNeeded();
        }
        return true;
    }

顺利找到Enter键的实现过程,当返回为false时候执行换行操作,否则无响应;
根据注释可以得到很好的说明:

 // if shift key is down, then we want to insert the '\n' char in the TextView;
 // otherwise, the default action is to send the message.

自此修改成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值