Text message UI-session editing interface (4) bottompanel

Source: Internet
Author: User
Text message UI-session editing interface (4) bottompanel 1. PrefaceThe previous article briefly introduced the receiver UI and SMS history. The following describes bottompanel, as shown in figure

This UI is relatively simple. The UI mainly includes the text message edit box, text message template button, and sendbutton.

2. Functional Analysis 2.1 UI Layout
<Linearlayout Android: Id = "@ + ID/bottom_panel" Android: Orientation = "horizontal" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: paddingtop = "5dip" Android: paddingbottom = "5dip" Android: paddingleft = "5dip" Android: paddingright = "5dip" Android: background = "@ drawable/bottombar_landscape_565"> <relativelayout Android: layout_height = "match_parent" Android: layout_width = "wrap_cont Ent "Android: layout_weight =" 1.0 "Android: Orientation =" horizontal "Android: Id =" @ + ID/relativelayout1 "> <edittext Android: id = "@ + ID/embedded_text_editor" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: layout_weight = "1.0" text edit box Android: autoText = "true" Android: Capitalize = "sentences" Android: nextfocusright = "@ + ID/send_button" Android: hint = "@ string/type_to_compose_text_ent Er_to_send "Android: maxlines =" 3 "Android: inputtype =" text0000message | textautocorrect | textcapsentences | textmultiline "Android: imeoptions =" actionsend | flagnoenteraction "Android: Background =" @ Android: drawable/edit_text "Android: maxlength =" 2000 "/> <imagebutton Android: Id =" @ + ID/smstemp_button "Android: layout_margintop =" 1dip "Android: layout_marginbottom = "3dip" SMS template button Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignright = "@ ID/embedded_text_editor" Android: src = "@ drawable/import_sms_template"/> </relativelayout> <linearlayout Android: id = "@ + ID/button_with_counter" Android: Orientation = "vertical" Android: layout_width = "wrap_content" Android: layout_height = "match_parent"> <button Android: id = "@ + ID/send_button" Android: layout_marginleft = "5dip" Android: layout_w Idth = "wrap_content" Android: layout_height = "0dip" Android: layout_weight = "1.0" Send button style = "? Android: ATTR/buttonstyle "Android: nextfocusleft =" @ + ID/embedded_text_editor "Android: text =" @ string/Send "/> <textview Android: id = "@ + ID/text_counter" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: gravity = "center_horizontal | bottom" Android: textcolor = "# ffffffff" Android: textsize = "11sp" SMS counter Android: textstyle = "bold" Android: paddingleft = "3dip" Android: paddingright = "3dip" Android: paddingbottom = "5dip" Android: visibility = "gone"/> </linearlayout>

There is not much to mention about the above layout files. 2.2 function analysis 2.2.1 text edit box initresourcerefs () initialization

     mTextEditor = (EditText) findViewById(R.id.embedded_text_editor);        mTextEditor.setOnEditorActionListener(this);        mTextEditor.addTextChangedListener(mTextEditorWatcher);        mTextEditor.setOnCreateContextMenuListener(mEditSMSMenuCreateListener);        mTextEditor.setFilters(new InputFilter[] {                new LengthFilter(MmsConfig.getMaxTextLimit())});
2.2.2 send button click event,
   if ((v == mSendButton) && isPreparedForSending()) {            confirmSendMessageIfNeeded();        }

Sending Short MMS is started here. 2.2.3 text message counter the core code for updating the counter is as follows:

    private void updateCounter(CharSequence text, int start, int before, int count) {        WorkingMessage workingMessage = mWorkingMessage;        if (workingMessage.requiresMms()) {            // If we're not removing text (i.e. no chance of converting back to SMS            // because of this change) and we're in MMS mode, just bail out since we            // then won't have to calculate the length unnecessarily.            final boolean textRemoved = (before > count);            if (!textRemoved) {                setSendButtonText(workingMessage.requiresMms());                return;            }        }        String msg = text.toString();        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);        if (sp.getBoolean("pref_key_enable_signature", false)) {            String signature = sp.getString("pref_key_edit_signature", "");            if (signature.trim().length() > 0) {                msg += " "+signature.trim();            }        }        int[] params = SmsMessage.calculateLength(msg, false);            /* 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.             */        int msgCount = params[0];        int remainingInCurrentMessage = params[2];        if (!MmsConfig.getMultipartSmsEnabled()) {            mWorkingMessage.setLengthRequiresMms(                    msgCount >= MmsConfig.getSmsToMmsTextThreshold(), true);        }        // Show the counter only if:        // - We are not in MMS mode        // - We are going to send more than one message OR we are getting close        boolean showCounter = false;        if (!workingMessage.requiresMms() &&                (msgCount > 1 ||                 remainingInCurrentMessage <= CHARS_REMAINING_BEFORE_COUNTER_SHOWN)) {            showCounter = true;        }        setSendButtonText(workingMessage.requiresMms());        if (showCounter) {            // Update the remaining characters and number of messages required.            String counterText = msgCount > 1 ? remainingInCurrentMessage + " / " + msgCount                    : String.valueOf(remainingInCurrentMessage);            mTextCounter.setText(counterText);            mTextCounter.setVisibility(View.VISIBLE);        } else {            mTextCounter.setVisibility(View.GONE);        }    }
3. Summary

This UI does not have much content. So far, the text message UI is difficult to edit and add text message attachments. The following describes the difficulties of text message attachments and their implementation principles.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.