Android 短信转换成彩信的消息数量(实例代码)
程序员文章站
2023-12-02 22:59:46
默认3条以上转为彩信
改为5条
路径vendor/mediatek/proprietary/packages/apps/mms/src/com/android/mms/...
默认3条以上转为彩信
改为5条
路径vendor/mediatek/proprietary/packages/apps/mms/src/com/android/mms/mmsconfig.java
private static int ssmstommstextthreshold = 6; // 4
变量定义字面意思就可以理解 以下是代码分析
vendor/mediatek/proprietary/packages/apps/mms/res/layout/compose_message_activity.xml
布局文件
vendor/mediatek/proprietary/packages/apps/mms/src/com/android/mms/ui/composemessageactivity.java private enhanceedittext mtexteditor; // text editor to type your message into //消息输入框 private textview mtextcounter; // shows the number of characters used in text editor //剩余字数显示 private textview msendbuttonmms; // press to send mms //彩信发送按钮,textview中加入图片 private imagebutton msendbuttonsms; // press to send sms //短信发送按钮 private void updatecounter(charsequence text, int start, int before, int count) { ... int[] params = null; int encodingtype = smsmessage.encoding_unknown; encodingtype = mopcomposeext.getsmsencodingtype(encodingtype, composemessageactivity.this); params = smsmessage.calculatelength(text, false, encodingtype); /* 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. */ final int msgcount = params[0]; //已输入短信条数 final int remainingincurrentmessage = params[2]; //剩余字数 mworkingmessage.setlengthrequiresmms( msgcount >= mmsconfig.getsmstommstextthreshold(), true); //转为彩信的短信条数 mmslog.d(tag, "updatecounter(): message msgcount = " + msgcount + " textthreshold() = " + mmsconfig.getsmstommstextthreshold() + " remainingincurrentmessage = " + remainingincurrentmessage); /// m: show the counter /// m: update the remaining characters and number of messages required. if (msgcount >= mmsconfig.getsmstommstextthreshold()) { mtextcounter.setvisibility(view.gone); return; } muihandler.postdelayed(new runnable() { @override public void run() { if (mopcomposeext.updatecounteruirun(mtexteditor, remainingincurrentmessage, msgcount, mworkingmessage)) { return; } mmslog.d(tag, "updatecounter requiresmms = " + mworkingmessage.requiresmms() + " line count = " + mtexteditor.getlinecount()); if (mworkingmessage.requiresmms() || mtexteditor.getlinecount() <= 1) { mtextcounter.setvisibility(view.gone); return; } mtextcounter.setvisibility(view.visible); string countertext = remainingincurrentmessage + "/" + msgcount; mtextcounter.settext(countertext); } }, 100); //显示短信发送按钮或彩信发送按钮 private view showsmsormmssendbutton(boolean ismms) { view showbutton = null; view hidebutton = null; // add for ipmessage if (ismms) { if (msubcount == 0 || (isrecipientseditorvisible() && textutils.isempty(mrecipientseditor.gettext())) /// m: fix bug alps00563318, show gray mms_send_button /// when haven't subject, text and attachment || ((msubjecttexteditor == null || (msubjecttexteditor != null && textutils.isempty(msubjecttexteditor.gettext().tostring().trim()))) && mtexteditor != null && textutils.isempty(mtexteditor.gettext().tostring().trim()) && !mworkingmessage.hasattachment()) || !missmsenabled) { msendbuttonmms.setcompounddrawableswithintrinsicbounds(null, null, null, getresources().getdrawable(r.drawable.ic_send_sms_unsend)); } else { msendbuttonmms.setcompounddrawableswithintrinsicbounds(null, null, null, getresources().getdrawable(r.drawable.ic_send_ipmsg)); } showbutton = msendbuttonmms; hidebutton = msendbuttonsms; } else { if (!mipcompose.onipshowsmsormmssendbutton(ismms)) { if ((mtexteditor.gettext().tostring().isempty()) || msubcount == 0 || (isrecipientseditorvisible() && textutils.isempty(mrecipientseditor.gettext())) || recipientcount() > mmsconfig.getsmsrecipientlimit() || !missmsenabled) { ///@} msendbuttonsms.setimageresource(r.drawable.ic_send_sms_unsend); } else { msendbuttonsms.setimageresource(r.drawable.ic_send_ipmsg); } } showbutton = msendbuttonsms; hidebutton = msendbuttonmms; } if (showbutton != null) { showbutton.setvisibility(view.visible); } if (hidebutton != null) { hidebutton.setvisibility(view.gone); } updatetexteditorhint(); return showbutton; }
以上所述是小编给大家介绍的android 短信转换成彩信的消息数量,希望对大家有所帮助
上一篇: vue 搭建后台系统模块化开发详解