blob: ce1f7aec8d158dbcfbe3383315138cc2b08f0244 [file] [log] [blame]
Emeric Vigier9701e032012-09-12 12:38:01 -04001package com.savoirfairelinux.sflphone.client;
2
3import android.os.Handler;
4import android.os.Bundle;
5import android.os.Message;
6import android.util.Log;
7import android.view.animation.AlphaAnimation;
8import android.view.animation.Animation;
9import android.view.animation.LinearInterpolator;
10import android.widget.ImageButton;
11
12import com.savoirfairelinux.sflphone.R;
13
14public class Manager {
15
16 private static final String TAG = "Manager";
17 private static int sipLogLevel = 6;
18 static Handler h;
Alexandre Savard398ce1b2012-09-12 17:34:41 -040019 // private static ButtonSectionFragment buttonSecFragment;
Emeric Vigier9701e032012-09-12 12:38:01 -040020 static String appPath;
21 static Animation animation;
22 static SFLPhoneHome uiThread;
23 static ImageButton buttonCall;
24 public static ManagerImpl managerImpl;
25
26 static {
27 // FIXME: this is the 2nd time we call ManagerImpl's constructor.
28 // First time was at JNI_OnLoad...
29 managerImpl = new ManagerImpl(sflphoneserviceJNI.instance(), true);
30 Log.i(TAG, "ManagerImpl::instance() = " + managerImpl);
31 }
32
33 public Manager() {}
34
35 public Manager(Handler h) {
36 // Change alpha from fully visible to invisible
37 animation = new AlphaAnimation(1, 0);
38 // duration - half a second
39 animation.setDuration(500);
40 // do not alter animation rate
41 animation.setInterpolator(new LinearInterpolator());
42 // Repeat animation infinitely
43 animation.setRepeatCount(Animation.INFINITE);
44 // Reverse
45 animation.setRepeatMode(Animation.REVERSE);
46
47 this.h = h;
48 }
49
50 public static void callBack(String s) {
51 Bundle b = new Bundle();
52 Log.i(TAG, "callBack: " + s);
53 b.putString("callback_string", s);
54 Message m = Message.obtain();
55 m.setData(b);
56 m.setTarget(h);
57 m.sendToTarget();
58 }
59
60 public static void incomingCall(String accountID, String callID, String from) {
61 Log.i(TAG, "incomingCall(" + accountID + ", " + callID + ", " + from + ")");
Emeric Vigier9701e032012-09-12 12:38:01 -040062
63 // FIXME that's ugly...
64 uiThread.runOnUiThread(new Runnable() {
65 public void run() {
66 try {
67 buttonCall.startAnimation(animation);
68 buttonCall.setImageResource(R.drawable.ic_incomingcall);
69 } catch (Exception e) {
70 Log.w(TAG, "exception in runOnUiThread ", e);
71 }
72 }
73 });
74
75 uiThread.setIncomingCallID(callID);
76 }
77
78 // FIXME
Alexandre Savard398ce1b2012-09-12 17:34:41 -040079 public static void setCallButton(ImageButton b) {
80 buttonCall = b;
Emeric Vigier9701e032012-09-12 12:38:01 -040081 }
82
83 public static void setActivity(SFLPhoneHome a) {
84 uiThread = a;
85 }
86
87 public static String getAppPath() {
88 return appPath;
89 }
90
91 public static void setAppPath(String path) {
92 appPath = path;
93 }
94
95 public static int getSipLogLevel() {
96 return sipLogLevel;
97 }
98
99 public static native void callVoid();
100 public static native Data getNewData(int i, String s);
101 public static native String getDataString(Data d);
102 public static native String getJniString();
103}