diff --git a/app/src/main/java/org/intelehealth/ekalarogya/activities/homeActivity/HomeActivity.java b/app/src/main/java/org/intelehealth/ekalarogya/activities/homeActivity/HomeActivity.java index 496ebbf7e8..f2a928e9f4 100644 --- a/app/src/main/java/org/intelehealth/ekalarogya/activities/homeActivity/HomeActivity.java +++ b/app/src/main/java/org/intelehealth/ekalarogya/activities/homeActivity/HomeActivity.java @@ -76,6 +76,7 @@ import org.intelehealth.ekalarogya.utilities.NetworkConnection; import org.intelehealth.ekalarogya.utilities.OfflineLogin; import org.intelehealth.ekalarogya.utilities.SessionManager; +import org.intelehealth.ekalarogya.webrtc.activity.EkalCallLogActivity; import org.intelehealth.ekalarogya.webrtc.activity.EkalChatActivity; import org.intelehealth.ekalarogya.webrtc.activity.EkalVideoActivity; import org.intelehealth.ekalarogya.widget.materialprogressbar.CustomProgressDialog; @@ -333,7 +334,10 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); - if (itemId == R.id.userProfileOption) { + if (itemId == R.id.actionCallLog) { + startActivity(new Intent(this, EkalCallLogActivity.class)); + return true; + } else if (itemId == R.id.userProfileOption) { Hw_Profile(); return true; } else if (itemId == R.id.settingsOption) { @@ -543,12 +547,14 @@ public void onNext(DownloadMindMapRes res) { Toast.makeText(context, getResources().getString(R.string.no_protocols_found), Toast.LENGTH_SHORT).show(); } } + @Override public void onError(Throwable e) { customProgressDialog.dismiss(); Toast.makeText(context, getResources().getString(R.string.unable_to_get_proper_response), Toast.LENGTH_SHORT).show(); Log.v(TAG, "jwt_response: " + e.toString()); } + @Override public void onComplete() { } @@ -638,6 +644,7 @@ public void onClick(DialogInterface dialog, int which) { } } } + @Override public void onError(Throwable e) { Log.e("Error", "" + e); diff --git a/app/src/main/java/org/intelehealth/ekalarogya/database/dao/PatientsDAO.java b/app/src/main/java/org/intelehealth/ekalarogya/database/dao/PatientsDAO.java index 4b655f7ef0..cd280bf610 100644 --- a/app/src/main/java/org/intelehealth/ekalarogya/database/dao/PatientsDAO.java +++ b/app/src/main/java/org/intelehealth/ekalarogya/database/dao/PatientsDAO.java @@ -434,8 +434,11 @@ public boolean updateOpemmrsId(String openmrsId, String synced, String uuid) thr db.endTransaction(); } try { - Intent intent = new Intent(IntelehealthApplication.getAppContext(), MyIntentService.class); - IntelehealthApplication.getAppContext().startService(intent); + Intent in = new Intent(); + in.setAction("OpenmrsID"); + IntelehealthApplication.getAppContext().sendBroadcast(in); +// Intent intent = new Intent(IntelehealthApplication.getAppContext(), MyIntentService.class); +// IntelehealthApplication.getAppContext().startService(intent); } catch (IllegalArgumentException e) { e.printStackTrace(); } diff --git a/app/src/main/java/org/intelehealth/ekalarogya/webrtc/activity/EkalCallLogActivity.kt b/app/src/main/java/org/intelehealth/ekalarogya/webrtc/activity/EkalCallLogActivity.kt index b80d28b4cb..f78f3fe6bd 100644 --- a/app/src/main/java/org/intelehealth/ekalarogya/webrtc/activity/EkalCallLogActivity.kt +++ b/app/src/main/java/org/intelehealth/ekalarogya/webrtc/activity/EkalCallLogActivity.kt @@ -37,8 +37,7 @@ class EkalCallLogActivity : CoreCallLogActivity(), BaseViewHolder.ViewHolderClic layoutManager = LinearLayoutManager(context) addItemDecoration( DividerItemDecoration( - this@EkalCallLogActivity, - DividerItemDecoration.VERTICAL + this@EkalCallLogActivity, DividerItemDecoration.VERTICAL ) ) this@EkalCallLogActivity.adapter.updateItems(logs.toMutableList()) diff --git a/app/src/main/res/menu/menu_home.xml b/app/src/main/res/menu/menu_home.xml index 68abeff3d5..37ef334ba8 100755 --- a/app/src/main/res/menu/menu_home.xml +++ b/app/src/main/res/menu/menu_home.xml @@ -8,10 +8,10 @@ android:orderInCategory="100" android:title="@string/menu_option_hw_profile" /> - - - - + End of Day Logout User Profile + @string/call_logs //Identification Screen diff --git a/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/activity/CoreVideoCallActivity.kt b/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/activity/CoreVideoCallActivity.kt index c1b470d062..3605727360 100644 --- a/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/activity/CoreVideoCallActivity.kt +++ b/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/activity/CoreVideoCallActivity.kt @@ -3,7 +3,9 @@ package org.intelehealth.klivekit.call.ui.activity import android.Manifest import android.content.Intent import android.media.MediaPlayer +import android.media.Ringtone import android.media.RingtoneManager +import android.os.Build import android.os.Bundle import android.view.WindowManager import androidx.appcompat.app.AppCompatActivity @@ -81,21 +83,21 @@ abstract class CoreVideoCallActivity : AppCompatActivity() { // initiate the incoming call ringtone -// private val ringtone: Ringtone by lazy { -// val notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) -// RingtoneManager.getRingtone(applicationContext, notification) -// } + private val ringtone: Ringtone by lazy { + val notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) + RingtoneManager.getRingtone(applicationContext, notification) + } // private val audioManager: AudioManager by lazy { // applicationContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager // } - private val mediaPlayer: MediaPlayer by lazy { - val notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) - MediaPlayer.create(this, notification).apply { - isLooping = true - }; - } +// private val mediaPlayer: MediaPlayer by lazy { +// val notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) +// MediaPlayer.create(this, notification).apply { +// isLooping = true +// }; +// } override fun onCreate(savedInstanceState: Bundle?) { window.addFlags( @@ -304,12 +306,20 @@ abstract class CoreVideoCallActivity : AppCompatActivity() { open fun playRingtone() { // mediaPlayer.prepare() - mediaPlayer.start() +// mediaPlayer.start() + if (!ringtone.isPlaying) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + ringtone.isLooping = true + } + ringtone.play() + } } open fun stopRingtone() { - Timber.e { "stopRingtone ${mediaPlayer.isPlaying}" } - if (mediaPlayer.isPlaying) mediaPlayer.stop() +// Timber.e { "stopRingtone ${mediaPlayer.isPlaying}" } +// if (mediaPlayer.isPlaying) mediaPlayer.stop() + Timber.e { "stopRingtone ${ringtone.isPlaying}" } + if (ringtone.isPlaying) ringtone.stop() } override fun onResume() { diff --git a/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/viewmodel/CoreVideoViewModel.kt b/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/viewmodel/CoreVideoViewModel.kt deleted file mode 100644 index 8e31a46952..0000000000 --- a/klivekit/src/main/java/org/intelehealth/klivekit/call/ui/viewmodel/CoreVideoViewModel.kt +++ /dev/null @@ -1,161 +0,0 @@ -package org.intelehealth.klivekit.call.ui.viewmodel - -import android.content.Context -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.github.ajalt.timberkt.Timber -import io.livekit.android.LiveKit -import io.livekit.android.events.RoomEvent -import io.livekit.android.events.collect -import io.livekit.android.room.Room -import io.livekit.android.room.track.CameraPosition -import io.livekit.android.room.track.LocalVideoTrack -import io.livekit.android.room.track.Track -import io.livekit.android.room.track.VideoTrack -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.launch -import org.intelehealth.klivekit.utils.extensions.hide - -/** - * Created by Vaghela Mithun R. on 08-06-2023 - 15:59. - * Email : mithun@intelehealth.org - * Mob : +919727206702 - **/ -open class CoreVideoViewModel( - private val context: Context, - private val url: String, - private val token: String -) : ViewModel() { - - protected val mutableError = MutableStateFlow(null) - val error = mutableError.hide() - - // Controls - private val mutableMicEnabled = MutableLiveData(true) - val micEnabled = mutableMicEnabled.hide() - - private val mutableCameraEnabled = MutableLiveData(true) - val cameraEnabled = mutableCameraEnabled.hide() - - private val mutableRemoteVideoTrack = MutableLiveData() - val remoteVideoTrack = mutableRemoteVideoTrack.hide() - - lateinit var room: Room - - open fun initRoom() { - room = LiveKit.create(appContext = context) - } - - open fun initRoomEvents() { - viewModelScope.launch { - room.events.collect { event -> - when (event) { - is RoomEvent.TrackSubscribed -> onTrackSubscribed(event) - is RoomEvent.ParticipantDisconnected -> onParticipantDisconnected(event) - else -> {} - } - } - } - } - - private fun onTrackSubscribed(event: RoomEvent.TrackSubscribed) { - val track = event.track - if (track is VideoTrack) { - mutableRemoteVideoTrack.postValue(track) - } - } - - private fun onParticipantDisconnected(event: RoomEvent.ParticipantDisconnected){ -// event.participant.sid == room.remoteParticipants.values.firstOrNull().sid - } - - suspend fun connectToRoom() { - try { - room.connect( - url = url, - token = token, - ) - - // Create and publish audio/video tracks - val localParticipant = room.localParticipant - localParticipant.setMicrophoneEnabled(true) - mutableMicEnabled.postValue(localParticipant.isMicrophoneEnabled()) - - localParticipant.setCameraEnabled(true) - mutableCameraEnabled.postValue(localParticipant.isCameraEnabled()) - - setupRemoteVideoTrack() - - } catch (e: Throwable) { - mutableError.value = e - } - } - - private fun configLocalTrack(){ - - } - - open fun setupRemoteVideoTrack() { - // Attach video of remote participant if already available. - val remoteVideoTrack = room.remoteParticipants.values.firstOrNull() - ?.getTrackPublication(Track.Source.CAMERA) - ?.track as? VideoTrack - - if (remoteVideoTrack != null) { - mutableRemoteVideoTrack.postValue(remoteVideoTrack) - } - } - - fun toggleMicrophone() { - viewModelScope.launch { - val enabled = room.localParticipant.isMicrophoneEnabled().not() - room.localParticipant.setMicrophoneEnabled(enabled) - mutableMicEnabled.postValue(enabled) - } - } - - fun toggleCamera() { - viewModelScope.launch { - val enabled = room.localParticipant.isCameraEnabled().not() - room.localParticipant.setCameraEnabled(enabled) - mutableCameraEnabled.postValue(enabled) - } - } - - fun flipCamera() { - val videoTrack = room.localParticipant.getTrackPublication(Track.Source.CAMERA) - ?.track as? LocalVideoTrack - ?: return - - val newPosition = when (videoTrack.options.position) { - CameraPosition.FRONT -> CameraPosition.BACK - CameraPosition.BACK -> CameraPosition.FRONT - else -> null - } - - videoTrack.switchCamera(position = newPosition) - } - - fun dismissError() { - mutableError.value = null - } - - open fun reconnect() { - Timber.e { "Reconnecting." } - room.disconnect() - viewModelScope.launch { - connectToRoom() - } - } - - override fun onCleared() { - super.onCleared() - disconnect() - } - - fun disconnect() { - room.disconnect() - room.release() - } -} \ No newline at end of file diff --git a/klivekit/src/main/java/org/intelehealth/klivekit/call/utils/CallNotificationHandler.kt b/klivekit/src/main/java/org/intelehealth/klivekit/call/utils/CallNotificationHandler.kt index d3d50fffe5..0c5f1c5f6a 100644 --- a/klivekit/src/main/java/org/intelehealth/klivekit/call/utils/CallNotificationHandler.kt +++ b/klivekit/src/main/java/org/intelehealth/klivekit/call/utils/CallNotificationHandler.kt @@ -144,8 +144,8 @@ object CallNotificationHandler { return NotificationCompat.Builder(context, getChannelId(context)) .setPriority(NotificationCompat.PRIORITY_HIGH) - .setContentTitle(getApplicationName(context)) - .setContentText("Incoming call from ${messageBody.doctorName ?: "unknown"}") + .setContentTitle(messageBody.doctorName ?: "unknown") + .setContentText("Incoming call") .setColor(ContextCompat.getColor(context, R.color.blue_1)) .setSmallIcon(messageBody.notificationIcon) // .setSound(getDefaultRingtoneUrl(), AudioManager.STREAM_RING) @@ -176,8 +176,8 @@ object CallNotificationHandler { return NotificationCompat.Builder(context, getChannelId(context)) .setPriority(NotificationCompat.PRIORITY_HIGH) - .setContentTitle("Ongoing call with ${messageBody.doctorName ?: "unknown"}") -// .setContentText("Ongoing call with ${messageBody.doctorName ?: "unknown"}") + .setContentTitle(messageBody.doctorName ?: "unknown") + .setContentText("Ongoing call") .setColor(ContextCompat.getColor(context, R.color.blue_1)) .setSmallIcon(messageBody.notificationIcon) .setCategory(NotificationCompat.CATEGORY_CALL).setContentIntent(notificationIntent) @@ -226,8 +226,8 @@ object CallNotificationHandler { messageBody.callStatus = CallStatus.MISSED return NotificationCompat.Builder(context, getChannelId(context)) .setPriority(NotificationCompat.PRIORITY_LOW) -// .setContentTitle(getApplicationName(context)) - .setContentText("Missed call from ${messageBody.doctorName}") + .setContentTitle(messageBody.doctorName) + .setContentText("Missed call") .setColor(ContextCompat.getColor(context, R.color.red)) .setSmallIcon(messageBody.notificationIcon) .setCategory(NotificationCompat.CATEGORY_MISSED_CALL).setAutoCancel(true) diff --git a/klivekit/src/main/java/org/intelehealth/klivekit/chat/ui/adapter/ChatListingAdapter.java b/klivekit/src/main/java/org/intelehealth/klivekit/chat/ui/adapter/ChatListingAdapter.java index 83017016e2..81a43e6533 100644 --- a/klivekit/src/main/java/org/intelehealth/klivekit/chat/ui/adapter/ChatListingAdapter.java +++ b/klivekit/src/main/java/org/intelehealth/klivekit/chat/ui/adapter/ChatListingAdapter.java @@ -21,7 +21,7 @@ import java.util.List; public class ChatListingAdapter extends DateHeaderAdapter { - +// Medicine adapter <- Test <- Aid adapter <- Header adapter <- Recycler.Adapter public interface AttachmentClickListener { void onClick(String url); } diff --git a/klivekit/src/main/java/org/intelehealth/klivekit/socket/SocketManager.kt b/klivekit/src/main/java/org/intelehealth/klivekit/socket/SocketManager.kt index aa05a8e9dc..1d6dcaaba4 100644 --- a/klivekit/src/main/java/org/intelehealth/klivekit/socket/SocketManager.kt +++ b/klivekit/src/main/java/org/intelehealth/klivekit/socket/SocketManager.kt @@ -1,5 +1,8 @@ package org.intelehealth.klivekit.socket +import android.app.ActivityManager +import androidx.lifecycle.ProcessLifecycleOwner +import androidx.lifecycle.lifecycleScope import com.github.ajalt.timberkt.Timber import com.google.gson.Gson import io.socket.client.IO @@ -107,6 +110,10 @@ open class SocketManager @Inject constructor() { private fun invokeListeners(event: String, args: Any?) { Timber.d { "No of listener => ${emitterListeners.size}" } emitterListeners.forEach { it.invoke(event).call(args) } + +// if (CallNotificationHandler.isAppInBackground() && event == EVENT_CALL_CANCEL_BY_DR) { +// +// } } private fun notifyIfNotActiveRoom(jsonArray: JSONArray, block: (ChatMessage) -> Unit) {