Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Jun 15, 2024
1 parent 3122217 commit e10cf9b
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MainActivity : FlutterActivity() {
val code = data.getQueryParameter("code")
val state = data.getQueryParameter("state")
val error = data.getQueryParameter("error")
oauthIntentCallback?.invoke(code, state, error);
oauthIntentCallback?.invoke(code, state, error)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NotificationsFlutterBridge @Inject constructor(

private val notifUtils = object : Pigeons.NotificationUtils {
override fun openNotification(arg: Pigeons.StringWrapper) {
val id = UUID.fromString(arg?.value)
val id = UUID.fromString(arg.value)
activeNotifs[id]?.notification?.contentIntent?.send()
}

Expand All @@ -65,7 +65,7 @@ class NotificationsFlutterBridge @Inject constructor(
}

override fun dismissNotificationWatch(arg: Pigeons.StringWrapper) {
val id = UUID.fromString(arg?.value)
val id = UUID.fromString(arg.value)
val command = BlobCommand.DeleteCommand(Random.nextInt(0, UShort.MAX_VALUE.toInt()).toUShort(), BlobCommand.BlobDatabase.Notification, SUUID(StructMapper(), id).toBytes())
GlobalScope.launch {
var blobResult = blobDBService.send(command)
Expand All @@ -85,7 +85,7 @@ class NotificationsFlutterBridge @Inject constructor(
?: Timber.w("Dismiss on untracked notif")
} catch (e: PendingIntent.CanceledException) {
}
result?.success(BooleanWrapper(true))
result.success(BooleanWrapper(true))

val command = BlobCommand.DeleteCommand(Random.nextInt(0, UShort.MAX_VALUE.toInt()).toUShort(), BlobCommand.BlobDatabase.Notification, SUUID(StructMapper(), id).toBytes())
GlobalScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PackageDetailsFlutterBridge @Inject constructor(
override fun getPackageList(): Pigeons.AppEntriesPigeon {
val mainIntent = Intent(Intent.ACTION_MAIN, null)
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER)
val packages = context.getPackageManager().queryIntentActivities(mainIntent, 0)
val packages = context.packageManager.queryIntentActivities(mainIntent, 0)
val ret = Pigeons.AppEntriesPigeon()
val pm = context.packageManager
ret.appName = ArrayList(packages.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.coroutines.Job
/**
* Helper that automatically closes down all pigeon bridges when activity is destroyed
*/
class BridgeLifecycleController constructor(
class BridgeLifecycleController(
private val binaryMessenger: BinaryMessenger,
coroutineScope: CoroutineScope
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class FirmwareUpdateControlFlutterBridge @Inject constructor(
error("Firmware update failed - Only reached ${putBytesController.status.value.progress}")
} else {
systemService.send(SystemMessage.FirmwareUpdateComplete())
firmwareUpdateCallbacks.onFirmwareUpdateFinished() {}
firmwareUpdateCallbacks.onFirmwareUpdateFinished {}
}
}
return@launchPigeonResult BooleanWrapper(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PermissionControlFlutterBridge @Inject constructor(
}

override fun requestLocationPermission(result: Pigeons.Result<Pigeons.NumberWrapper>) {
coroutineScope.launchPigeonResult(result!!, coroutineScope.coroutineContext) {
coroutineScope.launchPigeonResult(result, coroutineScope.coroutineContext) {
requestPermission(
REQUEST_CODE_LOCATION,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Manifest.permission.ACCESS_COARSE_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION
Expand All @@ -154,7 +154,7 @@ class PermissionControlFlutterBridge @Inject constructor(
}

override fun requestCalendarPermission(result: Pigeons.Result<Pigeons.NumberWrapper>) {
coroutineScope.launchPigeonResult(result!!, coroutineScope.coroutineContext) {
coroutineScope.launchPigeonResult(result, coroutineScope.coroutineContext) {
requestPermission(
REQUEST_CODE_CALENDAR,
Manifest.permission.READ_CALENDAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ private const val KEY_MASTER_NOTIFICATION_TOGGLE = "flutter.MASTER_NOTIFICATION_
private const val KEY_PREFIX_DISABLE_WORKAROUND = "flutter.DISABLE_WORKAROUND_"
private const val KEY_MUTED_NOTIF_PACKAGES = "flutter.MUTED_NOTIF_PACKAGES"

private const val LIST_IDENTIFIER = "VGhpcyBpcyB0aGUgcHJlZml4IGZvciBhIGxpc3Qu";
private const val LIST_IDENTIFIER = "VGhpcyBpcyB0aGUgcHJlZml4IGZvciBhIGxpc3Qu"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fun getCompatibleAppVariants(watchType: WatchType): List<WatchType> {
fun getBestVariant(watchType: WatchType, availableAppVariants: List<String>): WatchType? {
val compatibleVariants = getCompatibleAppVariants(watchType)

return compatibleVariants.firstOrNull() { variant ->
return compatibleVariants.firstOrNull { variant ->
availableAppVariants.contains(variant.codename)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ class WatchService : LifecycleService() {
return START_STICKY
}

override fun onDestroy() {
super.onDestroy()
}

private fun startNotificationLoop() {
coroutineScope.launch {
Timber.d("Notification Loop start")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GattStatus(val value: Int) {
p.name.startsWith("GATT_") &&
p.getInt(null) == value
}
var ret = err?.name?.replace("GATT", "")?.replace("_", "")?.toLowerCase(Locale.ROOT)?.capitalize()
var ret = err?.name?.replace("GATT", "")?.replace("_", "")?.lowercase(Locale.ROOT)?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
?: "Unknown error"
ret += " (${value})"
return ret
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package io.rebble.cobble.bluetooth.classic

import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothServerSocket
import androidx.annotation.RequiresPermission
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.runInterruptible
import timber.log.Timber
import java.util.UUID
import kotlin.coroutines.CoroutineContext

class ReconnectionSocketServer(private val adapter: BluetoothAdapter, private val ioDispatcher: CoroutineContext = Dispatchers.IO) {
companion object {
private val socketUUID = UUID.fromString("a924496e-cc7c-4dff-8a9f-9a76cc2e9d50");
private val socketUUID = UUID.fromString("a924496e-cc7c-4dff-8a9f-9a76cc2e9d50")
private val socketName = "PebbleBluetoothServerSocket"
}

Expand Down

0 comments on commit e10cf9b

Please sign in to comment.