1194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy/* 2194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * Copyright (C) 2011 The Android Open Source Project 3194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * 4194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * Licensed under the Apache License, Version 2.0 (the "License"); 5194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * you may not use this file except in compliance with the License. 6194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * You may obtain a copy of the License at 7194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * 8194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * http://www.apache.org/licenses/LICENSE-2.0 9194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * 10194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * Unless required by applicable law or agreed to in writing, software 11194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * distributed under the License is distributed on an "AS IS" BASIS, 12194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * See the License for the specific language governing permissions and 14194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * limitations under the License. 15194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy */ 16194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 17194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedypackage com.android.ex.chips.recipientchip; 18194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 19194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport android.graphics.Canvas; 20194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport android.graphics.Rect; 21194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport android.graphics.drawable.Drawable; 22194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 23194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport com.android.ex.chips.RecipientEntry; 24194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 25194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy/** 266c2a016fb00482339dc66b93822042f9f9e2424fJin Cao * VisibleRecipientChip defines a ReplacementSpan that contains information relevant to a 27194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * particular recipient and renders a background asset to go with it. 28194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy */ 296c2a016fb00482339dc66b93822042f9f9e2424fJin Caopublic class VisibleRecipientChip extends ReplacementDrawableSpan implements DrawableRecipientChip { 30194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy private final SimpleRecipientChip mDelegate; 31194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 3230043f9623013e8fee4d4b858aaddd45c99e0f4cKevin Lin public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) { 336c2a016fb00482339dc66b93822042f9f9e2424fJin Cao super(drawable); 34194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy mDelegate = new SimpleRecipientChip(entry); 35194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 36194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 37194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 38194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void setSelected(final boolean selected) { 39194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy mDelegate.setSelected(selected); 40194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 41194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 42194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 43194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public boolean isSelected() { 44194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.isSelected(); 45194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 46194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 47194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 48194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public CharSequence getDisplay() { 49194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getDisplay(); 50194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 51194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 52194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 53194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public CharSequence getValue() { 54194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getValue(); 55194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 56194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 57194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 58194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public long getContactId() { 59194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getContactId(); 60194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 61194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 62194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 637a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy public Long getDirectoryId() { 647a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy return mDelegate.getDirectoryId(); 657a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy } 667a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy 677a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy @Override 687a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy public String getLookupKey() { 697a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy return mDelegate.getLookupKey(); 707a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy } 717a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy 727a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy @Override 73194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public long getDataId() { 74194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getDataId(); 75194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 76194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 77194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 78194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public RecipientEntry getEntry() { 79194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getEntry(); 80194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 81194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 82194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 83194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void setOriginalText(final String text) { 84194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy mDelegate.setOriginalText(text); 85194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 86194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 87194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 88194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public CharSequence getOriginalText() { 89194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getOriginalText(); 90194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 91194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 92194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 93194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public Rect getBounds() { 946c2a016fb00482339dc66b93822042f9f9e2424fJin Cao return super.getBounds(); 95194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 96194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 97194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 98194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void draw(final Canvas canvas) { 996c2a016fb00482339dc66b93822042f9f9e2424fJin Cao mDrawable.draw(canvas); 100194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 101194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 102194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 103194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public String toString() { 104194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.toString(); 105194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 106194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy} 107