Skip to content

Commit

Permalink
update sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
dead8309 committed Jul 29, 2023
1 parent 8a55dd2 commit 1f216b4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 36 additions & 33 deletions app/src/main/java/kizzy/rpc/MyService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/token" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="181dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 1f216b4

Please sign in to comment.