blob: 4a967c341b2eed541c8f560c989aec0d7e4e4311 [file] [log] [blame]
Emeric Vigier05e894e2012-08-20 13:53:02 -04001package com.savoirfairelinux.sflphone.client;
2
Emeric Vigier62ca14d2012-08-24 11:05:09 -04003import android.os.Handler;
4import android.os.Bundle;
5import android.os.Message;
Emeric Vigier05e894e2012-08-20 13:53:02 -04006import android.util.Log;
Emeric Vigiera6bdb702012-08-31 15:34:53 -04007import android.view.animation.AlphaAnimation;
8import android.view.animation.Animation;
9import android.view.animation.LinearInterpolator;
10import android.widget.ImageButton;
11
12import com.savoirfairelinux.sflphone.R;
Emeric Vigier05e894e2012-08-20 13:53:02 -040013
14public class ManagerImpl {
15
16 private static final String TAG = "ManagerImpl";
Emeric Vigier7465d922012-08-28 18:14:17 -040017 private static int sipLogLevel = 6;
18 static Handler h;
Emeric Vigiera6bdb702012-08-31 15:34:53 -040019 private static ButtonSectionFragment buttonSecFragment;
Emeric Vigier7a255aa2012-08-29 09:49:18 -040020 static String appPath;
Emeric Vigiera6bdb702012-08-31 15:34:53 -040021 static Animation animation;
22 static SFLPhoneHome uiThread;
23 static ImageButton buttonCall;
Emeric Vigier62ca14d2012-08-24 11:05:09 -040024
25 public ManagerImpl () {}
26
Emeric Vigiera6bdb702012-08-31 15:34:53 -040027 public ManagerImpl(Handler h) {
28 // Change alpha from fully visible to invisible
29 animation = new AlphaAnimation(1, 0);
30 // duration - half a second
31 animation.setDuration(500);
32 // do not alter animation rate
33 animation.setInterpolator(new LinearInterpolator());
34 // Repeat animation infinitely
35 animation.setRepeatCount(Animation.INFINITE);
36 // Reverse
37 animation.setRepeatMode(Animation.REVERSE);
38
Emeric Vigier62ca14d2012-08-24 11:05:09 -040039 this.h = h;
40 }
41
42 public static void callBack(String s) {
43 Bundle b = new Bundle();
44 Log.i(TAG, "callBack: " + s);
45 b.putString("callback_string", s);
46 Message m = Message.obtain();
47 m.setData(b);
48 m.setTarget(h);
49 m.sendToTarget();
50 }
Emeric Vigiera6bdb702012-08-31 15:34:53 -040051
52 public static void incomingCall(String accountID, String callID, String from) {
53 Log.i(TAG, "incomingCall(" + accountID + ", " + callID + ", " + from + ")");
Emeric Vigiera6bdb702012-08-31 15:34:53 -040054
55 // FIXME that's ugly...
56 uiThread.runOnUiThread(new Runnable() {
57 public void run() {
58 try {
59 buttonCall.startAnimation(animation);
60 buttonCall.setImageResource(R.drawable.ic_incomingcall);
61 } catch (Exception e) {
Alexandre Savarddef3bfa2012-09-12 16:20:06 -040062 Log.w(TAG, "exception in runOnUiThread ", e);;
Emeric Vigiera6bdb702012-08-31 15:34:53 -040063 }
64 }
65 });
66
67 uiThread.setIncomingCallID(callID);
68 }
69
70 // FIXME
Alexandre Savarddef3bfa2012-09-12 16:20:06 -040071 public static void setCallButton(ImageButton b) {
72 buttonCall = b;
Emeric Vigiera6bdb702012-08-31 15:34:53 -040073 }
74
75 public static void setActivity(SFLPhoneHome a) {
76 uiThread = a;
77 }
Emeric Vigier05e894e2012-08-20 13:53:02 -040078
Emeric Vigier7a255aa2012-08-29 09:49:18 -040079 public static String getAppPath() {
80 return appPath;
81 }
82
83 public static void setAppPath(String path) {
84 appPath = path;
85 }
86
Emeric Vigier7465d922012-08-28 18:14:17 -040087 public static int getSipLogLevel() {
Emeric Vigier05e894e2012-08-20 13:53:02 -040088 return sipLogLevel;
89 }
90
Emeric Vigier62ca14d2012-08-24 11:05:09 -040091 public static native void callVoid();
92 public static native Data getNewData(int i, String s);
93 public static native String getDataString(Data d);
Emeric Vigier62ca14d2012-08-24 11:05:09 -040094
Emeric Vigier05e894e2012-08-20 13:53:02 -040095 public static native void setSipLogLevel(String level);
Emeric Vigier05e894e2012-08-20 13:53:02 -040096 public static native String getJniString();
Emeric Vigier05e894e2012-08-20 13:53:02 -040097 public static native void initN(String config_file);
Emeric Vigierd5c17f52012-08-29 09:29:33 -040098 public static native void placeCall(String accountID, String callID, String to);
Alexandre Savardedf48bd2012-08-30 17:00:38 -040099 public static native void hangUp(String callID);
Emeric Vigiera6bdb702012-08-31 15:34:53 -0400100 public static native void answerCall(String callID);
101 public static native void refuseCall(String callID);
Emeric Vigier05e894e2012-08-20 13:53:02 -0400102}