mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2026-03-22 00:28:15 +05:00
add lua libs repository, fix manifest generator
This commit is contained in:
@@ -63,6 +63,7 @@ import com.cherret.zaprett.ui.viewmodel.BinRepoViewModel
|
||||
import com.cherret.zaprett.ui.viewmodel.HomeViewModel
|
||||
import com.cherret.zaprett.ui.viewmodel.HostRepoViewModel
|
||||
import com.cherret.zaprett.ui.viewmodel.IpsetRepoViewModel
|
||||
import com.cherret.zaprett.ui.viewmodel.LuaLibsRepoViewModel
|
||||
import com.cherret.zaprett.ui.viewmodel.StrategyRepoViewModel
|
||||
import com.cherret.zaprett.utils.checkModuleInstallation
|
||||
import com.cherret.zaprett.utils.checkStoragePermission
|
||||
@@ -232,6 +233,10 @@ class MainActivity : ComponentActivity() {
|
||||
val viewModel: BinRepoViewModel = androidx.lifecycle.viewmodel.compose.viewModel()
|
||||
RepoScreen(navController, viewModel)
|
||||
}
|
||||
"lua_libs" -> {
|
||||
val viewModel: LuaLibsRepoViewModel = androidx.lifecycle.viewmodel.compose.viewModel()
|
||||
RepoScreen(navController, viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
composable("debugScreen") { DebugScreen(navController) }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.cherret.zaprett.data
|
||||
|
||||
enum class ItemType {
|
||||
bin, byedpi, nfqws, nfqws2, list, list_exclude, ipset, ipset_exclude
|
||||
bin, lua_lib, byedpi, nfqws, nfqws2, list, list_exclude, ipset, ipset_exclude
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.cherret.zaprett.data
|
||||
|
||||
enum class RepoTab {
|
||||
bins,
|
||||
lua_libs,
|
||||
lists,
|
||||
strategies,
|
||||
ipsets
|
||||
|
||||
@@ -262,6 +262,12 @@ fun SettingsScreen(navController: NavController, viewModel : SettingsViewModel =
|
||||
onClick = {
|
||||
navController.navigate("repo?source=bin") { launchSingleTop = true }
|
||||
}
|
||||
),
|
||||
Setting.Action(
|
||||
title = stringResource(R.string.lua_libs_repo),
|
||||
onClick = {
|
||||
navController.navigate("repo?source=lua_libs") { launchSingleTop = true }
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ abstract class BaseListsViewModel(application: Application) : AndroidViewModel(a
|
||||
val json = Json {
|
||||
prettyPrint = true
|
||||
ignoreUnknownKeys = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
var allItems by mutableStateOf<List<StorageData>>(emptyList())
|
||||
private set
|
||||
|
||||
@@ -83,6 +83,7 @@ abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(ap
|
||||
private val Json = Json {
|
||||
prettyPrint = true
|
||||
ignoreUnknownKeys = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@@ -96,6 +97,10 @@ abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(ap
|
||||
ItemType.bin -> true
|
||||
else -> false
|
||||
}
|
||||
RepoTab.lua_libs -> when(item.type) {
|
||||
ItemType.lua_lib -> true
|
||||
else -> false
|
||||
}
|
||||
RepoTab.lists -> when (item.type) {
|
||||
ItemType.list -> listType == ListType.whitelist
|
||||
ItemType.list_exclude -> listType == ListType.blacklist
|
||||
@@ -193,6 +198,7 @@ abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(ap
|
||||
if (getFileSha256(sourceFile) == item.artifact.sha256) {
|
||||
val targetDirSuffix = when (index.type) {
|
||||
ItemType.bin -> "bin"
|
||||
ItemType.lua_lib -> "libs"
|
||||
ItemType.byedpi -> "strategies/byedpi"
|
||||
ItemType.nfqws -> "strategies/nfqws"
|
||||
ItemType.nfqws2 -> "strategies/nfqws2"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.cherret.zaprett.ui.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
import com.cherret.zaprett.data.RepoTab
|
||||
import com.cherret.zaprett.data.StorageData
|
||||
import com.cherret.zaprett.utils.getAllLibs
|
||||
|
||||
class LuaLibsRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
||||
override fun getInstalledLists(): Array<StorageData> = getAllLibs()
|
||||
override val repoTab = RepoTab.lua_libs
|
||||
}
|
||||
@@ -216,6 +216,11 @@ fun getAllBin(): Array<StorageData> {
|
||||
return getValidManifests(listsDir)
|
||||
}
|
||||
|
||||
fun getAllLibs(): Array<StorageData> {
|
||||
val listsDir = getManifestsPath().resolve("libs")
|
||||
return getValidManifests(listsDir)
|
||||
}
|
||||
|
||||
fun getActiveLists(sharedPreferences: SharedPreferences): Array<StorageData> {
|
||||
if (getServiceType(sharedPreferences) != ServiceType.byedpi) {
|
||||
return readConfig().activeLists.mapNotNull { parseManifestFromFile(File(it)).getOrNull() }.toTypedArray()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<string name="general_section">Основные настройки</string>
|
||||
<string name="byedpi_section">Настройки ByeDPI</string>
|
||||
<string name="bins_repo">Репозиторий фейков</string>
|
||||
<string name="lua_libs_repo">Репозиторий Lua библиотек</string>
|
||||
<string name="btn_continue">Продолжить</string>
|
||||
<string name="btn_update">Обновить</string>
|
||||
<string name="btn_dismiss">Отмена</string>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<string name="general_section">General settings</string>
|
||||
<string name="byedpi_section">ByeDPI settings</string>
|
||||
<string name="bins_repo">Fakes repository</string>
|
||||
<string name="lua_libs_repo">Lua libs repository</string>
|
||||
<string name="btn_continue">Continue</string>
|
||||
<string name="btn_update">Update</string>
|
||||
<string name="btn_dismiss">Dismiss</string>
|
||||
|
||||
Reference in New Issue
Block a user