-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
968 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* | ||
* * Copyright (c) BlazeCode / Ralf Lehmann, 2022. | ||
* | ||
*/ | ||
|
||
package com.blazecode.tsviewer.util.wear | ||
|
||
import android.content.Context | ||
import com.google.android.gms.wearable.PutDataMapRequest | ||
import com.google.android.gms.wearable.Wearable | ||
|
||
class WearDataManager(val context: Context) { | ||
|
||
private val dataClient by lazy { Wearable.getDataClient(context) } | ||
|
||
companion object { | ||
private const val CLIENTS_PATH = "/clients" | ||
private const val CLIENT_LIST_KEY = "clientlist" | ||
private const val TIME_MILLIS = "timeMillis" | ||
} | ||
|
||
fun sendClientList(clientList: MutableList<String>) { | ||
var clientArray: Array<String> = arrayOf() | ||
for (client in clientList) { | ||
clientArray += client | ||
} | ||
|
||
val request = PutDataMapRequest.create(CLIENTS_PATH).apply { | ||
dataMap.putStringArray(CLIENT_LIST_KEY, clientArray) | ||
dataMap.putLong(TIME_MILLIS, System.currentTimeMillis()) | ||
} | ||
.asPutDataRequest() | ||
.setUrgent() | ||
|
||
val result = dataClient.putDataItem(request) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/blazecode/tsviewer/util/wear/WearableListenerService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* | ||
* * Copyright (c) BlazeCode / Ralf Lehmann, 2022. | ||
* | ||
*/ | ||
|
||
package com.blazecode.tsviewer.util.wear | ||
|
||
import android.content.Intent | ||
import com.blazecode.tsviewer.MainActivity | ||
import com.google.android.gms.wearable.DataEventBuffer | ||
import com.google.android.gms.wearable.DataMapItem | ||
import com.google.android.gms.wearable.WearableListenerService | ||
|
||
class WearableListenerService: WearableListenerService() { | ||
|
||
companion object { | ||
const val LAUNCH_PATH = "/start-activity" | ||
private const val LAUNCH_KEY = "startActivity" | ||
} | ||
|
||
override fun onDataChanged(dataEvents: DataEventBuffer) { | ||
super.onDataChanged(dataEvents) | ||
|
||
dataEvents.forEach { event -> | ||
event.dataItem.also { item -> | ||
if (item.uri.path!!.compareTo(LAUNCH_PATH) == 0) { | ||
DataMapItem.fromDataItem(item).dataMap.apply { | ||
|
||
this@WearableListenerService.startActivity( | ||
Intent(this@WearableListenerService, MainActivity::class.java) | ||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ dependencyResolutionManagement { | |
} | ||
rootProject.name = "TSViewer" | ||
include ':app' | ||
include ':wear' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'kotlin-parcelize' | ||
} | ||
|
||
android { | ||
namespace 'com.blazecode.tsviewer' | ||
compileSdkVersion 33 | ||
|
||
defaultConfig { | ||
applicationId "com.blazecode.tsviewer" | ||
minSdkVersion 26 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
vectorDrawables { | ||
useSupportLibrary true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
debug { | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion '1.1.1' | ||
} | ||
packagingOptions { | ||
resources { | ||
excludes += '/META-INF/{AL2.0,LGPL2.1}' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.9.0' | ||
implementation 'com.google.android.gms:play-services-wearable:18.0.0' | ||
implementation 'androidx.percentlayout:percentlayout:1.0.0' | ||
implementation 'androidx.legacy:legacy-support-v4:1.0.0' | ||
implementation 'androidx.recyclerview:recyclerview:1.2.1' | ||
implementation "androidx.compose.ui:ui:$compose_version" | ||
implementation "androidx.wear.compose:compose-material:$wear_compose_version" | ||
implementation "androidx.wear.compose:compose-foundation:$wear_compose_version" | ||
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" | ||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' | ||
implementation 'androidx.activity:activity-compose:1.6.1' | ||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" | ||
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" | ||
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" | ||
|
||
// COMPLICATIONS | ||
implementation "androidx.wear.watchface:watchface-complications-data-source-ktx:1.1.1" | ||
|
||
//DATA STORE | ||
implementation("androidx.datastore:datastore-preferences:1.0.0") | ||
|
||
// NAVIGATION | ||
implementation("androidx.navigation:navigation-compose:2.5.3") | ||
implementation "com.google.accompanist:accompanist-navigation-animation:0.27.0" | ||
} |
Oops, something went wrong.