From 1f216b457e5f4bab8c38048f1bb46a4a948ee535 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Sat, 29 Jul 2023 21:13:27 +0000 Subject: [PATCH] update sample app --- .idea/compiler.xml | 2 +- .idea/deploymentTargetDropDown.xml | 10 ++++ .idea/gradle.xml | 4 +- .idea/kotlinc.xml | 6 ++ .idea/migrations.xml | 10 ++++ .idea/misc.xml | 2 +- app/src/main/java/kizzy/rpc/MyService.kt | 69 ++++++++++++----------- app/src/main/res/layout/activity_main.xml | 8 +++ 8 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/migrations.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index f06701a..3f3c7c0 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,9 +4,8 @@ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..217e5c5 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index f454f30..46f3564 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -7,7 +7,7 @@ - + diff --git a/app/src/main/java/kizzy/rpc/MyService.kt b/app/src/main/java/kizzy/rpc/MyService.kt index 4046c2f..75e3120 100644 --- a/app/src/main/java/kizzy/rpc/MyService.kt +++ b/app/src/main/java/kizzy/rpc/MyService.kt @@ -7,13 +7,16 @@ import android.app.Service import android.content.Intent import android.os.IBinder import com.my.kizzyrpc.KizzyRPC -import com.my.kizzyrpc.model.Activity -import com.my.kizzyrpc.model.Assets -import com.my.kizzyrpc.model.Metadata -import com.my.kizzyrpc.model.Timestamps +import com.my.kizzyrpc.entities.presence.Activity +import com.my.kizzyrpc.entities.presence.Assets +import com.my.kizzyrpc.entities.presence.Metadata +import com.my.kizzyrpc.entities.presence.Timestamps +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.launch class MyService : Service() { - + val scope = CoroutineScope(SupervisorJob()) companion object { const val CHANNEL = "Discord RPC" const val START_ACTIVITY_ACTION = "START_ACTIVITY_ACTION" @@ -26,35 +29,35 @@ class MyService : Service() { token = intent?.getStringExtra("TOKEN") rpc = token?.let { KizzyRPC(it) } if (intent?.action.equals(START_ACTIVITY_ACTION)) { - rpc?.setActivity( - activity = Activity( - applicationId = "962990036020756480", - name = "hi", - details = "details", - state = "state", - type = 0, - timestamps = Timestamps( - start = System.currentTimeMillis(), - end = System.currentTimeMillis() + 500000 - ), - assets = Assets( - largeImage = "mp:attachments/973256105515974676/983674644823412798/unknown.png", - smallImage = "mp:attachments/973256105515974676/983674644823412798/unknown.png", - largeText = "large-image-text", - smallText = "small-image-text", - ), - buttons = listOf("Button 1", "Button 2"), - metadata = Metadata( - listOf( - "https://youtu.be/1yVm_M1sKBE", - "https://youtu.be/1yVm_M1sKBE", + scope.launch { + rpc?.setActivity( + activity = Activity( + applicationId = "962990036020756480", + name = "hi", + details = "details", + state = "state", + type = 0, + timestamps = Timestamps( + start = System.currentTimeMillis(), + end = System.currentTimeMillis() + 500000 + ), + assets = Assets( + largeImage = "mp:attachments/973256105515974676/983674644823412798/unknown.png", + smallImage = "mp:attachments/973256105515974676/983674644823412798/unknown.png", + largeText = "large-image-text", + smallText = "small-image-text", + ), + buttons = listOf("Button 1", "Button 2"), + metadata = Metadata( + listOf( + "https://youtu.be/1yVm_M1sKBE", + "https://youtu.be/1yVm_M1sKBE", + ) ) - ) - ), - status = "online", - since = System.currentTimeMillis() - ) - + ), + status = "online", + since = System.currentTimeMillis()) + } } notification() return super.onStartCommand(intent, flags, startId) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 47a7cc7..4dfb7d7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -30,4 +30,12 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@+id/token" /> +