1/*
2 * Copyright (C) 2015 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 */
16package com.android.messaging.ui;
17
18import android.content.Context;
19import android.util.AttributeSet;
20import android.widget.ImageView;
21import android.widget.ViewSwitcher;
22
23import com.android.messaging.R;
24
25/**
26 * Shows a tinted play pause button.
27 */
28public class AudioAttachmentPlayPauseButton extends ViewSwitcher {
29    private ImageView mPlayButton;
30    private ImageView mPauseButton;
31
32    private boolean mShowAsIncoming;
33
34    public AudioAttachmentPlayPauseButton(final Context context, final AttributeSet attrs) {
35        super(context, attrs);
36    }
37
38    @Override
39    protected void onFinishInflate() {
40        super.onFinishInflate();
41        mPlayButton = (ImageView) findViewById(R.id.play_button);
42        mPauseButton = (ImageView) findViewById(R.id.pause_button);
43        updateAppearance();
44    }
45
46    public void setVisualStyle(final boolean showAsIncoming) {
47        if (mShowAsIncoming != showAsIncoming) {
48            mShowAsIncoming = showAsIncoming;
49            updateAppearance();
50        }
51    }
52
53    private void updateAppearance() {
54        mPlayButton.setImageDrawable(ConversationDrawables.get()
55                .getPlayButtonDrawable(mShowAsIncoming));
56        mPauseButton.setImageDrawable(ConversationDrawables.get()
57                .getPauseButtonDrawable(mShowAsIncoming));
58    }
59}
60