@@ -3,9 +3,14 @@ package com.chatrtc.app;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.GridLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.PopupWindow;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@@ -48,6 +53,8 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
|||||||
private boolean isAudioEnabled = true;
|
private boolean isAudioEnabled = true;
|
||||||
private boolean isConnected = false;
|
private boolean isConnected = false;
|
||||||
|
|
||||||
|
private PopupWindow emojiPopup;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -103,12 +110,8 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
|||||||
private void setupClickListeners() {
|
private void setupClickListeners() {
|
||||||
btnSend.setOnClickListener(v -> sendMessage());
|
btnSend.setOnClickListener(v -> sendMessage());
|
||||||
|
|
||||||
// Simple emoji button - adds a smiley face
|
// Emoji button - shows emoji picker
|
||||||
btnEmoji.setOnClickListener(v -> {
|
btnEmoji.setOnClickListener(v -> showEmojiPicker());
|
||||||
String currentText = etMessage.getText().toString();
|
|
||||||
etMessage.setText(currentText + "😊");
|
|
||||||
etMessage.setSelection(etMessage.getText().length());
|
|
||||||
});
|
|
||||||
|
|
||||||
btnToggleVideo.setOnClickListener(v -> toggleVideo());
|
btnToggleVideo.setOnClickListener(v -> toggleVideo());
|
||||||
btnToggleAudio.setOnClickListener(v -> toggleAudio());
|
btnToggleAudio.setOnClickListener(v -> toggleAudio());
|
||||||
@@ -159,9 +162,10 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
|||||||
if (webRTCManager != null) {
|
if (webRTCManager != null) {
|
||||||
webRTCManager.toggleVideo(isVideoEnabled);
|
webRTCManager.toggleVideo(isVideoEnabled);
|
||||||
}
|
}
|
||||||
btnToggleVideo.setText(isVideoEnabled ? "Video Off" : "Video On");
|
// Keep the emoji icon, just change the visual state
|
||||||
btnToggleVideo.setBackgroundColor(getResources().getColor(
|
btnToggleVideo.setText(isVideoEnabled ? "📹" : "📹");
|
||||||
isVideoEnabled ? R.color.button_enabled : R.color.button_disabled));
|
btnToggleVideo.setAlpha(isVideoEnabled ? 1.0f : 0.5f);
|
||||||
|
btnToggleVideo.setBackgroundResource(isVideoEnabled ? R.drawable.btn_round_enabled : R.drawable.btn_round_disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleAudio() {
|
private void toggleAudio() {
|
||||||
@@ -169,9 +173,10 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
|||||||
if (webRTCManager != null) {
|
if (webRTCManager != null) {
|
||||||
webRTCManager.toggleAudio(isAudioEnabled);
|
webRTCManager.toggleAudio(isAudioEnabled);
|
||||||
}
|
}
|
||||||
btnToggleAudio.setText(isAudioEnabled ? "Mute" : "Unmute");
|
// Keep the emoji icon, just change the visual state
|
||||||
btnToggleAudio.setBackgroundColor(getResources().getColor(
|
btnToggleAudio.setText(isAudioEnabled ? "🎤" : "🔇");
|
||||||
isAudioEnabled ? R.color.button_enabled : R.color.button_disabled));
|
btnToggleAudio.setAlpha(isAudioEnabled ? 1.0f : 0.5f);
|
||||||
|
btnToggleAudio.setBackgroundResource(isAudioEnabled ? R.drawable.btn_round_enabled : R.drawable.btn_round_disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchCamera() {
|
private void switchCamera() {
|
||||||
@@ -190,6 +195,77 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
|||||||
etMessage.setEnabled(isConnected);
|
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
|
// WebRTCManager.WebRTCListener implementation
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(String senderNickname, String message) {
|
public void onMessageReceived(String senderNickname, String message) {
|
||||||
@@ -241,10 +317,17 @@ public class ChatActivity extends AppCompatActivity implements WebRTCManager.Web
|
|||||||
if (webRTCManager != null) {
|
if (webRTCManager != null) {
|
||||||
webRTCManager.cleanup();
|
webRTCManager.cleanup();
|
||||||
}
|
}
|
||||||
|
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||||
|
emojiPopup.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
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 {
|
public class WebRTCManager {
|
||||||
|
|
||||||
private static final String TAG = "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 real device on same network, use: "http://192.168.1.XXX:3000"
|
||||||
// For production: "https://your-server.com"
|
// 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