发布于 2017-08-23 20:58:12 | 15 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


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



相关阅读 :
Android 短信转换成彩信的消息数量(实例代码)
Android自定义View实现带数字的进度条实例代码
android短信拦截的实现代码
关于Android短信验证码的获取的示例
详解Android短信的发送和广播接收实现短信的监听
Android短信发送器实现方法
Android短信操作常见协议和常用代码
Android短信接收监听、自动回复短信操作例子
android短信监听工具(示例代码)
简单实现android短信发送器
Android 短信验证码自动填写
Android编程中的消息机制实例详解
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务