Support showing connected device in repeater tile
This commit is contained in:
@@ -22,8 +22,9 @@ class RepeaterTileService : KillableTileService() {
|
||||
|
||||
override fun onStartListening() {
|
||||
super.onStartListening()
|
||||
if (!RepeaterService.supported) updateTile()
|
||||
else bindService(Intent(this, RepeaterService::class.java), this, Context.BIND_AUTO_CREATE)
|
||||
if (RepeaterService.supported) {
|
||||
bindService(Intent(this, RepeaterService::class.java), this, Context.BIND_AUTO_CREATE)
|
||||
} else updateTile()
|
||||
}
|
||||
|
||||
override fun onStopListening() {
|
||||
@@ -57,6 +58,7 @@ class RepeaterTileService : KillableTileService() {
|
||||
|
||||
private fun updateTile(group: WifiP2pGroup? = binder?.group) {
|
||||
qsTile?.run {
|
||||
subtitle(null)
|
||||
when ((binder ?: return).service.status) {
|
||||
RepeaterService.Status.IDLE -> {
|
||||
state = Tile.STATE_INACTIVE
|
||||
@@ -65,6 +67,9 @@ class RepeaterTileService : KillableTileService() {
|
||||
RepeaterService.Status.ACTIVE -> {
|
||||
state = Tile.STATE_ACTIVE
|
||||
label = group?.networkName
|
||||
val size = group?.clientList?.size ?: 0
|
||||
if (size > 0) subtitle(resources.getQuantityString(
|
||||
R.plurals.quick_settings_hotspot_secondary_label_num_devices, size, size))
|
||||
}
|
||||
else -> { // STARTING or DESTROYED, which should never occur
|
||||
state = Tile.STATE_UNAVAILABLE
|
||||
|
||||
Reference in New Issue
Block a user