温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android应用中怎么将短信转换成彩信

发布时间:2020-12-05 16:19:20 来源:亿速云 阅读:183 作者:Leah 栏目:移动开发

本篇文章为大家展示了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应用中怎么将短信转换成彩信,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI