1 /* 2 * Copyright (C) 2013 Google Inc. 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package com.android.mail.ui; 18 19 import com.google.common.collect.Lists; 20 21 import android.content.Context; 22 import android.view.LayoutInflater; 23 24 import com.android.mail.providers.Account; 25 26 import com.android.mail.R; 27 28 import java.util.ArrayList; 29 30 public class ConversationListHelper { 31 /** 32 * Creates a list of newly created special views. 33 */ 34 public ArrayList<ConversationSpecialItemView> makeConversationListSpecialViews( 35 final Context context, final ControllableActivity activity, final Account account) { 36 final ConversationSyncDisabledTipView conversationSyncDisabledTipView = 37 (ConversationSyncDisabledTipView) LayoutInflater.from(context) 38 .inflate(R.layout.conversation_sync_disabled_tip_view, null); 39 conversationSyncDisabledTipView.bindAccount(account, activity); 40 41 final ConversationsInOutboxTipView conversationsInOutboxTipView = 42 (ConversationsInOutboxTipView) LayoutInflater.from(context) 43 .inflate(R.layout.conversation_outbox_tip_view, null); 44 conversationsInOutboxTipView.bind(account, activity.getFolderSelector()); 45 46 // Conversation photo teaser view 47 final ConversationPhotoTeaserView conversationPhotoTeaser = 48 (ConversationPhotoTeaserView) LayoutInflater.from(context) 49 .inflate(R.layout.conversation_photo_teaser_view, null); 50 51 // Long press to select tip 52 final ConversationLongPressTipView conversationLongPressTipView = 53 (ConversationLongPressTipView) LayoutInflater.from(context) 54 .inflate(R.layout.conversation_long_press_to_select_tip_view, null); 55 56 final NestedFolderTeaserView nestedFolderTeaserView = 57 (NestedFolderTeaserView) LayoutInflater.from(context) 58 .inflate(R.layout.nested_folder_teaser_view, null); 59 nestedFolderTeaserView.bind(account, activity.getFolderSelector()); 60 61 // Order matters. If a and b are added in order itemViews.add(a), itemViews.add(b), 62 // they will appear in conversation list as: 63 // b 64 // a 65 final ArrayList<ConversationSpecialItemView> itemViews = Lists.newArrayList(); 66 itemViews.add(conversationPhotoTeaser); 67 itemViews.add(conversationLongPressTipView); 68 itemViews.add(conversationSyncDisabledTipView); 69 itemViews.add(conversationsInOutboxTipView); 70 itemViews.add(nestedFolderTeaserView); 71 return itemViews; 72 } 73 } 74