Home | History | Annotate | Download | only in compose
      1 package com.android.mail.compose;
      2 
      3 import android.content.Context;
      4 import android.util.AttributeSet;
      5 import android.view.LayoutInflater;
      6 import android.view.ViewGroup;
      7 import android.widget.ImageButton;
      8 
      9 import com.android.mail.R;
     10 import com.android.mail.providers.Attachment;
     11 import com.android.mail.ui.AttachmentTile;
     12 
     13 public class ComposeAttachmentTile extends AttachmentTile implements AttachmentDeletionInterface {
     14     private ImageButton mDeleteButton;
     15 
     16     public ComposeAttachmentTile(Context context) {
     17         this(context, null);
     18     }
     19 
     20     public ComposeAttachmentTile(Context context, AttributeSet attrs) {
     21         super(context, attrs);
     22 
     23         setAlwaysShowInfoText(true);
     24     }
     25 
     26     public static ComposeAttachmentTile inflate(LayoutInflater inflater, ViewGroup parent) {
     27         ComposeAttachmentTile view = (ComposeAttachmentTile) inflater.inflate(
     28                 R.layout.compose_attachment_tile, parent, false);
     29         return view;
     30     }
     31 
     32     @Override
     33     public void render(Attachment attachment, AttachmentPreviewCache attachmentPreviewCache) {
     34         // the super implementation is good enough. just broaden its access.
     35         super.render(attachment, attachmentPreviewCache);
     36         mDeleteButton.setContentDescription(
     37                 getResources().getString(R.string.remove_attachment_desc, attachment.getName()));
     38     }
     39 
     40     @Override
     41     protected void onFinishInflate() {
     42         super.onFinishInflate();
     43 
     44         mDeleteButton = (ImageButton) findViewById(R.id.attachment_tile_close_button);
     45     }
     46 
     47     @Override
     48     public void addDeleteListener(OnClickListener clickListener) {
     49         mDeleteButton.setOnClickListener(clickListener);
     50     }
     51 }
     52