mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Updated remote recording to show toast
This commit is contained in:
parent
9268ef5d2f
commit
3c0640ce11
4 changed files with 41 additions and 49 deletions
|
|
@ -60,8 +60,6 @@ import org.linphone.utils.slideInToastFromTopForDuration
|
|||
class CallActivity : AppCompatActivity() {
|
||||
companion object {
|
||||
private const val TAG = "[Call Activity]"
|
||||
|
||||
private const val PERSISTENT_TOAST_TAG = "PERSISTENT"
|
||||
}
|
||||
|
||||
private lateinit var binding: CallActivityBinding
|
||||
|
|
@ -112,13 +110,15 @@ class CallActivity : AppCompatActivity() {
|
|||
|
||||
callViewModel.showLowWifiSignalEvent.observe(this) {
|
||||
it.consume { show ->
|
||||
val tag = "LOW_WIFI_SIGNAL"
|
||||
if (show) {
|
||||
showPersistentRedToast(
|
||||
getString(R.string.toast_alert_low_wifi_signal),
|
||||
R.drawable.wifi_low
|
||||
R.drawable.wifi_low,
|
||||
tag
|
||||
)
|
||||
} else {
|
||||
removePersistentRedToasts()
|
||||
removePersistentRedToast(tag)
|
||||
showGreenToast(
|
||||
getString(R.string.toast_alert_low_wifi_signal_cleared),
|
||||
R.drawable.wifi_high,
|
||||
|
|
@ -130,13 +130,15 @@ class CallActivity : AppCompatActivity() {
|
|||
|
||||
callViewModel.showLowCellularSignalEvent.observe(this) {
|
||||
it.consume { show ->
|
||||
val tag = "LOW_CELLULAR_SIGNAL"
|
||||
if (show) {
|
||||
showPersistentRedToast(
|
||||
getString(R.string.toast_alert_low_cellular_signal),
|
||||
R.drawable.cell_signal_low
|
||||
R.drawable.cell_signal_low,
|
||||
tag
|
||||
)
|
||||
} else {
|
||||
removePersistentRedToasts()
|
||||
removePersistentRedToast(tag)
|
||||
showGreenToast(
|
||||
getString(R.string.toast_alert_low_cellular_signal_cleared),
|
||||
R.drawable.cell_signal_full,
|
||||
|
|
@ -312,13 +314,14 @@ class CallActivity : AppCompatActivity() {
|
|||
)
|
||||
}
|
||||
|
||||
private fun showPersistentRedToast(
|
||||
fun showPersistentRedToast(
|
||||
message: String,
|
||||
@DrawableRes icon: Int,
|
||||
tag: String,
|
||||
doNotTint: Boolean = false
|
||||
) {
|
||||
val redToast = AppUtils.getRedToast(this, binding.toastsArea, message, icon, doNotTint)
|
||||
redToast.root.tag = PERSISTENT_TOAST_TAG
|
||||
redToast.root.tag = tag
|
||||
binding.toastsArea.addView(redToast.root)
|
||||
|
||||
redToast.root.slideInToastFromTop(
|
||||
|
|
@ -327,9 +330,9 @@ class CallActivity : AppCompatActivity() {
|
|||
)
|
||||
}
|
||||
|
||||
private fun removePersistentRedToasts() {
|
||||
fun removePersistentRedToast(tag: String) {
|
||||
for (child in binding.toastsArea.children) {
|
||||
if (child.tag == PERSISTENT_TOAST_TAG) {
|
||||
if (child.tag == tag) {
|
||||
binding.toastsArea.removeView(child)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,27 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
callViewModel.isRemoteRecordingEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val isRemoteRecording = pair.first
|
||||
val displayName = pair.second
|
||||
val toastTag = "REMOTE_RECORDING"
|
||||
|
||||
if (isRemoteRecording) {
|
||||
Log.i("$TAG Showing [$displayName] is recording toast")
|
||||
val message = getString(R.string.call_remote_is_recording, displayName)
|
||||
(requireActivity() as CallActivity).showPersistentRedToast(
|
||||
message,
|
||||
R.drawable.record_fill,
|
||||
toastTag
|
||||
)
|
||||
} else {
|
||||
Log.i("$TAG Removing [$displayName] is recording toast")
|
||||
(requireActivity() as CallActivity).removePersistentRedToast(toastTag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actionsBottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
when (newState) {
|
||||
|
|
|
|||
|
|
@ -74,10 +74,6 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val isRecording = MutableLiveData<Boolean>()
|
||||
|
||||
val isRemoteRecording = MutableLiveData<Boolean>()
|
||||
|
||||
val remoteRecordingLabel = MutableLiveData<String>()
|
||||
|
||||
val canBePaused = MutableLiveData<Boolean>()
|
||||
|
||||
val isPaused = MutableLiveData<Boolean>()
|
||||
|
|
@ -102,6 +98,10 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<String>()
|
||||
}
|
||||
|
||||
val isRemoteRecordingEvent: MutableLiveData<Event<Pair<Boolean, String>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Boolean, String>>>()
|
||||
}
|
||||
|
||||
val goToInitiateBlindTransferEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -171,15 +171,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
override fun onRemoteRecording(call: Call, recording: Boolean) {
|
||||
Log.i("$TAG Remote recording changed: $recording")
|
||||
isRemoteRecording.postValue(recording)
|
||||
if (recording) {
|
||||
remoteRecordingLabel.postValue(
|
||||
AppUtils.getFormattedString(
|
||||
R.string.call_remote_is_recording,
|
||||
displayedName.value.orEmpty()
|
||||
)
|
||||
)
|
||||
}
|
||||
isRemoteRecordingEvent.postValue(Event(Pair(recording, displayedName.value.orEmpty())))
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -747,12 +739,8 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
isRecording.postValue(call.params.isRecording)
|
||||
isRemoteRecording.postValue(call.remoteParams?.isRecording)
|
||||
remoteRecordingLabel.postValue(
|
||||
AppUtils.getFormattedString(
|
||||
R.string.call_remote_is_recording,
|
||||
displayedName.value.orEmpty()
|
||||
)
|
||||
isRemoteRecordingEvent.postValue(
|
||||
Event(Pair(call.remoteParams?.isRecording ?: false, displayedName.value.orEmpty()))
|
||||
)
|
||||
|
||||
callDuration.postValue(call.duration)
|
||||
|
|
|
|||
|
|
@ -224,26 +224,6 @@
|
|||
app:layout_constraintHeight_max="200dp"
|
||||
app:layout_constraintWidth_max="200dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_300"
|
||||
android:id="@+id/remote_recording"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="45dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text="@{viewModel.remoteRecordingLabel, default=@string/call_remote_is_recording}"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_900"
|
||||
android:gravity="center_vertical"
|
||||
android:drawableStart="@drawable/record_fill"
|
||||
android:drawablePadding="10dp"
|
||||
android:background="@drawable/shape_remote_recording_background"
|
||||
android:visibility="@{viewModel.isRemoteRecording ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintWidth_min="180dp"
|
||||
app:layout_constraintTop_toTopOf="@id/background"
|
||||
app:layout_constraintStart_toStartOf="@id/background"
|
||||
app:drawableTint="@color/red_danger_500" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/recording"
|
||||
android:layout_width="@dimen/icon_size"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue