merge: bring pinyin habit ranking into English keyboard branch
Keep English QuickType/mmap and Chinese schema hygiene on one branch. Secure fields skip Rime; English still loads its lexicon only while English is active.
This commit is contained in:
@@ -90,4 +90,31 @@ final class RimeDeploymentController: ObservableObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Wipes implicit typing habits under the same hostHeavy gate as deploy,
|
||||
/// so the keyboard extension cannot keep LevelDB open while files vanish.
|
||||
func clearTypingHabits() {
|
||||
guard activeTask == nil else { return }
|
||||
|
||||
OSGDiag.log("typing.habits.clear begin \(OSGDiag.memoryTag())", category: "flow")
|
||||
status = .deploying
|
||||
activeTask = Task { @MainActor in
|
||||
defer { activeTask = nil }
|
||||
FlowSessionBridge.setHostHeavy(true)
|
||||
do {
|
||||
try await TypingHabitStore.clearAll()
|
||||
FlowSessionBridge.setHostHeavy(false)
|
||||
AppGroupConfigDarwin.postConfigChanged()
|
||||
status = RimeResourceInstaller.isReady ? .ready : .idle
|
||||
OSGDiag.log("typing.habits.clear done \(OSGDiag.memoryTag())", category: "flow")
|
||||
} catch {
|
||||
FlowSessionBridge.setHostHeavy(false)
|
||||
status = .failed(error.localizedDescription)
|
||||
OSGDiag.log(
|
||||
"typing.habits.clear failed error=\(error.localizedDescription)",
|
||||
category: "flow"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ struct TypingInputSettingsView: View {
|
||||
@ObservedObject private var config = ProviderConfig.shared
|
||||
@ObservedObject private var configuration = TypingInputConfiguration.shared
|
||||
@ObservedObject private var deployment = RimeDeploymentController.shared
|
||||
@State private var showClearHabitsConfirmation = false
|
||||
|
||||
private var isDeploying: Bool { deployment.isDeploying }
|
||||
|
||||
@@ -69,11 +70,36 @@ struct TypingInputSettingsView: View {
|
||||
}
|
||||
.disabled(isDeploying)
|
||||
}
|
||||
|
||||
Section {
|
||||
Button(AppL10n.string("settings.typingInput.habits.clear", language: config.uiLanguage)) {
|
||||
showClearHabitsConfirmation = true
|
||||
}
|
||||
.disabled(isDeploying)
|
||||
.foregroundStyle(palette.danger)
|
||||
} footer: {
|
||||
Text(AppL10n.string("settings.typingInput.habits.footer", language: config.uiLanguage))
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(palette.background)
|
||||
.navigationTitle(AppL10n.string("settings.typingInput.title", language: config.uiLanguage))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.confirmationDialog(
|
||||
AppL10n.string("settings.typingInput.habits.clear.title", language: config.uiLanguage),
|
||||
isPresented: $showClearHabitsConfirmation,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button(
|
||||
AppL10n.string("settings.typingInput.habits.clear.confirm", language: config.uiLanguage),
|
||||
role: .destructive
|
||||
) {
|
||||
deployment.clearTypingHabits()
|
||||
}
|
||||
Button(AppL10n.string("common.cancel", language: config.uiLanguage), role: .cancel) {}
|
||||
} message: {
|
||||
Text(AppL10n.string("settings.typingInput.habits.clear.message", language: config.uiLanguage))
|
||||
}
|
||||
}
|
||||
|
||||
private var hasDeploymentError: Bool {
|
||||
|
||||
@@ -238,6 +238,11 @@
|
||||
"settings.typingInput.resources.ready" = "Ready";
|
||||
"settings.typingInput.resources.pending" = "Not initialized";
|
||||
"settings.typingInput.resources.redeploy" = "Redeploy Input Resources";
|
||||
"settings.typingInput.habits.clear" = "Clear Typing Habits";
|
||||
"settings.typingInput.habits.clear.title" = "Clear Typing Habits?";
|
||||
"settings.typingInput.habits.clear.confirm" = "Clear";
|
||||
"settings.typingInput.habits.clear.message" = "Resets learned word order for Chinese and English. Personal dictionary entries are kept.";
|
||||
"settings.typingInput.habits.footer" = "Learned frequency only. Words you added to the personal dictionary stay.";
|
||||
"settings.speechRecognition.title" = "Speech Recognition";
|
||||
"settings.textPolish.title" = "Text Polish";
|
||||
"settings.preferences.title" = "Preferences";
|
||||
|
||||
@@ -238,6 +238,11 @@
|
||||
"settings.typingInput.resources.ready" = "已就绪";
|
||||
"settings.typingInput.resources.pending" = "待初始化";
|
||||
"settings.typingInput.resources.redeploy" = "重新部署输入法资源";
|
||||
"settings.typingInput.habits.clear" = "清除打字习惯";
|
||||
"settings.typingInput.habits.clear.title" = "清除打字习惯?";
|
||||
"settings.typingInput.habits.clear.confirm" = "清除";
|
||||
"settings.typingInput.habits.clear.message" = "将重置中文和英文的学习词序。个性词库中的词条会保留。";
|
||||
"settings.typingInput.habits.footer" = "只清除使用频度。你手动加入个性词库的词不会受影响。";
|
||||
"settings.speechRecognition.title" = "语音识别";
|
||||
"settings.textPolish.title" = "文本润色";
|
||||
"settings.preferences.title" = "偏好设置";
|
||||
|
||||
Reference in New Issue
Block a user