Skip to content

Commit

Permalink
Add setting toggle for lock screen scrubber
Browse files Browse the repository at this point in the history
  • Loading branch information
bjtitus committed Dec 11, 2024
1 parent a22de83 commit aa4e900
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions podcasts/Analytics/AnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ enum AnalyticsEvent: String {
case settingsGeneralSkipBackChanged
case settingsGeneralKeepScreenAwakeToggled
case settingsGeneralOpenPlayerAutomaticallyToggled
case settingsGeneralDisableLockScreenScrubberToggled
case settingsGeneralIntelligentPlaybackToggled
case settingsGeneralPlayUpNextOnTapToggled
case settingsGeneralRemoteSkipsChaptersToggled
Expand Down
2 changes: 2 additions & 0 deletions podcasts/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ struct Constants {
static let sleepTimerFinishedDate = "sleepTimerFinishedDate"
static let sleepTimerSetting = "sleepTimerSetting"

static let isLockScreenScrubbingDisabled = "IsLockScreenScrubbingDisabled"

enum headphones {
static let previousAction = SettingValue("headphones.previousAction",
defaultValue: HeadphoneControlAction.skipBack)
Expand Down
20 changes: 18 additions & 2 deletions podcasts/GeneralSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class GeneralSettingsViewController: PCViewController, UITableViewDelegate, UITa

let debounce = Debounce(delay: Constants.defaultDebounceTime)

private enum TableRow { case skipForward, skipBack, keepScreenAwake, openPlayer, intelligentPlaybackResumption, defaultRowAction, extraMediaActions, defaultAddToUpNextSwipe, defaultGrouping, defaultArchive, playUpNextOnTap, legacyBluetooth, multiSelectGesture, openLinksInBrowser, publishChapterTitles, autoplay, autoRestartSleepTimer, shakeToRestartSleepTimer }
private var tableData: [[TableRow]] = [[.defaultRowAction, .defaultGrouping, .defaultArchive, .defaultAddToUpNextSwipe, .openLinksInBrowser], [.skipForward, .skipBack, .keepScreenAwake, .openPlayer, .intelligentPlaybackResumption], [.autoRestartSleepTimer], [.shakeToRestartSleepTimer], [.playUpNextOnTap], [.extraMediaActions], [.legacyBluetooth], [.multiSelectGesture], [.publishChapterTitles], [.autoplay]]
private enum TableRow { case skipForward, skipBack, keepScreenAwake, openPlayer, intelligentPlaybackResumption, defaultRowAction, extraMediaActions, defaultAddToUpNextSwipe, defaultGrouping, defaultArchive, playUpNextOnTap, legacyBluetooth, multiSelectGesture, openLinksInBrowser, publishChapterTitles, autoplay, autoRestartSleepTimer, shakeToRestartSleepTimer, isLockScreenScrubberDisabled }
private var tableData: [[TableRow]] = [[.defaultRowAction, .defaultGrouping, .defaultArchive, .defaultAddToUpNextSwipe, .openLinksInBrowser], [.skipForward, .skipBack, .keepScreenAwake, .openPlayer, .isLockScreenScrubberDisabled, .intelligentPlaybackResumption], [.autoRestartSleepTimer], [.shakeToRestartSleepTimer], [.playUpNextOnTap], [.extraMediaActions], [.legacyBluetooth], [.multiSelectGesture], [.publishChapterTitles], [.autoplay]]

@IBOutlet var settingsTable: UITableView! {
didSet {
Expand Down Expand Up @@ -277,6 +277,16 @@ class GeneralSettingsViewController: PCViewController, UITableViewDelegate, UITa
cell.cellSwitch.removeTarget(self, action: nil, for: .valueChanged)
cell.cellSwitch.addTarget(self, action: #selector(shakeToRestartSleepTimerToggled(_:)), for: .valueChanged)

return cell
case .isLockScreenScrubberDisabled:
let cell = tableView.dequeueReusableCell(withIdentifier: switchCellId, for: indexPath) as! SwitchCell

cell.cellLabel.text = L10n.settingsGeneralLockScreenDisabled
cell.cellSwitch.isOn = !Settings.isLockScreenScrubbingDisabled

cell.cellSwitch.removeTarget(self, action: nil, for: .valueChanged)
cell.cellSwitch.addTarget(self, action: #selector(disableLockScreenScrubberToggled(_:)), for: .valueChanged)

return cell
}
}
Expand Down Expand Up @@ -541,6 +551,12 @@ class GeneralSettingsViewController: PCViewController, UITableViewDelegate, UITa
Settings.trackValueToggled(.settingsGeneralShakeToResetSleepTimerToggled, enabled: sender.isOn)
}

@objc private func disableLockScreenScrubberToggled(_ sender: UISwitch) {
Settings.isLockScreenScrubbingDisabled = !sender.isOn

Settings.trackValueToggled(.settingsGeneralDisableLockScreenScrubberToggled, enabled: !sender.isOn)
}

override var preferredStatusBarStyle: UIStatusBarStyle {
AppTheme.defaultStatusBarStyle()
}
Expand Down
9 changes: 9 additions & 0 deletions podcasts/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import PocketCastsUtils

class Settings: NSObject {

static var isLockScreenScrubbingDisabled: Bool {
set {
UserDefaults.standard.set(newValue, forKey: Constants.UserDefaults.openLinksInExternalBrowser)
}
get {
return UserDefaults.standard.bool(forKey: Constants.UserDefaults.openLinksInExternalBrowser)
}
}

static var openLinks: Bool {
set {
if FeatureFlag.newSettingsStorage.enabled {
Expand Down
2 changes: 2 additions & 0 deletions podcasts/Strings+Generated.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions podcasts/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,9 @@
/* Subtitle explaining the feature that adjusts the playback position when resuming. */
"settings_general_smart_playback_subtitle" = "If on, Pocket Casts will go back a little in episodes you resume so you can catch up more comfortably.";

/* Setting toggle to enable the feature that disables the lock screen scrubber. */
"settings_general_lock_screen_disabled" = "Lock Screen Scrubbing";

/* Setting option to choose how to handle swiping to add something to the queue. */
"settings_general_up_next_swipe" = "Up Next Swipe";

Expand Down

0 comments on commit aa4e900

Please sign in to comment.