mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '1969d38e0f2748fdb20e98a70547039974ec8385'
# Conflicts: # submodules/TelegramUI/Sources/OpenUrl.swift
This commit is contained in:
commit
692931b27b
@ -12526,6 +12526,8 @@ Sorry for the inconvenience.";
|
||||
"Browser.ContextMenu.CopyLink" = "Copy Link";
|
||||
"Browser.ContextMenu.Share" = "Share";
|
||||
|
||||
"WebBrowser.Telegram" = "Telegram";
|
||||
|
||||
"Monetization.Proceeds.Ton.Info" = "TON from your total balance can be used for ads or withdrawn as rewards 3 days after they are earned.";
|
||||
"Monetization.Proceeds.Stars.Info" = "Stars from your total balance can be used for ads or withdrawn as rewards 21 days after they are earned.";
|
||||
"Monetization.Proceeds.TonAndStars.Info" = "Stars and TON from your total balance can be used for ads or withdrawn as rewards 21 and 3 days respectively after they are earned.";
|
||||
|
@ -178,6 +178,7 @@ final class BrowserNavigationBarComponent: CombinedComponent {
|
||||
|
||||
context.add(readingProgress
|
||||
.position(CGPoint(x: readingProgress.size.width / 2.0, y: size.height / 2.0))
|
||||
.opacity(context.component.centerItem?.id == AnyHashable("search") ? 0.0 : 1.0)
|
||||
)
|
||||
|
||||
context.add(separator
|
||||
|
@ -917,8 +917,10 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
||||
let defaultWebBrowser: String
|
||||
if let option = options.first(where: { $0.identifier == webBrowserSettings.defaultWebBrowser }) {
|
||||
defaultWebBrowser = option.title
|
||||
} else {
|
||||
} else if webBrowserSettings.defaultWebBrowser == "inApp" {
|
||||
defaultWebBrowser = presentationData.strings.WebBrowser_InAppSafari
|
||||
} else {
|
||||
defaultWebBrowser = presentationData.strings.WebBrowser_Telegram
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -8,18 +8,20 @@ import TelegramPresentationData
|
||||
import ItemListUI
|
||||
import PhotoResources
|
||||
import OpenInExternalAppUI
|
||||
import AccountContext
|
||||
import AppBundle
|
||||
|
||||
class WebBrowserItem: ListViewItem, ItemListItem {
|
||||
let engine: TelegramEngine
|
||||
let context: AccountContext
|
||||
let presentationData: ItemListPresentationData
|
||||
let title: String
|
||||
let application: OpenInApplication
|
||||
let application: OpenInApplication?
|
||||
let checked: Bool
|
||||
public let sectionId: ItemListSectionId
|
||||
let action: () -> Void
|
||||
|
||||
public init(engine: TelegramEngine, presentationData: ItemListPresentationData, title: String, application: OpenInApplication, checked: Bool, sectionId: ItemListSectionId, action: @escaping () -> Void) {
|
||||
self.engine = engine
|
||||
public init(context: AccountContext, presentationData: ItemListPresentationData, title: String, application: OpenInApplication?, checked: Bool, sectionId: ItemListSectionId, action: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.presentationData = presentationData
|
||||
self.title = title
|
||||
self.application = application
|
||||
@ -131,6 +133,7 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
||||
let makeIconLayout = self.iconNode.asyncLayout()
|
||||
|
||||
let currentItem = self.item
|
||||
|
||||
|
||||
return { item, params, neighbors in
|
||||
let leftInset: CGFloat = params.leftInset + 16.0 + 43.0
|
||||
@ -140,18 +143,25 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
||||
let imageApply = makeIconLayout(arguments)
|
||||
|
||||
var updatedIconSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
||||
if currentItem?.application != item.application {
|
||||
if currentItem == nil {
|
||||
switch item.application {
|
||||
case .none:
|
||||
let icons = item.context.sharedContext.applicationBindings.getAvailableAlternateIcons()
|
||||
let current = item.context.sharedContext.applicationBindings.getAlternateIconName()
|
||||
let currentIcon = icons.first(where: { $0.name == current })?.imageName ?? "BlueIcon"
|
||||
if let image = UIImage(named: currentIcon, in: getAppBundle(), compatibleWith: nil) {
|
||||
updatedIconSignal = openInAppIcon(engine: item.context.engine, appIcon: .image(image: image))
|
||||
}
|
||||
case .safari:
|
||||
if let image = UIImage(bundleImageName: "Open In/Safari") {
|
||||
updatedIconSignal = openInAppIcon(engine: item.engine, appIcon: .image(image: image))
|
||||
updatedIconSignal = openInAppIcon(engine: item.context.engine, appIcon: .image(image: image))
|
||||
}
|
||||
case .maps:
|
||||
if let image = UIImage(bundleImageName: "Open In/Maps") {
|
||||
updatedIconSignal = openInAppIcon(engine: item.engine, appIcon: .image(image: image))
|
||||
updatedIconSignal = openInAppIcon(engine: item.context.engine, appIcon: .image(image: image))
|
||||
}
|
||||
case let .other(_, identifier, _, store):
|
||||
updatedIconSignal = openInAppIcon(engine: item.engine, appIcon: .resource(resource: OpenInAppIconResource(appStoreId: identifier, store: store)))
|
||||
updatedIconSignal = openInAppIcon(engine: item.context.engine, appIcon: .resource(resource: OpenInAppIconResource(appStoreId: identifier, store: store)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ private enum WebBrowserSettingsSection: Int32 {
|
||||
|
||||
private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
|
||||
case browserHeader(PresentationTheme, String)
|
||||
case browser(PresentationTheme, String, OpenInApplication, String?, Bool, Int32)
|
||||
case browser(PresentationTheme, String, OpenInApplication?, String?, Bool, Int32)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
switch self {
|
||||
@ -71,7 +71,7 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
|
||||
case let .browserHeader(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .browser(_, title, application, identifier, selected, _):
|
||||
return WebBrowserItem(engine: arguments.context.engine, presentationData: presentationData, title: title, application: application, checked: selected, sectionId: self.section) {
|
||||
return WebBrowserItem(context: arguments.context, presentationData: presentationData, title: title, application: application, checked: selected, sectionId: self.section) {
|
||||
arguments.updateDefaultBrowser(identifier)
|
||||
}
|
||||
}
|
||||
@ -84,9 +84,10 @@ private func webBrowserSettingsControllerEntries(context: AccountContext, presen
|
||||
let options = availableOpenInOptions(context: context, item: .url(url: "http://telegram.org"))
|
||||
|
||||
entries.append(.browserHeader(presentationData.theme, presentationData.strings.WebBrowser_DefaultBrowser))
|
||||
entries.append(.browser(presentationData.theme, presentationData.strings.WebBrowser_InAppSafari, .safari, nil, selectedBrowser == nil, 0))
|
||||
entries.append(.browser(presentationData.theme, presentationData.strings.WebBrowser_Telegram, nil, nil, selectedBrowser == nil, 0))
|
||||
entries.append(.browser(presentationData.theme, presentationData.strings.WebBrowser_InAppSafari, .safari, "inApp", selectedBrowser == "inApp", 1))
|
||||
|
||||
var index: Int32 = 1
|
||||
var index: Int32 = 2
|
||||
for option in options {
|
||||
entries.append(.browser(presentationData.theme, option.title, option.application, option.identifier, option.identifier == selectedBrowser, index))
|
||||
index += 1
|
||||
|
@ -1186,7 +1186,7 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
|
||||
|
||||
let starsRevenueContextAndState = context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||
|> mapToSignal { peer -> Signal<(StarsRevenueStatsContext?, StarsRevenueStats?), NoError> in
|
||||
guard let peer, case let .user(user) = peer, let botInfo = user.botInfo, botInfo.flags.contains(.canEdit) || context.sharedContext.applicationBindings.appBuildType == .public else {
|
||||
guard let peer, case let .user(user) = peer, let botInfo = user.botInfo, botInfo.flags.contains(.canEdit) || context.sharedContext.applicationBindings.appBuildType == .internal else {
|
||||
return .single((nil, nil))
|
||||
}
|
||||
let starsRevenueStatsContext = StarsRevenueStatsContext(account: context.account, peerId: peerId)
|
||||
|
@ -1036,9 +1036,19 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
|
||||
let _ = (settings
|
||||
|> deliverOnMainQueue).startStandalone(next: { settings in
|
||||
if settings.defaultWebBrowser == nil {
|
||||
//TODO:release check !isCompact
|
||||
if isCompact || "".isEmpty {
|
||||
if let defaultWebBrowser = settings.defaultWebBrowser, defaultWebBrowser != "inApp" {
|
||||
let openInOptions = availableOpenInOptions(context: context, item: .url(url: url))
|
||||
if let option = openInOptions.first(where: { $0.identifier == settings.defaultWebBrowser }) {
|
||||
if case let .openUrl(url) = option.action() {
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
} else {
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
}
|
||||
} else {
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
}
|
||||
} else {
|
||||
if settings.defaultWebBrowser == nil && isCompact {
|
||||
let controller = BrowserScreen(context: context, subject: .webPage(url: parsedUrl.absoluteString))
|
||||
navigationController?.pushViewController(controller)
|
||||
} else {
|
||||
@ -1051,17 +1061,6 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
context.sharedContext.applicationBindings.openUrl(parsedUrl.absoluteString)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let openInOptions = availableOpenInOptions(context: context, item: .url(url: url))
|
||||
if let option = openInOptions.first(where: { $0.identifier == settings.defaultWebBrowser }) {
|
||||
if case let .openUrl(url) = option.action() {
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
} else {
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
}
|
||||
} else {
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user