Skip to content

Commit abecee7

Browse files
authored
Merge pull request #39 from SimpleAppProjects/develop
v1.14.0-r1
2 parents 727da9d + 0bb58d2 commit abecee7

File tree

6 files changed

+59
-59
lines changed

6 files changed

+59
-59
lines changed

mobile/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android {
2121
minSdkVersion rootProject.minSdkVersion
2222
targetSdkVersion rootProject.targetSdkVersion
2323
// NOTE: Version Code Format [TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)]
24-
versionCode 331914040
24+
versionCode 331914050
2525
versionName "1.14.0"
2626

2727
vectorDrawables.useSupportLibrary = true

mobile/src/main/java/com/thewizrd/simplewear/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MainActivity : AppCompatActivity() {
5555
.runOnCommit {
5656
isReadyToView = true
5757
}
58-
.commit()
58+
.commitAllowingStateLoss()
5959
}
6060
}
6161
}

mobile/src/main/java/com/thewizrd/simplewear/media/MediaControllerService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,8 @@ class MediaControllerService : Service(), MessageClient.OnMessageReceivedListene
765765
JSONParser.serializer(
766766
PositionState(
767767
durationMs,
768-
it.playbackState.position,
769-
it.playbackState.playbackSpeed
768+
it.playbackState?.position ?: 0,
769+
it.playbackState?.playbackSpeed ?: 1f
770770
),
771771
PositionState::class.java
772772
)

wear/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
minSdkVersion 26
1313
targetSdkVersion rootProject.targetSdkVersion
1414
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)
15-
versionCode 331914041
15+
versionCode 331914051
1616
versionName "1.14.0"
1717

1818
vectorDrawables.useSupportLibrary = true

wear/src/main/java/com/thewizrd/simplewear/wearable/tiles/DashboardTileMessenger.kt

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,22 @@ class DashboardTileMessenger(private val context: Context) :
147147
val connectedNodes = getConnectedNodes()
148148
mPhoneNodeWithApp = WearableHelper.pickBestNodeId(capabilityInfo.nodes)
149149

