diff --git a/app/src/main/kotlin/li/songe/gkd/data/Tuple.kt b/app/src/main/kotlin/li/songe/gkd/data/Tuple.kt deleted file mode 100644 index 191572176..000000000 --- a/app/src/main/kotlin/li/songe/gkd/data/Tuple.kt +++ /dev/null @@ -1,9 +0,0 @@ -package li.songe.gkd.data - -data class Tuple3( - val t0: T0, - val t1: T1, - val t2: T2, -) { - override fun toString() = "($t0, $t1, $t2)" -} diff --git a/app/src/main/kotlin/li/songe/gkd/debug/FloatingService.kt b/app/src/main/kotlin/li/songe/gkd/debug/FloatingService.kt index afb0877af..9a08e685f 100644 --- a/app/src/main/kotlin/li/songe/gkd/debug/FloatingService.kt +++ b/app/src/main/kotlin/li/songe/gkd/debug/FloatingService.kt @@ -15,7 +15,6 @@ import com.torrydo.floatingbubbleview.service.expandable.ExpandableBubbleService import kotlinx.coroutines.flow.MutableStateFlow import li.songe.gkd.app import li.songe.gkd.appScope -import li.songe.gkd.data.Tuple3 import li.songe.gkd.notif.floatingNotif import li.songe.gkd.notif.notifyService import li.songe.gkd.permission.canDrawOverlaysState @@ -44,20 +43,20 @@ class FloatingService : ExpandableBubbleService() { // https://github.com/gkd-kit/gkd/issues/62 // https://github.com/gkd-kit/gkd/issues/61 - val defaultFingerData = Tuple3(0L, 0f, 0f) + val defaultFingerData = Triple(0L, 0f, 0f) var fingerDownData = defaultFingerData val maxDistanceOffset = 50 builder.addFloatingBubbleListener(object : FloatingBubbleListener { override fun onFingerDown(x: Float, y: Float) { - fingerDownData = Tuple3(System.currentTimeMillis(), x, y) + fingerDownData = Triple(System.currentTimeMillis(), x, y) } override fun onFingerMove(x: Float, y: Float) { if (fingerDownData === defaultFingerData) { return } - val dx = fingerDownData.t1 - x - val dy = fingerDownData.t2 - y + val dx = fingerDownData.second - x + val dy = fingerDownData.third - y val distance = sqrt(dx * dx + dy * dy) if (distance > maxDistanceOffset) { // reset @@ -66,7 +65,7 @@ class FloatingService : ExpandableBubbleService() { } override fun onFingerUp(x: Float, y: Float) { - if (System.currentTimeMillis() - fingerDownData.t0 < ViewConfiguration.getTapTimeout()) { + if (System.currentTimeMillis() - fingerDownData.first < ViewConfiguration.getTapTimeout()) { // is onClick appScope.launchTry { SnapshotExt.captureSnapshot() diff --git a/app/src/main/kotlin/li/songe/gkd/shizuku/ShizukuApi.kt b/app/src/main/kotlin/li/songe/gkd/shizuku/ShizukuApi.kt index 204967609..4850efafb 100644 --- a/app/src/main/kotlin/li/songe/gkd/shizuku/ShizukuApi.kt +++ b/app/src/main/kotlin/li/songe/gkd/shizuku/ShizukuApi.kt @@ -10,7 +10,6 @@ import kotlinx.coroutines.flow.update import li.songe.gkd.META import li.songe.gkd.appScope import li.songe.gkd.data.AppInfo -import li.songe.gkd.data.Tuple3 import li.songe.gkd.data.otherUserMapFlow import li.songe.gkd.data.toAppInfo import li.songe.gkd.util.allPackageInfoMapFlow @@ -75,7 +74,7 @@ fun initShizuku() { packageManagerFlow, userAppInfoMapFlow, allPackageInfoMapFlow, - ) { a, b, c -> Tuple3(a, b, c) }.debounce(3000) + ) { a, b, c -> Triple(a, b, c) }.debounce(3000) .collect { (pkgManager, userAppInfoMap, allPackageInfoMap) -> otherUserAppInfoMapFlow.update { if (pkgManager != null) { diff --git a/app/src/main/kotlin/li/songe/gkd/ui/ActionLogPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/ActionLogPage.kt index 0f2b6e4f7..8dd48e48c 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ActionLogPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ActionLogPage.kt @@ -62,7 +62,6 @@ import li.songe.gkd.data.ActionLog import li.songe.gkd.data.ExcludeData import li.songe.gkd.data.RawSubscription import li.songe.gkd.data.SubsConfig -import li.songe.gkd.data.Tuple3 import li.songe.gkd.data.stringify import li.songe.gkd.data.switch import li.songe.gkd.db.DbSet @@ -192,7 +191,7 @@ fun ActionLogPage( ) { items( count = actionDataItems.itemCount, - key = actionDataItems.itemKey { c -> c.t0.id } + key = actionDataItems.itemKey { c -> c.first.id } ) { i -> val item = actionDataItems[i] ?: return@items val lastItem = if (i > 0) actionDataItems[i - 1] else null @@ -204,7 +203,7 @@ fun ActionLogPage( item = item, lastItem = lastItem, onClick = { - previewActionLog = item.t0 + previewActionLog = item.first }, subsId = subsId, appId = appId, @@ -363,15 +362,15 @@ fun ActionLogPage( @Composable private fun ActionLogCard( i: Int, - item: Tuple3, - lastItem: Tuple3?, + item: Triple, + lastItem: Triple?, onClick: () -> Unit, subsId: Long?, appId: String?, ) { val context = LocalContext.current as MainActivity val (actionLog, group, rule) = item - val lastActionLog = lastItem?.t0 + val lastActionLog = lastItem?.first val isDiffApp = actionLog.appId != lastActionLog?.appId val verticalPadding = if (i == 0) 0.dp else if (isDiffApp) 12.dp else 8.dp val subsIdToRaw by subsIdToRawFlow.collectAsState() diff --git a/app/src/main/kotlin/li/songe/gkd/ui/ActionLogVm.kt b/app/src/main/kotlin/li/songe/gkd/ui/ActionLogVm.kt index 25c2b673a..e6ac6d59b 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ActionLogVm.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ActionLogVm.kt @@ -10,7 +10,6 @@ import androidx.paging.map import com.ramcosta.composedestinations.generated.destinations.ActionLogPageDestination import kotlinx.coroutines.flow.combine import li.songe.gkd.data.SubsConfig -import li.songe.gkd.data.Tuple3 import li.songe.gkd.db.DbSet import li.songe.gkd.util.subsIdToRawFlow @@ -42,7 +41,7 @@ class ActionLogVm(stateHandle: SavedStateHandle) : ViewModel() { getOrNull(c.ruleIndex) } } - Tuple3(c, group, rule) + Triple(c, group, rule) } } .cachedIn(viewModelScope) diff --git a/app/src/main/kotlin/li/songe/gkd/ui/SubsPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/SubsPage.kt index e9fb0b18f..2f7529dfd 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/SubsPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/SubsPage.kt @@ -129,7 +129,7 @@ fun SubsPage( val listState = rememberLazyListState() var isFirstVisit by remember { mutableStateOf(true) } LaunchedEffect( - key1 = appAndConfigs.mapHashCode { it.t0.id } + key1 = appAndConfigs.mapHashCode { it.first.id } ) { if (isFirstVisit) { isFirstVisit = false @@ -261,7 +261,7 @@ fun SubsPage( modifier = Modifier.scaffoldPadding(contentPadding), state = listState ) { - itemsIndexed(appAndConfigs, { i, a -> i.toString() + a.t0.id }) { _, a -> + itemsIndexed(appAndConfigs, { i, a -> i.toString() + a.first.id }) { _, a -> val (appRaw, subsConfig, enableSize) = a SubsAppCard( rawApp = appRaw, diff --git a/app/src/main/kotlin/li/songe/gkd/ui/SubsVm.kt b/app/src/main/kotlin/li/songe/gkd/ui/SubsVm.kt index 515c2108d..661141a6e 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/SubsVm.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/SubsVm.kt @@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import li.songe.gkd.data.RawSubscription import li.songe.gkd.data.SubsConfig -import li.songe.gkd.data.Tuple3 import li.songe.gkd.db.DbSet import li.songe.gkd.util.SortTypeOption import li.songe.gkd.util.appInfoCacheFlow @@ -107,7 +106,7 @@ class SubsVm(stateHandle: SavedStateHandle) : ViewModel() { categoryConfigs.find { c -> c.categoryKey == groupToCategoryMap[g]?.key } ) } - Tuple3(app, appSubsConfigs.find { s -> s.appId == app.id }, enableSize) + Triple(app, appSubsConfigs.find { s -> s.appId == app.id }, enableSize) } }.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) @@ -117,11 +116,11 @@ class SubsVm(stateHandle: SavedStateHandle) : ViewModel() { if (searchStr.isBlank()) { appAndConfigs } else { - val results = mutableListOf>() + val results = mutableListOf>() val remnantList = appAndConfigs.toMutableList() //1. 搜索已安装应用名称 remnantList.toList().apply { remnantList.clear() }.forEach { a -> - val name = appInfoCache[a.t0.id]?.name + val name = appInfoCache[a.first.id]?.name if (name?.contains(searchStr, true) == true) { results.add(a) } else { @@ -130,8 +129,8 @@ class SubsVm(stateHandle: SavedStateHandle) : ViewModel() { } //2. 搜索未安装应用名称 remnantList.toList().apply { remnantList.clear() }.forEach { a -> - val name = a.t0.name - if (appInfoCache[a.t0.id] == null && name?.contains(searchStr, true) == true) { + val name = a.first.name + if (appInfoCache[a.first.id] == null && name?.contains(searchStr, true) == true) { results.add(a) } else { remnantList.add(a) @@ -139,7 +138,7 @@ class SubsVm(stateHandle: SavedStateHandle) : ViewModel() { } //3. 搜索应用 id remnantList.toList().apply { remnantList.clear() }.forEach { a -> - if (a.t0.id.contains(searchStr, true)) { + if (a.first.id.contains(searchStr, true)) { results.add(a) } else { remnantList.add(a)