搜狗输入法MMs界面不换行;
- 定位改问题问题的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.
自此修改成功。