Skip to content

Commit ca49a88

Browse files
Run ktlintFormat commit what can be auto-fixed
1 parent 85256bf commit ca49a88

File tree

255 files changed

+9681
-6971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+9681
-6971
lines changed

android/app/build.gradle.kts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ if (localPropertiesFile.exists()) {
1919
}
2020
}
2121

22-
val flutterRoot = localProperties.getProperty("flutter.sdk")
22+
val flutterRoot =
23+
localProperties.getProperty("flutter.sdk")
2324
?: throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
2425

2526
val flutterVersionCode = localProperties.getProperty("flutter.versionCode") ?: "1"
2627
val flutterVersionName = localProperties.getProperty("flutter.versionName") ?: "1.0"
27-
//apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
28+
// apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2829
apply(from = "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle")
2930

3031
android {
@@ -75,7 +76,11 @@ android {
7576
buildTypes {
7677
getByName("release") {
7778
isMinifyEnabled = true
78-
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", rootProject.file("shared/androidMain/proguard-rules.pro"))
79+
proguardFiles(
80+
getDefaultProguardFile("proguard-android-optimize.txt"),
81+
"proguard-rules.pro",
82+
rootProject.file("shared/androidMain/proguard-rules.pro")
83+
)
7984
signingConfig = signingConfigs.getByName("release")
8085
}
8186
getByName("debug") {
@@ -104,11 +109,12 @@ android {
104109

105110
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
106111
kotlinOptions {
107-
freeCompilerArgs = listOf(
112+
freeCompilerArgs =
113+
listOf(
108114
"-opt-in=kotlin.RequiresOptIn",
109115
"-opt-in=kotlin.ExperimentalUnsignedTypes",
110116
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
111-
)
117+
)
112118
}
113119
}
114120

android/app/src/androidTest/kotlin/io/rebble/cobble/shared/js/WebViewJsRunnerTest.kt

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import org.junit.Test
1414
import java.io.File
1515

1616
class WebViewJsRunnerTest {
17-
1817
private lateinit var context: Context
19-
private val json = Json {ignoreUnknownKeys = true}
18+
private val json = Json { ignoreUnknownKeys = true }
2019
private val coroutineScope = CoroutineScope(Dispatchers.Default)
20+
2121
@Before
2222
fun setUp() {
2323
context = InstrumentationRegistry.getInstrumentation().targetContext
@@ -39,46 +39,55 @@ class WebViewJsRunnerTest {
3939
}
4040

4141
@Test
42-
fun test() = runBlocking {
43-
val appInfo: PbwAppInfo = json.decodeFromString(
44-
"""
45-
{
46-
"targetPlatforms": [
47-
"aplite",
48-
"basalt",
49-
"chalk",
50-
"diorite"
51-
],
52-
"projectType": "native",
53-
"messageKeys": {},
54-
"companyName": "ttmm",
55-
"enableMultiJS": true,
56-
"versionLabel": "2.12",
57-
"longName": "ttmmbrn",
58-
"shortName": "ttmmbrn",
59-
"name": "ttmmbrn",
60-
"sdkVersion": "3",
61-
"displayName": "ttmmbrn",
62-
"uuid": "c4c60c62-2c22-4ad7-aef4-cad9481da58b",
63-
"appKeys": {},
64-
"capabilities": [
65-
"health",
66-
"location",
67-
"configurable"
68-
],
69-
"watchapp": {
70-
"watchface": true
71-
},
72-
"resources": {
73-
"media": []
42+
fun test() =
43+
runBlocking {
44+
val appInfo: PbwAppInfo =
45+
json.decodeFromString(
46+
"""
47+
{
48+
"targetPlatforms": [
49+
"aplite",
50+
"basalt",
51+
"chalk",
52+
"diorite"
53+
],
54+
"projectType": "native",
55+
"messageKeys": {},
56+
"companyName": "ttmm",
57+
"enableMultiJS": true,
58+
"versionLabel": "2.12",
59+
"longName": "ttmmbrn",
60+
"shortName": "ttmmbrn",
61+
"name": "ttmmbrn",
62+
"sdkVersion": "3",
63+
"displayName": "ttmmbrn",
64+
"uuid": "c4c60c62-2c22-4ad7-aef4-cad9481da58b",
65+
"appKeys": {},
66+
"capabilities": [
67+
"health",
68+
"location",
69+
"configurable"
70+
],
71+
"watchapp": {
72+
"watchface": true
73+
},
74+
"resources": {
75+
"media": []
76+
}
7477
}
75-
}
76-
""".trimIndent()
77-
)
78-
val printTestPath = assetsToSdcard("print_test.js")
79-
val webViewJsRunner = WebViewJsRunner(context, PebbleDevice(null, "dummy"), coroutineScope, appInfo, printTestPath)
80-
webViewJsRunner.start()
81-
delay(1000)
82-
webViewJsRunner.stop()
83-
}
78+
""".trimIndent()
79+
)
80+
val printTestPath = assetsToSdcard("print_test.js")
81+
val webViewJsRunner =
82+
WebViewJsRunner(
83+
context,
84+
PebbleDevice(null, "dummy"),
85+
coroutineScope,
86+
appInfo,
87+
printTestPath
88+
)
89+
webViewJsRunner.start()
90+
delay(1000)
91+
webViewJsRunner.stop()
92+
}
8493
}

android/app/src/main/kotlin/io/rebble/cobble/CobbleApplication.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class CobbleApplication : FlutterApplication() {
3333
private fun beginConnectingToDefaultWatch() {
3434
component.initServiceLifecycleControl()
3535

36-
val macAddressOfDefaultPebble = component.createPairedStorage()
36+
val macAddressOfDefaultPebble =
37+
component.createPairedStorage()
3738
.getMacAddressOfDefaultPebble()
3839
if (macAddressOfDefaultPebble != null) {
3940
component.createConnectionLooper().connectToWatch(macAddressOfDefaultPebble)

android/app/src/main/kotlin/io/rebble/cobble/FlutterMainActivity.kt

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ class FlutterMainActivity : FlutterActivity() {
3535
var intentCallback: ((Intent) -> Unit)? = null
3636

3737
val activityResultCallbacks = ArrayMap<Int, (resultCode: Int, data: Intent?) -> Unit>()
38-
val activityPermissionCallbacks = ArrayMap<
38+
val activityPermissionCallbacks =
39+
ArrayMap<
3940
Int,
40-
(permissions: Array<String>, grantResults: IntArray) -> Unit>()
41-
42-
override fun onRequestPermissionsResult(requestCode: Int,
43-
permissions: Array<String>, grantResults: IntArray) {
41+
(permissions: Array<String>, grantResults: IntArray) -> Unit
42+
>()
43+
44+
override fun onRequestPermissionsResult(
45+
requestCode: Int,
46+
permissions: Array<String>,
47+
grantResults: IntArray
48+
) {
4449
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
4550

4651
activityPermissionCallbacks[requestCode]?.invoke(permissions, grantResults)
@@ -56,32 +61,54 @@ class FlutterMainActivity : FlutterActivity() {
5661
"pebble" -> {
5762
when (data.host) {
5863
"custom-boot-config-url" -> {
59-
val prefs = getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
64+
val prefs =
65+
getSharedPreferences(
66+
"FlutterSharedPreferences",
67+
Context.MODE_PRIVATE
68+
)
6069
try {
6170
val boot = URI.create(data.pathSegments[0])
6271

63-
val dialogClickListener = DialogInterface.OnClickListener { dialog, which ->
64-
when (which) {
65-
DialogInterface.BUTTON_POSITIVE -> {
66-
prefs.edit().putString("flutter.boot", boot.toString()).apply()
67-
Toast.makeText(context, "Updated boot URL: $boot", Toast.LENGTH_LONG).show()
68-
bootIntentCallback?.invoke(true)
69-
}
70-
71-
DialogInterface.BUTTON_NEGATIVE -> {
72-
Toast.makeText(context, "Cancelled boot URL change", Toast.LENGTH_SHORT).show()
73-
bootIntentCallback?.invoke(false)
72+
val dialogClickListener =
73+
DialogInterface.OnClickListener { dialog, which ->
74+
when (which) {
75+
DialogInterface.BUTTON_POSITIVE -> {
76+
prefs.edit().putString(
77+
"flutter.boot",
78+
boot.toString()
79+
).apply()
80+
Toast.makeText(
81+
context,
82+
"Updated boot URL: $boot",
83+
Toast.LENGTH_LONG
84+
).show()
85+
bootIntentCallback?.invoke(true)
86+
}
87+
88+
DialogInterface.BUTTON_NEGATIVE -> {
89+
Toast.makeText(
90+
context,
91+
"Cancelled boot URL change",
92+
Toast.LENGTH_SHORT
93+
).show()
94+
bootIntentCallback?.invoke(false)
95+
}
7496
}
7597
}
76-
}
7798

7899
AlertDialog.Builder(context)
79-
.setTitle(R.string.bootUrlWarningTitle)
80-
.setMessage(getString(R.string.bootUrlWarningBody, boot.toString()))
81-
.setPositiveButton("Allow", dialogClickListener)
82-
.setNegativeButton("Deny", dialogClickListener).show()
100+
.setTitle(R.string.bootUrlWarningTitle)
101+
.setMessage(
102+
getString(R.string.bootUrlWarningBody, boot.toString())
103+
)
104+
.setPositiveButton("Allow", dialogClickListener)
105+
.setNegativeButton("Deny", dialogClickListener).show()
83106
} catch (e: IllegalArgumentException) {
84-
Toast.makeText(this, "Boot URL not updated, was invalid", Toast.LENGTH_LONG).show()
107+
Toast.makeText(
108+
this,
109+
"Boot URL not updated, was invalid",
110+
Toast.LENGTH_LONG
111+
).show()
85112
}
86113
}
87114
}
@@ -103,7 +130,8 @@ class FlutterMainActivity : FlutterActivity() {
103130

104131
override fun onCreate(savedInstanceState: Bundle?) {
105132
val injectionComponent = (applicationContext as CobbleApplication).component
106-
val activityComponent = injectionComponent.createFlutterActivitySubcomponentFactory()
133+
val activityComponent =
134+
injectionComponent.createFlutterActivitySubcomponentFactory()
107135
.create(this)
108136

109137
coroutineScope = lifecycleScope + injectionComponent.createExceptionHandler()
@@ -113,21 +141,24 @@ class FlutterMainActivity : FlutterActivity() {
113141
// Bridges need to be created after super.onCreate() to ensure
114142
// flutter stuff is ready
115143
flutterBridges = activityComponent.createCommonBridges() +
116-
activityComponent.createUiBridges()
144+
activityComponent.createUiBridges()
117145

118146
startAdditionalServices()
119147

120148
if (!hasNotificationPostingPermission()) {
121149
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
122-
requestPermissions(arrayOf(android.Manifest.permission.POST_NOTIFICATIONS), REQUEST_CODE_NOTIFICATIONS_POST)
150+
requestPermissions(
151+
arrayOf(android.Manifest.permission.POST_NOTIFICATIONS),
152+
REQUEST_CODE_NOTIFICATIONS_POST
153+
)
123154
}
124155
}
125156

126157
handleIntent(intent)
127158
}
128159

129160
override fun onDestroy() {
130-
//closeDatabase()
161+
// closeDatabase()
131162
super.onDestroy()
132163
}
133164

@@ -144,7 +175,6 @@ class FlutterMainActivity : FlutterActivity() {
144175
val inCallServiceIntent = Intent(this, InCallService::class.java)
145176
startService(inCallServiceIntent)
146177

147-
148178
/*if (context.hasNotificationAccessPermission()) {
149179
NotificationListenerService.requestRebind(
150180
NotificationListener.getComponentName(context)
@@ -157,7 +187,11 @@ class FlutterMainActivity : FlutterActivity() {
157187
handleIntent(intent)
158188
}
159189

160-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
190+
override fun onActivityResult(
191+
requestCode: Int,
192+
resultCode: Int,
193+
data: Intent?
194+
) {
161195
super.onActivityResult(requestCode, resultCode, data)
162196

163197
activityResultCallbacks[requestCode]?.invoke(resultCode, data)
@@ -166,4 +200,4 @@ class FlutterMainActivity : FlutterActivity() {
166200
public override fun getFlutterEngine(): FlutterEngine? {
167201
return super.getFlutterEngine()
168202
}
169-
}
203+
}

android/app/src/main/kotlin/io/rebble/cobble/MainActivity.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.rebble.cobble
22

33
import android.content.Intent
4-
import android.media.MediaCodec
5-
import android.media.MediaCodecList
6-
import android.media.MediaFormat
74
import android.net.Uri
85
import android.os.Bundle
96
import androidx.activity.compose.setContent
@@ -14,18 +11,12 @@ import androidx.core.view.WindowCompat
1411
import androidx.lifecycle.lifecycleScope
1512
import androidx.navigation.NavHostController
1613
import androidx.navigation.compose.rememberNavController
17-
import androidx.navigation.navOptions
18-
import io.rebble.cobble.shared.AndroidPlatformContext
1914
import io.rebble.cobble.shared.Logging
20-
import io.rebble.cobble.shared.PlatformContext
2115
import io.rebble.cobble.shared.ui.nav.Routes
2216
import io.rebble.cobble.shared.ui.view.MainView
23-
import io.rebble.cobble.shared.util.File
2417
import kotlinx.coroutines.CoroutineScope
2518
import kotlinx.coroutines.plus
2619
import kotlinx.datetime.Clock
27-
import kotlinx.serialization.encodeToString
28-
import kotlinx.serialization.json.Json
2920

3021
class MainActivity : AppCompatActivity() {
3122
lateinit var coroutineScope: CoroutineScope
@@ -35,7 +26,8 @@ class MainActivity : AppCompatActivity() {
3526
super.onCreate(savedInstanceState)
3627

3728
val injectionComponent = (applicationContext as CobbleApplication).component
38-
val activityComponent = injectionComponent.createActivitySubcomponentFactory()
29+
val activityComponent =
30+
injectionComponent.createActivitySubcomponentFactory()
3931
.create(this)
4032
coroutineScope = lifecycleScope + injectionComponent.createExceptionHandler()
4133
val jobScheduler = injectionComponent.createAndroidJobScheduler()
@@ -60,9 +52,10 @@ class MainActivity : AppCompatActivity() {
6052
val uri = intent.data
6153
if (intent.scheme == "content" && uri != null) {
6254
Logging.d("Received pbw install intent")
63-
val fileSize = contentResolver.openAssetFileDescriptor(uri, "r").use {
64-
it?.length
65-
}
55+
val fileSize =
56+
contentResolver.openAssetFileDescriptor(uri, "r").use {
57+
it?.length
58+
}
6659
if (fileSize == null || fileSize > 10_000_000) {
6760
Logging.e("Invalid PBW file size, ignoring")
6861
return
@@ -77,7 +70,10 @@ class MainActivity : AppCompatActivity() {
7770
}
7871

7972
private fun cacheIncomingPbw(uri: Uri): Uri {
80-
val cached = applicationContext.cacheDir.resolve("local-${Clock.System.now().toEpochMilliseconds()}.pbw")
73+
val cached =
74+
applicationContext.cacheDir.resolve(
75+
"local-${Clock.System.now().toEpochMilliseconds()}.pbw"
76+
)
8177
cached.deleteOnExit()
8278
applicationContext.contentResolver.openInputStream(uri).use { input ->
8379
cached.outputStream().use { output ->

0 commit comments

Comments
 (0)