首页 > 代码库 > 短信转彩信限制页数

短信转彩信限制页数

需求

Message->option->settings->Txt Message(SMS)->Sms size limit for converting to mms - Over 10 segment

Options:
- over 3 pages
- over 6 pages
- over 10 pages
- Never

方法:

packages/apps/Mms/xml/multicardpreferences.xml
packages/apps/Mms/xml/preferences.xml
packages/apps/Mms/xml/smsmulticardpreferences.xml
packages/apps/Mms/xml/smspreferences.xml

在上诉文件中添加列表项

<ListPreference
            android:key="pref_key_sms_mms_max"
            android:title="@string/sms_input_Maximum_title"
            android:defaultValue="http://www.mamicode.com/4"
            android:entries="@array/pref_sms_input_Maximum_choice"
            android:entryValues="@array/pref_sms_input_Maximum_values"
            android:dialogTitle="@string/sms_input_Maximum_dialog_title"
            android:summary="@string/sms_input_Maximum_summary"/>

定义字符串

/trunk/packages/apps/Mms/res/values/mtk_arrays.xml
/trunk/packages/apps/Mms/res/values/mtk_strings.xml

 <string-array name="pref_sms_input_Maximum_choice">
        <item>over 3 pages</item>
        <item>over 6 pages</item>
        <item>over 10 pages</item>
    <item>never</item>
    </string-array>
    <string-array name="pref_sms_input_Maximum_values" translatable="false">
        <item>4</item>
        <item>7</item>
        <item>11</item>
    <item>999</item>
    </string-array>

 

<string name="sms_input_Maximum_title">Converting to MMS</string>
    <string name="sms_input_Maximum_dialog_title">SMS size limit for converting to MMS</string>
    <string name="sms_input_Maximum_summary">When SMS size is over the given value, SMS converts to MMS</string>


3,/trunk/packages/apps/Mms/src/com/android/mms/ui/SmsPreferenceActivity.java

在java中添加菜单项

 private void addSmsToMmsPreference() {
    if (true) {
            mSmsInputMax = (ListPreference) findPreference(SMS_INPUT_MAX);
        if (mSmsInputMax != null) {
                 mSmsInputMax.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                // TODO Auto-generated method stub
                Log.i("wangdandan", "newValue = "http://www.mamicode.com/+newValue);
                String str = (String) newValue;
                int value = http://www.mamicode.com/Integer.valueOf(str);
                MmsConfig.setSmsToMmsText(value);
                return true;
            }
        });     
        
            }
        }
    }

在private void restoreDefaultPreferences()方法中重新赋值

 editor.putString(SMS_INPUT_MAX, "11");
            MmsConfig.setSmsToMmsText(11);

3,/trunk/packages/apps/Mms/src/com/android/mms/MmsConfig.java

 

 else if ("smsToMmsTextThreshold".equalsIgnoreCase(value)) {
                            /// M: Operator Plugin

                if (FeatureOption.SAGEREAL_SMSTOMMS_LIMIT){  //工程中添加的宏控
                     SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
                    String vaule = sp.getString(SmsPreferenceActivity.SMS_INPUT_MAX, "11");
                    Log.i("wangdandan", "loadMmsSettings.vaule = "+vaule);
                    mMmsConfigPlugin.setSmsToMmsTextThreshold(Integer.parseInt(vaule));
                            } else {
                                mMmsConfigPlugin.setSmsToMmsTextThreshold(Integer.parseInt(text));
                }

                        }

 

 public static void setSmsToMmsText(int value) {
        mMmsConfigPlugin.setSmsToMmsTextThreshold(value);
    }