Android 短信轉(zhuǎn)換成彩信的消息數(shù)量(實(shí)例代碼)
默認(rèn)3條以上轉(zhuǎn)為彩信
改為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 //剩余字?jǐn)?shù)顯示 private TextView mSendButtonMms; // Press to send mms //彩信發(fā)送按鈕,TextView中加入圖片 private ImageButton mSendButtonSms; // Press to send sms //短信發(fā)送按鈕 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]; //已輸入短信條數(shù) final int remainingInCurrentMessage = params[2]; //剩余字?jǐn)?shù) mWorkingMessage.setLengthRequiresMms( msgCount >= MmsConfig.getSmsToMmsTextThreshold(), true); //轉(zhuǎn)為彩信的短信條數(shù) 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); //顯示短信發(fā)送按鈕或彩信發(fā)送按鈕 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 短信轉(zhuǎn)換成彩信的消息數(shù)量,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
AlertDialog點(diǎn)擊按鈕不消失的實(shí)現(xiàn)方法
我有一個(gè)文本輸入對(duì)話框,當(dāng)我點(diǎn)擊對(duì)話框上的“是”按鈕,它會(huì)驗(yàn)證輸入,然后關(guān)閉對(duì)話框,但是,如果輸入錯(cuò)誤,我想停留在同一個(gè)對(duì)話框中。怎么實(shí)現(xiàn)此功能呢?下面通過(guò)本文給大家分享下2017-01-01Android使用ViewPager快速切換Fragment時(shí)卡頓的優(yōu)化方案
今天小編就為大家分享一篇關(guān)于Android使用ViewPager快速切換Fragment時(shí)卡頓的優(yōu)化方案,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-12-12利用DrawerLayout和觸摸事件分發(fā)實(shí)現(xiàn)抽屜側(cè)滑效果
這篇文章主要為大家詳細(xì)介紹了利用DrawerLayout和觸摸事件分發(fā)實(shí)現(xiàn)抽屜側(cè)滑效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10Android RecyclerView的焦點(diǎn)記憶封裝
這篇文章主要介紹了Android RecyclerView的焦點(diǎn)記憶封裝,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-04-04Android 數(shù)據(jù)庫(kù)文件存取至儲(chǔ)存卡的方法
這篇文章主要介紹了Android 數(shù)據(jù)庫(kù)文件存取至儲(chǔ)存卡的方法的相關(guān)資料,需要的朋友可以參考下2016-03-03Android實(shí)現(xiàn)跑馬燈效果的兩種簡(jiǎn)單方式
這篇文章主要給大家介紹了關(guān)于Android實(shí)現(xiàn)跑馬燈的兩種簡(jiǎn)單方式,文中介紹了兩種方法,分別說(shuō)了每個(gè)方法的優(yōu)缺點(diǎn),需要的朋友可以選擇性使用,下面來(lái)一起看看吧2021-07-07去掉activity默認(rèn)動(dòng)畫效果的簡(jiǎn)單方法
下面小編就為大家?guī)?lái)一篇去掉activity默認(rèn)動(dòng)畫效果的簡(jiǎn)單方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-12-12