mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2025-07-15 01:05:27 +08:00
Compare commits
6 Commits
ci/update-
...
build/spot
Author | SHA1 | Date | |
---|---|---|---|
b1e5f25341 | |||
e85efceb39 | |||
bfe207e682 | |||
a150fdb147 | |||
23d39c0e93 | |||
81a4ebd327 |
23
.editorconfig
Normal file
23
.editorconfig
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[*.{kt,kts}]
|
||||||
|
end_of_line = lf
|
||||||
|
ij_kotlin_allow_trailing_comma = false
|
||||||
|
ij_kotlin_allow_trailing_comma_on_call_site = false
|
||||||
|
ij_kotlin_imports_layout = *
|
||||||
|
ij_kotlin_indent_before_arrow_on_new_line = false
|
||||||
|
ij_kotlin_line_break_after_multiline_when_entry = true
|
||||||
|
ij_kotlin_packages_to_use_import_on_demand = java.util.*,kotlinx.android.synthetic.**
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
ktlint_annotation_handle_annotations_with_parameters_same_as_annotations_without_parameters = [unset]
|
||||||
|
ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8
|
||||||
|
ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4
|
||||||
|
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
|
||||||
|
ktlint_code_style = android_studio
|
||||||
|
ktlint_enum_entry_name_casing = upper_or_camel_cases
|
||||||
|
ktlint_function_naming_ignore_when_annotated_with = [unset]
|
||||||
|
ktlint_function_signature_body_expression_wrapping = default
|
||||||
|
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
|
||||||
|
ktlint_ignore_back_ticked_identifier = false
|
||||||
|
ktlint_property_naming_constant_naming = screaming_snake_case
|
||||||
|
max_line_length = 100
|
7
.github/workflows/build_pull_request.yml
vendored
7
.github/workflows/build_pull_request.yml
vendored
@ -13,10 +13,17 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Cache Gradle
|
- name: Cache Gradle
|
||||||
uses: burrunan/gradle-cache-action@v1
|
uses: burrunan/gradle-cache-action@v1
|
||||||
|
|
||||||
|
- name: Spotless Check
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: ./gradlew spotlessCheck --no-daemon
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -18,6 +18,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Java
|
- name: Setup Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
|
@ -12,7 +12,7 @@ interface PatchBundleDao {
|
|||||||
fun getPropsById(uid: Int): Flow<BundleProperties?>
|
fun getPropsById(uid: Int): Flow<BundleProperties?>
|
||||||
|
|
||||||
@Query("UPDATE patch_bundles SET version = :patches WHERE uid = :uid")
|
@Query("UPDATE patch_bundles SET version = :patches WHERE uid = :uid")
|
||||||
suspend fun updateVersion(uid: Int, patches: String?)
|
suspend fun updateVersionHash(uid: Int, patches: String?)
|
||||||
|
|
||||||
@Query("UPDATE patch_bundles SET auto_update = :value WHERE uid = :uid")
|
@Query("UPDATE patch_bundles SET auto_update = :value WHERE uid = :uid")
|
||||||
suspend fun setAutoUpdate(uid: Int, value: Boolean)
|
suspend fun setAutoUpdate(uid: Int, value: Boolean)
|
||||||
@ -26,7 +26,7 @@ interface PatchBundleDao {
|
|||||||
@Transaction
|
@Transaction
|
||||||
suspend fun reset() {
|
suspend fun reset() {
|
||||||
purgeCustomBundles()
|
purgeCustomBundles()
|
||||||
updateVersion(0, null) // Reset the main source
|
updateVersionHash(0, null) // Reset the main source
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("DELETE FROM patch_bundles WHERE uid = :uid")
|
@Query("DELETE FROM patch_bundles WHERE uid = :uid")
|
||||||
|
@ -33,12 +33,12 @@ sealed class Source {
|
|||||||
data class PatchBundleEntity(
|
data class PatchBundleEntity(
|
||||||
@PrimaryKey val uid: Int,
|
@PrimaryKey val uid: Int,
|
||||||
@ColumnInfo(name = "name") val name: String,
|
@ColumnInfo(name = "name") val name: String,
|
||||||
@ColumnInfo(name = "version") val version: String? = null,
|
@ColumnInfo(name = "version") val versionHash: String? = null,
|
||||||
@ColumnInfo(name = "source") val source: Source,
|
@ColumnInfo(name = "source") val source: Source,
|
||||||
@ColumnInfo(name = "auto_update") val autoUpdate: Boolean
|
@ColumnInfo(name = "auto_update") val autoUpdate: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
data class BundleProperties(
|
data class BundleProperties(
|
||||||
@ColumnInfo(name = "version") val version: String? = null,
|
@ColumnInfo(name = "version") val versionHash: String? = null,
|
||||||
@ColumnInfo(name = "auto_update") val autoUpdate: Boolean
|
@ColumnInfo(name = "auto_update") val autoUpdate: Boolean
|
||||||
)
|
)
|
@ -15,7 +15,7 @@ class LocalPatchBundle(name: String, id: Int, directory: File) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
reload()?.also {
|
reload()?.also {
|
||||||
saveVersion(it.readManifestAttribute("Version"))
|
saveVersionHash(it.readManifestAttribute("Version"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ sealed class PatchBundleSource(initialName: String, val uid: Int, directory: Fil
|
|||||||
|
|
||||||
suspend fun getName() = nameFlow.first()
|
suspend fun getName() = nameFlow.first()
|
||||||
|
|
||||||
|
val versionFlow = state.map { it.patchBundleOrNull()?.readManifestAttribute("Version") }
|
||||||
|
val patchCountFlow = state.map { it.patchBundleOrNull()?.patches?.size ?: 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the bundle has been downloaded to local storage.
|
* Returns true if the bundle has been downloaded to local storage.
|
||||||
*/
|
*/
|
||||||
@ -84,9 +87,9 @@ sealed class PatchBundleSource(initialName: String, val uid: Int, directory: Fil
|
|||||||
fun propsFlow() = configRepository.getProps(uid).flowOn(Dispatchers.Default)
|
fun propsFlow() = configRepository.getProps(uid).flowOn(Dispatchers.Default)
|
||||||
suspend fun getProps() = propsFlow().first()!!
|
suspend fun getProps() = propsFlow().first()!!
|
||||||
|
|
||||||
suspend fun currentVersion() = getProps().version
|
suspend fun currentVersionHash() = getProps().versionHash
|
||||||
protected suspend fun saveVersion(version: String?) =
|
protected suspend fun saveVersionHash(version: String?) =
|
||||||
configRepository.updateVersion(uid, version)
|
configRepository.updateVersionHash(uid, version)
|
||||||
|
|
||||||
suspend fun setName(name: String) {
|
suspend fun setName(name: String) {
|
||||||
configRepository.setName(uid, name)
|
configRepository.setName(uid, name)
|
||||||
|
@ -25,7 +25,7 @@ sealed class RemotePatchBundle(name: String, id: Int, directory: File, val endpo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveVersion(info.version)
|
saveVersionHash(info.version)
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ sealed class RemotePatchBundle(name: String, id: Int, directory: File, val endpo
|
|||||||
|
|
||||||
suspend fun update(): Boolean = withContext(Dispatchers.IO) {
|
suspend fun update(): Boolean = withContext(Dispatchers.IO) {
|
||||||
val info = getLatestInfo()
|
val info = getLatestInfo()
|
||||||
if (hasInstalled() && info.version == currentVersion())
|
if (hasInstalled() && info.version == currentVersionHash())
|
||||||
return@withContext false
|
return@withContext false
|
||||||
|
|
||||||
download(info)
|
download(info)
|
||||||
|
@ -25,7 +25,7 @@ class PatchBundlePersistenceRepository(db: AppDatabase) {
|
|||||||
PatchBundleEntity(
|
PatchBundleEntity(
|
||||||
uid = generateUid(),
|
uid = generateUid(),
|
||||||
name = name,
|
name = name,
|
||||||
version = null,
|
versionHash = null,
|
||||||
source = source,
|
source = source,
|
||||||
autoUpdate = autoUpdate
|
autoUpdate = autoUpdate
|
||||||
).also {
|
).also {
|
||||||
@ -34,8 +34,11 @@ class PatchBundlePersistenceRepository(db: AppDatabase) {
|
|||||||
|
|
||||||
suspend fun delete(uid: Int) = dao.remove(uid)
|
suspend fun delete(uid: Int) = dao.remove(uid)
|
||||||
|
|
||||||
suspend fun updateVersion(uid: Int, version: String?) =
|
/**
|
||||||
dao.updateVersion(uid, version)
|
* Sets the version hash used for updates.
|
||||||
|
*/
|
||||||
|
suspend fun updateVersionHash(uid: Int, versionHash: String?) =
|
||||||
|
dao.updateVersionHash(uid, versionHash)
|
||||||
|
|
||||||
suspend fun setAutoUpdate(uid: Int, value: Boolean) = dao.setAutoUpdate(uid, value)
|
suspend fun setAutoUpdate(uid: Int, value: Boolean) = dao.setAutoUpdate(uid, value)
|
||||||
|
|
||||||
@ -47,7 +50,7 @@ class PatchBundlePersistenceRepository(db: AppDatabase) {
|
|||||||
val defaultSource = PatchBundleEntity(
|
val defaultSource = PatchBundleEntity(
|
||||||
uid = 0,
|
uid = 0,
|
||||||
name = "",
|
name = "",
|
||||||
version = null,
|
versionHash = null,
|
||||||
source = Source.API,
|
source = Source.API,
|
||||||
autoUpdate = false
|
autoUpdate = false
|
||||||
)
|
)
|
||||||
|
@ -42,9 +42,8 @@ fun BundleInformationDialog(
|
|||||||
val props by remember(bundle) {
|
val props by remember(bundle) {
|
||||||
bundle.propsFlow()
|
bundle.propsFlow()
|
||||||
}.collectAsStateWithLifecycle(null)
|
}.collectAsStateWithLifecycle(null)
|
||||||
val patchCount = remember(state) {
|
val patchCount by bundle.patchCountFlow.collectAsStateWithLifecycle(0)
|
||||||
state.patchBundleOrNull()?.patches?.size ?: 0
|
val version by bundle.versionFlow.collectAsStateWithLifecycle(null)
|
||||||
}
|
|
||||||
|
|
||||||
if (viewCurrentBundlePatches) {
|
if (viewCurrentBundlePatches) {
|
||||||
BundlePatchesDialog(
|
BundlePatchesDialog(
|
||||||
@ -98,8 +97,8 @@ fun BundleInformationDialog(
|
|||||||
name = bundleName,
|
name = bundleName,
|
||||||
remoteUrl = bundle.asRemoteOrNull?.endpoint,
|
remoteUrl = bundle.asRemoteOrNull?.endpoint,
|
||||||
patchCount = patchCount,
|
patchCount = patchCount,
|
||||||
version = props?.version,
|
version = version,
|
||||||
autoUpdate = props?.autoUpdate ?: false,
|
autoUpdate = props?.autoUpdate == true,
|
||||||
onAutoUpdateChange = {
|
onAutoUpdateChange = {
|
||||||
composableScope.launch {
|
composableScope.launch {
|
||||||
bundle.asRemoteOrNull?.setAutoUpdate(it)
|
bundle.asRemoteOrNull?.setAutoUpdate(it)
|
||||||
|
@ -47,9 +47,8 @@ fun BundleItem(
|
|||||||
var showDeleteConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
var showDeleteConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
val state by bundle.state.collectAsStateWithLifecycle()
|
val state by bundle.state.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val version by remember(bundle) {
|
val version by bundle.versionFlow.collectAsStateWithLifecycle(null)
|
||||||
bundle.propsFlow().map { props -> props?.version }
|
val patchCount by bundle.patchCountFlow.collectAsStateWithLifecycle(0)
|
||||||
}.collectAsStateWithLifecycle(null)
|
|
||||||
val name by bundle.nameState
|
val name by bundle.nameState
|
||||||
|
|
||||||
if (viewBundleDialogPage) {
|
if (viewBundleDialogPage) {
|
||||||
@ -93,7 +92,7 @@ fun BundleItem(
|
|||||||
|
|
||||||
headlineContent = { Text(name) },
|
headlineContent = { Text(name) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
state.patchBundleOrNull()?.patches?.size?.let { patchCount ->
|
if (state is PatchBundleSource.State.Loaded) {
|
||||||
Text(pluralStringResource(R.plurals.patch_count, patchCount, patchCount))
|
Text(pluralStringResource(R.plurals.patch_count, patchCount, patchCount))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -57,9 +57,7 @@ fun BundleSelector(bundles: List<PatchBundleSource>, onFinish: (PatchBundleSourc
|
|||||||
}
|
}
|
||||||
bundles.forEach {
|
bundles.forEach {
|
||||||
val name by it.nameState
|
val name by it.nameState
|
||||||
val version by remember(it) {
|
val version by it.versionFlow.collectAsStateWithLifecycle(null)
|
||||||
it.propsFlow().map { props -> props?.version }
|
|
||||||
}.collectAsStateWithLifecycle(null)
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
@ -79,7 +79,7 @@ data class BundleInfo(
|
|||||||
targetList.add(it)
|
targetList.add(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
BundleInfo(source.getName(), source.currentVersion(), source.uid, compatible, incompatible, universal)
|
BundleInfo(source.getName(), bundle.readManifestAttribute("Version"), source.uid, compatible, incompatible, universal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,4 +7,12 @@ plugins {
|
|||||||
alias(libs.plugins.kotlin.parcelize) apply false
|
alias(libs.plugins.kotlin.parcelize) apply false
|
||||||
alias(libs.plugins.about.libraries) apply false
|
alias(libs.plugins.about.libraries) apply false
|
||||||
alias(libs.plugins.compose.compiler) apply false
|
alias(libs.plugins.compose.compiler) apply false
|
||||||
|
alias(libs.plugins.spotless)
|
||||||
|
}
|
||||||
|
|
||||||
|
spotless {
|
||||||
|
kotlin {
|
||||||
|
target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt")
|
||||||
|
ktlint().setEditorConfigPath("$projectDir/.editorconfig")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ compose-icons = "1.2.4"
|
|||||||
kotlin-process = "1.5.1"
|
kotlin-process = "1.5.1"
|
||||||
hidden-api-stub = "4.3.3"
|
hidden-api-stub = "4.3.3"
|
||||||
binary-compatibility-validator = "0.17.0"
|
binary-compatibility-validator = "0.17.0"
|
||||||
|
spotless-gradle-plugin = "7.0.4"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
# AndroidX Core
|
# AndroidX Core
|
||||||
@ -144,3 +145,4 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "
|
|||||||
devtools = { id = "com.google.devtools.ksp", version.ref = "dev-tools-gradle-plugin" }
|
devtools = { id = "com.google.devtools.ksp", version.ref = "dev-tools-gradle-plugin" }
|
||||||
about-libraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "about-libraries-gradle-plugin" }
|
about-libraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "about-libraries-gradle-plugin" }
|
||||||
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
|
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
|
||||||
|
spotless = { id = "com.diffplug.spotless", version.ref = "spotless-gradle-plugin" }
|
||||||
|
Reference in New Issue
Block a user