Skip to content

Commit ab34da7

Browse files
committed
DashboardTile: update to load state from cache
1 parent 35f6e94 commit ab34da7

File tree

20 files changed

+853
-939
lines changed

20 files changed

+853
-939
lines changed

shared_resources/src/main/java/com/thewizrd/shared_resources/actions/Action.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,22 @@ abstract class Action(_action: Actions) {
6060
}
6161
}
6262
}
63+
64+
override fun equals(other: Any?): Boolean {
65+
if (this === other) return true
66+
if (other !is Action) return false
67+
68+
if (isActionSuccessful != other.isActionSuccessful) return false
69+
if (actionStatus != other.actionStatus) return false
70+
if (actionType != other.actionType) return false
71+
72+
return true
73+
}
74+
75+
override fun hashCode(): Int {
76+
var result = isActionSuccessful.hashCode()
77+
result = 31 * result + actionStatus.hashCode()
78+
result = 31 * result + actionType.hashCode()
79+
return result
80+
}
6381
}
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
package com.thewizrd.shared_resources.actions
22

3-
class BatteryStatus(var batteryLevel: Int, var isCharging: Boolean)
3+
class BatteryStatus(var batteryLevel: Int, var isCharging: Boolean) {
4+
override fun equals(other: Any?): Boolean {
5+
if (this === other) return true
6+
if (other !is BatteryStatus) return false
7+
8+
if (batteryLevel != other.batteryLevel) return false
9+
if (isCharging != other.isCharging) return false
10+
11+
return true
12+
}
13+
14+
override fun hashCode(): Int {
15+
var result = batteryLevel
16+
result = 31 * result + isCharging.hashCode()
17+
return result
18+
}
19+
}

shared_resources/src/main/java/com/thewizrd/shared_resources/actions/MultiChoiceAction.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,17 @@ class MultiChoiceAction : Action {
3636
else -> 1
3737
}
3838
}
39+
40+
override fun equals(other: Any?): Boolean {
41+
if (this === other) return true
42+
if (other !is MultiChoiceAction) return false
43+
44+
if (value != other.value) return false
45+
46+
return true
47+
}
48+
49+
override fun hashCode(): Int {
50+
return value
51+
}
3952
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
package com.thewizrd.shared_resources.actions
22

3-
class NormalAction(action: Actions) : Action(action)
3+
class NormalAction(action: Actions) : Action(action) {
4+
override fun equals(other: Any?): Boolean {
5+
if (this === other) return true
6+
if (other !is NormalAction) return false
7+
if (!super.equals(other)) return false
8+
return true
9+
}
10+
11+
override fun hashCode(): Int {
12+
return super.hashCode()
13+
}
14+
}

shared_resources/src/main/java/com/thewizrd/shared_resources/actions/TimedAction.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,22 @@ class TimedAction(var timeInMillis: Long, val action: Action) : Action(Actions.T
1919
}
2020
}
2121
}
22+
23+
override fun equals(other: Any?): Boolean {
24+
if (this === other) return true
25+
if (other !is TimedAction) return false
26+
if (!super.equals(other)) return false
27+
28+
if (timeInMillis != other.timeInMillis) return false
29+
if (action != other.action) return false
30+
31+
return true
32+
}
33+
34+
override fun hashCode(): Int {
35+
var result = super.hashCode()
36+
result = 31 * result + timeInMillis.hashCode()
37+
result = 31 * result + action.hashCode()
38+
return result
39+
}
2240
}

shared_resources/src/main/java/com/thewizrd/shared_resources/actions/ToggleAction.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,17 @@ class ToggleAction(action: Actions, var isEnabled: Boolean) : Action(action) {
44
init {
55
isActionSuccessful = true
66
}
7+
8+
override fun equals(other: Any?): Boolean {
9+
if (this === other) return true
10+
if (other !is ToggleAction) return false
11+
12+
if (isEnabled != other.isEnabled) return false
13+
14+
return true
15+
}
16+
17+
override fun hashCode(): Int {
18+
return isEnabled.hashCode()
19+
}
720
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
package com.thewizrd.shared_resources.actions
22

3-
open class ValueAction(action: Actions, var direction: ValueDirection) : Action(action)
3+
open class ValueAction(action: Actions, var direction: ValueDirection) : Action(action) {
4+
override fun equals(other: Any?): Boolean {
5+
if (this === other) return true
6+
if (other !is ValueAction) return false
7+
8+
if (direction != other.direction) return false
9+
10+
return true
11+
}
12+
13+
override fun hashCode(): Int {
14+
return direction.hashCode()
15+
}
16+
}
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
package com.thewizrd.shared_resources.actions
22

3-
class VolumeAction(var valueDirection: ValueDirection, var streamType: AudioStreamType?) : ValueAction(Actions.VOLUME, valueDirection)
3+
class VolumeAction(var valueDirection: ValueDirection, var streamType: AudioStreamType?) :
4+
ValueAction(Actions.VOLUME, valueDirection) {
5+
override fun equals(other: Any?): Boolean {
6+
if (this === other) return true
7+
if (other !is VolumeAction) return false
8+
if (!super.equals(other)) return false
9+
10+
if (valueDirection != other.valueDirection) return false
11+
if (streamType != other.streamType) return false
12+
13+
return true
14+
}
15+
16+
override fun hashCode(): Int {
17+
var result = super.hashCode()
18+
result = 31 * result + valueDirection.hashCode()
19+
result = 31 * result + (streamType?.hashCode() ?: 0)
20+
return result
21+
}
22+
}

wear/proguard-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
# Application classes that will be serialized/deserialized over Gson
3636
-keep class com.thewizrd.simplewear.datastore.media.MediaDataCache { *; }
37+
-keep class com.thewizrd.simplewear.datastore.dashboard.DashboardDataCache { *; }
3738

3839
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
3940
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)

wear/src/main/AndroidManifest.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
android:scheme="wear"
141141
android:path="/media/playback_state/bridge" />
142142

143+
<!-- Media Tile -->
143144
<data
144145
android:host="*"
145146
android:scheme="wear"
@@ -160,6 +161,20 @@
160161
android:host="*"
161162
android:scheme="wear"
162163
android:path="/media/app/info" />
164+
165+
<!-- Dashboard Tile -->
166+
<data
167+
android:host="*"
168+
android:scheme="wear"
169+
android:path="/status/wifi" />
170+
<data
171+
android:host="*"
172+
android:scheme="wear"
173+
android:path="/status/battery" />
174+
<data
175+
android:host="*"
176+
android:scheme="wear"
177+
android:path="/actions" />
163178
</intent-filter>
164179
</service>
165180

0 commit comments

Comments
 (0)