diff options
Diffstat (limited to 'src/com/android/mail/drawer')
-rw-r--r-- | src/com/android/mail/drawer/AccountDrawerItem.java | 86 | ||||
-rw-r--r-- | src/com/android/mail/drawer/BlankHeaderDrawerItem.java | 69 | ||||
-rw-r--r-- | src/com/android/mail/drawer/BottomSpaceDrawerItem.java | 69 | ||||
-rw-r--r-- | src/com/android/mail/drawer/DrawerItem.java | 231 | ||||
-rw-r--r-- | src/com/android/mail/drawer/FolderDrawerItem.java | 79 | ||||
-rw-r--r-- | src/com/android/mail/drawer/FooterItem.java | 108 | ||||
-rw-r--r-- | src/com/android/mail/drawer/HeaderDrawerItem.java | 74 | ||||
-rw-r--r-- | src/com/android/mail/drawer/HelpItem.java | 60 | ||||
-rw-r--r-- | src/com/android/mail/drawer/SettingsItem.java | 60 | ||||
-rw-r--r-- | src/com/android/mail/drawer/WaitViewDrawerItem.java | 68 |
10 files changed, 904 insertions, 0 deletions
diff --git a/src/com/android/mail/drawer/AccountDrawerItem.java b/src/com/android/mail/drawer/AccountDrawerItem.java new file mode 100644 index 000000000..cdd49327d --- /dev/null +++ b/src/com/android/mail/drawer/AccountDrawerItem.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; + +import com.android.bitmap.BitmapCache; +import com.android.mail.R; +import com.android.mail.bitmap.ContactResolver; +import com.android.mail.providers.Account; +import com.android.mail.ui.AccountItemView; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.utils.FolderUri; + +class AccountDrawerItem extends DrawerItem { + /** True if the drawer item represents the current account, false otherwise */ + private final boolean mIsSelected; + private final BitmapCache mImagesCache; + private final ContactResolver mContactResolver; + + AccountDrawerItem(ControllableActivity activity, Account account, + int unreadCount, boolean isCurrentAccount, BitmapCache cache, + ContactResolver contactResolver) { + super(activity, null, NONFOLDER_ITEM, account); + mIsSelected = isCurrentAccount; + mImagesCache = cache; + mContactResolver = contactResolver; + // TODO: Unread count should eventually percolate through to the account switcher + } + + @Override + public String toString() { + return "[DrawerItem VIEW_ACCOUNT, mAccount=" + mAccount + "]"; + } + + /** + * Return a view for an account object. + * + * @param convertView a view, possibly null, to be recycled. + * @param parent the parent viewgroup to attach to. + * @return a view to display at this position. + */ + @Override + public View getView(View convertView, ViewGroup parent) { + final AccountItemView accountItemView; + if (convertView != null) { + accountItemView = (AccountItemView) convertView; + } else { + accountItemView = + (AccountItemView) mInflater.inflate(R.layout.account_item, parent, false); + } + accountItemView.bind(mActivity.getActivityContext(), mAccount, mIsSelected, + mImagesCache, mContactResolver); + return accountItemView; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } + + @Override + public boolean isItemEnabled() { + return true; + } + + @Override + public @DrawerItemType int getType() { + return VIEW_ACCOUNT; + } +} diff --git a/src/com/android/mail/drawer/BlankHeaderDrawerItem.java b/src/com/android/mail/drawer/BlankHeaderDrawerItem.java new file mode 100644 index 000000000..35abcfc36 --- /dev/null +++ b/src/com/android/mail/drawer/BlankHeaderDrawerItem.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; + +import com.android.mail.R; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.utils.FolderUri; + +class BlankHeaderDrawerItem extends DrawerItem { + BlankHeaderDrawerItem(ControllableActivity activity) { + super(activity, null, NONFOLDER_ITEM, null); + } + + @Override + public String toString() { + return "[DrawerItem VIEW_BLANK_HEADER]"; + } + + /** + * Returns a blank divider + * + * @param convertView A previous view, perhaps null + * @param parent the parent of this view + * @return a blank header + */ + @Override + public View getView(View convertView, ViewGroup parent) { + final View blankHeaderView; + if (convertView != null) { + blankHeaderView = convertView; + } else { + blankHeaderView = mInflater.inflate(R.layout.folder_list_blank_header, parent, + false); + } + return blankHeaderView; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } + + @Override + public boolean isItemEnabled() { + return false; + } + + @Override + public @DrawerItemType int getType() { + return VIEW_BLANK_HEADER; + } +} diff --git a/src/com/android/mail/drawer/BottomSpaceDrawerItem.java b/src/com/android/mail/drawer/BottomSpaceDrawerItem.java new file mode 100644 index 000000000..9d8ef5ee1 --- /dev/null +++ b/src/com/android/mail/drawer/BottomSpaceDrawerItem.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; + +import com.android.mail.R; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.utils.FolderUri; + +class BottomSpaceDrawerItem extends DrawerItem { + BottomSpaceDrawerItem(ControllableActivity activity) { + super(activity, null, NONFOLDER_ITEM, null); + } + + @Override + public String toString() { + return "[DrawerItem VIEW_BOTTOM_SPACE]"; + } + + /** + * Returns a blank spacer + * + * @param convertView A previous view, perhaps null + * @param parent the parent of this view + * @return a blank spacer + */ + @Override + public View getView(View convertView, ViewGroup parent) { + final View blankHeaderView; + if (convertView != null) { + blankHeaderView = convertView; + } else { + blankHeaderView = mInflater.inflate(R.layout.folder_list_bottom_space, parent, + false); + } + return blankHeaderView; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } + + @Override + public boolean isItemEnabled() { + return false; + } + + @Override + public @DrawerItemType int getType() { + return VIEW_BOTTOM_SPACE; + } +} diff --git a/src/com/android/mail/drawer/DrawerItem.java b/src/com/android/mail/drawer/DrawerItem.java new file mode 100644 index 000000000..a360f1282 --- /dev/null +++ b/src/com/android/mail/drawer/DrawerItem.java @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.support.annotation.IntDef; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.bitmap.BitmapCache; +import com.android.mail.bitmap.ContactResolver; +import com.android.mail.providers.Account; +import com.android.mail.providers.Folder; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.ui.FolderListFragment; +import com.android.mail.utils.FolderUri; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + + +/** + * An element that is shown in the {@link com.android.mail.ui.FolderListFragment}. This class is + * only used for elements that are shown in the {@link com.android.mail.ui.DrawerFragment}. + * This class is an enumeration of a few element types: Account, a folder, a recent folder, + * or a header (a resource string). A {@link DrawerItem} can only be one type and can never + * switch types. Items are created using methods like + * {@link DrawerItem#ofAccount(ControllableActivity, Account, int, boolean, BitmapCache, + * ContactResolver)}, + * {@link DrawerItem#ofWaitView(ControllableActivity)}, etc. + * + * Once created, the item can create a view using + * {@link #getView(android.view.View, android.view.ViewGroup)}. + */ +public abstract class DrawerItem { + public final Folder mFolder; + public final Account mAccount; + + /** These are view types for view recycling purposes */ + @Retention(RetentionPolicy.CLASS) + @IntDef({VIEW_FOLDER, VIEW_HEADER, VIEW_BLANK_HEADER, VIEW_BOTTOM_SPACE, VIEW_ACCOUNT, + VIEW_WAITING_FOR_SYNC, VIEW_FOOTER_HELP, VIEW_FOOTER_SETTINGS}) + public @interface DrawerItemType {} + /** A normal folder, also a child, if a parent is specified. */ + public static final int VIEW_FOLDER = 0; + /** A text-label which serves as a header in sectioned lists. */ + public static final int VIEW_HEADER = 1; + /** A blank divider which serves as a header in sectioned lists. */ + public static final int VIEW_BLANK_HEADER = 2; + /** A spacer which serves as a footer below the last item. */ + public static final int VIEW_BOTTOM_SPACE = 3; + /** An account object, which allows switching accounts rather than folders. */ + public static final int VIEW_ACCOUNT = 4; + /** An expandable object for expanding/collapsing more of the list */ + public static final int VIEW_WAITING_FOR_SYNC = 5; + /** A footer item for Help */ + public static final int VIEW_FOOTER_HELP = 6; + /** A footer item for Settings */ + public static final int VIEW_FOOTER_SETTINGS = 7; + /** The value (1-indexed) of the last View type. Useful when returning the number of types. */ + private static final int LAST_FIELD = VIEW_FOOTER_SETTINGS + 1; + + /** The parent activity */ + protected final ControllableActivity mActivity; + protected final LayoutInflater mInflater; + + /** + * These values determine the behavior of the drawer items. + * + * Either {@link #FOLDER_INBOX}, {@link #FOLDER_RECENT} or {@link #FOLDER_OTHER} when + * {@link #getType()} is {@link #VIEW_FOLDER}, or {@link #NONFOLDER_ITEM} otherwise. + */ + @Retention(RetentionPolicy.CLASS) + @IntDef({UNSET, NONFOLDER_ITEM, FOLDER_INBOX, FOLDER_RECENT, FOLDER_OTHER}) + public @interface DrawerItemCategory {} + public final @DrawerItemCategory int mItemCategory; + /** Non existent item or folder type not yet set */ + public static final int UNSET = 0; + /** An unclickable text-header visually separating the different types. */ + public static final int NONFOLDER_ITEM = 0; + /** An inbox folder: Inbox, ...*/ + public static final int FOLDER_INBOX = 1; + /** A folder from whom a conversation was recently viewed */ + public static final int FOLDER_RECENT = 2; + /** A non-inbox folder that is shown in the "everything else" group. */ + public static final int FOLDER_OTHER = 3; + + /** + * Creates a drawer item with every instance variable specified. + * + * @param activity the underlying activity + * @param folder a non-null folder, if this is a folder type + * @param itemCategory the type of the folder. For folders this is: + * {@link #FOLDER_INBOX}, {@link #FOLDER_RECENT}, {@link #FOLDER_OTHER}, + * or for non-folders this is {@link #NONFOLDER_ITEM} + * @param account the account object, for an account drawer element + */ + protected DrawerItem(ControllableActivity activity, Folder folder, + @DrawerItemCategory int itemCategory, Account account) { + mActivity = activity; + mFolder = folder; + mItemCategory = itemCategory; + mAccount = account; + mInflater = LayoutInflater.from(activity.getActivityContext()); + } + + /** + * Create a folder item with the given type. + * + * @param activity the underlying activity + * @param folder a folder that this item represents + * @param itemCategory one of {@link #FOLDER_INBOX}, {@link #FOLDER_RECENT} or + * {@link #FOLDER_OTHER} + * @return a drawer item for the folder. + */ + public static DrawerItem ofFolder(ControllableActivity activity, Folder folder, + @DrawerItemCategory int itemCategory) { + return new FolderDrawerItem(activity, folder, itemCategory); + } + + /** + * Creates an item from an account. + * @param activity the underlying activity + * @param account the account to create a drawer item for + * @param unreadCount the unread count of the account, pass zero if + * @param isCurrentAccount true if the account is the current account, false otherwise + * @return a drawer item for the account. + */ + public static DrawerItem ofAccount(ControllableActivity activity, Account account, + int unreadCount, boolean isCurrentAccount, BitmapCache cache, + ContactResolver contactResolver) { + return new AccountDrawerItem(activity, account, unreadCount, isCurrentAccount, cache, + contactResolver); + } + + /** + * Create a header item with a string resource. + * + * @param activity the underlying activity + * @param resource the string resource: R.string.all_folders_heading + * @return a drawer item for the header. + */ + public static DrawerItem ofHeader(ControllableActivity activity, int resource) { + return new HeaderDrawerItem(activity, resource); + } + + public static DrawerItem ofBlankHeader(ControllableActivity activity) { + return new BlankHeaderDrawerItem(activity); + } + + public static DrawerItem ofBottomSpace(ControllableActivity activity) { + return new BottomSpaceDrawerItem(activity); + } + + /** + * Create a "waiting for initialization" item. + * + * @param activity the underlying activity + * @return a drawer item with an indeterminate progress indicator. + */ + public static DrawerItem ofWaitView(ControllableActivity activity) { + return new WaitViewDrawerItem(activity); + } + + public static DrawerItem ofHelpItem(ControllableActivity activity, Account account, + FolderListFragment.DrawerStateListener drawerListener) { + return new HelpItem(activity, account, drawerListener); + } + + public static DrawerItem ofSettingsItem(ControllableActivity activity, Account account, + FolderListFragment.DrawerStateListener drawerListener) { + return new SettingsItem(activity, account, drawerListener); + } + + /** + * Returns a view for the given item. The method signature is identical to that required by a + * {@link android.widget.ListAdapter#getView(int, android.view.View, android.view.ViewGroup)}. + */ + public abstract View getView(View convertView, ViewGroup parent); + + /** + * Book-keeping for how many different view types there are. + * @return number of different types of view items + */ + public static int getViewTypeCount() { + return LAST_FIELD; + } + + /** + * Returns whether this view is enabled or not. An enabled view is one that accepts user taps + * and acts upon them. + * @return true if this view is enabled, false otherwise. + */ + public abstract boolean isItemEnabled(); + + /** + * Returns whether this view is highlighted or not. + * + * + * @param currentFolder The current folder, according to the + * {@link com.android.mail.ui.FolderListFragment} + * @param currentType The type of the current folder. We want to only highlight a folder once. + * A folder might be in two places at once: in "All Folders", and in + * "Recent Folder". Valid types of selected folders are : + * {@link DrawerItem#FOLDER_INBOX}, {@link DrawerItem#FOLDER_RECENT} or + * {@link DrawerItem#FOLDER_OTHER}, or {@link DrawerItem#UNSET}. + + * @return true if this DrawerItem results in a view that is highlighted (this DrawerItem is + * the current folder. + */ + public abstract boolean isHighlighted(FolderUri currentFolder, int currentType); + + public abstract @DrawerItemType int getType(); + + public void onClick(View v) {} +} + diff --git a/src/com/android/mail/drawer/FolderDrawerItem.java b/src/com/android/mail/drawer/FolderDrawerItem.java new file mode 100644 index 000000000..823d686c1 --- /dev/null +++ b/src/com/android/mail/drawer/FolderDrawerItem.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; + +import com.android.mail.R; +import com.android.mail.providers.Folder; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.ui.FolderItemView; +import com.android.mail.utils.FolderUri; + +class FolderDrawerItem extends DrawerItem { + FolderDrawerItem(ControllableActivity activity, Folder folder, + @DrawerItemCategory int folderCategory) { + super(activity, folder, folderCategory, null); + } + + @Override + public String toString() { + return "[DrawerItem VIEW_FOLDER, mFolder=" + mFolder + ", mItemCategory=" + + mItemCategory + "]"; + } + + /** + * Return a folder: either a parent folder or a normal (child or flat) + * folder. + * + * @param convertView a view, possibly null, to be recycled. + * @return a view showing a folder at the given position. + */ + @Override + public View getView(View convertView, ViewGroup parent) { + final FolderItemView folderItemView; + if (convertView != null) { + folderItemView = (FolderItemView) convertView; + } else { + folderItemView = + (FolderItemView) mInflater.inflate(R.layout.folder_item, parent, false); + } + folderItemView.bind(mFolder, null /* parentUri */); + folderItemView.setIcon(mFolder); + return folderItemView; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + // True if folder types and URIs are the same + if (currentFolder != null && mFolder != null && mFolder.folderUri != null) { + return (mItemCategory == currentType) && mFolder.folderUri.equals(currentFolder); + } + return false; + } + + @Override + public boolean isItemEnabled() { + return true; + } + + @Override + public @DrawerItemType int getType() { + return VIEW_FOLDER; + } +} diff --git a/src/com/android/mail/drawer/FooterItem.java b/src/com/android/mail/drawer/FooterItem.java new file mode 100644 index 000000000..51bebd3d1 --- /dev/null +++ b/src/com/android/mail/drawer/FooterItem.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.android.mail.R; +import com.android.mail.providers.Account; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.ui.DrawerController; +import com.android.mail.ui.FolderListFragment; + +/** + * The base class of all footer items. Subclasses must fill in the logic of + * {@link #onFooterClicked()} which contains the behavior when the item is selected. + */ +public abstract class FooterItem extends DrawerItem implements View.OnClickListener { + + private final FolderListFragment.DrawerStateListener mDrawerListener; + private final int mImageResourceId; + private final int mTextResourceId; + + FooterItem(ControllableActivity activity, Account account, + FolderListFragment.DrawerStateListener drawerListener, + final int imageResourceId, final int textResourceId) { + super(activity, null, NONFOLDER_ITEM, account); + mDrawerListener = drawerListener; + mImageResourceId = imageResourceId; + mTextResourceId = textResourceId; + } + + private int getImageResourceId() { + return mImageResourceId; + } + + private int getTextResourceId() { + return mTextResourceId; + } + + /** + * Executes the behavior associated with this footer item.<br> + * <br> + * WARNING: you probably don't want to call this directly; use {@link #onClick(View)} instead. + * This method actually performs the action, and its execution may be deferred from when the + * 'click' happens so we can smoothly close the drawer beforehand. + */ + public abstract void onFooterClicked(); + + @Override + public final void onClick(View v) { + final DrawerController dc = mActivity.getDrawerController(); + if (dc.isDrawerEnabled()) { + // close the drawer and defer handling the click until onDrawerClosed + mActivity.getAccountController().closeDrawer(false /* hasNewFolderOrAccount */, + null /* nextAccount */, null /* nextFolder */); + mDrawerListener.setPendingFooterClick(this); + } else { + onFooterClicked(); + } + } + + /** + * For analytics + * @return label for analytics event + */ + protected String getEventLabel() { + return "drawer_footer/" + mActivity.getViewMode().getModeString(); + } + + @Override + public View getView(View convertView, ViewGroup parent) { + final ViewGroup footerItemView; + if (convertView != null) { + footerItemView = (ViewGroup) convertView; + } else { + footerItemView = + (ViewGroup) mInflater.inflate(R.layout.drawer_footer_item, parent, false); + } + + // adjust the text of the footer item + final TextView textView = (TextView) footerItemView. + findViewById(R.id.drawer_footer_text); + textView.setText(getTextResourceId()); + + // adjust the icon of the footer item + final ImageView imageView = (ImageView) footerItemView. + findViewById(R.id.drawer_footer_image); + imageView.setImageResource(getImageResourceId()); + return footerItemView; + } +} diff --git a/src/com/android/mail/drawer/HeaderDrawerItem.java b/src/com/android/mail/drawer/HeaderDrawerItem.java new file mode 100644 index 000000000..e21daf1e9 --- /dev/null +++ b/src/com/android/mail/drawer/HeaderDrawerItem.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.android.mail.R; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.utils.FolderUri; + +class HeaderDrawerItem extends DrawerItem { + private final int mResource; + + HeaderDrawerItem(ControllableActivity activity, int resource) { + super(activity, null, NONFOLDER_ITEM, null); + mResource = resource; + } + + @Override + public String toString() { + return "[DrawerItem VIEW_HEADER, mResource=" + mResource + "]"; + } + + /** + * Returns a text divider between divisions. + * + * @param convertView a previous view, perhaps null + * @param parent the parent of this view + * @return a text header at the given position. + */ + @Override + public View getView(View convertView, ViewGroup parent) { + final View headerView; + if (convertView != null) { + headerView = convertView; + } else { + headerView = mInflater.inflate(R.layout.folder_list_header, parent, false); + } + final TextView textView = (TextView) headerView.findViewById(R.id.header_text); + textView.setText(mResource); + return headerView; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } + + @Override + public boolean isItemEnabled() { + return false; + } + + @Override + public @DrawerItemType int getType() { + return VIEW_HEADER; + } +} diff --git a/src/com/android/mail/drawer/HelpItem.java b/src/com/android/mail/drawer/HelpItem.java new file mode 100644 index 000000000..651b7d3c0 --- /dev/null +++ b/src/com/android/mail/drawer/HelpItem.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import com.android.mail.R; +import com.android.mail.analytics.Analytics; +import com.android.mail.providers.Account; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.ui.FolderListFragment; +import com.android.mail.ui.ViewMode; +import com.android.mail.utils.FolderUri; + +class HelpItem extends FooterItem { + HelpItem(ControllableActivity activity, Account account, + FolderListFragment.DrawerStateListener drawerListener) { + super(activity, account, drawerListener, + R.drawable.ic_drawer_help_24dp, R.string.help_and_feedback); + } + + @Override + public void onFooterClicked() { + Analytics.getInstance().sendMenuItemEvent(Analytics.EVENT_CATEGORY_MENU_ITEM, + R.id.help_info_menu_item, getEventLabel(), 0); + mActivity.showHelp(mAccount, ViewMode.CONVERSATION_LIST); + } + + @Override + public int getType() { + return VIEW_FOOTER_HELP; + } + + @Override + public String toString() { + return "[FooterItem VIEW_HELP_ITEM]"; + } + + @Override + public boolean isItemEnabled() { + return false; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } +} diff --git a/src/com/android/mail/drawer/SettingsItem.java b/src/com/android/mail/drawer/SettingsItem.java new file mode 100644 index 000000000..07d3fca5d --- /dev/null +++ b/src/com/android/mail/drawer/SettingsItem.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import com.android.mail.R; +import com.android.mail.analytics.Analytics; +import com.android.mail.providers.Account; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.ui.FolderListFragment; +import com.android.mail.utils.FolderUri; +import com.android.mail.utils.Utils; + +class SettingsItem extends FooterItem { + SettingsItem(ControllableActivity activity, Account account, + FolderListFragment.DrawerStateListener drawerListener) { + super(activity, account, drawerListener, + R.drawable.ic_drawer_settings_24dp, R.string.menu_settings); + } + + @Override + public void onFooterClicked() { + Analytics.getInstance().sendMenuItemEvent(Analytics.EVENT_CATEGORY_MENU_ITEM, + R.id.settings, getEventLabel(), 0); + Utils.showSettings(mActivity.getActivityContext(), mAccount); + } + + @Override + public int getType() { + return VIEW_FOOTER_SETTINGS; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } + + @Override + public boolean isItemEnabled() { + return false; + } + + @Override + public String toString() { + return "[FooterItem VIEW_SETTINGS_ITEM]"; + } +} diff --git a/src/com/android/mail/drawer/WaitViewDrawerItem.java b/src/com/android/mail/drawer/WaitViewDrawerItem.java new file mode 100644 index 000000000..ba9fc19d0 --- /dev/null +++ b/src/com/android/mail/drawer/WaitViewDrawerItem.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mail.drawer; + +import android.view.View; +import android.view.ViewGroup; + +import com.android.mail.R; +import com.android.mail.ui.ControllableActivity; +import com.android.mail.utils.FolderUri; + +class WaitViewDrawerItem extends DrawerItem { + WaitViewDrawerItem(ControllableActivity activity) { + super(activity, null, NONFOLDER_ITEM, null); + } + + @Override + public String toString() { + return "[DrawerItem VIEW_WAITING_FOR_SYNC]"; + } + + /** + * Return a view for the 'Waiting for sync' item with the indeterminate progress indicator. + * + * @param convertView a view, possibly null, to be recycled. + * @param parent the parent hosting this view. + * @return a view for "Waiting for sync..." at given position. + */ + @Override + public View getView(View convertView, ViewGroup parent) { + final ViewGroup emptyView; + if (convertView != null) { + emptyView = (ViewGroup) convertView; + } else { + emptyView = (ViewGroup) mInflater.inflate(R.layout.drawer_empty_view, parent, false); + } + return emptyView; + } + + @Override + public boolean isHighlighted(FolderUri currentFolder, int currentType) { + return false; + } + + @Override + public boolean isItemEnabled() { + return false; + } + + @Override + public @DrawerItemType int getType() { + return VIEW_WAITING_FOR_SYNC; + } +} |