InvisibleRecipientChip.java revision 194d427ebcfc2133bda410e0e4c399250d9a6066
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;
32194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
33194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public InvisibleRecipientChip(final RecipientEntry entry) {
34194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        super();
35194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
36194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        mDelegate = new SimpleRecipientChip(entry);
37194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
38194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
39194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
40194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public void setSelected(final boolean selected) {
41194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        mDelegate.setSelected(selected);
42194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
43194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
44194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
45194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public boolean isSelected() {
46194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.isSelected();
47194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
48194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
49194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
50194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public CharSequence getDisplay() {
51194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.getDisplay();
52194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
53194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
54194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
55194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public CharSequence getValue() {
56194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.getValue();
57194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
58194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
59194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
60194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public long getContactId() {
61194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.getContactId();
62194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
63194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
64194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
65194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public long getDataId() {
66194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.getDataId();
67194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
68194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
69194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
70194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public RecipientEntry getEntry() {
71194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.getEntry();
72194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
73194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
74194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
75194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public void setOriginalText(final String text) {
76194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        mDelegate.setOriginalText(text);
77194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
78194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
79194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
80194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public CharSequence getOriginalText() {
81194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return mDelegate.getOriginalText();
82194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
83194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
84194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
85194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public void draw(final Canvas canvas, final CharSequence text, final int start, final int end,
86194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy            final float x, final int top, final int y, final int bottom, final Paint paint) {
87194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        // Do nothing.
88194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
89194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
90194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
91194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public int getSize(final Paint paint, final CharSequence text, final int start, final int end,
92194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy            final Paint.FontMetricsInt fm) {
93194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return 0;
94194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
95194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
96194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
97194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public Rect getBounds() {
98194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        return new Rect(0, 0, 0, 0);
99194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
100194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy
101194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    @Override
102194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    public void draw(final Canvas canvas) {
103194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy        // do nothing.
104194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy    }
105194d427ebcfc2133bda410e0e4c399250d9a6066Scott Kennedy}
106