Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Rename values of State
Browse files Browse the repository at this point in the history
  • Loading branch information
SanmerDev committed Jun 11, 2024
1 parent 54344f9 commit 66401d0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ fun ModuleItem(
progress = progress,
indeterminate = ops.isOpsRunning,
alpha = when (module.state) {
State.DISABLE, State.REMOVE -> 0.5f
State.Disable, State.Remove -> 0.5f
else -> 1f
},
decoration = when (module.state) {
State.REMOVE -> TextDecoration.LineThrough
State.Remove -> TextDecoration.LineThrough
else -> TextDecoration.None
},
switch = {
Switch(
checked = module.state == State.ENABLE,
checked = module.state == State.Enable,
onCheckedChange = ops.toggle,
enabled = isProviderAlive
)
},
indicator = {
when (module.state) {
State.REMOVE -> StateIndicator(R.drawable.trash)
State.UPDATE -> StateIndicator(R.drawable.device_mobile_down)
State.Remove -> StateIndicator(R.drawable.trash)
State.Update -> StateIndicator(R.drawable.device_mobile_down)
else -> {}
}
},
Expand Down Expand Up @@ -178,7 +178,7 @@ private fun RemoveOrRestore(
) {
Icon(
modifier = Modifier.size(20.dp),
painter = painterResource(id = if (module.state == State.REMOVE) {
painter = painterResource(id = if (module.state == State.Remove) {
R.drawable.rotate
} else {
R.drawable.trash
Expand All @@ -188,7 +188,7 @@ private fun RemoveOrRestore(

Spacer(modifier = Modifier.width(6.dp))
Text(
text = stringResource(id = if (module.state == State.REMOVE) {
text = stringResource(id = if (module.state == State.Remove) {
R.string.module_restore
} else {
R.string.module_remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class InstallViewModel @Inject constructor(
private fun insertLocal(module: LocalModule) {
viewModelScope.launch {
localRepository.insertLocal(
module.copy(state = State.UPDATE)
module.copy(state = State.Update)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ModulesViewModel @Inject constructor(
comparator(menu.option, menu.descending)
).let { v ->
if (menu.pinEnabled) {
v.sortedByDescending { it.state == State.ENABLE }
v.sortedByDescending { it.state == State.Enable }
} else {
v
}
Expand Down Expand Up @@ -179,7 +179,7 @@ class ModulesViewModel @Inject constructor(
}

fun createModuleOps(module: LocalModule) = when (module.state) {
State.ENABLE -> ModuleOps(
State.Enable -> ModuleOps(
isOpsRunning = opsTasks.contains(module.id),
toggle = {
opsTasks.add(module.id)
Expand All @@ -191,7 +191,7 @@ class ModulesViewModel @Inject constructor(
}
)

State.DISABLE -> ModuleOps(
State.Disable -> ModuleOps(
isOpsRunning = opsTasks.contains(module.id),
toggle = {
opsTasks.add(module.id)
Expand All @@ -203,7 +203,7 @@ class ModulesViewModel @Inject constructor(
}
)

State.REMOVE -> ModuleOps(
State.Remove -> ModuleOps(
isOpsRunning = opsTasks.contains(module.id),
toggle = {},
change = {
Expand All @@ -212,7 +212,7 @@ class ModulesViewModel @Inject constructor(
}
)

State.UPDATE -> ModuleOps(
State.Update -> ModuleOps(
isOpsRunning = opsTasks.contains(module.id),
toggle = {},
change = {}
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/kotlin/dev/sanmer/mrepo/content/State.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.sanmer.mrepo.content

enum class State {
ENABLE,
REMOVE,
DISABLE,
UPDATE
Enable,
Remove,
Disable,
Update
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ internal abstract class BaseModuleManagerImpl : IModuleManager.Stub() {

private fun readState(moduleDir: File): State {
moduleDir.resolve("remove").apply {
if (exists()) return State.REMOVE
if (exists()) return State.Remove
}

moduleDir.resolve("disable").apply {
if (exists()) return State.DISABLE
if (exists()) return State.Disable
}

moduleDir.resolve("update").apply {
if (exists()) return State.UPDATE
if (exists()) return State.Update
}

return State.ENABLE
return State.Enable
}

private fun readLastUpdated(moduleDir: File): Long {
Expand All @@ -119,7 +119,7 @@ internal abstract class BaseModuleManagerImpl : IModuleManager.Stub() {

private fun Map<String, String>.toModule(
path: String = "unknown",
state: State = State.ENABLE,
state: State = State.Enable,
lastUpdated: Long = 0L
) = Module(
id = getOrDefault("id", path),
Expand Down

0 comments on commit 66401d0

Please sign in to comment.