mirror of
https://github.com/home-assistant/android
synced 2024-09-06 17:23:32 +00:00
More quick settings tiles when needed (#3185)
- Add a lot more quick settings tile services - Enable QS tile services only for tiles up to the highest tile # in use + 4, with a minimum of 12, to prevent long lists and make it work 'automagically'
This commit is contained in:
parent
4ff2fcca4b
commit
a9e3a5daee
|
@ -400,11 +400,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile2Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -412,11 +410,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile3Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -424,11 +420,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile4Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -436,11 +430,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile5Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -448,11 +440,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile6Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -460,11 +450,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile7Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -472,11 +460,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile8Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -484,11 +470,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile9Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -496,11 +480,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile10Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -508,11 +490,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile11Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -520,11 +500,9 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".qs.Tile12Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
|
@ -532,8 +510,315 @@
|
|||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile13Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_13"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile14Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_14"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile15Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_15"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile16Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_16"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile17Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_17"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile18Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_18"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile19Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_19"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile20Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_20"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile21Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_21"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile22Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_22"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile23Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_23"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile24Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_24"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile25Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_25"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile26Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_26"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile27Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_27"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile28Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_28"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile29Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_29"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile30Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_30"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile31Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_31"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile32Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_32"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile33Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_33"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile34Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_34"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile35Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_35"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile36Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_36"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile37Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_37"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile38Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_38"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile39Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_39"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".qs.Tile40Service"
|
||||
android:icon="@drawable/ic_stat_ic_notification"
|
||||
android:label="@string/tile_40"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile13Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_13"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile14Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_14"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile15Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_15"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile16Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_16"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile17Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_17"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile18Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_18"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile19Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_19"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile20Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_20"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile21Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_21"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile22Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_22"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile23Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_23"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile24Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_24"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile25Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_25"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile26Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_26"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile27Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_27"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile28Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_28"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile29Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_29"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile30Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_30"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile31Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_31"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile32Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_32"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile33Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_33"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile34Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_34"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile35Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_35"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile36Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_36"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile37Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_37"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile38Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_38"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile39Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_39"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.homeassistant.companion.android.qs
|
||||
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class Tile40Service : TileExtensions() {
|
||||
|
||||
companion object {
|
||||
const val TILE_ID = "tile_40"
|
||||
}
|
||||
|
||||
override fun getTile(): Tile? {
|
||||
return if (qsTile != null)
|
||||
qsTile
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun getTileId(): String {
|
||||
return TILE_ID
|
||||
}
|
||||
}
|
|
@ -30,13 +30,17 @@ import io.homeassistant.companion.android.common.data.integration.IntegrationRep
|
|||
import io.homeassistant.companion.android.common.data.integration.getIcon
|
||||
import io.homeassistant.companion.android.database.qs.TileDao
|
||||
import io.homeassistant.companion.android.database.qs.TileEntity
|
||||
import io.homeassistant.companion.android.database.qs.getHighestInUse
|
||||
import io.homeassistant.companion.android.database.qs.isSetup
|
||||
import io.homeassistant.companion.android.database.qs.numberedId
|
||||
import io.homeassistant.companion.android.settings.SettingsActivity
|
||||
import io.homeassistant.companion.android.settings.qs.updateActiveTileServices
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
import io.homeassistant.companion.android.common.R as commonR
|
||||
|
@ -87,7 +91,7 @@ abstract class TileExtensions : TileService() {
|
|||
super.onTileRemoved()
|
||||
Log.d(TAG, "Tile: ${getTileId()} removed")
|
||||
handleInject()
|
||||
mainScope.launch {
|
||||
runBlocking {
|
||||
setTileAdded(getTileId(), false)
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +283,10 @@ abstract class TileExtensions : TileService() {
|
|||
)
|
||||
} // else if it doesn't exist and is removed we don't have to save anything
|
||||
}
|
||||
|
||||
val highestInUse = tileDao.getHighestInUse()?.numberedId ?: 0
|
||||
Log.d(TAG, "Highest tile in use: $highestInUse")
|
||||
updateActiveTileServices(highestInUse, applicationContext)
|
||||
}
|
||||
|
||||
private fun getTileIcon(tileIconId: Int?, entity: Entity<*>?, context: Context): Bitmap? {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.homeassistant.companion.android.settings.qs
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.app.StatusBarManager
|
||||
import android.content.ComponentName
|
||||
|
@ -28,13 +29,43 @@ import io.homeassistant.companion.android.common.data.integration.domain
|
|||
import io.homeassistant.companion.android.common.data.integration.getIcon
|
||||
import io.homeassistant.companion.android.database.qs.TileDao
|
||||
import io.homeassistant.companion.android.database.qs.TileEntity
|
||||
import io.homeassistant.companion.android.database.qs.getHighestInUse
|
||||
import io.homeassistant.companion.android.database.qs.isSetup
|
||||
import io.homeassistant.companion.android.database.qs.numberedId
|
||||
import io.homeassistant.companion.android.qs.Tile10Service
|
||||
import io.homeassistant.companion.android.qs.Tile11Service
|
||||
import io.homeassistant.companion.android.qs.Tile12Service
|
||||
import io.homeassistant.companion.android.qs.Tile13Service
|
||||
import io.homeassistant.companion.android.qs.Tile14Service
|
||||
import io.homeassistant.companion.android.qs.Tile15Service
|
||||
import io.homeassistant.companion.android.qs.Tile16Service
|
||||
import io.homeassistant.companion.android.qs.Tile17Service
|
||||
import io.homeassistant.companion.android.qs.Tile18Service
|
||||
import io.homeassistant.companion.android.qs.Tile19Service
|
||||
import io.homeassistant.companion.android.qs.Tile1Service
|
||||
import io.homeassistant.companion.android.qs.Tile20Service
|
||||
import io.homeassistant.companion.android.qs.Tile21Service
|
||||
import io.homeassistant.companion.android.qs.Tile22Service
|
||||
import io.homeassistant.companion.android.qs.Tile23Service
|
||||
import io.homeassistant.companion.android.qs.Tile24Service
|
||||
import io.homeassistant.companion.android.qs.Tile25Service
|
||||
import io.homeassistant.companion.android.qs.Tile26Service
|
||||
import io.homeassistant.companion.android.qs.Tile27Service
|
||||
import io.homeassistant.companion.android.qs.Tile28Service
|
||||
import io.homeassistant.companion.android.qs.Tile29Service
|
||||
import io.homeassistant.companion.android.qs.Tile2Service
|
||||
import io.homeassistant.companion.android.qs.Tile30Service
|
||||
import io.homeassistant.companion.android.qs.Tile31Service
|
||||
import io.homeassistant.companion.android.qs.Tile32Service
|
||||
import io.homeassistant.companion.android.qs.Tile33Service
|
||||
import io.homeassistant.companion.android.qs.Tile34Service
|
||||
import io.homeassistant.companion.android.qs.Tile35Service
|
||||
import io.homeassistant.companion.android.qs.Tile36Service
|
||||
import io.homeassistant.companion.android.qs.Tile37Service
|
||||
import io.homeassistant.companion.android.qs.Tile38Service
|
||||
import io.homeassistant.companion.android.qs.Tile39Service
|
||||
import io.homeassistant.companion.android.qs.Tile3Service
|
||||
import io.homeassistant.companion.android.qs.Tile40Service
|
||||
import io.homeassistant.companion.android.qs.Tile4Service
|
||||
import io.homeassistant.companion.android.qs.Tile5Service
|
||||
import io.homeassistant.companion.android.qs.Tile6Service
|
||||
|
@ -60,6 +91,50 @@ class ManageTilesViewModel @Inject constructor(
|
|||
|
||||
companion object {
|
||||
private const val TAG = "ManageTilesViewModel"
|
||||
|
||||
@SuppressLint("InlinedApi", "NewApi")
|
||||
val idToTileService = mapOf(
|
||||
Tile1Service.TILE_ID to Tile1Service::class.java,
|
||||
Tile2Service.TILE_ID to Tile2Service::class.java,
|
||||
Tile3Service.TILE_ID to Tile3Service::class.java,
|
||||
Tile4Service.TILE_ID to Tile4Service::class.java,
|
||||
Tile5Service.TILE_ID to Tile5Service::class.java,
|
||||
Tile6Service.TILE_ID to Tile6Service::class.java,
|
||||
Tile7Service.TILE_ID to Tile7Service::class.java,
|
||||
Tile8Service.TILE_ID to Tile8Service::class.java,
|
||||
Tile9Service.TILE_ID to Tile9Service::class.java,
|
||||
Tile10Service.TILE_ID to Tile10Service::class.java,
|
||||
Tile11Service.TILE_ID to Tile11Service::class.java,
|
||||
Tile12Service.TILE_ID to Tile12Service::class.java,
|
||||
Tile13Service.TILE_ID to Tile13Service::class.java,
|
||||
Tile14Service.TILE_ID to Tile14Service::class.java,
|
||||
Tile15Service.TILE_ID to Tile15Service::class.java,
|
||||
Tile16Service.TILE_ID to Tile16Service::class.java,
|
||||
Tile17Service.TILE_ID to Tile17Service::class.java,
|
||||
Tile18Service.TILE_ID to Tile18Service::class.java,
|
||||
Tile19Service.TILE_ID to Tile19Service::class.java,
|
||||
Tile20Service.TILE_ID to Tile20Service::class.java,
|
||||
Tile21Service.TILE_ID to Tile21Service::class.java,
|
||||
Tile22Service.TILE_ID to Tile22Service::class.java,
|
||||
Tile23Service.TILE_ID to Tile23Service::class.java,
|
||||
Tile24Service.TILE_ID to Tile24Service::class.java,
|
||||
Tile25Service.TILE_ID to Tile25Service::class.java,
|
||||
Tile26Service.TILE_ID to Tile26Service::class.java,
|
||||
Tile27Service.TILE_ID to Tile27Service::class.java,
|
||||
Tile28Service.TILE_ID to Tile28Service::class.java,
|
||||
Tile29Service.TILE_ID to Tile29Service::class.java,
|
||||
Tile30Service.TILE_ID to Tile30Service::class.java,
|
||||
Tile31Service.TILE_ID to Tile31Service::class.java,
|
||||
Tile32Service.TILE_ID to Tile32Service::class.java,
|
||||
Tile33Service.TILE_ID to Tile33Service::class.java,
|
||||
Tile34Service.TILE_ID to Tile34Service::class.java,
|
||||
Tile35Service.TILE_ID to Tile35Service::class.java,
|
||||
Tile36Service.TILE_ID to Tile36Service::class.java,
|
||||
Tile37Service.TILE_ID to Tile37Service::class.java,
|
||||
Tile38Service.TILE_ID to Tile38Service::class.java,
|
||||
Tile39Service.TILE_ID to Tile39Service::class.java,
|
||||
Tile40Service.TILE_ID to Tile40Service::class.java
|
||||
)
|
||||
}
|
||||
|
||||
lateinit var iconPack: IconPack
|
||||
|
@ -188,22 +263,12 @@ class ManageTilesViewModel @Inject constructor(
|
|||
)
|
||||
tileDao.add(tileData)
|
||||
|
||||
val highestInUse = tileDao.getHighestInUse()?.numberedId ?: 0
|
||||
updateActiveTileServices(highestInUse, app)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !selectedTileAdded) {
|
||||
val statusBarManager = app.getSystemService<StatusBarManager>()
|
||||
val service = when (selectedTile.id) {
|
||||
Tile2Service.TILE_ID -> Tile2Service::class.java
|
||||
Tile3Service.TILE_ID -> Tile3Service::class.java
|
||||
Tile4Service.TILE_ID -> Tile4Service::class.java
|
||||
Tile5Service.TILE_ID -> Tile5Service::class.java
|
||||
Tile6Service.TILE_ID -> Tile6Service::class.java
|
||||
Tile7Service.TILE_ID -> Tile7Service::class.java
|
||||
Tile8Service.TILE_ID -> Tile8Service::class.java
|
||||
Tile9Service.TILE_ID -> Tile9Service::class.java
|
||||
Tile10Service.TILE_ID -> Tile10Service::class.java
|
||||
Tile11Service.TILE_ID -> Tile11Service::class.java
|
||||
Tile12Service.TILE_ID -> Tile12Service::class.java
|
||||
else -> Tile1Service::class.java
|
||||
}
|
||||
val service = idToTileService[selectedTile.id] ?: Tile1Service::class.java
|
||||
val icon = selectedIconDrawable?.let {
|
||||
it.toBitmapOrNull(it.intrinsicWidth, it.intrinsicHeight)?.let { bitmap ->
|
||||
android.graphics.drawable.Icon.createWithBitmap(bitmap)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package io.homeassistant.companion.android.settings.qs
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import kotlin.math.min
|
||||
import io.homeassistant.companion.android.R as commonR
|
||||
|
||||
data class TileSlot(
|
||||
|
@ -17,3 +21,24 @@ fun loadTileSlots(resources: Resources): List<TileSlot> {
|
|||
val tileNameArray = resources.getStringArray(commonR.array.tile_name)
|
||||
return tileIdArray.zip(tileNameArray).map { (id, name) -> TileSlot(id, name) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables services for tiles to ensure that only the required number of tiles + a few more
|
||||
* are available, instead of all possible tiles.
|
||||
*/
|
||||
fun updateActiveTileServices(highestInUse: Int, context: Context) {
|
||||
val tileIdArray = context.resources.getStringArray(commonR.array.tile_ids)
|
||||
val packageManager = context.packageManager
|
||||
val activeTilesRequired = min(tileIdArray.size, highestInUse + 4)
|
||||
ManageTilesViewModel.idToTileService.toList().forEachIndexed { index, (_, service) ->
|
||||
packageManager.setComponentEnabledSetting(
|
||||
ComponentName(context, service),
|
||||
if (index < activeTilesRequired) {
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
} else {
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|
||||
},
|
||||
PackageManager.DONT_KILL_APP
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,34 @@
|
|||
<item>tile_10</item>
|
||||
<item>tile_11</item>
|
||||
<item>tile_12</item>
|
||||
<item>tile_13</item>
|
||||
<item>tile_14</item>
|
||||
<item>tile_15</item>
|
||||
<item>tile_16</item>
|
||||
<item>tile_17</item>
|
||||
<item>tile_18</item>
|
||||
<item>tile_19</item>
|
||||
<item>tile_20</item>
|
||||
<item>tile_21</item>
|
||||
<item>tile_22</item>
|
||||
<item>tile_23</item>
|
||||
<item>tile_24</item>
|
||||
<item>tile_25</item>
|
||||
<item>tile_26</item>
|
||||
<item>tile_27</item>
|
||||
<item>tile_28</item>
|
||||
<item>tile_29</item>
|
||||
<item>tile_30</item>
|
||||
<item>tile_31</item>
|
||||
<item>tile_32</item>
|
||||
<item>tile_33</item>
|
||||
<item>tile_34</item>
|
||||
<item>tile_35</item>
|
||||
<item>tile_36</item>
|
||||
<item>tile_37</item>
|
||||
<item>tile_38</item>
|
||||
<item>tile_39</item>
|
||||
<item>tile_40</item>
|
||||
</string-array>
|
||||
<string-array name="tile_name">
|
||||
<item>@string/tile_1</item>
|
||||
|
@ -37,5 +65,33 @@
|
|||
<item>@string/tile_10</item>
|
||||
<item>@string/tile_11</item>
|
||||
<item>@string/tile_12</item>
|
||||
<item>@string/tile_13</item>
|
||||
<item>@string/tile_14</item>
|
||||
<item>@string/tile_15</item>
|
||||
<item>@string/tile_16</item>
|
||||
<item>@string/tile_17</item>
|
||||
<item>@string/tile_18</item>
|
||||
<item>@string/tile_19</item>
|
||||
<item>@string/tile_20</item>
|
||||
<item>@string/tile_21</item>
|
||||
<item>@string/tile_22</item>
|
||||
<item>@string/tile_23</item>
|
||||
<item>@string/tile_24</item>
|
||||
<item>@string/tile_25</item>
|
||||
<item>@string/tile_26</item>
|
||||
<item>@string/tile_27</item>
|
||||
<item>@string/tile_28</item>
|
||||
<item>@string/tile_29</item>
|
||||
<item>@string/tile_30</item>
|
||||
<item>@string/tile_31</item>
|
||||
<item>@string/tile_32</item>
|
||||
<item>@string/tile_33</item>
|
||||
<item>@string/tile_34</item>
|
||||
<item>@string/tile_35</item>
|
||||
<item>@string/tile_36</item>
|
||||
<item>@string/tile_37</item>
|
||||
<item>@string/tile_38</item>
|
||||
<item>@string/tile_39</item>
|
||||
<item>@string/tile_40</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -11,6 +11,16 @@ interface TileDao {
|
|||
@Query("SELECT * FROM qs_tiles WHERE tileId = :tileId")
|
||||
suspend fun get(tileId: String): TileEntity?
|
||||
|
||||
@Query("SELECT * FROM qs_tiles")
|
||||
suspend fun getAll(): List<TileEntity>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun add(tileEntity: TileEntity)
|
||||
}
|
||||
|
||||
suspend fun TileDao.getHighestInUse(): TileEntity? {
|
||||
return getAll()
|
||||
.filter { it.added || it.isSetup }
|
||||
.sortedByDescending { it.tileId.split("_")[1].toInt() }
|
||||
.getOrNull(0)
|
||||
}
|
||||
|
|
|
@ -26,3 +26,6 @@ data class TileEntity(
|
|||
|
||||
val TileEntity.isSetup: Boolean
|
||||
get() = this.label.isNotBlank() && this.entityId.isNotBlank()
|
||||
|
||||
val TileEntity.numberedId: Int
|
||||
get() = this.tileId.split("_")[1].toInt()
|
||||
|
|
|
@ -744,9 +744,37 @@
|
|||
<string name="tile_10">Tile 10</string>
|
||||
<string name="tile_11">Tile 11</string>
|
||||
<string name="tile_12">Tile 12</string>
|
||||
<string name="tile_13">Tile 13</string>
|
||||
<string name="tile_14">Tile 14</string>
|
||||
<string name="tile_15">Tile 15</string>
|
||||
<string name="tile_16">Tile 16</string>
|
||||
<string name="tile_17">Tile 17</string>
|
||||
<string name="tile_18">Tile 18</string>
|
||||
<string name="tile_19">Tile 19</string>
|
||||
<string name="tile_2">Tile 2</string>
|
||||
<string name="tile_20">Tile 20</string>
|
||||
<string name="tile_21">Tile 21</string>
|
||||
<string name="tile_22">Tile 22</string>
|
||||
<string name="tile_23">Tile 23</string>
|
||||
<string name="tile_24">Tile 24</string>
|
||||
<string name="tile_25">Tile 25</string>
|
||||
<string name="tile_26">Tile 26</string>
|
||||
<string name="tile_27">Tile 27</string>
|
||||
<string name="tile_28">Tile 28</string>
|
||||
<string name="tile_29">Tile 29</string>
|
||||
<string name="tile_3">Tile 3</string>
|
||||
<string name="tile_30">Tile 30</string>
|
||||
<string name="tile_31">Tile 31</string>
|
||||
<string name="tile_32">Tile 32</string>
|
||||
<string name="tile_33">Tile 33</string>
|
||||
<string name="tile_34">Tile 34</string>
|
||||
<string name="tile_35">Tile 35</string>
|
||||
<string name="tile_36">Tile 36</string>
|
||||
<string name="tile_37">Tile 37</string>
|
||||
<string name="tile_38">Tile 38</string>
|
||||
<string name="tile_39">Tile 39</string>
|
||||
<string name="tile_4">Tile 4</string>
|
||||
<string name="tile_40">Tile 40</string>
|
||||
<string name="tile_5">Tile 5</string>
|
||||
<string name="tile_6">Tile 6</string>
|
||||
<string name="tile_7">Tile 7</string>
|
||||
|
|
Loading…
Reference in a new issue