-
Notifications
You must be signed in to change notification settings - Fork 12
/
WatchFaceConfigActivity.kt
46 lines (43 loc) · 1.67 KB
/
WatchFaceConfigActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.louiscad.composeoclockplayground
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.lifecycle.lifecycleScope
import androidx.wear.watchface.editor.EditorSession
import com.louiscad.composeoclockplayground.editor.WatchFaceConfigContent
import com.louiscad.composeoclockplayground.editor.WatchFaceEditorSession
import kotlinx.coroutines.*
import splitties.toast.longToast
import splitties.toast.toast
class WatchFaceConfigActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
lifecycleScope.launch(start = CoroutineStart.UNDISPATCHED) {
val activity = this@WatchFaceConfigActivity
val editorSession = WatchFaceEditorSession(
scope = lifecycleScope,
session = EditorSession.createOnWatchEditorSession(activity)
)
setContent {
WatchFaceConfigContent(
editorSession = editorSession,
)
}
if (Settings.System.canWrite(applicationContext)) {
toast("Can write settings!")
} else {
longToast( "Go into \"Advcanced\"…")
longToast( "and enable \"Modify system settings\"")
startActivity(
Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null)
)
)
}
}
}
}