blob: bb605c3c327744c456fe4d7defac4f48e324a48e [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
Adrien Béraudc99b8432013-04-25 16:27:46 +100045public class CallElementView extends FrameLayout
46{
47 private ViewGroup contactCard = null;
48 private ViewGroup callCard = null;
alisionf76de3b2013-04-16 15:35:22 -040049
Adrien Béraudc99b8432013-04-25 16:27:46 +100050 public CallElementView(Context context, AttributeSet attrs)
51 {
52 super(context, attrs);
53 }
alisionf76de3b2013-04-16 15:35:22 -040054
Adrien Béraudc99b8432013-04-25 16:27:46 +100055 public CallElementView(Context context, AttributeSet attrs, int defStyle)
56 {
57 super(context, attrs, defStyle);
58 }
alisionf76de3b2013-04-16 15:35:22 -040059
Adrien Béraudc99b8432013-04-25 16:27:46 +100060 @Override
61 protected void onAttachedToWindow()
62 {
63 // Layouts may be inflated or we may use fragments.
64 // contactCard = (ViewGroup) findViewById(R.id.contactview);
65 // callCard = (ViewGroup) findViewById(R.id.callview);
66 // callCard.setVisibility(View.GONE);
67 }
alisionf76de3b2013-04-16 15:35:22 -040068
Adrien Béraudc99b8432013-04-25 16:27:46 +100069 private Interpolator accelerator = new AccelerateInterpolator();
70 private Interpolator decelerator = new DecelerateInterpolator();
Adrien Béraudffd32412012-08-07 18:39:23 -040071
Adrien Béraudc99b8432013-04-25 16:27:46 +100072 // from Android API Demo "ListFlipper"
73 private void flipit()
74 {
75 if (contactCard == null || callCard == null)
76 return;
alisionf76de3b2013-04-16 15:35:22 -040077
Adrien Béraudc99b8432013-04-25 16:27:46 +100078 final View visibleList;
79 final View invisibleList;
80 if (contactCard.getVisibility() == View.GONE) {
81 visibleList = callCard;
82 invisibleList = contactCard;
83 } else {
84 invisibleList = callCard;
85 visibleList = contactCard;
86 }
87 ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, 90f);
88 visToInvis.setDuration(500);
89 visToInvis.setInterpolator(accelerator);
90 final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY", -90f, 0f);
91 invisToVis.setDuration(500);
92 invisToVis.setInterpolator(decelerator);
93 visToInvis.addListener(new AnimatorListenerAdapter() {
94 @Override
95 public void onAnimationEnd(Animator anim)
96 {
97 visibleList.setVisibility(View.GONE);
98 invisToVis.start();
99 invisibleList.setVisibility(View.VISIBLE);
100 }
101 });
102 visToInvis.start();
103 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400104
Adrien Béraudffd32412012-08-07 18:39:23 -0400105}