1 package com.android.mail.ui; 2 3 import android.content.Context; 4 5 import com.android.mail.R; 6 import com.android.mail.analytics.Analytics; 7 import com.android.mail.browse.ConversationCursor; 8 import com.android.mail.preferences.MailPrefs; 9 import com.android.mail.providers.Folder; 10 11 /** 12 * A teaser to introduce people to the contact photo check boxes 13 */ 14 public class ConversationPhotoTeaserView extends ConversationTipView { 15 private final MailPrefs mMailPrefs; 16 private boolean mShown; 17 ConversationPhotoTeaserView(final Context context)18 public ConversationPhotoTeaserView(final Context context) { 19 super(context); 20 21 mMailPrefs = MailPrefs.get(context); 22 setText(getResources().getString(R.string.conversation_photo_welcome_text)); 23 } 24 25 @Override getStartIconAttr()26 protected ImageAttrSet getStartIconAttr() { 27 return new ImageAttrSet(R.drawable.ic_check_24dp, 28 R.drawable.conversation_photo_teaser_checkmark_bg, null); 29 } 30 31 @Override onUpdate(Folder folder, ConversationCursor cursor)32 public void onUpdate(Folder folder, ConversationCursor cursor) { 33 mShown = checkWhetherToShow(); 34 } 35 36 @Override getShouldDisplayInList()37 public boolean getShouldDisplayInList() { 38 // show if 1) sender images are enabled 2) there are items 39 mShown = checkWhetherToShow(); 40 return mShown; 41 } 42 checkWhetherToShow()43 private boolean checkWhetherToShow() { 44 // show if 1) sender images are disabled 2) there are items 45 return shouldShowSenderImage() && !mAdapter.isEmpty() 46 && !mMailPrefs.isConversationPhotoTeaserAlreadyShown(); 47 } 48 49 @Override onCabModeEntered()50 public void onCabModeEntered() { 51 if (mShown) { 52 dismiss(); 53 } 54 } 55 56 @Override dismiss()57 public void dismiss() { 58 if (mShown) { 59 mMailPrefs.setConversationPhotoTeaserAlreadyShown(); 60 mShown = false; 61 Analytics.getInstance().sendEvent("list_swipe", "photo_teaser", null, 0); 62 } 63 super.dismiss(); 64 } 65 shouldShowSenderImage()66 protected boolean shouldShowSenderImage() { 67 return mMailPrefs.getShowSenderImages(); 68 } 69 } 70