Выпуск WDTT Plus v12
This commit is contained in:
1 parent
b3aad32990
commit
cd441e604e
108 files changed
+22337
-2201
No files matched your search
@@ -3,7 +3,9 @@ package com.wdtt.plus.ui
|
||||
import android.content.pm.PackageManager
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.rememberScrollableState
|
||||
import androidx.compose.foundation.gestures.scrollable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
@@ -57,76 +59,6 @@ object AppCache {
|
||||
var cachedList: List<AppItem>? = null
|
||||
}
|
||||
|
||||
private val VpnDetectionExactPackages = setOf(
|
||||
"ru.sberbankmobile",
|
||||
"ru.tinkoff.mb",
|
||||
"ru.vtb24.mobilebanking.android",
|
||||
"ru.alfabank.mobile.android",
|
||||
"ru.ozon.app.android",
|
||||
"com.wildberries.ru",
|
||||
"ru.beru.android",
|
||||
"ru.megamarket",
|
||||
"ru.sbermarket",
|
||||
"ru.samokat.android",
|
||||
"com.avito.android",
|
||||
"ru.yandex.searchplugin",
|
||||
"ru.yandex.yandexmaps",
|
||||
"ru.yandex.music",
|
||||
"ru.kinopoisk",
|
||||
"com.yandex.browser",
|
||||
"ru.yandex.taxi",
|
||||
"com.vkontakte.android",
|
||||
"com.vk.vkvideo",
|
||||
"ru.vk.music",
|
||||
"ru.ok.android",
|
||||
"ru.rutube.app",
|
||||
"ru.mail.mailapp",
|
||||
"ru.mail.cloud",
|
||||
"ru.mts",
|
||||
"ru.beeline.services",
|
||||
"ru.tele2.mytele2",
|
||||
"ru.megafon.mlk",
|
||||
"ru.rostel",
|
||||
"ru.gosuslugi.mobile",
|
||||
"ru.vk.store",
|
||||
"ru.dublgis.dgismobile",
|
||||
"ru.maximoff.max"
|
||||
)
|
||||
|
||||
private val VpnDetectionKeywords = listOf(
|
||||
"sber", "сбер",
|
||||
"tinkoff", "t-bank", "tbank", "тинькофф", "тбанк",
|
||||
"vtb", "втб",
|
||||
"alfa", "alpha", "альфа",
|
||||
"ozon", "озон",
|
||||
"wildberries", "вайлдберриз",
|
||||
"yandex", "яндекс",
|
||||
"vkontakte", "вконтакте",
|
||||
"rutube", "рутуб",
|
||||
"gosuslugi", "госуслуг",
|
||||
"dublgis", "2gis", "dgis", "дубльгис",
|
||||
"avito", "авито",
|
||||
"mts", "мтс",
|
||||
"beeline", "билайн",
|
||||
"megafon", "мегафон",
|
||||
"tele2", "теле2",
|
||||
"mail.ru", "mailapp",
|
||||
"ok.ru", "odnoklassniki",
|
||||
"kinopoisk", "кинопоиск",
|
||||
"samokat", "самокат",
|
||||
"megamarket", "sbermarket",
|
||||
"rostel", "ростел",
|
||||
"maximoff"
|
||||
)
|
||||
|
||||
private fun AppItem.matchesVpnDetectionApp(): Boolean {
|
||||
val packageLower = packageName.lowercase()
|
||||
if (packageLower in VpnDetectionExactPackages) return true
|
||||
val titleLower = name.lowercase()
|
||||
val haystack = "$packageLower $titleLower"
|
||||
return VpnDetectionKeywords.any { keyword -> haystack.contains(keyword) }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ExceptionsTab(
|
||||
@@ -229,22 +161,50 @@ fun ExceptionsTab(
|
||||
}
|
||||
}
|
||||
|
||||
val collapsingHeaderConnection = remember(topBlockHeightPx) {
|
||||
fun consumeHeaderScroll(deltaPx: Float, allowExpand: Boolean): Float {
|
||||
val previousOffset = topBlockOffsetPx
|
||||
val nextOffset = collapsingHeaderOffsetAfterScroll(
|
||||
currentOffsetPx = previousOffset,
|
||||
headerHeightPx = topBlockHeightPx,
|
||||
deltaPx = deltaPx,
|
||||
allowExpand = allowExpand,
|
||||
)
|
||||
if (nextOffset != previousOffset) {
|
||||
topBlockOffsetPx = nextOffset
|
||||
topBlockPositionInitialized = true
|
||||
}
|
||||
return nextOffset - previousOffset
|
||||
}
|
||||
|
||||
val collapsingHeaderConnection = remember(topBlockHeightPx, listState) {
|
||||
object : NestedScrollConnection {
|
||||
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
|
||||
if (topBlockHeightPx <= 0f) return Offset.Zero
|
||||
val delta = available.y
|
||||
val canCollapse = delta < 0f && topBlockOffsetPx > -topBlockHeightPx
|
||||
val canExpand = delta > 0f && topBlockOffsetPx < 0f
|
||||
if (!canCollapse && !canExpand) return Offset.Zero
|
||||
val consumed = consumeHeaderScroll(
|
||||
deltaPx = delta,
|
||||
allowExpand = !listState.canScrollBackward,
|
||||
)
|
||||
return Offset(x = 0f, y = consumed)
|
||||
}
|
||||
|
||||
val previousOffset = topBlockOffsetPx
|
||||
topBlockOffsetPx = (previousOffset + delta).coerceIn(-topBlockHeightPx, 0f)
|
||||
topBlockPositionInitialized = true
|
||||
return Offset(x = 0f, y = topBlockOffsetPx - previousOffset)
|
||||
override fun onPostScroll(
|
||||
consumed: Offset,
|
||||
available: Offset,
|
||||
source: NestedScrollSource,
|
||||
): Offset {
|
||||
if (available.y <= 0f) return Offset.Zero
|
||||
val headerConsumed = consumeHeaderScroll(
|
||||
deltaPx = available.y,
|
||||
allowExpand = true,
|
||||
)
|
||||
return Offset(x = 0f, y = headerConsumed)
|
||||
}
|
||||
}
|
||||
}
|
||||
val searchHeaderScrollState = rememberScrollableState { deltaPx ->
|
||||
consumeHeaderScroll(deltaPx = deltaPx, allowExpand = true)
|
||||
}
|
||||
val collapseFraction = if (topBlockHeightPx > 0f) {
|
||||
(-topBlockOffsetPx / topBlockHeightPx).coerceIn(0f, 1f)
|
||||
} else {
|
||||
@@ -356,7 +316,12 @@ fun ExceptionsTab(
|
||||
OutlinedButton(
|
||||
onClick = {
|
||||
val detectedPackages = appsList
|
||||
.filter { it.matchesVpnDetectionApp() }
|
||||
.filter {
|
||||
matchesQuickExclusionApp(
|
||||
name = it.name,
|
||||
packageName = it.packageName,
|
||||
)
|
||||
}
|
||||
.map { it.packageName }
|
||||
.toSet()
|
||||
if (detectedPackages.isEmpty()) {
|
||||
@@ -383,7 +348,7 @@ fun ExceptionsTab(
|
||||
)
|
||||
}
|
||||
Text(
|
||||
"Банки, маркетплейсы и другие приложения, чувствительные к VPN. Поиск выполняется по известным названиям.",
|
||||
"Приложения из белых списков мобильного интернета и другие сервисы, чувствительные к VPN. Выбираются только найденные на устройстве.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(top = 6.dp)
|
||||
@@ -409,7 +374,11 @@ fun ExceptionsTab(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 16.dp * collapseFraction, bottom = 12.dp)
|
||||
.height(52.dp),
|
||||
.height(52.dp)
|
||||
.scrollable(
|
||||
state = searchHeaderScrollState,
|
||||
orientation = Orientation.Vertical,
|
||||
),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
leadingIcon = { Icon(Icons.Default.Search, null, modifier = Modifier.size(20.dp)) },
|
||||
singleLine = true,
|
||||
|
||||
Reference in new issue
Block a user