Remove unused code.

Change-Id: I1d0d976bd44d089cb1f0d6f852ddc497ab0cee29
diff --git a/src/com/android/mail/utils/Utils.java b/src/com/android/mail/utils/Utils.java
index 532af6b..eef1197 100644
--- a/src/com/android/mail/utils/Utils.java
+++ b/src/com/android/mail/utils/Utils.java
@@ -42,12 +42,10 @@
 import android.provider.Browser;
 import android.text.Spannable;
 import android.text.SpannableString;
-import android.text.SpannableStringBuilder;
 import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.TextUtils.SimpleStringSplitter;
 import android.text.style.CharacterStyle;
-import android.text.style.ForegroundColorSpan;
 import android.text.style.StyleSpan;
 import android.text.style.TextAppearanceSpan;
 import android.util.TypedValue;
@@ -86,7 +84,6 @@
      * longest extension we recognize is 4 characters (e.g. "html", "docx")
      */
     private static final int FILE_EXTENSION_MAX_CHARS = 4;
-    private static final Map<Integer, Integer> sPriorityToLength = Maps.newHashMap();
     public static final String SENDER_LIST_TOKEN_ELIDED = "e";
     public static final String SENDER_LIST_TOKEN_NUM_MESSAGES = "n";
     public static final String SENDER_LIST_TOKEN_NUM_DRAFTS = "d";
@@ -94,9 +91,6 @@
     public static final String SENDER_LIST_TOKEN_SENDING = "s";
     public static final String SENDER_LIST_TOKEN_SEND_FAILED = "f";
     public static final Character SENDER_LIST_SEPARATOR = '\n';
-    public static final SimpleStringSplitter sSenderListSplitter = new SimpleStringSplitter(
-            SENDER_LIST_SEPARATOR);
-    public static String[] sSenderFragments = new String[8];
 
     public static final String EXTRA_ACCOUNT = "account";
     public static final String EXTRA_ACCOUNT_URI = "accountUri";
@@ -231,332 +225,12 @@
         }
     }
 
-    // TODO: Move this to the UI Provider.
-    private static CharacterStyle sUnreadStyleSpan = null;
-    private static CharacterStyle sReadStyleSpan;
-    private static CharacterStyle sDraftsStyleSpan;
-    private static CharSequence sMeString;
-    private static CharSequence sDraftSingularString;
-    private static CharSequence sDraftPluralString;
-    private static CharSequence sSendingString;
-    private static CharSequence sSendFailedString;
-
     private static int sMaxUnreadCount = -1;
     private static final CharacterStyle ACTION_BAR_UNREAD_STYLE = new StyleSpan(Typeface.BOLD);
     private static String sUnreadText;
     private static int sDefaultFolderBackgroundColor = -1;
     private static int sUseFolderListFragmentTransition = -1;
 
