mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-04-29 03:15:59 +02:00
03f35f40b5
- Anti-Delete: save deleted messages locally - Ghost Mode: hide online status, read receipts - Voice Morpher: audio processing effects - Device Spoof: spoof device info - Custom GhostIcon app icon - User Notes: personal notes for contacts - Misc settings and controllers - GPLv2 License
148 lines
4.7 KiB
Swift
148 lines
4.7 KiB
Swift
import Foundation
|
|
|
|
/// MiscSettingsManager - Central manager for Misc privacy settings
|
|
/// Handles: Forward bypass, View-Once persistence, Screenshot bypass
|
|
public final class MiscSettingsManager {
|
|
public static let shared = MiscSettingsManager()
|
|
|
|
private enum Keys {
|
|
static let isEnabled = "MiscSettings.isEnabled"
|
|
static let bypassCopyProtection = "MiscSettings.bypassCopyProtection"
|
|
static let disableViewOnceAutoDelete = "MiscSettings.disableViewOnceAutoDelete"
|
|
static let bypassScreenshotProtection = "MiscSettings.bypassScreenshotProtection"
|
|
static let blockAds = "MiscSettings.blockAds"
|
|
static let alwaysOnline = "MiscSettings.alwaysOnline"
|
|
}
|
|
|
|
private let defaults = UserDefaults.standard
|
|
|
|
// MARK: - Main Toggle
|
|
|
|
public var isEnabled: Bool {
|
|
get { defaults.bool(forKey: Keys.isEnabled) }
|
|
set {
|
|
defaults.set(newValue, forKey: Keys.isEnabled)
|
|
notifySettingsChanged()
|
|
}
|
|
}
|
|
|
|
// MARK: - Individual Features
|
|
|
|
/// Allow forwarding/copying from protected channels and chats
|
|
public var bypassCopyProtection: Bool {
|
|
get { defaults.bool(forKey: Keys.bypassCopyProtection) }
|
|
set {
|
|
defaults.set(newValue, forKey: Keys.bypassCopyProtection)
|
|
notifySettingsChanged()
|
|
}
|
|
}
|
|
|
|
/// Keep View-Once media visible (don't auto-delete after viewing)
|
|
public var disableViewOnceAutoDelete: Bool {
|
|
get { defaults.bool(forKey: Keys.disableViewOnceAutoDelete) }
|
|
set {
|
|
defaults.set(newValue, forKey: Keys.disableViewOnceAutoDelete)
|
|
notifySettingsChanged()
|
|
}
|
|
}
|
|
|
|
/// Allow screenshots in secret chats and protected content
|
|
public var bypassScreenshotProtection: Bool {
|
|
get { defaults.bool(forKey: Keys.bypassScreenshotProtection) }
|
|
set {
|
|
defaults.set(newValue, forKey: Keys.bypassScreenshotProtection)
|
|
notifySettingsChanged()
|
|
}
|
|
}
|
|
|
|
/// Block all sponsored messages (ads) in channels
|
|
public var blockAds: Bool {
|
|
get { defaults.bool(forKey: Keys.blockAds) }
|
|
set {
|
|
defaults.set(newValue, forKey: Keys.blockAds)
|
|
notifySettingsChanged()
|
|
}
|
|
}
|
|
|
|
/// Keep online status always active
|
|
public var alwaysOnline: Bool {
|
|
get { defaults.bool(forKey: Keys.alwaysOnline) }
|
|
set {
|
|
defaults.set(newValue, forKey: Keys.alwaysOnline)
|
|
notifySettingsChanged()
|
|
}
|
|
}
|
|
|
|
// MARK: - Computed Properties (considers master toggle)
|
|
|
|
public var shouldBypassCopyProtection: Bool {
|
|
return isEnabled && bypassCopyProtection
|
|
}
|
|
|
|
public var shouldDisableViewOnceAutoDelete: Bool {
|
|
return isEnabled && disableViewOnceAutoDelete
|
|
}
|
|
|
|
public var shouldBypassScreenshotProtection: Bool {
|
|
return isEnabled && bypassScreenshotProtection
|
|
}
|
|
|
|
public var shouldBlockAds: Bool {
|
|
return isEnabled && blockAds
|
|
}
|
|
|
|
public var shouldAlwaysBeOnline: Bool {
|
|
return isEnabled && alwaysOnline
|
|
}
|
|
|
|
// MARK: - Utility
|
|
|
|
public var activeFeatureCount: Int {
|
|
var count = 0
|
|
if bypassCopyProtection { count += 1 }
|
|
if disableViewOnceAutoDelete { count += 1 }
|
|
if bypassScreenshotProtection { count += 1 }
|
|
if blockAds { count += 1 }
|
|
if alwaysOnline { count += 1 }
|
|
return count
|
|
}
|
|
|
|
public func enableAll() {
|
|
bypassCopyProtection = true
|
|
disableViewOnceAutoDelete = true
|
|
bypassScreenshotProtection = true
|
|
blockAds = true
|
|
alwaysOnline = true
|
|
}
|
|
|
|
public func disableAll() {
|
|
bypassCopyProtection = false
|
|
disableViewOnceAutoDelete = false
|
|
bypassScreenshotProtection = false
|
|
blockAds = false
|
|
alwaysOnline = false
|
|
}
|
|
|
|
// MARK: - Notification
|
|
|
|
public static let settingsChangedNotification = Notification.Name("MiscSettingsChanged")
|
|
|
|
private func notifySettingsChanged() {
|
|
NotificationCenter.default.post(name: MiscSettingsManager.settingsChangedNotification, object: nil)
|
|
}
|
|
|
|
// MARK: - Init
|
|
|
|
private init() {
|
|
// Set default values if first launch
|
|
if !defaults.bool(forKey: "MiscSettings.initialized") {
|
|
defaults.set(true, forKey: "MiscSettings.initialized")
|
|
defaults.set(false, forKey: Keys.isEnabled)
|
|
defaults.set(true, forKey: Keys.bypassCopyProtection)
|
|
defaults.set(true, forKey: Keys.disableViewOnceAutoDelete)
|
|
defaults.set(true, forKey: Keys.bypassScreenshotProtection)
|
|
defaults.set(true, forKey: Keys.blockAds)
|
|
}
|
|
}
|
|
}
|