blob: 1031e09530a07ec059554fa38a3073d43562efd7 [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
alisionf76de3b2013-04-16 15:35:22 -040047public class CallElementView extends FrameLayout {
48 private ViewGroup contactCard = null;
49 private ViewGroup callCard = null;
50
51 public CallElementView(Context context, AttributeSet attrs) {
52 super(context, attrs);
53 }
54
55 public CallElementView(Context context, AttributeSet attrs, int defStyle) {
56 super(context, attrs, defStyle);
57 }
58
59 @Override
60 protected void onAttachedToWindow() {
61 // Layouts may be inflated or we may use fragments.
62 // contactCard = (ViewGroup) findViewById(R.id.contactview);
63 // callCard = (ViewGroup) findViewById(R.id.callview);
64 // callCard.setVisibility(View.GONE);
65 }
66
Adrien Béraudffd32412012-08-07 18:39:23 -040067 private Interpolator accelerator = new AccelerateInterpolator();
68 private Interpolator decelerator = new DecelerateInterpolator();
69
70 // from Android API Demo "ListFlipper"
alisionf76de3b2013-04-16 15:35:22 -040071 private void flipit() {
72 if (contactCard == null || callCard == null)
73 return;
74
Adrien Béraudffd32412012-08-07 18:39:23 -040075 final View visibleList;
76 final View invisibleList;
77 if (contactCard.getVisibility() == View.GONE) {
78 visibleList = callCard;
79 invisibleList = contactCard;
80 } else {
81 invisibleList = callCard;
82 visibleList = contactCard;
83 }
84 ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, 90f);
85 visToInvis.setDuration(500);
86 visToInvis.setInterpolator(accelerator);
alisionf76de3b2013-04-16 15:35:22 -040087 final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY", -90f, 0f);
Adrien Béraudffd32412012-08-07 18:39:23 -040088 invisToVis.setDuration(500);
89 invisToVis.setInterpolator(decelerator);
90 visToInvis.addListener(new AnimatorListenerAdapter() {
91 @Override
92 public void onAnimationEnd(Animator anim) {
93 visibleList.setVisibility(View.GONE);
94 invisToVis.start();
95 invisibleList.setVisibility(View.VISIBLE);
96 }
97 });
98 visToInvis.start();
99 }
100
Adrien Béraudffd32412012-08-07 18:39:23 -0400101}