1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.car.cluster.sample.cards;
18
19import android.content.Context;
20import android.graphics.BitmapFactory;
21import android.util.AttributeSet;
22import android.widget.TextView;
23
24import com.android.car.cluster.sample.R;
25
26/**
27 * Card that represents hangout notification.
28 */
29public class MessageCard extends CardView {
30
31    private TextView mContactName;
32
33    public MessageCard(Context context, PriorityChangedListener listener) {
34        this(context, null, CardType.HANGOUT, listener);
35    }
36
37    public MessageCard(Context context, AttributeSet attrs, @CardType int cardType,
38            PriorityChangedListener listener) {
39        super(context, attrs, cardType, listener);
40    }
41
42    @Override
43    protected void init() {
44        super.init();
45
46        inflate(R.layout.hangout_layout);
47
48        mDetailsPanel = viewById(R.id.msg_text_panel);
49        mContactName = viewById(R.id.msg_card_contact_name);
50        setRightIcon(BitmapFactory.decodeResource(getResources(), R.drawable.hangouts_icon));
51
52        mPriority = PRIORITY_HANGOUT_NOTIFICATION;
53
54        // Remove this notification in 5 seconds.
55        runDelayed(5000, new Runnable() {
56            @Override
57            public void run() {
58                removeGracefully();
59            }
60        });
61    }
62
63    public void setContactName(String contactName) {
64        mContactName.setText(contactName);
65    }
66}
67