Skip to content

Commit

Permalink
fix: 替换规则热更新 #146
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Jan 29, 2024
1 parent cd7aaa7 commit 6ca8d20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.github.jing332.tts_server_android.compose.systts.replace.edit.RuleEdi
import com.github.jing332.tts_server_android.compose.theme.AppTheme
import com.github.jing332.tts_server_android.data.appDb
import com.github.jing332.tts_server_android.data.entities.replace.ReplaceRule
import com.github.jing332.tts_server_android.service.systts.SystemTtsService

class ReplaceManagerActivity : AppCompatActivity() {
@Suppress("DEPRECATION")
Expand All @@ -42,6 +43,8 @@ class ReplaceManagerActivity : AppCompatActivity() {
}
RuleEditScreen(rule, onRuleChange = { rule = it }, onSave = {
appDb.replaceRuleDao.insert(rule)
if (rule.isEnabled)
SystemTtsService.notifyUpdateConfig(isOnlyReplacer = true)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.Input
import androidx.compose.material.icons.automirrored.filled.PlaylistAdd
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.AddCard
import androidx.compose.material.icons.filled.AppShortcut
import androidx.compose.material.icons.filled.Input
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Output
import androidx.compose.material.icons.filled.PlaylistAdd
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -156,7 +156,7 @@ internal fun ManagerScreen(vm: ReplaceRuleManagerViewModel = viewModel(), finish
navigateToEdit()
},
leadingIcon = {
Icon(Icons.Default.PlaylistAdd, null)
Icon(Icons.AutoMirrored.Filled.PlaylistAdd, null)
}
)
DropdownMenuItem(
Expand Down Expand Up @@ -195,7 +195,7 @@ internal fun ManagerScreen(vm: ReplaceRuleManagerViewModel = viewModel(), finish
showOptions = false
showImportSheet = true
},
leadingIcon = { Icon(Icons.Default.Input, null) }
leadingIcon = { Icon(Icons.AutoMirrored.Filled.Input, null) }
)

DropdownMenuItem(
Expand Down Expand Up @@ -295,6 +295,8 @@ internal fun ManagerScreen(vm: ReplaceRuleManagerViewModel = viewModel(), finish
onEdit = { showGroupEditDialog = g },
onDelete = {
vm.deleteGroup(groupWithRules)
if (groupWithRules.list.find { it.isEnabled } != null)
SystemTtsService.notifyUpdateConfig(isOnlyReplacer = true)
},
onExport = { showExportSheet = listOf(groupWithRules) },
onSort = { showSortDialog = groupWithRules.list }
Expand All @@ -318,7 +320,11 @@ internal fun ManagerScreen(vm: ReplaceRuleManagerViewModel = viewModel(), finish
},
onClick = { },
onEdit = { navigateToEdit(rule) },
onDelete = { vm.deleteRule(rule) },
onDelete = {
vm.deleteRule(rule)
if (rule.isEnabled)
SystemTtsService.notifyUpdateConfig(isOnlyReplacer = true)
},
onMoveTop = { vm.moveTop(rule) },
onMoveBottom = { vm.moveBottom(rule) }
)
Expand Down

0 comments on commit 6ca8d20

Please sign in to comment.