using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class CallStateBridge : MonoBehaviour
{
    public Text Label;

#if UNITY_ANDROID
         AndroidJavaObject jc;
#endif

    void Start()
    {
#if UNITY_ANDROID
             AndroidJNI.AttachCurrentThread();
             jc = new AndroidJavaClass("com.ea.android.theimpossibleline.rowsamsung.MainActivity");
             jc.CallStatic("setCallBack", new object[2] {gameObject.name, "OnCallStateChange"});
#endif
    }

    public void OnCallStateChange(string state)
    {
        Label.text = "CHIAMATA "+ state;
        
        if (state == "1")
            GameManager.Singleton.OpenGate();
    }

#if UNITY_ANDROID
         public int CheckCallStatus()
    {
        return jc.CallStatic<int>("getCallStatus");
    }
#endif
}