// Path: Signaling-Java/app/src/main/java/com/tokbox/sample/signaling/message/SignalMessage.java
// public class SignalMessage {
// 
//     private String messageText;
// 
//     private Boolean remote;
// 
//     public SignalMessage(String messageText) {
// 
//         this.messageText = messageText;
//         this.remote = false;
//     }
// 
//     public SignalMessage(String messageText, Boolean remote) {
// 
//         this.messageText = messageText;
//         this.remote = remote;
//     }
// 
//     public String getMessageText() {
//         return this.messageText;
//     }
// 
//     public void setMessageText(String mMessageText) {
//         this.messageText = mMessageText;
//     }
// 
//     public Boolean isRemote() {
//         return this.remote;
//     }
// 
//     public void setRemote(Boolean remote) {
//         this.remote = remote;
//     }
// 
// }
// 
// Path: Signaling-Java/app/src/main/java/com/tokbox/sample/signaling/message/SignalMessageAdapter.java
// public class SignalMessageAdapter extends ArrayAdapter<SignalMessage> {
// 
//     public static final int VIEW_TYPE_LOCAL = 0;
//     public static final int VIEW_TYPE_REMOTE = 1;
//     private static final Map<Integer, Integer> viewTypes;
// 
//     static {
//         Map<Integer, Integer> aMap = new HashMap<>();
//         aMap.put(VIEW_TYPE_LOCAL, R.layout.message_single_local);
//         aMap.put(VIEW_TYPE_REMOTE, R.layout.message_single_remote);
//         viewTypes = Collections.unmodifiableMap(aMap);
//     }
// 
//     public SignalMessageAdapter(Context context) {
//         super(context, 0);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
// 
//         SignalMessage message = getItem(position);
// 
//         if (convertView == null) {
//             int type = getItemViewType(position);
//             convertView = LayoutInflater.from(getContext()).inflate(viewTypes.get(type), null);
//         }
// 
//         TextView messageTextView = (TextView) convertView.findViewById(R.id.message_text);
//         if (messageTextView != null) {
//             messageTextView.setText(message.getMessageText());
//         }
// 
//         return convertView;
//     }
// 
//     @Override
//     public int getItemViewType(int position) {
// 
//         SignalMessage message = getItem(position);
//         return message.isRemote() ? VIEW_TYPE_REMOTE : VIEW_TYPE_LOCAL;
//     }
// 
//     @Override
//     public int getViewTypeCount() {
//         return viewTypes.size();
//     }
// }


import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.opentok.android.Connection;
import com.opentok.android.OpentokError;
import com.opentok.android.Session;
import com.opentok.android.Stream;
import com.tokbox.sample.signaling.message.SignalMessage;
import com.tokbox.sample.signaling.message.SignalMessageAdapter;

        @Override
        public void onStreamDropped(Session session, Stream stream) {
            Log.i(TAG, "Stream Dropped");
        }

        @Override
        public void onError(Session session, OpentokError opentokError) {
            finishWithMessage("Session error: " + opentokError.getMessage());
        }
    };

    private Session.SignalListener signalListener = new Session.SignalListener() {
        @Override
        public void onSignalReceived(Session session, String type, String data, Connection connection) {

            boolean remote = !connection.equals(session.getConnection());
            if (type != null && type.equals(SIGNAL_TYPE)) {
                showMessage(data, remote);
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if(!OpenTokConfig.isValid()) {
            finishWithMessage("Invalid OpenTokConfig. " + OpenTokConfig.getDescription());
// Path: Signaling-Java/app/src/main/java/com/tokbox/sample/signaling/message/SignalMessage.java
// public class SignalMessage {
// 
//     private String messageText;
// 
//     private Boolean remote;
// 
//     public SignalMessage(String messageText) {
// 
//         this.messageText = messageText;
//         this.remote = false;
//     }
// 
//     public SignalMessage(String messageText, Boolean remote) {
// 
//         this.messageText = messageText;
//         this.remote = remote;
//     }
// 
//     public String getMessageText() {
//         return this.messageText;
//     }
// 
//     public void setMessageText(String mMessageText) {
//         this.messageText = mMessageText;
//     }
// 
//     public Boolean isRemote() {
//         return this.remote;
//     }
// 
//     public void setRemote(Boolean remote) {
//         this.remote = remote;
//     }
// 
// }
// 
// Path: Signaling-Java/app/src/main/java/com/tokbox/sample/signaling/message/SignalMessageAdapter.java
// public class SignalMessageAdapter extends ArrayAdapter<SignalMessage> {
// 
//     public static final int VIEW_TYPE_LOCAL = 0;
//     public static final int VIEW_TYPE_REMOTE = 1;
//     private static final Map<Integer, Integer> viewTypes;
// 
//     static {
//         Map<Integer, Integer> aMap = new HashMap<>();
//         aMap.put(VIEW_TYPE_LOCAL, R.layout.message_single_local);
//         aMap.put(VIEW_TYPE_REMOTE, R.layout.message_single_remote);
//         viewTypes = Collections.unmodifiableMap(aMap);
//     }
// 
//     public SignalMessageAdapter(Context context) {
//         super(context, 0);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
// 
//         SignalMessage message = getItem(position);
// 
//         if (convertView == null) {
//             int type = getItemViewType(position);
//             convertView = LayoutInflater.from(getContext()).inflate(viewTypes.get(type), null);
//         }
// 
//         TextView messageTextView = (TextView) convertView.findViewById(R.id.message_text);
//         if (messageTextView != null) {
//             messageTextView.setText(message.getMessageText());
//         }
// 
//         return convertView;
//     }
// 
//     @Override
//     public int getItemViewType(int position) {
// 
//         SignalMessage message = getItem(position);
//         return message.isRemote() ? VIEW_TYPE_REMOTE : VIEW_TYPE_LOCAL;
//     }
// 
//     @Override
//     public int getViewTypeCount() {
//         return viewTypes.size();
//     }
// }


// Path: Signaling-Java/app/src/main/java/com/tokbox/sample/signaling/MainActivity.java
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.opentok.android.Connection;
import com.opentok.android.OpentokError;
import com.opentok.android.Session;
import com.opentok.android.Stream;
import com.tokbox.sample.signaling.message.SignalMessage;
import com.tokbox.sample.signaling.message.SignalMessageAdapter;


        @Override
        public void onStreamDropped(Session session, Stream stream) {
            Log.i(TAG, "Stream Dropped");
        }

        @Override
        public void onError(Session session, OpentokError opentokError) {
            finishWithMessage("Session error: " + opentokError.getMessage());
        }
    };

    private Session.SignalListener signalListener = new Session.SignalListener() {
        @Override
        public void onSignalReceived(Session session, String type, String data, Connection connection) {

            boolean remote = !connection.equals(session.getConnection());
            if (type != null && type.equals(SIGNAL_TYPE)) {
                showMessage(data, remote);
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if(!OpenTokConfig.isValid()) {
            finishWithMessage("Invalid OpenTokConfig. " + OpenTokConfig.getDescription());
            return;