kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Add tooltip to status image icon
rodzic
b4687b0a2f
commit
672fc6f481
|
@ -25,6 +25,7 @@ import android.view.MotionEvent
|
|||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.TooltipCompat
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
|
@ -390,14 +391,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}.attach()
|
||||
|
||||
model.isConnected.observe(this, Observer { connected ->
|
||||
val image = when (connected) {
|
||||
MeshService.ConnectionState.CONNECTED -> R.drawable.cloud_on
|
||||
MeshService.ConnectionState.DEVICE_SLEEP -> R.drawable.ic_twotone_cloud_upload_24
|
||||
MeshService.ConnectionState.DISCONNECTED -> R.drawable.cloud_off
|
||||
else -> R.drawable.cloud_off
|
||||
}
|
||||
|
||||
connectStatusImage.setImageResource(image)
|
||||
updateConnectionStatusImage(connected)
|
||||
})
|
||||
|
||||
// Handle any intent
|
||||
|
@ -406,6 +400,26 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
askToRate()
|
||||
}
|
||||
|
||||
private fun updateConnectionStatusImage(connected: MeshService.ConnectionState) {
|
||||
|
||||
val (image, tooltip) = when (connected) {
|
||||
MeshService.ConnectionState.CONNECTED -> Pair(R.drawable.cloud_on, R.string.connected)
|
||||
MeshService.ConnectionState.DEVICE_SLEEP -> Pair(
|
||||
R.drawable.ic_twotone_cloud_upload_24,
|
||||
R.string.device_sleeping
|
||||
)
|
||||
MeshService.ConnectionState.DISCONNECTED -> Pair(
|
||||
R.drawable.cloud_off,
|
||||
R.string.disconnected
|
||||
)
|
||||
else -> Pair(R.drawable.cloud_off, R.string.disconnected)
|
||||
}
|
||||
|
||||
connectStatusImage.setImageResource(image)
|
||||
TooltipCompat.setTooltipText(connectStatusImage, getString(tooltip))
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<string name="connected_count">Connected: %s of %s online</string>
|
||||
<string name="list_of_nodes">A list of nodes in the network</string>
|
||||
<string name="update_firmware">Update Firmware</string>
|
||||
<string name="connected">Connected to radio (%s)</string>
|
||||
<string name="connected_to">Connected to radio (%s)</string>
|
||||
<string name="not_connected">Not connected, select radio below</string>
|
||||
<string name="connected_sleeping">Connected to radio, but it is sleeping</string>
|
||||
|
|
Ładowanie…
Reference in New Issue