From fca41efd0607215548076760bdf4756ab804f840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarci=CC=81sio=20Costa?= Date: Thu, 14 Sep 2023 19:08:53 -0700 Subject: [PATCH 1/2] feature: - added the ability to combine meaning and reading reviews on Anki Mode - added option to settings screen, which is only shown when Anki Mode is enabled - reading / meaning order shown respects the configuration set when back-to-back is enabled - this feature works by making use of "back-to-back" reviews built-in functionality, so any time a non-radical review is marked correct, it takes the "next task" and marks that as correct as well. --- ios/ReviewSession.swift | 6 ++++-- ios/ReviewSettingsViewController.swift | 20 ++++++++++++++++++++ ios/ReviewViewController.swift | 15 ++++++++++++++- ios/Settings.swift | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ios/ReviewSession.swift b/ios/ReviewSession.swift index 038be33b..1cbe5ab0 100644 --- a/ios/ReviewSession.swift +++ b/ios/ReviewSession.swift @@ -39,7 +39,8 @@ class ReviewSession { self.services = services reviewQueue = items - if Settings.groupMeaningReading { + if Settings.groupMeaningReading || (Settings.ankiMode && + Settings.ankiModeCombineReadingMeaning) { activeQueueSize = 1 } else { activeQueueSize = Int(Settings.reviewBatchSize) @@ -85,7 +86,8 @@ class ReviewSession { activeTaskType = .reading } else if activeTask.answeredReading || activeSubject.readings.isEmpty { activeTaskType = .meaning - } else if Settings.groupMeaningReading { + } else if Settings.groupMeaningReading || (Settings.ankiMode && + Settings.ankiModeCombineReadingMeaning) { activeTaskType = Settings.meaningFirst ? .meaning : .reading } else { activeTaskType = TaskType.random() diff --git a/ios/ReviewSettingsViewController.swift b/ios/ReviewSettingsViewController.swift index b94e83d3..58e764b3 100644 --- a/ios/ReviewSettingsViewController.swift +++ b/ios/ReviewSettingsViewController.swift @@ -19,6 +19,7 @@ class ReviewSettingsViewController: UITableViewController, TKMViewController { private var services: TKMServices! private var model: TableModel? private var groupMeaningReadingIndexPath: IndexPath? + private var ankiModeCombineReadingMeaningIndexPath: IndexPath? func setup(services: TKMServices) { self.services = services @@ -151,6 +152,17 @@ class ReviewSettingsViewController: UITableViewController, TKMViewController { target: self, action: #selector(ankiModeSwitchChanged(_:)))) + let ankiModeCombineReadingMeaning = SwitchModelItem(style: .subtitle, + title: "Combine Reading + Meaning", + subtitle: "Only one review for reading and meaning with Anki Mode activated", + on: Settings.ankiModeCombineReadingMeaning, + target: self, + action: #selector(ankiModeCombineReadingMeaningSwitchChanged(_:))) + + ankiModeCombineReadingMeaning.numberOfSubtitleLines = 0 + ankiModeCombineReadingMeaningIndexPath = model.add(ankiModeCombineReadingMeaning, + hidden:!Settings.ankiMode) + model.add(section: "Audio") model.add(SwitchModelItem(style: .subtitle, title: "Play audio automatically", @@ -292,6 +304,14 @@ class ReviewSettingsViewController: UITableViewController, TKMViewController { @objc private func ankiModeSwitchChanged(_ switchView: UISwitch) { Settings.ankiMode = switchView.isOn + Settings.ankiModeCombineReadingMeaning = false + if let indexPath = ankiModeCombineReadingMeaningIndexPath { + model?.setIndexPath(indexPath, hidden: !switchView.isOn) + } + } + + @objc private func ankiModeCombineReadingMeaningSwitchChanged(_ switchView: UISwitch) { + Settings.ankiModeCombineReadingMeaning = switchView.isOn } @objc private func playAudioAutomaticallySwitchChanged(_ switchView: UISwitch) { diff --git a/ios/ReviewViewController.swift b/ios/ReviewViewController.swift index 80321ddd..e8c5ccc8 100644 --- a/ios/ReviewViewController.swift +++ b/ios/ReviewViewController.swift @@ -503,6 +503,12 @@ class ReviewViewController: UIViewController, UITextFieldDelegate, SubjectDelega } } + if session.activeAssignment.subjectType != .radical, + Settings.ankiMode, + Settings.ankiModeCombineReadingMeaning { + taskTypePrompt = Settings.meaningFirst ? "Meaning + Reading" : "Reading + Meaning" + } + // Choose a random font. currentFontName = randomFont(thatCanRenderText: session.activeSubject.japanese) @@ -1019,10 +1025,17 @@ class ReviewViewController: UIViewController, UITextFieldDelegate, SubjectDelega } // Mark the task. - let marked = session.markAnswer(result) + var marked = session.markAnswer(result) // Show a new task if it was correct. if result != .Incorrect { + if session.activeAssignment.subjectType != .radical, // or kana mode? + Settings.ankiMode, + Settings.ankiModeCombineReadingMeaning { + session.nextTask() + marked = session.markAnswer(.Correct) + } + if Settings.playAudioAutomatically, session.activeTaskType == .reading, let subject = session.activeSubject, subject.hasVocabulary, !subject.vocabulary.audio.isEmpty { diff --git a/ios/Settings.swift b/ios/Settings.swift index 2f617f31..8687927f 100644 --- a/ios/Settings.swift +++ b/ios/Settings.swift @@ -197,6 +197,7 @@ protocol SettingProtocol { @Setting(false, #keyPath(allowSkippingReviews)) static var allowSkippingReviews: Bool @Setting(true, #keyPath(minimizeReviewPenalty)) static var minimizeReviewPenalty: Bool @Setting(false, #keyPath(ankiMode)) static var ankiMode: Bool + @Setting(false, #keyPath(ankiModeCombineReadingMeaning)) static var ankiModeCombineReadingMeaning: Bool @Setting(true, #keyPath(showPreviousLevelGraph)) static var showPreviousLevelGraph: Bool @Setting(true, #keyPath(showKanaOnlyVocab)) static var showKanaOnlyVocab: Bool From c681a930a6664e5ed776e4be41ee4ba384e96823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarci=CC=81sio=20Costa?= Date: Fri, 15 Sep 2023 15:04:44 -0700 Subject: [PATCH 2/2] Updated text --- ios/ReviewSettingsViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/ReviewSettingsViewController.swift b/ios/ReviewSettingsViewController.swift index 58e764b3..640f7419 100644 --- a/ios/ReviewSettingsViewController.swift +++ b/ios/ReviewSettingsViewController.swift @@ -154,7 +154,7 @@ class ReviewSettingsViewController: UITableViewController, TKMViewController { let ankiModeCombineReadingMeaning = SwitchModelItem(style: .subtitle, title: "Combine Reading + Meaning", - subtitle: "Only one review for reading and meaning with Anki Mode activated", + subtitle: "Only one review for reading and meaning with Anki mode enabled", on: Settings.ankiModeCombineReadingMeaning, target: self, action: #selector(ankiModeCombineReadingMeaningSwitchChanged(_:)))