blob: 9ccd7bc698bc8559526255c3151e030511bb4053 [file] [log] [blame]
Adrien BĂ©raudffd32412012-08-07 18:39:23 -04001/*
2 * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3 *
4 * Author: Adrien Beraud <adrien.beraud@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Additional permission under GNU GPL version 3 section 7:
21 *
22 * If you modify this program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a
24 * modified version of that library), containing parts covered by the
25 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26 * grants you additional permission to convey the resulting work.
27 * Corresponding Source for a non-source form of such a combination
28 * shall include the source code for the parts of OpenSSL used as well
29 * as that of the covered work.
30 */
31package com.savoirfairelinux.sflphone.client;
32
33import android.animation.Animator;
34import android.animation.AnimatorListenerAdapter;
35import android.animation.ObjectAnimator;
36import android.content.Context;
37import android.util.AttributeSet;
38import android.view.View;
39import android.view.ViewGroup;
40import android.view.animation.AccelerateInterpolator;
41import android.view.animation.DecelerateInterpolator;
42import android.view.animation.Interpolator;
43import android.widget.FrameLayout;
44
45import com.savoirfairelinux.sflphone.R;
46
47public class CallElementView extends FrameLayout
48{
49 private ViewGroup contactCard = null;
50 private ViewGroup callCard = null;
51
52 public CallElementView(Context context, AttributeSet attrs)
53 {
54 super(context, attrs);
55 }
56
57 public CallElementView(Context context, AttributeSet attrs, int defStyle)
58 {
59 super(context, attrs, defStyle);
60 }
61
62 @Override
63 protected void onAttachedToWindow()
64 {
65 // Layouts may be inflated or we may use fragments.
66 contactCard = (ViewGroup) findViewById(R.id.contactview);
67 callCard = (ViewGroup) findViewById(R.id.callview);
68 callCard.setVisibility(View.GONE);
69 }
70
71 private Interpolator accelerator = new AccelerateInterpolator();
72 private Interpolator decelerator = new DecelerateInterpolator();
73
74 // from Android API Demo "ListFlipper"
75 private void flipit()
76 {
77 if(contactCard == null || callCard == null)
78 return;
79
80 final View visibleList;
81 final View invisibleList;
82 if (contactCard.getVisibility() == View.GONE) {
83 visibleList = callCard;
84 invisibleList = contactCard;
85 } else {
86 invisibleList = callCard;
87 visibleList = contactCard;
88 }
89 ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, 90f);
90 visToInvis.setDuration(500);
91 visToInvis.setInterpolator(accelerator);
92 final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY",
93 -90f, 0f);
94 invisToVis.setDuration(500);
95 invisToVis.setInterpolator(decelerator);
96 visToInvis.addListener(new AnimatorListenerAdapter() {
97 @Override
98 public void onAnimationEnd(Animator anim) {
99 visibleList.setVisibility(View.GONE);
100 invisToVis.start();
101 invisibleList.setVisibility(View.VISIBLE);
102 }
103 });
104 visToInvis.start();
105 }
106
107
108}