@@ -3,9 +3,14 @@ package com.chatrtc.app;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@@ -48,6 +53,8 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
||||
private boolean isAudioEnabled = true;
|
||||
private boolean isConnected = false;
|
||||
|
||||
private PopupWindow emojiPopup;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -103,12 +110,8 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
||||
private void setupClickListeners() {
|
||||
btnSend.setOnClickListener(v -> sendMessage());
|
||||
|
||||
// Simple emoji button - adds a smiley face
|
||||
btnEmoji.setOnClickListener(v -> {
|
||||
String currentText = etMessage.getText().toString();
|
||||
etMessage.setText(currentText + "😊");
|
||||
etMessage.setSelection(etMessage.getText().length());
|
||||
});
|
||||
// Emoji button - shows emoji picker
|
||||
btnEmoji.setOnClickListener(v -> showEmojiPicker());
|
||||
|
||||
btnToggleVideo.setOnClickListener(v -> toggleVideo());
|
||||
btnToggleAudio.setOnClickListener(v -> toggleAudio());
|
||||
@@ -159,9 +162,10 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
||||
if (webRTCManager != null) {
|
||||
webRTCManager.toggleVideo(isVideoEnabled);
|
||||
}
|
||||
btnToggleVideo.setText(isVideoEnabled ? "Video Off" : "Video On");
|
||||
btnToggleVideo.setBackgroundColor(getResources().getColor(
|
||||
isVideoEnabled ? R.color.button_enabled : R.color.button_disabled));
|
||||
// Keep the emoji icon, just change the visual state
|
||||
btnToggleVideo.setText(isVideoEnabled ? "📹" : "📹");
|
||||
btnToggleVideo.setAlpha(isVideoEnabled ? 1.0f : 0.5f);
|
||||
btnToggleVideo.setBackgroundResource(isVideoEnabled ? R.drawable.btn_round_enabled : R.drawable.btn_round_disabled);
|
||||
}
|
||||
|
||||
private void toggleAudio() {
|
||||
@@ -169,9 +173,10 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
||||
if (webRTCManager != null) {
|
||||
webRTCManager.toggleAudio(isAudioEnabled);
|
||||
}
|
||||
btnToggleAudio.setText(isAudioEnabled ? "Mute" : "Unmute");
|
||||
btnToggleAudio.setBackgroundColor(getResources().getColor(
|
||||
isAudioEnabled ? R.color.button_enabled : R.color.button_disabled));
|
||||
// Keep the emoji icon, just change the visual state
|
||||
btnToggleAudio.setText(isAudioEnabled ? "🎤" : "🔇");
|
||||
btnToggleAudio.setAlpha(isAudioEnabled ? 1.0f : 0.5f);
|
||||
btnToggleAudio.setBackgroundResource(isAudioEnabled ? R.drawable.btn_round_enabled : R.drawable.btn_round_disabled);
|
||||
}
|
||||
|
||||
private void switchCamera() {
|
||||
@@ -190,6 +195,77 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
||||
etMessage.setEnabled(isConnected);
|
||||
}
|
||||
|
||||
private void showEmojiPicker() {
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
emojiPopup.dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create emoji grid layout
|
||||
GridLayout emojiGrid = new GridLayout(this);
|
||||
emojiGrid.setColumnCount(6);
|
||||
emojiGrid.setPadding(20, 20, 20, 20);
|
||||
emojiGrid.setBackgroundColor(getResources().getColor(R.color.white));
|
||||
|
||||
// Common emojis
|
||||
String[] emojis = {
|
||||
"😊", "😂", "😍", "🥰", "😎", "🤔",
|
||||
"😮", "😢", "😭", "😡", "👍", "👎",
|
||||
"👏", "🙏", "❤️", "💔", "🔥", "⭐",
|
||||
"✨", "🎉", "🎊", "💯", "✅", "❌",
|
||||
"👋", "🤝", "💪", "🙌", "🤷", "🤦"
|
||||
};
|
||||
|
||||
// Add emoji buttons
|
||||
for (String emoji : emojis) {
|
||||
Button emojiButton = new Button(this);
|
||||
emojiButton.setText(emoji);
|
||||
emojiButton.setTextSize(18);
|
||||
emojiButton.setBackground(null);
|
||||
emojiButton.setPadding(10, 10, 10, 10);
|
||||
|
||||
GridLayout.LayoutParams params = new GridLayout.LayoutParams();
|
||||
params.width = 80;
|
||||
params.height = 80;
|
||||
params.setMargins(3, 3, 3, 3);
|
||||
emojiButton.setLayoutParams(params);
|
||||
|
||||
emojiButton.setOnClickListener(v -> {
|
||||
addEmojiToMessage(emoji);
|
||||
emojiPopup.dismiss();
|
||||
});
|
||||
|
||||
emojiGrid.addView(emojiButton);
|
||||
}
|
||||
|
||||
// Wrap the grid in a ScrollView
|
||||
ScrollView scrollView = new ScrollView(this);
|
||||
scrollView.addView(emojiGrid);
|
||||
scrollView.setBackgroundColor(getResources().getColor(R.color.white));
|
||||
|
||||
// Set fixed dimensions for the popup
|
||||
int popupWidth = 500; // Fixed width
|
||||
int popupHeight = 300; // Fixed height to ensure it fits on screen
|
||||
|
||||
// Create popup window with fixed size
|
||||
emojiPopup = new PopupWindow(scrollView, popupWidth, popupHeight, true);
|
||||
emojiPopup.setOutsideTouchable(true);
|
||||
|
||||
// Show popup above the emoji button
|
||||
emojiPopup.showAsDropDown(btnEmoji, 0, -popupHeight - 20);
|
||||
}
|
||||
|
||||
private void addEmojiToMessage(String emoji) {
|
||||
String currentText = etMessage.getText().toString();
|
||||
int cursorPosition = etMessage.getSelectionStart();
|
||||
|
||||
StringBuilder newText = new StringBuilder(currentText);
|
||||
newText.insert(cursorPosition, emoji);
|
||||
|
||||
etMessage.setText(newText.toString());
|
||||
etMessage.setSelection(cursorPosition + emoji.length());
|
||||
}
|
||||
|
||||
// WebRTCManager.WebRTCListener implementation
|
||||
@Override
|
||||
public void onMessageReceived(String senderNickname, String message) {
|
||||
@@ -241,10 +317,17 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
||||
if (webRTCManager != null) {
|
||||
webRTCManager.cleanup();
|
||||
}
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
emojiPopup.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
emojiPopup.dismiss();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import io.socket.client.Socket;
|
||||
public class WebRTCManager {
|
||||
|
||||
private static final String TAG = "WebRTCManager";
|
||||
private static final String SIGNALING_SERVER_URL = "http://10.0.2.2:3000"; // For Android emulator
|
||||
private static final String SIGNALING_SERVER_URL = "https://chat.manalejandro.com"; // For Android emulator
|
||||
// For real device on same network, use: "http://192.168.1.XXX:3000"
|
||||
// For production: "https://your-server.com"
|
||||
|
||||
|
||||
6
android-app/app/src/main/res/drawable/btn_round_disabled.xml
Archivo normal
6
android-app/app/src/main/res/drawable/btn_round_disabled.xml
Archivo normal
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/button_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/button_border" />
|
||||
</shape>
|
||||
6
android-app/app/src/main/res/drawable/btn_round_enabled.xml
Archivo normal
6
android-app/app/src/main/res/drawable/btn_round_enabled.xml
Archivo normal
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/button_enabled" />
|
||||
<stroke android:width="1dp" android:color="@color/button_border" />
|
||||
</shape>
|
||||
Referencia en una nueva incidencia
Block a user