mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-08 06:56:10 +00:00
Address Jack review on alternate app icons (#1568).
This commit is contained in:
parent
d461b07793
commit
88885d178b
File diff suppressed because it is too large
Load Diff
@ -67,11 +67,10 @@ enum AlternateAppIconSettings {
|
||||
}
|
||||
}
|
||||
|
||||
// periphery:ignore - convenience for iOS settings; storage APIs below are
|
||||
// what panic wipe and tests exercise on the macOS scan.
|
||||
/// Current preference (UserDefaults). The App Info picker calls
|
||||
/// `setSelected` directly — no setter here.
|
||||
static var selected: Icon {
|
||||
get { selected(in: .standard) }
|
||||
set { setSelected(newValue, in: .standard, applySystem: true) }
|
||||
selected(in: .standard)
|
||||
}
|
||||
|
||||
static func selected(in defaults: UserDefaults) -> Icon {
|
||||
@ -95,9 +94,12 @@ enum AlternateAppIconSettings {
|
||||
apply(selected(in: .standard))
|
||||
}
|
||||
|
||||
/// Panic wipe clears the *stored* preference only — do not call `apply`.
|
||||
/// `setAlternateIconName` pops a system alert that names "bitchat", which
|
||||
/// would un-disguise the phone at the worst moment. The home-screen glyph
|
||||
/// stays until the next intentional picker change or relaunch policy.
|
||||
static func reset(in defaults: UserDefaults = .standard) {
|
||||
defaults.removeObject(forKey: storageKey)
|
||||
apply(.primary)
|
||||
}
|
||||
|
||||
private static func apply(_ icon: Icon) {
|
||||
|
||||
@ -65,7 +65,7 @@ struct AppInfoView: View {
|
||||
static let tabInfo = String(localized: "app_info.tab.info", defaultValue: "info", comment: "Segmented control label for the info pane of the app info sheet")
|
||||
|
||||
static let iconTitle = String(localized: "app_info.settings.icon.title", defaultValue: "HOME SCREEN ICON", comment: "Section header (uppercase) for alternate app icon picker") // periphery:ignore - iOS App Info settings UI
|
||||
static let iconSubtitle = String(localized: "app_info.settings.icon.subtitle", defaultValue: "optional low-profile icons. the real app name still shows in settings and search — this only changes the home-screen glyph.", comment: "Caption under the alternate app icon picker explaining the limits of disguise") // periphery:ignore - iOS App Info settings UI
|
||||
static let iconSubtitle = String(localized: "app_info.settings.icon.subtitle", defaultValue: "optional low-profile icons. the home-screen label still reads “bitchat”, and the real name still shows in settings and search — this only changes the glyph.", comment: "Caption under the alternate app icon picker explaining the limits of disguise") // periphery:ignore - iOS App Info settings UI
|
||||
|
||||
static let connectivityTitle = String(localized: "app_info.settings.connectivity.title", defaultValue: "CONNECTIVITY", comment: "Section header (uppercase) for the connectivity toggles: mesh bridge, internet gateway, tor routing")
|
||||
|
||||
|
||||
@ -3,9 +3,13 @@ import Testing
|
||||
@testable import bitchat
|
||||
|
||||
struct AlternateAppIconSettingsTests {
|
||||
private func makeDefaults() -> UserDefaults {
|
||||
private func makeDefaults() -> (suite: String, defaults: UserDefaults) {
|
||||
let suite = "bitchat.tests.alticon.\(UUID().uuidString)"
|
||||
return UserDefaults(suiteName: suite)!
|
||||
return (suite, UserDefaults(suiteName: suite)!)
|
||||
}
|
||||
|
||||
private func cleanup(_ suite: String) {
|
||||
UserDefaults().removePersistentDomain(forName: suite)
|
||||
}
|
||||
|
||||
@Test func primarySystemNameIsNil() {
|
||||
@ -24,7 +28,8 @@ struct AlternateAppIconSettingsTests {
|
||||
}
|
||||
|
||||
@Test func selectedPersistsRawValueWithoutTouchingSystem() {
|
||||
let defaults = makeDefaults()
|
||||
let (suite, defaults) = makeDefaults()
|
||||
defer { cleanup(suite) }
|
||||
#expect(AlternateAppIconSettings.selected(in: defaults) == .primary)
|
||||
|
||||
AlternateAppIconSettings.setSelected(.notes, in: defaults, applySystem: false)
|
||||
@ -36,10 +41,12 @@ struct AlternateAppIconSettingsTests {
|
||||
#expect(AlternateAppIconSettings.selected(in: defaults) == .primary)
|
||||
}
|
||||
|
||||
@Test func resetClearsStoredPreference() {
|
||||
let defaults = makeDefaults()
|
||||
@Test func resetClearsStoredPreferenceWithoutApplyingPrimary() {
|
||||
let (suite, defaults) = makeDefaults()
|
||||
defer { cleanup(suite) }
|
||||
AlternateAppIconSettings.setSelected(.quiet, in: defaults, applySystem: false)
|
||||
defaults.removeObject(forKey: AlternateAppIconSettings.storageKey)
|
||||
AlternateAppIconSettings.reset(in: defaults)
|
||||
#expect(defaults.string(forKey: AlternateAppIconSettings.storageKey) == nil)
|
||||
#expect(AlternateAppIconSettings.selected(in: defaults) == .primary)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user