Wear: tile add msg wear control disabled
This commit is contained in:
parent
6321758634
commit
ad440740d2
2 changed files with 16 additions and 3 deletions
|
@ -77,12 +77,14 @@ abstract open class TileBase : TileService() {
|
||||||
): ListenableFuture<Tile> = serviceScope.future {
|
): ListenableFuture<Tile> = serviceScope.future {
|
||||||
Log.i(TAG, "onTileRequest: ")
|
Log.i(TAG, "onTileRequest: ")
|
||||||
val actionsSelected = getSelectedActions()
|
val actionsSelected = getSelectedActions()
|
||||||
|
val wearControlEnabled = hasWearControl()
|
||||||
|
|
||||||
Tile.Builder()
|
Tile.Builder()
|
||||||
.setResourcesVersion(resourceVersion)
|
.setResourcesVersion(resourceVersion)
|
||||||
.setTimeline(
|
.setTimeline(
|
||||||
Timeline.Builder().addTimelineEntry(
|
Timeline.Builder().addTimelineEntry(
|
||||||
TimelineEntry.Builder().setLayout(
|
TimelineEntry.Builder().setLayout(
|
||||||
Layout.Builder().setRoot(layout(actionsSelected, requestParams.deviceParameters!!)).build()
|
Layout.Builder().setRoot(layout(wearControlEnabled, actionsSelected, requestParams.deviceParameters!!)).build()
|
||||||
).build()
|
).build()
|
||||||
).build()
|
).build()
|
||||||
)
|
)
|
||||||
|
@ -124,7 +126,12 @@ abstract open class TileBase : TileService() {
|
||||||
.addContent(action(action2, deviceParameters))
|
.addContent(action(action2, deviceParameters))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun layout(actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement {
|
private fun layout(enabled: Boolean, actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement {
|
||||||
|
if (!enabled) {
|
||||||
|
return Text.Builder()
|
||||||
|
.setText(resources.getString(R.string.wear_control_not_enabled))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
if (actions.isNotEmpty()) {
|
if (actions.isNotEmpty()) {
|
||||||
val b = Column.Builder()
|
val b = Column.Builder()
|
||||||
if (actions.size == 1 || actions.size == 3) {
|
if (actions.size == 1 || actions.size == 3) {
|
||||||
|
@ -213,6 +220,11 @@ abstract open class TileBase : TileService() {
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
private fun hasWearControl(): Boolean {
|
||||||
|
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
return sharedPrefs.getBoolean("wearcontrol", false)
|
||||||
|
}
|
||||||
|
|
||||||
private fun getSelectedActions(): List<Action> {
|
private fun getSelectedActions(): List<Action> {
|
||||||
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
setDefaultSettings(sharedPrefs)
|
setDefaultSettings(sharedPrefs)
|
||||||
|
|
|
@ -172,6 +172,7 @@
|
||||||
<string name="temp_target_manual">Manual</string>
|
<string name="temp_target_manual">Manual</string>
|
||||||
<string name="temp_target_cancel">Cancel</string>
|
<string name="temp_target_cancel">Cancel</string>
|
||||||
<string name="tile_none">None</string>
|
<string name="tile_none">None</string>
|
||||||
<string name="tile_no_config">No tile config available</string>
|
<string name="tile_no_config">No config available</string>
|
||||||
|
<string name="wear_control_not_enabled">Wear control disabled</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue