mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
53d3ecc6a6
commit
70d814c83c
@ -12753,6 +12753,10 @@ Sorry for the inconvenience.";
|
|||||||
"SensitiveContent.ViewAnyway" = "View Anyway";
|
"SensitiveContent.ViewAnyway" = "View Anyway";
|
||||||
"SensitiveContent.SettingsInfo" = "You can update the visibility of sensitive media in [Data and Storage > Show 18+ Content]().";
|
"SensitiveContent.SettingsInfo" = "You can update the visibility of sensitive media in [Data and Storage > Show 18+ Content]().";
|
||||||
|
|
||||||
|
"SensitiveContent.Enable.Title" = "18+ Content";
|
||||||
|
"SensitiveContent.Enable.Text" = "Confirm that you are over 18 years old and update settings to see potentially explicit and sensitive content.";
|
||||||
|
"SensitiveContent.Enable.Confirm" = "Confirm";
|
||||||
|
|
||||||
"Notification.Refund" = "You received a refund of {amount} from {name}";
|
"Notification.Refund" = "You received a refund of {amount} from {name}";
|
||||||
|
|
||||||
"InviteLink.SubscriptionFee.Title" = "SUBSCRIPTION FEE";
|
"InviteLink.SubscriptionFee.Title" = "SUBSCRIPTION FEE";
|
||||||
|
@ -13,6 +13,7 @@ import AccountContext
|
|||||||
import OpenInExternalAppUI
|
import OpenInExternalAppUI
|
||||||
import ItemListPeerActionItem
|
import ItemListPeerActionItem
|
||||||
import StorageUsageScreen
|
import StorageUsageScreen
|
||||||
|
import PresentationDataUtils
|
||||||
|
|
||||||
public enum AutomaticSaveIncomingPeerType {
|
public enum AutomaticSaveIncomingPeerType {
|
||||||
case privateChats
|
case privateChats
|
||||||
@ -35,7 +36,6 @@ private final class DataAndStorageControllerArguments {
|
|||||||
let openBrowserSelection: () -> Void
|
let openBrowserSelection: () -> Void
|
||||||
let openIntents: () -> Void
|
let openIntents: () -> Void
|
||||||
let toggleSensitiveContent: (Bool) -> Void
|
let toggleSensitiveContent: (Bool) -> Void
|
||||||
let toggleOtherSensitiveContent: (Bool) -> Void
|
|
||||||
|
|
||||||
init(
|
init(
|
||||||
openStorageUsage: @escaping () -> Void,
|
openStorageUsage: @escaping () -> Void,
|
||||||
@ -51,8 +51,7 @@ private final class DataAndStorageControllerArguments {
|
|||||||
toggleDownloadInBackground: @escaping (Bool) -> Void,
|
toggleDownloadInBackground: @escaping (Bool) -> Void,
|
||||||
openBrowserSelection: @escaping () -> Void,
|
openBrowserSelection: @escaping () -> Void,
|
||||||
openIntents: @escaping () -> Void,
|
openIntents: @escaping () -> Void,
|
||||||
toggleSensitiveContent: @escaping (Bool) -> Void,
|
toggleSensitiveContent: @escaping (Bool) -> Void
|
||||||
toggleOtherSensitiveContent: @escaping (Bool) -> Void
|
|
||||||
) {
|
) {
|
||||||
self.openStorageUsage = openStorageUsage
|
self.openStorageUsage = openStorageUsage
|
||||||
self.openNetworkUsage = openNetworkUsage
|
self.openNetworkUsage = openNetworkUsage
|
||||||
@ -68,7 +67,6 @@ private final class DataAndStorageControllerArguments {
|
|||||||
self.openBrowserSelection = openBrowserSelection
|
self.openBrowserSelection = openBrowserSelection
|
||||||
self.openIntents = openIntents
|
self.openIntents = openIntents
|
||||||
self.toggleSensitiveContent = toggleSensitiveContent
|
self.toggleSensitiveContent = toggleSensitiveContent
|
||||||
self.toggleOtherSensitiveContent = toggleOtherSensitiveContent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +79,6 @@ private enum DataAndStorageSection: Int32 {
|
|||||||
case other
|
case other
|
||||||
case connection
|
case connection
|
||||||
case sensitiveContent
|
case sensitiveContent
|
||||||
case otherSensitiveContent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DataAndStorageEntryTag: ItemListItemTag, Equatable {
|
public enum DataAndStorageEntryTag: ItemListItemTag, Equatable {
|
||||||
@ -132,7 +129,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||||||
|
|
||||||
case connectionHeader(PresentationTheme, String)
|
case connectionHeader(PresentationTheme, String)
|
||||||
case connectionProxy(PresentationTheme, String, String)
|
case connectionProxy(PresentationTheme, String, String)
|
||||||
case otherSensitiveContent(String, Bool)
|
|
||||||
|
|
||||||
var section: ItemListSectionId {
|
var section: ItemListSectionId {
|
||||||
switch self {
|
switch self {
|
||||||
@ -152,8 +148,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||||||
return DataAndStorageSection.sensitiveContent.rawValue
|
return DataAndStorageSection.sensitiveContent.rawValue
|
||||||
case .connectionHeader, .connectionProxy:
|
case .connectionHeader, .connectionProxy:
|
||||||
return DataAndStorageSection.connection.rawValue
|
return DataAndStorageSection.connection.rawValue
|
||||||
case .otherSensitiveContent:
|
|
||||||
return DataAndStorageSection.otherSensitiveContent.rawValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +201,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||||||
return 38
|
return 38
|
||||||
case .connectionProxy:
|
case .connectionProxy:
|
||||||
return 39
|
return 39
|
||||||
case .otherSensitiveContent:
|
|
||||||
return 40
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,12 +350,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .otherSensitiveContent(text, value):
|
|
||||||
if case .otherSensitiveContent(text, value) = rhs {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,8 +436,8 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||||||
case let .raiseToListenInfo(_, text):
|
case let .raiseToListenInfo(_, text):
|
||||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
||||||
case let .sensitiveContent(text, value):
|
case let .sensitiveContent(text, value):
|
||||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, enableInteractiveChanges: false, sectionId: self.section, style: .blocks, updated: { value in
|
||||||
arguments.toggleOtherSensitiveContent(value)
|
arguments.toggleSensitiveContent(value)
|
||||||
}, tag: DataAndStorageEntryTag.sensitiveContent)
|
}, tag: DataAndStorageEntryTag.sensitiveContent)
|
||||||
case let .sensitiveContentInfo(text):
|
case let .sensitiveContentInfo(text):
|
||||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
||||||
@ -467,10 +453,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||||
arguments.openProxy()
|
arguments.openProxy()
|
||||||
})
|
})
|
||||||
case let .otherSensitiveContent(text, value):
|
|
||||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
|
||||||
arguments.toggleOtherSensitiveContent(value)
|
|
||||||
}, tag: nil)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,8 +656,10 @@ private func dataAndStorageControllerEntries(state: DataAndStorageControllerStat
|
|||||||
entries.append(.raiseToListen(presentationData.theme, presentationData.strings.Settings_RaiseToListen, data.mediaInputSettings.enableRaiseToSpeak))
|
entries.append(.raiseToListen(presentationData.theme, presentationData.strings.Settings_RaiseToListen, data.mediaInputSettings.enableRaiseToSpeak))
|
||||||
entries.append(.raiseToListenInfo(presentationData.theme, presentationData.strings.Settings_RaiseToListenInfo))
|
entries.append(.raiseToListenInfo(presentationData.theme, presentationData.strings.Settings_RaiseToListenInfo))
|
||||||
|
|
||||||
entries.append(.sensitiveContent(presentationData.strings.Settings_SensitiveContent, contentSettingsConfiguration?.sensitiveContentEnabled ?? false))
|
if let contentSettingsConfiguration = contentSettingsConfiguration, contentSettingsConfiguration.canAdjustSensitiveContent {
|
||||||
entries.append(.sensitiveContentInfo(presentationData.strings.Settings_SensitiveContentInfo))
|
entries.append(.sensitiveContent(presentationData.strings.Settings_SensitiveContent, contentSettingsConfiguration.sensitiveContentEnabled))
|
||||||
|
entries.append(.sensitiveContentInfo(presentationData.strings.Settings_SensitiveContentInfo))
|
||||||
|
}
|
||||||
|
|
||||||
let proxyValue: String
|
let proxyValue: String
|
||||||
if let proxySettings = data.proxySettings, let activeServer = proxySettings.activeServer, proxySettings.enabled {
|
if let proxySettings = data.proxySettings, let activeServer = proxySettings.activeServer, proxySettings.enabled {
|
||||||
@ -691,12 +675,6 @@ private func dataAndStorageControllerEntries(state: DataAndStorageControllerStat
|
|||||||
entries.append(.connectionHeader(presentationData.theme, presentationData.strings.ChatSettings_ConnectionType_Title.uppercased()))
|
entries.append(.connectionHeader(presentationData.theme, presentationData.strings.ChatSettings_ConnectionType_Title.uppercased()))
|
||||||
entries.append(.connectionProxy(presentationData.theme, presentationData.strings.SocksProxySetup_Title, proxyValue))
|
entries.append(.connectionProxy(presentationData.theme, presentationData.strings.SocksProxySetup_Title, proxyValue))
|
||||||
|
|
||||||
// #if DEBUG
|
|
||||||
// if let contentSettingsConfiguration = contentSettingsConfiguration, contentSettingsConfiguration.canAdjustSensitiveContent {
|
|
||||||
// entries.append(.otherSensitiveContent("Display Sensitive Content", contentSettingsConfiguration.sensitiveContentEnabled))
|
|
||||||
// }
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,17 +900,30 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
|||||||
}, openIntents: {
|
}, openIntents: {
|
||||||
let controller = intentsSettingsController(context: context)
|
let controller = intentsSettingsController(context: context)
|
||||||
pushControllerImpl?(controller)
|
pushControllerImpl?(controller)
|
||||||
}, toggleSensitiveContent: { _ in
|
}, toggleSensitiveContent: { value in
|
||||||
}, toggleOtherSensitiveContent: { value in
|
let update = {
|
||||||
let _ = (contentSettingsConfiguration.get()
|
let _ = (contentSettingsConfiguration.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { [weak contentSettingsConfiguration] settings in
|
|> deliverOnMainQueue).start(next: { [weak contentSettingsConfiguration] settings in
|
||||||
if var settings = settings {
|
if var settings = settings {
|
||||||
settings.sensitiveContentEnabled = value
|
settings.sensitiveContentEnabled = value
|
||||||
contentSettingsConfiguration?.set(.single(settings))
|
contentSettingsConfiguration?.set(.single(settings))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
updateSensitiveContentDisposable.set(updateRemoteContentSettingsConfiguration(postbox: context.account.postbox, network: context.account.network, sensitiveContentEnabled: value).start())
|
updateSensitiveContentDisposable.set(updateRemoteContentSettingsConfiguration(postbox: context.account.postbox, network: context.account.network, sensitiveContentEnabled: value).start())
|
||||||
|
}
|
||||||
|
if value {
|
||||||
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
let alertController = textAlertController(context: context, title: presentationData.strings.SensitiveContent_Enable_Title, text: presentationData.strings.SensitiveContent_Enable_Text, actions: [
|
||||||
|
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}),
|
||||||
|
TextAlertAction(type: .defaultAction, title: presentationData.strings.SensitiveContent_Enable_Confirm, action: {
|
||||||
|
update()
|
||||||
|
})
|
||||||
|
])
|
||||||
|
presentControllerImpl?(alertController, nil)
|
||||||
|
} else {
|
||||||
|
update()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let preferencesKey: PostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
let preferencesKey: PostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||||
@ -952,6 +943,8 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sensitiveContent = Atomic<Bool?>(value: nil)
|
||||||
|
|
||||||
let signal = combineLatest(queue: .mainQueue(),
|
let signal = combineLatest(queue: .mainQueue(),
|
||||||
context.sharedContext.presentationData,
|
context.sharedContext.presentationData,
|
||||||
statePromise.get(),
|
statePromise.get(),
|
||||||
@ -976,8 +969,14 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
|||||||
defaultWebBrowser = presentationData.strings.WebBrowser_Telegram
|
defaultWebBrowser = presentationData.strings.WebBrowser_Telegram
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let previousSensitiveContent = sensitiveContent.swap(contentSettingsConfiguration?.sensitiveContentEnabled)
|
||||||
|
var animateChanges = false
|
||||||
|
if previousSensitiveContent != contentSettingsConfiguration?.sensitiveContentEnabled {
|
||||||
|
animateChanges = true
|
||||||
|
}
|
||||||
|
|
||||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.ChatSettings_Title), leftNavigationButton: nil, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.ChatSettings_Title), leftNavigationButton: nil, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: dataAndStorageControllerEntries(state: state, data: dataAndStorageData, presentationData: presentationData, defaultWebBrowser: defaultWebBrowser, contentSettingsConfiguration: contentSettingsConfiguration, networkUsage: usageSignal.network, storageUsage: usageSignal.storage, mediaAutoSaveSettings: mediaAutoSaveSettings, autosaveExceptionPeers: autosaveExceptionPeers, mediaSettings: mediaSettings), style: .blocks, ensureVisibleItemTag: focusOnItemTag, emptyStateItem: nil, animateChanges: false)
|
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: dataAndStorageControllerEntries(state: state, data: dataAndStorageData, presentationData: presentationData, defaultWebBrowser: defaultWebBrowser, contentSettingsConfiguration: contentSettingsConfiguration, networkUsage: usageSignal.network, storageUsage: usageSignal.storage, mediaAutoSaveSettings: mediaAutoSaveSettings, autosaveExceptionPeers: autosaveExceptionPeers, mediaSettings: mediaSettings), style: .blocks, ensureVisibleItemTag: focusOnItemTag, emptyStateItem: nil, animateChanges: animateChanges)
|
||||||
|
|
||||||
return (controllerState, (listState, arguments))
|
return (controllerState, (listState, arguments))
|
||||||
} |> afterDisposed {
|
} |> afterDisposed {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user