Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .gradle/9.2.1/checksums/checksums.lock
Binary file not shown.
Binary file modified .gradle/9.2.1/checksums/md5-checksums.bin
Binary file not shown.
Binary file modified .gradle/9.2.1/checksums/sha1-checksums.bin
Binary file not shown.
Binary file modified .gradle/9.2.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/9.2.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/9.2.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/9.2.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/9.2.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}

buildTypes {
Expand Down Expand Up @@ -109,5 +112,6 @@ dependencies {

//rtc
implementation 'io.agora.rtc:full-sdk:4.2.3'
//implementation 'io.agora.rtc:full-sdk:4.2.6'

}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name= "android.hardware.camera.any"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion ="28"/>
<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -64,9 +65,9 @@

<activity android:name=".ui.Chat.UsersActivity" />
<activity android:name=".ui.Chat.ChatActivity"/>
<activity android:name=".ui.Chat.IncomingCallActivity"/>
<activity android:name=".ui.Chat.VideoCallActivity" />
<activity android:name=".ui.Chat.OutgoingCallActivity" />

<activity android:name=".ui.Chat.CallsActivity" />

<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
Expand Down
61 changes: 0 additions & 61 deletions app/src/main/java/com/example/phasmatic/ui/Chat/CallListener.java

This file was deleted.

56 changes: 0 additions & 56 deletions app/src/main/java/com/example/phasmatic/ui/Chat/CallManager.java

This file was deleted.

127 changes: 127 additions & 0 deletions app/src/main/java/com/example/phasmatic/ui/Chat/CallsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.example.phasmatic.ui.Chat;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.example.phasmatic.R;
import com.example.phasmatic.data.model.User;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import java.util.List;

public class CallsActivity extends AppCompatActivity {

private static final String TAG = "CALLS";

private Spinner spnUsers;
private EditText edtMeetingCode;
private Button btnJoinCall;

private String currentUserId;
private String currentUserFullName;
private String currentUserEmail;
private String currentUserPhone;

private DatabaseReference usersRef;

private final List<User> userList = new ArrayList<>();
private final List<String> userNames = new ArrayList<>();
private ArrayAdapter<String> usersAdapter;

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

currentUserId = getIntent().getStringExtra("userId");
currentUserFullName = getIntent().getStringExtra("userFullName");
currentUserEmail = getIntent().getStringExtra("userEmail");
currentUserPhone = getIntent().getStringExtra("userPhone");

spnUsers = findViewById(R.id.spnUsers);
edtMeetingCode = findViewById(R.id.edtMeetingCode);
btnJoinCall = findViewById(R.id.btnJoinCall);

FirebaseDatabase db = FirebaseDatabase.getInstance(
"https://mega-5a5b4-default-rtdb.europe-west1.firebasedatabase.app"
);
usersRef = db.getReference("users");

usersAdapter = new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_item,
userNames
);
usersAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnUsers.setAdapter(usersAdapter);

loadUsers();

btnJoinCall.setOnClickListener(v -> joinCall());
}

private void loadUsers() {
usersRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
userList.clear();
userNames.clear();

for (DataSnapshot child : snapshot.getChildren()) {
User u = child.getValue(User.class);
if (u == null) continue;

if (child.getKey() != null && child.getKey().equals(currentUserId)) {
continue;
}

u.setId(child.getKey());
userList.add(u);
userNames.add(u.getFullName() != null ? u.getFullName() : child.getKey());
}

usersAdapter.notifyDataSetChanged();
}

@Override
public void onCancelled(@NonNull DatabaseError error) { }
});
}

private void joinCall() {
String code = edtMeetingCode.getText().toString().trim();
if (code.isEmpty()) {
edtMeetingCode.setError("Meeting code required");
return;
}

int pos = spnUsers.getSelectedItemPosition();
String otherUid = null;
String otherName = null;
if (pos >= 0 && pos < userList.size()) {
User other = userList.get(pos);
otherUid = other.getId();
otherName = other.getFullName();
}

Log.d(TAG, "joinCall: channel=" + code +
" otherUid=" + otherUid + " otherName=" + otherName);

Intent i = new Intent(this, VideoCallActivity.class);
i.putExtra("channelName", code);
startActivity(i);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public class ChatActivity extends AppCompatActivity {

private ImageButton btnBack, btnSend, btnVoice, btnVideoCall;
private ImageButton btnBack, btnSend, btnVoice;
private TextView txtChatWith;
private EditText etMessage;
private RecyclerView rvMessages;
Expand All @@ -54,7 +54,6 @@ public class ChatActivity extends AppCompatActivity {
private String currentUid;
private String otherUid;
private String otherName;
CallListener callListener;


private ProfileMenuHelper profileMenuHelper;
Expand All @@ -78,7 +77,6 @@ protected void onCreate(Bundle savedInstanceState) {
etMessage = findViewById(R.id.etMessage);
rvMessages = findViewById(R.id.rvMessages);
imgProfile = findViewById(R.id.imgProfile);
btnVideoCall = findViewById(R.id.btnvideoCall);

currentUid = getIntent().getStringExtra("userId");
otherUid = getIntent().getStringExtra("otherUid");
Expand Down Expand Up @@ -120,7 +118,6 @@ protected void onCreate(Bundle savedInstanceState) {
btnSend.setOnClickListener(v -> sendMessage());

findOrCreateConversation();
setupVideoCall();


btnVoice.setOnClickListener(v -> startSpeechRecognizer());
Expand All @@ -130,45 +127,15 @@ protected void onStart() {
super.onStart();
//String currentUid = "βαλε_εδω_το_uid_του_user"; // πχ απο intent ή auth

callListener = new CallListener(this, currentUid);
callListener.start();
}

@Override
protected void onStop() {
super.onStop();

if (callListener != null) {
callListener.stop();
}
}


private void setupVideoCall() {

btnVideoCall.setOnClickListener(v -> {

if (conversationKey == null) return;

CallManager callManager = new CallManager();

String callId = callManager.startCall(
currentUid,
otherUid,
conversationKey
);

if (callId == null) return;

Intent i = new Intent(ChatActivity.this, OutgoingCallActivity.class);
i.putExtra("callId", callId);
i.putExtra("channelName", conversationKey);
i.putExtra("otherUid", otherUid);
i.putExtra("otherName", otherName);
startActivity(i);
});
}

private void listenCallStatus(String callId) {

DatabaseReference callRef = db.getReference("calls").child(callId);
Expand Down
Loading