diff options
author | Andy Huang <ath@google.com> | 2012-03-13 23:13:53 -0700 |
---|---|---|
committer | Andy Huang <ath@google.com> | 2012-03-15 22:06:12 -0700 |
commit | c03208720e5650f0acb748f82ed10ac770d6ceb4 (patch) | |
tree | 74bc0e9cdf69077ec05e40720feab4698130b0b5 /src/com/android/mail/ui/FolderDisplayer.java | |
parent | 397621b93f83f8933f7a29a9b6d7fe2b88ec4008 (diff) | |
download | android_packages_apps_UnifiedEmail-c03208720e5650f0acb748f82ed10ac770d6ceb4.tar.gz android_packages_apps_UnifiedEmail-c03208720e5650f0acb748f82ed10ac770d6ceb4.tar.bz2 android_packages_apps_UnifiedEmail-c03208720e5650f0acb748f82ed10ac770d6ceb4.zip |
bring in classes to support conversation view's subject/labels
No functional change.
Bring in classes and refactor existing folder-display related
classes. Remove FolderValues and use plain Folder. If we need
somewhere to tuck display-only Folder properties or behavior, we
should wrap base Folders instead of duplicating fields.
Folder objects now support equality checking using the
(globally unique) URI.
Change-Id: Ic4cd9b555a6a71ed037a1e730f36f7f64c50ca36
Diffstat (limited to 'src/com/android/mail/ui/FolderDisplayer.java')
-rw-r--r-- | src/com/android/mail/ui/FolderDisplayer.java | 126 |
1 files changed, 26 insertions, 100 deletions
diff --git a/src/com/android/mail/ui/FolderDisplayer.java b/src/com/android/mail/ui/FolderDisplayer.java index 765135247..9cdca3c3a 100644 --- a/src/com/android/mail/ui/FolderDisplayer.java +++ b/src/com/android/mail/ui/FolderDisplayer.java @@ -17,131 +17,57 @@ package com.android.mail.ui; -import com.android.mail.providers.Folder; -import com.android.mail.utils.LogUtils; -import com.android.mail.utils.Utils; import com.google.common.collect.Sets; import android.content.Context; -import android.graphics.Color; -import android.net.Uri; -import android.os.Debug; import android.text.TextUtils; -import java.util.ArrayList; -import java.util.Arrays; +import com.android.mail.R; +import com.android.mail.providers.Conversation; +import com.android.mail.providers.Folder; +import com.android.mail.utils.LogUtils; + import java.util.SortedSet; /** * Used to generate folder display information given a raw folders string. - * (The raw folders string can be obtained from {@link ConversationCursor#getRawFolders()}.) + * (The raw folders string can be obtained from {@link Conversation#rawFolders}.) * */ public class FolderDisplayer { public static final String LOG_TAG = new LogUtils().getLogTag(); protected Context mContext; - protected String mAccount; - protected SortedSet<FolderValues> mFolderValuesSortedSet; - - // Reference to the map of folder canonical name to folder id for the folders needed for - // the folder displayer. This is set in loadConversationFolders - protected static class FolderValues implements Comparable<FolderValues> { - public final String colorId; - - public final String name; - - public final int folderId; + protected final SortedSet<Folder> mFoldersSortedSet = Sets.newTreeSet(); - public final Uri folderUri; - - public int backgroundColor; - - public int textColor; - - public boolean showBgColor; - - public FolderValues(int id, Uri uri, String color, String n, String bgColor, String fgColor, - Context context) { - folderId = id; - colorId = color; - name = n; - folderUri = uri; - final boolean showBgColor = !TextUtils.isEmpty(bgColor); - if (showBgColor) { - backgroundColor = Integer.parseInt(bgColor); - } else { - backgroundColor = Utils.getDefaultFolderBackgroundColor(context); - } - // TODO(mindyp): add default fg text color and text color from preference. - final boolean showTextColor = !TextUtils.isEmpty(fgColor); - if (showTextColor) { - textColor = Integer.parseInt(fgColor); - } else { - textColor = Utils.getDefaultFolderTextColor(context); - } - } + protected final int mDefaultBgColor; + protected final int mDefaultFgColor; - @Override - public int compareTo(FolderValues another) { - return name.compareToIgnoreCase(another.name); - } - } - - /** - * Initialize the FolderDisplayer for the specified account. - * - * @param context Context to use for loading string resources - * @param account - */ - public void initialize(Context context, String account) { + public FolderDisplayer(Context context) { mContext = context; - mAccount = account; + + mDefaultFgColor = context.getResources().getColor(R.color.default_folder_foreground_color); + mDefaultBgColor = context.getResources().getColor(R.color.default_folder_background_color); } /** * Configure the FolderDisplayer object by parsing the rawFolders string. * - * @param folder string containing serialized folders to display. + * @param foldersString string containing serialized folders to display. + * @param ignoreFolder (optional) folder to omit from the displayed set */ - public void loadConversationFolders(Folder ignoreFolder, String folderString) { - SortedSet<FolderValues> folderValuesSet = Sets.newTreeSet(); - ArrayList<Folder> folders = new ArrayList<Folder>(); - if (!TextUtils.isEmpty(folderString)) { - ArrayList<String> folderArray = new ArrayList<String>(Arrays.asList(TextUtils.split( - folderString, Folder.FOLDER_SEPARATOR_PATTERN))); - Folder f; - for (String folder : folderArray) { - f = new Folder(folder); - if (ignoreFolder == null || !ignoreFolder.uri.equals(f.uri)) { - folders.add(f); - } - } - } else if (ignoreFolder != null) { - folders.add(ignoreFolder); - } - for (Folder folder : folders) { - int folderId = folder.id; - Uri uri = folder.uri; - String canonicalName = folder.name; - String colorId = folder.bgColor; + public void loadConversationFolders(String foldersString, Folder ignoreFolder) { + mFoldersSortedSet.clear(); - // We will sometimes see folders that the folder map does not yet know about or that - // do not have names yet. - if (TextUtils.isEmpty(canonicalName)) continue; - String stringToDisplay = null; - - if (!Folder.isProviderFolder(folder)) { - stringToDisplay = folder.name; + for (Folder f : Folder.forFoldersString(foldersString)) { + // We will sometimes see folders that do not have names yet. + if (TextUtils.isEmpty(f.name) || (ignoreFolder != null && ignoreFolder.equals(f))) { + continue; } - stringToDisplay = folder.name; - if (stringToDisplay != null) { - folderValuesSet.add( - new FolderValues(folderId, uri, colorId, stringToDisplay, - folder.bgColor, folder.fgColor, mContext)); - } - } + // TODO: maybe do additional processing for system folder names here - mFolderValuesSortedSet = folderValuesSet; + mFoldersSortedSet.add(f); + } } -}
\ No newline at end of file + +} |