mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Differentiate between WiFi and cellular signals in alerts
This commit is contained in:
parent
e0b146039f
commit
86d9e25f17
5 changed files with 78 additions and 5 deletions
|
|
@ -150,7 +150,7 @@ class VoipActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
callsViewModel.showLowSignalEvent.observe(this) {
|
||||
callsViewModel.showLowWifiSignalEvent.observe(this) {
|
||||
it.consume { show ->
|
||||
if (show) {
|
||||
showRedToast(
|
||||
|
|
@ -167,6 +167,23 @@ class VoipActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
callsViewModel.showLowCellularSignalEvent.observe(this) {
|
||||
it.consume { show ->
|
||||
if (show) {
|
||||
showRedToast(
|
||||
getString(R.string.toast_alert_low_cellular_signal),
|
||||
R.drawable.cell_signal_low
|
||||
)
|
||||
} else {
|
||||
hideRedToast()
|
||||
showGreenToast(
|
||||
getString(R.string.toast_alert_low_cellular_signal_cleared),
|
||||
R.drawable.cell_signal_full
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.toggleFullScreenEvent.observe(this) {
|
||||
it.consume { hide ->
|
||||
hideUI(hide)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ import org.linphone.utils.Event
|
|||
class CallsViewModel @UiThread constructor() : ViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Calls ViewModel]"
|
||||
|
||||
private const val ALERT_SIGNAL_TYPE_KEY = "signal-type"
|
||||
private const val ALERT_SIGNAL_TYPE_WIFI = "wifi"
|
||||
private const val ALERT_SIGNAL_TYPE_CELLULAR = "mobile"
|
||||
}
|
||||
|
||||
val goToActiveCallEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
|
@ -45,7 +49,9 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val noMoreCallEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val showLowSignalEvent = MutableLiveData<Event<Boolean>>()
|
||||
val showLowWifiSignalEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val showLowCellularSignalEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
private val alertListener = object : AlertListenerStub() {
|
||||
@WorkerThread
|
||||
|
|
@ -55,7 +61,22 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
|
|||
alert.removeListener(this)
|
||||
|
||||
if (alert.type == Alert.Type.QoSLowSignal) {
|
||||
showLowSignalEvent.postValue(Event(false))
|
||||
val signalType = alert.informations?.getString(ALERT_SIGNAL_TYPE_KEY)
|
||||
when (signalType) {
|
||||
ALERT_SIGNAL_TYPE_WIFI -> {
|
||||
Log.i("$TAG Wi-Fi signal no longer low")
|
||||
showLowWifiSignalEvent.postValue(Event(false))
|
||||
}
|
||||
ALERT_SIGNAL_TYPE_CELLULAR -> {
|
||||
Log.i("$TAG Cellular signal no longer low")
|
||||
showLowCellularSignalEvent.postValue(Event(false))
|
||||
}
|
||||
else -> {
|
||||
Log.w(
|
||||
"$TAG Unexpected type of signal [$signalType] found in alert information"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +117,22 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
|
|||
alert.addListener(alertListener)
|
||||
|
||||
if (alert.type == Alert.Type.QoSLowSignal) {
|
||||
showLowSignalEvent.postValue(Event(true))
|
||||
val signalType = alert.informations?.getString(ALERT_SIGNAL_TYPE_KEY)
|
||||
when (signalType) {
|
||||
ALERT_SIGNAL_TYPE_WIFI -> {
|
||||
Log.i("$TAG Triggered low signal alert is for Wi-Fi")
|
||||
showLowWifiSignalEvent.postValue(Event(true))
|
||||
}
|
||||
ALERT_SIGNAL_TYPE_CELLULAR -> {
|
||||
Log.i("$TAG Triggered low signal alert is for cellular")
|
||||
showLowCellularSignalEvent.postValue(Event(true))
|
||||
}
|
||||
else -> {
|
||||
Log.w(
|
||||
"$TAG Unexpected type of signal [$signalType] found in alert information"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
app/src/main/res/drawable/cell_signal_full.xml
Normal file
9
app/src/main/res/drawable/cell_signal_full.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="256"
|
||||
android:viewportHeight="256">
|
||||
<path
|
||||
android:pathData="M168,72L168,200a8,8 0,0 1,-16 0L152,72a8,8 0,0 1,16 0ZM200,24a8,8 0,0 0,-8 8L192,200a8,8 0,0 0,16 0L208,32A8,8 0,0 0,200 24ZM120,104a8,8 0,0 0,-8 8v88a8,8 0,0 0,16 0L128,112A8,8 0,0 0,120 104ZM80,144a8,8 0,0 0,-8 8v48a8,8 0,0 0,16 0L88,152A8,8 0,0 0,80 144ZM40,184a8,8 0,0 0,-8 8v8a8,8 0,0 0,16 0v-8A8,8 0,0 0,40 184Z"
|
||||
android:fillColor="#4e6074"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/cell_signal_low.xml
Normal file
9
app/src/main/res/drawable/cell_signal_low.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="256"
|
||||
android:viewportHeight="256">
|
||||
<path
|
||||
android:pathData="M88,152v48a8,8 0,0 1,-16 0V152a8,8 0,0 1,16 0ZM40,184a8,8 0,0 0,-8 8v8a8,8 0,0 0,16 0v-8A8,8 0,0 0,40 184Z"
|
||||
android:fillColor="#4e6074"/>
|
||||
</vector>
|
||||
|
|
@ -79,7 +79,9 @@
|
|||
<string name="toast_phone_number_copied_to_clipboard">Number copied into clipboard</string>
|
||||
<string name="toast_call_history_deleted">History has been deleted</string>
|
||||
<string name="toast_alert_low_wifi_signal">Low Wi-Fi signal!</string>
|
||||
<string name="toast_alert_low_wifi_signal_cleared">Wi-Fi signal no longer low</string>
|
||||
<string name="toast_alert_low_wifi_signal_cleared">Wi-Fi signal is no longer low</string>
|
||||
<string name="toast_alert_low_cellular_signal">Low cellular signal!</string>
|
||||
<string name="toast_alert_low_cellular_signal_cleared">Cellular signal is no longer low</string>
|
||||
<string name="toast_call_can_be_trusted">This call can be trusted</string>
|
||||
|
||||
<string name="assistant_country_picker_title">Choose your country</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue