fix draggable bugs

merge-requests/745/head
mosazaid 5 years ago
parent 550b4a848d
commit 259a63384e

@ -20,7 +20,6 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.hmg.hmgDr.Model.ChangeCallStatusRequestModel; import com.hmg.hmgDr.Model.ChangeCallStatusRequestModel;
import com.hmg.hmgDr.Model.GetSessionStatusModel; import com.hmg.hmgDr.Model.GetSessionStatusModel;
@ -63,7 +62,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
private Runnable mVolRunnable, mConnectedRunnable; private Runnable mVolRunnable, mConnectedRunnable;
private FrameLayout mPublisherViewContainer; private FrameLayout mPublisherViewContainer;
private RelativeLayout mSubscriberViewContainer; private FrameLayout mSubscriberViewContainer;
private RelativeLayout controlPanel; private RelativeLayout controlPanel;
private String apiKey; private String apiKey;
@ -432,7 +431,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
if (mPublisher != null) { if (mPublisher != null) {
isCameraClicked = !isCameraClicked; isCameraClicked = !isCameraClicked;
mPublisher.setPublishVideo(!isCameraClicked); mPublisher.setPublishVideo(!isCameraClicked);
int res = isCameraClicked ? R.drawable.video_disanabled : R.drawable.video_enabled; int res = isCameraClicked ? R.drawable.video_disabled : R.drawable.video_enabled;
mCameraBtn.setImageResource(res); mCameraBtn.setImageResource(res);
} }
} }

@ -17,6 +17,7 @@ import android.widget.*
import androidx.annotation.Nullable import androidx.annotation.Nullable
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.GestureDetectorCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.hmg.hmgDr.Model.GetSessionStatusModel import com.hmg.hmgDr.Model.GetSessionStatusModel
import com.hmg.hmgDr.Model.SessionStatusModel import com.hmg.hmgDr.Model.SessionStatusModel
@ -97,8 +98,8 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
private var isConnected = false private var isConnected = false
private var sessionStatusModel: GetSessionStatusModel? = null private var sessionStatusModel: GetSessionStatusModel? = null
private var videoCallResponseListener: VideoCallResponseListener? =null private var videoCallResponseListener: VideoCallResponseListener? = null
private lateinit var mDetector: GestureDetectorCompat
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
requireActivity().setTheme(R.style.AppTheme) requireActivity().setTheme(R.style.AppTheme)
@ -144,12 +145,12 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
} }
} }
fun setCallListener(videoCallResponseListener: VideoCallResponseListener){ fun setCallListener(videoCallResponseListener: VideoCallResponseListener) {
this.videoCallResponseListener = videoCallResponseListener this.videoCallResponseListener = videoCallResponseListener
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View {
parentView = inflater.inflate(R.layout.activity_video_call, container, false) parentView = inflater.inflate(R.layout.activity_video_call, container, false)
@ -166,10 +167,12 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
requestPermissions() requestPermissions()
handleDragDialog() handleDragDialog()
mDetector = GestureDetectorCompat(context, MyGestureListener { showControlPanelTemporarily() })
return parentView return parentView
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
if (mSession == null) { if (mSession == null) {
@ -258,18 +261,6 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
hiddenButtons() hiddenButtons()
checkClientConnected() checkClientConnected()
mSubscriberViewContainer.setOnClickListener {
controlPanel!!.visibility = View.VISIBLE
mVolHandler!!.removeCallbacks(mVolRunnable!!)
mVolHandler!!.postDelayed(mVolRunnable!!, (5 * 1000).toLong())
}
// mSubscriberViewContainer!!.setOnTouchListener { v: View?, event: MotionEvent? ->
// controlPanel!!.visibility = View.VISIBLE
// mVolHandler!!.removeCallbacks(mVolRunnable!!)
// mVolHandler!!.postDelayed(mVolRunnable!!, (5 * 1000).toLong())
// true
// }
if (appLang == "ar") { if (appLang == "ar") {
progressBarLayout!!.layoutDirection = View.LAYOUT_DIRECTION_RTL progressBarLayout!!.layoutDirection = View.LAYOUT_DIRECTION_RTL
} }
@ -474,7 +465,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
disconnectSession() disconnectSession()
} }
private fun onMinimizedClicked(view: View?) { private fun onMinimizedClicked(view: View?) {
if (isFullScreen) { if (isFullScreen) {
dialog?.window?.setLayout( dialog?.window?.setLayout(
400, 400,
@ -494,10 +485,10 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
} }
private fun setViewsVisibility() { private fun setViewsVisibility() {
val iconSize : Int = context!!.resources.getDimension(R.dimen.video_icon_size).toInt() val iconSize: Int = context!!.resources.getDimension(R.dimen.video_icon_size).toInt()
val iconSizeSmall : Int = context!!.resources.getDimension(R.dimen.video_icon_size_small).toInt() val iconSizeSmall: Int = context!!.resources.getDimension(R.dimen.video_icon_size_small).toInt()
val btnMinimizeLayoutParam : ConstraintLayout.LayoutParams = btnMinimize.layoutParams as ConstraintLayout.LayoutParams val btnMinimizeLayoutParam: ConstraintLayout.LayoutParams = btnMinimize.layoutParams as ConstraintLayout.LayoutParams
val mCallBtnLayoutParam : ConstraintLayout.LayoutParams = mCallBtn.layoutParams as ConstraintLayout.LayoutParams val mCallBtnLayoutParam: ConstraintLayout.LayoutParams = mCallBtn.layoutParams as ConstraintLayout.LayoutParams
// val localPreviewMargin : Int = context!!.resources.getDimension(R.dimen.local_preview_margin_top).toInt() // val localPreviewMargin : Int = context!!.resources.getDimension(R.dimen.local_preview_margin_top).toInt()
// val localPreviewWidth : Int = context!!.resources.getDimension(R.dimen.local_preview_width).toInt() // val localPreviewWidth : Int = context!!.resources.getDimension(R.dimen.local_preview_width).toInt()
@ -512,7 +503,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
val remotePreviewIconSize: Int = context!!.resources.getDimension(R.dimen.remote_back_icon_size).toInt() val remotePreviewIconSize: Int = context!!.resources.getDimension(R.dimen.remote_back_icon_size).toInt()
val remotePreviewIconSizeSmall: Int = context!!.resources.getDimension(R.dimen.remote_back_icon_size_small).toInt() val remotePreviewIconSizeSmall: Int = context!!.resources.getDimension(R.dimen.remote_back_icon_size_small).toInt()
val remotePreviewLayoutParam : FrameLayout.LayoutParams = mSubscriberViewIcon.layoutParams as FrameLayout.LayoutParams val remotePreviewLayoutParam: FrameLayout.LayoutParams = mSubscriberViewIcon.layoutParams as FrameLayout.LayoutParams
val constraintSet = ConstraintSet() val constraintSet = ConstraintSet()
//layoutParam.constrain //layoutParam.constrain
@ -574,7 +565,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
if (mPublisher != null) { if (mPublisher != null) {
isCameraClicked = !isCameraClicked isCameraClicked = !isCameraClicked
mPublisher!!.publishVideo = !isCameraClicked mPublisher!!.publishVideo = !isCameraClicked
val res = if (isCameraClicked) R.drawable.video_disanabled else R.drawable.video_enabled val res = if (isCameraClicked) R.drawable.video_disabled else R.drawable.video_enabled
mCameraBtn!!.setImageResource(res) mCameraBtn!!.setImageResource(res)
} }
} }
@ -604,12 +595,13 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
getWindowManagerDefaultDisplay() getWindowManagerDefaultDisplay()
videoCallContainer.setOnTouchListener(dragListener) videoCallContainer.setOnTouchListener(dragListener)
// mSubscriberViewContainer.setOnTouchListener(dragListener) mSubscriberViewContainer.setOnTouchListener(dragListener)
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
val dragListener : View.OnTouchListener = View.OnTouchListener{ _, event -> val dragListener: View.OnTouchListener = View.OnTouchListener { _, event ->
//Get Floating widget view params mDetector.onTouchEvent(event)
//Get Floating widget view params //Get Floating widget view params
val layoutParams: WindowManager.LayoutParams = dialog!!.window!!.attributes val layoutParams: WindowManager.LayoutParams = dialog!!.window!!.attributes
//get the touch location coordinates //get the touch location coordinates
@ -636,11 +628,12 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
val barHeight: Int = getStatusBarHeight() val barHeight: Int = getStatusBarHeight()
if (y_cord_Destination < 0) { if (y_cord_Destination < 0) {
// y_cord_Destination = 0 // y_cord_Destination = 0
y_cord_Destination = // y_cord_Destination =
-(szWindow.y - (videoCallContainer.height /*+ barHeight*/)) // -(szWindow.y - (videoCallContainer.height /*+ barHeight*/))
y_cord_Destination = - (szWindow.y/2)
} else if (y_cord_Destination + (videoCallContainer.height + barHeight) > szWindow.y) { } else if (y_cord_Destination + (videoCallContainer.height + barHeight) > szWindow.y) {
y_cord_Destination = // y_cord_Destination = szWindow.y - (videoCallContainer.height + barHeight)
szWindow.y - (videoCallContainer.height + barHeight) y_cord_Destination = (szWindow.y/2)
} }
layoutParams.y = y_cord_Destination layoutParams.y = y_cord_Destination
@ -662,6 +655,12 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
true true
} }
private fun showControlPanelTemporarily() {
controlPanel!!.visibility = View.VISIBLE
mVolHandler!!.removeCallbacks(mVolRunnable!!)
mVolHandler!!.postDelayed(mVolRunnable!!, (5 * 1000).toLong())
}
/* Reset position of Floating Widget view on dragging */ /* Reset position of Floating Widget view on dragging */
private fun resetPosition(x_cord_now: Int) { private fun resetPosition(x_cord_now: Int) {
if (x_cord_now <= szWindow.x / 2) { if (x_cord_now <= szWindow.x / 2) {
@ -741,6 +740,15 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
).toInt() ).toInt()
} }
private class MyGestureListener(val onTabCall: () -> Unit) : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
onTabCall()
return true
}
}
companion object { companion object {
@JvmStatic @JvmStatic
fun newInstance(args: Bundle) = fun newInstance(args: Bundle) =

@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]";
const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_LETTERS = "[a-zA-Z &'\"]";
const ONLY_DATE = "[0-9/]"; const ONLY_DATE = "[0-9/]";
const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/';
const BASE_URL = 'https://hmgwebservices.com/'; // const BASE_URL = 'https://hmgwebservices.com/';
// const BASE_URL = 'https://uat.hmgwebservices.com/'; const BASE_URL = 'https://uat.hmgwebservices.com/';
const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh";
const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList";
const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient";

Loading…
Cancel
Save