InvisibleRecipientChip.java revision e2348bfcd0a710201ba98cd5642cc1e3b5fa6465
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.Paint; 21194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport android.graphics.Rect; 22194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport android.text.style.ReplacementSpan; 23194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 24194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedyimport com.android.ex.chips.RecipientEntry; 25194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 26194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy/** 27194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * RecipientChip defines a span that contains information relevant to a 28194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy * particular recipient. 29194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy */ 30194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedypublic class InvisibleRecipientChip extends ReplacementSpan implements DrawableRecipientChip { 31194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy private final SimpleRecipientChip mDelegate; 32e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam private static final Rect NULL_RECTANGLE = new Rect(0, 0, 0, 0); 33194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 34194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public InvisibleRecipientChip(final RecipientEntry entry) { 35194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy super(); 36194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 37194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy mDelegate = new SimpleRecipientChip(entry); 38194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 39194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 40194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 41194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void setSelected(final boolean selected) { 42194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy mDelegate.setSelected(selected); 43194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 44194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 45194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 46194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public boolean isSelected() { 47194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.isSelected(); 48194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 49194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 50194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 51194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public CharSequence getDisplay() { 52194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getDisplay(); 53194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 54194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 55194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 56194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public CharSequence getValue() { 57194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getValue(); 58194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 59194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 60194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 61194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public long getContactId() { 62194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getContactId(); 63194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 64194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 65194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 667a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy public Long getDirectoryId() { 677a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy return mDelegate.getDirectoryId(); 687a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy } 697a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy 707a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy @Override 717a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy public String getLookupKey() { 727a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy return mDelegate.getLookupKey(); 737a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy } 747a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy 757a4e67708498ec46c2e9b3bad69d3807d88c064eScott Kennedy @Override 76194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public long getDataId() { 77194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getDataId(); 78194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 79194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 80194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 81194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public RecipientEntry getEntry() { 82194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getEntry(); 83194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 84194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 85194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 86194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void setOriginalText(final String text) { 87194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy mDelegate.setOriginalText(text); 88194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 89194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 90194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 91194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public CharSequence getOriginalText() { 92194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return mDelegate.getOriginalText(); 93194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 94194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 95194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 96194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void draw(final Canvas canvas, final CharSequence text, final int start, final int end, 97194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy final float x, final int top, final int y, final int bottom, final Paint paint) { 98194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy // Do nothing. 99194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 100194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 101194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 102194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public int getSize(final Paint paint, final CharSequence text, final int start, final int end, 103194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy final Paint.FontMetricsInt fm) { 104194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy return 0; 105194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 106194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 107194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 108194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public Rect getBounds() { 109e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam return NULL_RECTANGLE; 110e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam } 111e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam 112e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam @Override 113e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam public Rect getWarningIconBounds() { 114e2348bfcd0a710201ba98cd5642cc1e3b5fa6465Joseph Moghadam return NULL_RECTANGLE; 115194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 116194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy 117194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy @Override 118194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy public void draw(final Canvas canvas) { 119194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy // do nothing. 120194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy } 121194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy} 122