Skip to content
Snippets Groups Projects
Commit ae1b77c4 authored by Chris's avatar Chris
Browse files

Added Ringtone, Finished Accept Call Button, Linked OpenTok, Fixed Permissions

parent 80987c26
Branches master
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
......@@ -33,6 +34,9 @@ public class CallingActivity extends AppCompatActivity {
private String callingID = "", ringingID = "";
// Ringtone
private MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -44,6 +48,8 @@ public class CallingActivity extends AppCompatActivity {
receiverUserId = getIntent().getExtras().get("visit_user_id").toString();
usersRef = FirebaseDatabase.getInstance().getReference().child("User");
mediaPlayer = MediaPlayer.create(this, R.raw.ringing);
nameContact = findViewById(R.id.name_calling);
profileImage = findViewById(R.id.profile_image_calling);
cancelCallBtn = findViewById(R.id.cancel_call);
......@@ -53,13 +59,36 @@ public class CallingActivity extends AppCompatActivity {
@Override
public void onClick(View v)
{
mediaPlayer.stop();
checker = "clicked";
cancelCallingUser();
}
});
acceptCallBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
mediaPlayer.stop();
final HashMap<String, Object> callingPickUpMap = new HashMap<>();
callingPickUpMap.put("picked", "picked");
usersRef.child(senderUserId).child("Ringing").updateChildren(callingPickUpMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task)
{
if (task.isSuccessful())
{
Intent intent = new Intent(CallingActivity.this, VideoChatActivity.class);
startActivity(intent);
}
}
});
}
});
getAndSetUserProfileInfo();
}
......@@ -93,14 +122,17 @@ public class CallingActivity extends AppCompatActivity {
protected void onStart() {
super.onStart();
mediaPlayer.start();
// sender calling a receiver
usersRef.child(receiverUserId).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot)
{
if (!checker.equals("clicked") && !dataSnapshot.hasChild("Calling") && !dataSnapshot.hasChild("Ringing")) // user is not busy
{
//mediaPlayer.start();
final HashMap<String, Object> callingInfo = new HashMap<>();
callingInfo.put("calling", receiverUserId);
......@@ -138,6 +170,13 @@ public class CallingActivity extends AppCompatActivity {
acceptCallBtn.setVisibility(View.VISIBLE);
}
if (dataSnapshot.child(receiverUserId).child("Ringing").hasChild("picked"))
{
mediaPlayer.stop();
Intent intent = new Intent(CallingActivity.this, VideoChatActivity.class);
startActivity(intent);
}
}
@Override
......
......@@ -31,9 +31,9 @@ import pub.devrel.easypermissions.EasyPermissions;
public class VideoChatActivity extends AppCompatActivity
implements Session.SessionListener, PublisherKit.PublisherListener
{
private static String API_Key = "";
private static String SESSION_ID = "";
private static String TOKEN = "";
private static String API_Key = "47033554";
private static String SESSION_ID = "2_MX40NzAzMzU1NH5-MTYwNzQ2Njg4MTYyMH40VjhlTEJLVDBKNkR0VnJMSVIyUWtCNEZ-fg";
private static String TOKEN = "T1==cGFydG5lcl9pZD00NzAzMzU1NCZzaWc9YWNhMzliMzFkZWRkMTBjYTk5ZjJlNjJjMTAzZDg4YmQ4ZjAwYjZkZjpzZXNzaW9uX2lkPTJfTVg0ME56QXpNelUxTkg1LU1UWXdOelEyTmpnNE1UWXlNSDQwVmpobFRFSkxWREJLTmtSMFZuSk1TVkl5VVd0Q05FWi1mZyZjcmVhdGVfdGltZT0xNjA3NDY2OTQ4Jm5vbmNlPTAuOTkzNDMyOTA3NTgxMDMyOSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNjEwMDU4OTQ3JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9";
private static final String LOG_TAG = VideoChatActivity.class.getSimpleName();
private static final int RC_VIDEO_APP_PERM = 124;
......@@ -114,6 +114,7 @@ public class VideoChatActivity extends AppCompatActivity
});
}
});
requestPermissions();
}
@Override
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment