Android 短信转换成彩信的消息数量(实例代码)

 更新时间:2017年05月25日 09:52:48   作者:chenhao132654  
本文通过实例代码给大家介绍了Android 短信转换成彩信的消息数量,需要的朋友可以参考下

默认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 短信转换成彩信的消息数量,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

相关文章

  • Android提高之TelephonyManager功能探秘

    Android提高之TelephonyManager功能探秘

    这篇文章主要介绍了Android的TelephonyManager功能,可以帮助读者更好的理解Java反射机制,需要的朋友可以参考下
    2014-08-08
  • Android 摄像头高斯模糊的示例代码

    Android 摄像头高斯模糊的示例代码

    本篇文章主要介绍了Android 摄像头高斯模糊的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-12-12
  • Android数据存储几种方式讲解

    Android数据存储几种方式讲解

    在开发过程中,数据存取是较为频繁的,今天我们来了解下android几种常见的数据存取方式。在Android中,sharePreferences是一种轻量级的数据存储方式,采用键值对的存储方式,存储少量数据,支持基本类型的简单数据存储
    2022-12-12
  • Android GridView仿微信添加多图效果

    Android GridView仿微信添加多图效果

    这篇文章主要为大家详细介绍了Android GridView仿微信添加多图效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-05-05
  • Android编程获取APP应用程序基本信息辅助类【APP名称、包名、图标,版本号等】

    Android编程获取APP应用程序基本信息辅助类【APP名称、包名、图标,版本号等】

    这篇文章主要介绍了Android编程获取APP应用程序基本信息辅助类,可实现针对APP名称、包名、图标,版本号等信息的获取功能,需要的朋友可以参考下
    2017-12-12
  • Android基于CountDownTimer实现倒计时功能

    Android基于CountDownTimer实现倒计时功能

    这篇文章主要介绍了Android基于CountDownTimer实现倒计时功能,简单分析了基于CountDownTimer类实现倒计时功能的技巧,需要的朋友可以参考下
    2015-12-12
  • Android使用SoundPool播放音效

    Android使用SoundPool播放音效

    这篇文章主要为大家详细介绍了Android使用SoundPool播放音效,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-07-07
  • Kotlin-Android之Activity使用详解

    Kotlin-Android之Activity使用详解

    这篇文章主要介绍了Kotlin-Android之Activity使用详解,本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下
    2021-09-09
  • Android UI系列-----ScrollView和HorizontalScrollView的详解

    Android UI系列-----ScrollView和HorizontalScrollView的详解

    本篇文章主要是介绍的Android UI系列-----ScrollView和HorizontalScrollView,ScrollView和HorizontalScrollView都是布局容器,有需要的可以了解一下。
    2016-11-11
  • Android 动态的显示时间

    Android 动态的显示时间

    本文给大家分享一段代码实现android动态显示时间,代码简单易懂,非常不错,具有参考借鉴价值,需要的朋友参考下吧
    2016-12-12

最新评论