150-
if (mPhoneNodeWithApp == null) {
150+
mPhoneNodeWithApp?.let { node ->
151+
if (node.isNearby && connectedNodes.any { it.id == node.id }) {
152+
tileModel.setConnectionStatus(WearConnectionStatus.CONNECTED)
153+
} else {
154+
try {
155+
sendPing(node.id)
156+
tileModel.setConnectionStatus(WearConnectionStatus.CONNECTED)
157+
} catch (e: ApiException) {
158+
if (e.statusCode == WearableStatusCodes.TARGET_NODE_NOT_CONNECTED) {
159+
tileModel.setConnectionStatus(WearConnectionStatus.DISCONNECTED)
160+
} else {
161+
Logger.writeLine(Log.ERROR, e)
162+
}
163+
}
164+
}
165+
} ?: run {
151166
/*
152167
* If a device is disconnected from the wear network, capable nodes are empty
153168
*
@@ -163,21 +178,6 @@ class DashboardTileMessenger(private val context: Context) :
163178
WearConnectionStatus.APPNOTINSTALLED
164179
}
165180
)
166-
} else {
167-
if (mPhoneNodeWithApp!!.isNearby && connectedNodes.any { it.id == mPhoneNodeWithApp!!.id }) {
168-
tileModel.setConnectionStatus(WearConnectionStatus.CONNECTED)
169-
} else {
170-
try {
171-
sendPing(mPhoneNodeWithApp!!.id)
172-
tileModel.setConnectionStatus(WearConnectionStatus.CONNECTED)
173-
} catch (e: ApiException) {
174-
if (e.statusCode == WearableStatusCodes.TARGET_NODE_NOT_CONNECTED) {
175-
tileModel.setConnectionStatus(WearConnectionStatus.DISCONNECTED)
176-
} else {
177-
Logger.writeLine(Log.ERROR, e)
178-
}
179-
}
180-
}
181181
}
182182

183183
requestTileUpdate(context)
@@ -188,28 +188,12 @@ class DashboardTileMessenger(private val context: Context) :
188188
val connectedNodes = getConnectedNodes()
189189
mPhoneNodeWithApp = checkIfPhoneHasApp()
190190

191-
if (mPhoneNodeWithApp == null) {
192-
/*
193-
* If a device is disconnected from the wear network, capable nodes are empty
194-
*
195-
* No capable nodes can mean the app is not installed on the remote device or the
196-
* device is disconnected.
197-
*
198-
* Verify if we're connected to any nodes; if not, we're truly disconnected
199-
*/
200-
tileModel.setConnectionStatus(
201-
if (connectedNodes.isEmpty()) {
202-
WearConnectionStatus.DISCONNECTED
203-
} else {
204-
WearConnectionStatus.APPNOTINSTALLED
205-
}
206-
)
207-
} else {
208-
if (mPhoneNodeWithApp!!.isNearby && connectedNodes.any { it.id == mPhoneNodeWithApp!!.id }) {
191+
mPhoneNodeWithApp?.let { node ->
192+
if (node.isNearby && connectedNodes.any { it.id == node.id }) {
209193
tileModel.setConnectionStatus(WearConnectionStatus.CONNECTED)
210194
} else {
211195
try {
212-
sendPing(mPhoneNodeWithApp!!.id)
196+
sendPing(node.id)
213197
tileModel.setConnectionStatus(
214198
WearConnectionStatus.CONNECTED
215199
)
@@ -223,6 +207,22 @@ class DashboardTileMessenger(private val context: Context) :
223207
}
224208
}
225209
}
210+
} ?: run {
211+
/*
212+
* If a device is disconnected from the wear network, capable nodes are empty
213+
*
214+
* No capable nodes can mean the app is not installed on the remote device or the
215+
* device is disconnected.
216+
*
217+
* Verify if we're connected to any nodes; if not, we're truly disconnected
218+
*/
219+
tileModel.setConnectionStatus(
220+
if (connectedNodes.isEmpty()) {
221+
WearConnectionStatus.DISCONNECTED
222+
} else {
223+
WearConnectionStatus.APPNOTINSTALLED
224+
}
225+
)
226226
}
227227

228228
if (refreshTile) {

wear/src/main/java/com/thewizrd/simplewear/wearable/tiles/MediaPlayerTileMessenger.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -367,28 +367,12 @@ class MediaPlayerTileMessenger(private val context: Context) :
367367
val connectedNodes = getConnectedNodes()
368368
mPhoneNodeWithApp = checkIfPhoneHasApp()
369369

370-
if (mPhoneNodeWithApp == null) {
371-
/*
372-
* If a device is disconnected from the wear network, capable nodes are empty
373-
*
374-
* No capable nodes can mean the app is not installed on the remote device or the
375-
* device is disconnected.
376-
*
377-
* Verify if we're connected to any nodes; if not, we're truly disconnected
378-
*/
379-
tileModel.setConnectionStatus(
380-
if (connectedNodes.isEmpty()) {
381-
WearConnectionStatus.DISCONNECTED
382-
} else {
383-
WearConnectionStatus.APPNOTINSTALLED
384-
}
385-
)
386-
} else {
387-
if (mPhoneNodeWithApp!!.isNearby && connectedNodes.any { it.id == mPhoneNodeWithApp!!.id }) {
370+
mPhoneNodeWithApp?.let { node ->
371+
if (node.isNearby && connectedNodes.any { it.id == node.id }) {
388372
tileModel.setConnectionStatus(WearConnectionStatus.CONNECTED)
389373
} else {
390374
try {
391-
sendPing(mPhoneNodeWithApp!!.id)
375+
sendPing(node.id)
392376
tileModel.setConnectionStatus(
393377
WearConnectionStatus.CONNECTED
394378
)
@@ -402,6 +386,22 @@ class MediaPlayerTileMessenger(private val context: Context) :
402386
}
403387
}
404388
}
389+
} ?: run {
390+
/*
391+
* If a device is disconnected from the wear network, capable nodes are empty
392+
*
393+
* No capable nodes can mean the app is not installed on the remote device or the
394+
* device is disconnected.
395+
*
396+
* Verify if we're connected to any nodes; if not, we're truly disconnected
397+
*/
398+
tileModel.setConnectionStatus(
399+
if (connectedNodes.isEmpty()) {
400+
WearConnectionStatus.DISCONNECTED
401+
} else {
402+
WearConnectionStatus.APPNOTINSTALLED
403+
}
404+
)
405405
}
406406

407407
if (refreshTile) {

0 commit comments

Comments
 (0)