短信ui--会话编辑界面(四)BottomPanel
来源:互联网 发布:windows编程视频教程 编辑:程序博客网 时间:2024/06/03 21:51
短信ui--会话编辑界面(四)BottomPanel
1、前言
前面的文章简单介绍了接收者ui以及短信历史记录,下面讲解BottomPanel,该ui如下图所示
该ui比较简单,ui主要是短信编辑框、短信模版按钮、以及sendbutton。
2、功能简析
2.1 ui布局
<LinearLayout android:id="@+id/bottom_panel" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="5dip" android:paddingBottom="5dip" android:paddingLeft="5dip" android:paddingRight="5dip" android:background="@drawable/bottombar_landscape_565"> <RelativeLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_weight="1.0" android:orientation="horizontal" android:id="@+id/relativeLayout1"> <EditText android:id="@+id/embedded_text_editor" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.0" 文本编辑框 android:autoText="true" android:capitalize="sentences" android:nextFocusRight="@+id/send_button" android:hint="@string/type_to_compose_text_enter_to_send" android:maxLines="3" android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine" android:imeOptions="actionSend|flagNoEnterAction" android:background="@android:drawable/edit_text" android:maxLength="2000" /> <ImageButton android:id="@+id/smstemp_button" android:layout_marginTop="1dip" android:layout_marginBottom="3dip" 短信模版按钮 android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@id/embedded_text_editor" android:src="@drawable/import_sms_template" /> </RelativeLayout> <LinearLayout android:id="@+id/button_with_counter" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="match_parent" > <Button android:id="@+id/send_button" android:layout_marginLeft="5dip" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1.0" 发送按钮 style="?android:attr/buttonStyle" android:nextFocusLeft="@+id/embedded_text_editor" android:text="@string/send" /> <TextView android:id="@+id/text_counter" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal|bottom" android:textColor="#ffffffff" android:textSize="11sp" 短信计数器 android:textStyle="bold" android:paddingLeft="3dip" android:paddingRight="3dip" android:paddingBottom="5dip" android:visibility="gone" /> </LinearLayout> </LinearLayout>对于上述布局文件,没有太多可讲的。
2.2 功能分析
2.2.1 文本编辑框
initResourceRefs()初始化
mTextEditor = (EditText) findViewById(R.id.embedded_text_editor); mTextEditor.setOnEditorActionListener(this); mTextEditor.addTextChangedListener(mTextEditorWatcher); mTextEditor.setOnCreateContextMenuListener(mEditSMSMenuCreateListener); mTextEditor.setFilters(new InputFilter[] { new LengthFilter(MmsConfig.getMaxTextLimit())});
2.2.2 发送按钮
发送按钮点击事件,
if ((v == mSendButton) && isPreparedForSending()) { confirmSendMessageIfNeeded(); }这里就开始了发送短彩信。
2.2.3 短信计数器
这里要是更新计数器其核心代码如下
private void updateCounter(CharSequence text, int start, int before, int count) { WorkingMessage workingMessage = mWorkingMessage; if (workingMessage.requiresMms()) { // If we're not removing text (i.e. no chance of converting back to SMS // because of this change) and we're in MMS mode, just bail out since we // then won't have to calculate the length unnecessarily. final boolean textRemoved = (before > count); if (!textRemoved) { setSendButtonText(workingMessage.requiresMms()); return; } } String msg = text.toString(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (sp.getBoolean("pref_key_enable_signature", false)) { String signature = sp.getString("pref_key_edit_signature", ""); if (signature.trim().length() > 0) { msg += " "+signature.trim(); } } int[] params = SmsMessage.calculateLength(msg, false); /* SmsMessage.calculateLength returns an int[4] with: * int[0] being the number of SMS's required, * int[1] the number of code units used, * int[2] is the number of code units remaining until the next message. * int[3] is the encoding type that should be used for the message. */ int msgCount = params[0]; int remainingInCurrentMessage = params[2]; if (!MmsConfig.getMultipartSmsEnabled()) { mWorkingMessage.setLengthRequiresMms( msgCount >= MmsConfig.getSmsToMmsTextThreshold(), true); } // Show the counter only if: // - We are not in MMS mode // - We are going to send more than one message OR we are getting close boolean showCounter = false; if (!workingMessage.requiresMms() && (msgCount > 1 || remainingInCurrentMessage <= CHARS_REMAINING_BEFORE_COUNTER_SHOWN)) { showCounter = true; } setSendButtonText(workingMessage.requiresMms()); if (showCounter) { // Update the remaining characters and number of messages required. String counterText = msgCount > 1 ? remainingInCurrentMessage + " / " + msgCount : String.valueOf(remainingInCurrentMessage); mTextCounter.setText(counterText); mTextCounter.setVisibility(View.VISIBLE); } else { mTextCounter.setVisibility(View.GONE); } }
3、总结
该ui没有太多内容,解析到现在为止,短信ui部分的难点还有一个就是短信附件编辑和添加,短信附件的难点以及它们实现的原理请关注下文。- 短信ui--会话编辑界面(四)BottomPanel
- 短信ui-会话编辑界面(二)接收者UI
- 短信ui-会话编辑界面(一) 初识
- 短信ui-会话编辑界面(一) 初识
- 短信ui--会话编辑界面(三)历史记录
- 短信ui--会话编辑界面(五)彩信附件
- 短信ui--会话编辑界面之彩信附件
- 短信ui分析--会话列表
- 短信ui分析--会话列表
- 短信ui分析--设置界面
- 短信ui分析--短信界面更新
- 基于Android的短信应用开发(四)——读取短信会话并显示会话联系人
- Android短信会话(查看会话记录以及会话详情界面)---短信管家3
- windowbuilder 打开UI编辑界面
- 短信ui--短信设置界面之sim卡短信管理
- 短信和会话界面的数据库实现(sms and threads)
- 短信ui--设置界面之小区广播
- 源码分析Mms--ConversationList短信主界面会话列表
- 上传 超大文件( 4G) 到 java socket 服务器
- 链表环与两链表求交问题(2012年微软、新浪面试题)
- GridView,基本用法,高级用法,分页
- 接口抽象
- 天凉好个秋(连载八)
- 短信ui--会话编辑界面(四)BottomPanel
- subprocess
- jbpm学习笔记(三)--管理流程实例
- Unable to resolve target 'android-XX'
- 使用递归遍与历释放二叉数
- platform_driver_register,什么时候调用PROBE函数 注册后如何找到驱动匹配的设备
- jquery submit()不能提交表单的解决方法
- servlet
- 开发操作系统实践(五)——新的引导扇区代码