-    public static void getStyledSenderSnippet(Context context, String senderInstructions,
-            SpannableStringBuilder senderBuilder, SpannableStringBuilder statusBuilder,
-            int maxChars, boolean forceAllUnread, boolean forceAllRead, boolean allowDraft) {
-        Resources res = context.getResources();
-        if (sUnreadStyleSpan == null) {
-            sUnreadStyleSpan = new StyleSpan(Typeface.BOLD);
-            sReadStyleSpan = new StyleSpan(Typeface.NORMAL);
-            sDraftsStyleSpan = new ForegroundColorSpan(res.getColor(R.color.drafts));
-
-            sMeString = context.getText(R.string.me_subject_pronun);
-            sDraftSingularString = res.getQuantityText(R.plurals.draft, 1);
-            sDraftPluralString = res.getQuantityText(R.plurals.draft, 2);
-            SpannableString sendingString = new SpannableString(context.getText(R.string.sending));
-            sendingString.setSpan(CharacterStyle.wrap(sDraftsStyleSpan), 0, sendingString.length(),
-                    0);
-            sSendingString = sendingString;
-            sSendFailedString = context.getText(R.string.send_failed);
-        }
-
-        getSenderSnippet(senderInstructions, senderBuilder, statusBuilder, maxChars,
-                sUnreadStyleSpan, sReadStyleSpan, sDraftsStyleSpan, sMeString,
-                sDraftSingularString, sDraftPluralString, sSendingString, sSendFailedString,
-                forceAllUnread, forceAllRead, allowDraft);
-    }
-
-    /**
-     * Uses sender instructions to build a formatted string.
-     * <p>
-     * Sender list instructions contain compact information about the sender
-     * list. Most work that can be done without knowing how much room will be
-     * availble for the sender list is done when creating the instructions.
-     * <p>
-     * The instructions string consists of tokens separated by
-     * SENDER_LIST_SEPARATOR. Here are the tokens, one per line:
-     * <ul>
-     * <li><tt>n</tt></li>
-     * <li><em>int</em>, the number of non-draft messages in the conversation</li>
-     * <li><tt>d</tt</li>
-     * <li><em>int</em>, the number of drafts in the conversation</li>
-     * <li><tt>l</tt></li>
-     * <li><em>literal html to be included in the output</em></li>
-     * <li><tt>s</tt> indicates that the message is sending (in the outbox
-     * without errors)</li>
-     * <li><tt>f</tt> indicates that the message failed to send (in the outbox
-     * with errors)</li>
-     * <li><em>for each message</em>
-     * <ul>
-     * <li><em>int</em>, 0 for read, 1 for unread</li>
-     * <li><em>int</em>, the priority of the message. Zero is the most important
-     * </li>
-     * <li><em>text</em>, the sender text or blank for messages from 'me'</li>
-     * </ul>
-     * </li>
-     * <li><tt>e</tt> to indicate that one or more messages have been elided</li>
-     * <p>
-     * The instructions indicate how many messages and drafts are in the
-     * conversation and then describe the most important messages in order,
-     * indicating the priority of each message and whether the message is
-     * unread.
-     *
-     * @param instructions instructions as described above
-     * @param senderBuilder the SpannableStringBuilder to append to for sender
-     *            information
-     * @param statusBuilder the SpannableStringBuilder to append to for status
-     * @param maxChars the number of characters available to display the text
-     * @param unreadStyle the CharacterStyle for unread messages, or null
-     * @param draftsStyle the CharacterStyle for draft messages, or null
-     * @param sendingString the string to use when there are messages scheduled
-     *            to be sent
-     * @param sendFailedString the string to use when there are messages that
-     *            mailed to send
-     * @param meString the string to use for messages sent by this user
-     * @param draftString the string to use for "Draft"
-     * @param draftPluralString the string to use for "Drafts"
-     */
-    public static synchronized void getSenderSnippet(String instructions,
-            SpannableStringBuilder senderBuilder, SpannableStringBuilder statusBuilder,
-            int maxChars, CharacterStyle unreadStyle, CharacterStyle readStyle,
-            CharacterStyle draftsStyle, CharSequence meString, CharSequence draftString,
-            CharSequence draftPluralString, CharSequence sendingString,
-            CharSequence sendFailedString, boolean forceAllUnread, boolean forceAllRead,
-            boolean allowDraft) {
-        assert !(forceAllUnread && forceAllRead);
-        boolean unreadStatusIsForced = forceAllUnread || forceAllRead;
-        boolean forcedUnreadStatus = forceAllUnread;
-
-        // Measure each fragment. It's ok to iterate over the entire set of
-        // fragments because it is
-        // never a long list, even if there are many senders.
-        final Map<Integer, Integer> priorityToLength = sPriorityToLength;
-        priorityToLength.clear();
-
-        int maxFoundPriority = Integer.MIN_VALUE;
-        int numMessages = 0;
-        int numDrafts = 0;
-        CharSequence draftsFragment = "";
-        CharSequence sendingFragment = "";
-        CharSequence sendFailedFragment = "";
-
-        sSenderListSplitter.setString(instructions);
-        int numFragments = 0;
-        String[] fragments = sSenderFragments;
-        int currentSize = fragments.length;
-        while (sSenderListSplitter.hasNext()) {
-            fragments[numFragments++] = sSenderListSplitter.next();
-            if (numFragments == currentSize) {
-                sSenderFragments = new String[2 * currentSize];
-                System.arraycopy(fragments, 0, sSenderFragments, 0, currentSize);
-                currentSize *= 2;
-                fragments = sSenderFragments;
-            }
-        }
-
-        for (int i = 0; i < numFragments;) {
-            String fragment0 = fragments[i++];
-            if ("".equals(fragment0)) {
-                // This should be the final fragment.
-            } else if (SENDER_LIST_TOKEN_ELIDED.equals(fragment0)) {
-                // ignore
-            } else if (SENDER_LIST_TOKEN_NUM_MESSAGES.equals(fragment0)) {
-                numMessages = Integer.valueOf(fragments[i++]);
-            } else if (SENDER_LIST_TOKEN_NUM_DRAFTS.equals(fragment0)) {
-                String numDraftsString = fragments[i++];
-                numDrafts = Integer.parseInt(numDraftsString);
-                draftsFragment = numDrafts == 1 ? draftString : draftPluralString + " ("
-                        + numDraftsString + ")";
-            } else if (SENDER_LIST_TOKEN_LITERAL.equals(fragment0)) {
-                senderBuilder.append(Utils.convertHtmlToPlainText(fragments[i++]));
-                return;
-            } else if (SENDER_LIST_TOKEN_SENDING.equals(fragment0)) {
-                sendingFragment = sendingString;
-            } else if (SENDER_LIST_TOKEN_SEND_FAILED.equals(fragment0)) {
-                sendFailedFragment = sendFailedString;
-            } else {
-                String priorityString = fragments[i++];
-                CharSequence nameString = fragments[i++];
-                if (nameString.length() == 0)
-                    nameString = meString;
-                int priority = Integer.parseInt(priorityString);
-                priorityToLength.put(priority, nameString.length());
-                maxFoundPriority = Math.max(maxFoundPriority, priority);
-            }
-        }
-        String numMessagesFragment = (numMessages != 0) ? " \u00A0"
-                + Integer.toString(numMessages + numDrafts) : "";
-
-        // Don't allocate fixedFragment unless we need it
-        SpannableStringBuilder fixedFragment = null;
-        int fixedFragmentLength = 0;
-        if (draftsFragment.length() != 0 && allowDraft) {
-            fixedFragment = new SpannableStringBuilder();
-            fixedFragment.append(draftsFragment);
-            if (draftsStyle != null) {
-                fixedFragment.setSpan(CharacterStyle.wrap(draftsStyle), 0, fixedFragment.length(),
-                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-            }
-        }
-        if (sendingFragment.length() != 0) {
-            if (fixedFragment == null) {
-                fixedFragment = new SpannableStringBuilder();
-            }
-            if (fixedFragment.length() != 0)
-                fixedFragment.append(", ");
-            fixedFragment.append(sendingFragment);
-        }
-        if (sendFailedFragment.length() != 0) {
-            if (fixedFragment == null) {
-                fixedFragment = new SpannableStringBuilder();
-            }
-            if (fixedFragment.length() != 0)
-                fixedFragment.append(", ");
-            fixedFragment.append(sendFailedFragment);
-        }
-
-        if (fixedFragment != null) {
-            fixedFragmentLength = fixedFragment.length();
-        }
-        maxChars -= fixedFragmentLength;
-
-        int maxPriorityToInclude = -1; // inclusive
-        int numCharsUsed = numMessagesFragment.length();
-        int numSendersUsed = 0;
-        while (maxPriorityToInclude < maxFoundPriority) {
-            if (priorityToLength.containsKey(maxPriorityToInclude + 1)) {
-                int length = numCharsUsed + priorityToLength.get(maxPriorityToInclude + 1);
-                if (numCharsUsed > 0)
-                    length += 2;
-                // We must show at least two senders if they exist. If we don't
-                // have space for both
-                // then we will truncate names.
-                if (length > maxChars && numSendersUsed >= 2) {
-                    break;
-                }
-                numCharsUsed = length;
-                numSendersUsed++;
-            }
-            maxPriorityToInclude++;
-        }
-
-        int numCharsToRemovePerWord = 0;
-        if (numCharsUsed > maxChars) {
-            numCharsToRemovePerWord = (numCharsUsed - maxChars) / numSendersUsed;
-        }
-
-        String lastFragment = null;
-        CharacterStyle lastStyle = null;
-        for (int i = 0; i < numFragments;) {
-            String fragment0 = fragments[i++];
-            if ("".equals(fragment0)) {
-                // This should be the final fragment.
-            } else if (SENDER_LIST_TOKEN_ELIDED.equals(fragment0)) {
-                if (lastFragment != null) {
-                    addStyledFragment(senderBuilder, lastFragment, lastStyle, false);
-                    senderBuilder.append(" ");
-                    addStyledFragment(senderBuilder, "..", lastStyle, true);
-                    senderBuilder.append(" ");
-                }
-                lastFragment = null;
-            } else if (SENDER_LIST_TOKEN_NUM_MESSAGES.equals(fragment0)) {
-                i++;
-            } else if (SENDER_LIST_TOKEN_NUM_DRAFTS.equals(fragment0)) {
-                i++;
-            } else if (SENDER_LIST_TOKEN_SENDING.equals(fragment0)) {
-            } else if (SENDER_LIST_TOKEN_SEND_FAILED.equals(fragment0)) {
-            } else {
-                final String unreadString = fragment0;
-                final String priorityString = fragments[i++];
-                String nameString = fragments[i++];
-                if (nameString.length() == 0) {
-                    nameString = meString.toString();
-                } else {
-                    nameString = Utils.convertHtmlToPlainText(nameString).toString();
-                }
-                if (numCharsToRemovePerWord != 0) {
-                    nameString = nameString.substring(0,
-                            Math.max(nameString.length() - numCharsToRemovePerWord, 0));
-                }
-                final boolean unread = unreadStatusIsForced ? forcedUnreadStatus : Integer
-                        .parseInt(unreadString) != 0;
-                final int priority = Integer.parseInt(priorityString);
-                if (priority <= maxPriorityToInclude) {
-                    if (lastFragment != null && !lastFragment.equals(nameString)) {
-                        addStyledFragment(senderBuilder, lastFragment.concat(","), lastStyle,
-                                false);
-                        senderBuilder.append(" ");
-                    }
-                    lastFragment = nameString;
-                    lastStyle = unread ? unreadStyle : readStyle;
-                } else {
-                    if (lastFragment != null) {
-                        addStyledFragment(senderBuilder, lastFragment, lastStyle, false);
-                        // Adjacent spans can cause the TextView in Gmail widget
-                        // confused and leads to weird behavior on scrolling.
-                        // Our workaround here is to separate the spans by
-                        // spaces.
-                        senderBuilder.append(" ");
-                        addStyledFragment(senderBuilder, "..", lastStyle, true);
-                        senderBuilder.append(" ");
-                    }
-                    lastFragment = null;
-                }
-            }
-        }
-        if (lastFragment != null) {
-            addStyledFragment(senderBuilder, lastFragment, lastStyle, false);
-        }
-        senderBuilder.append(numMessagesFragment);
-        if (fixedFragmentLength != 0) {
-            statusBuilder.append(fixedFragment);
-        }
-    }
-
-    /**
-     * Adds a fragment with given style to a string builder.
-     *
-     * @param builder the current string builder
-     * @param fragment the fragment to be added
-     * @param style the style of the fragment
-     * @param withSpaces whether to add the whole fragment or to divide it into
-     *            smaller ones
-     */
-    private static void addStyledFragment(SpannableStringBuilder builder, String fragment,
-            CharacterStyle style, boolean withSpaces) {
-        if (withSpaces) {
-            int pos = builder.length();
-            builder.append(fragment);
-            builder.setSpan(CharacterStyle.wrap(style), pos, builder.length(),
-                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-        } else {
-            int start = 0;
-            while (true) {
-                int pos = fragment.substring(start).indexOf(' ');
-                if (pos == -1) {
-                    addStyledFragment(builder, fragment.substring(start), style, true);
-                    break;
-                } else {
-                    pos += start;
-                    if (start < pos) {
-                        addStyledFragment(builder, fragment.substring(start, pos), style, true);
-                        builder.append(' ');
-                    }
-                    start = pos + 1;
-                    if (start >= fragment.length()) {
-                        break;
-                    }
-                }
-            }
-        }
-    }
-
     /**
      * Returns a boolean indicating whether the table UI should be shown.
      */