mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-30 09:21:28 +00:00
Various improvements
This commit is contained in:
parent
002e0a7082
commit
ada188209e
@ -12526,6 +12526,8 @@ Sorry for the inconvenience.";
|
|||||||
"Browser.ContextMenu.CopyLink" = "Copy Link";
|
"Browser.ContextMenu.CopyLink" = "Copy Link";
|
||||||
"Browser.ContextMenu.Share" = "Share";
|
"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.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.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.";
|
"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
|
context.add(readingProgress
|
||||||
.position(CGPoint(x: readingProgress.size.width / 2.0, y: size.height / 2.0))
|
.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
|
context.add(separator
|
||||||
|
@ -917,8 +917,10 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
|||||||
let defaultWebBrowser: String
|
let defaultWebBrowser: String
|
||||||
if let option = options.first(where: { $0.identifier == webBrowserSettings.defaultWebBrowser }) {
|
if let option = options.first(where: { $0.identifier == webBrowserSettings.defaultWebBrowser }) {
|
||||||
defaultWebBrowser = option.title
|
defaultWebBrowser = option.title
|
||||||
} else {
|
} else if webBrowserSettings.defaultWebBrowser == "inApp" {
|
||||||
defaultWebBrowser = presentationData.strings.WebBrowser_InAppSafari
|
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)
|
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 ItemListUI
|
||||||
import PhotoResources
|
import PhotoResources
|
||||||
import OpenInExternalAppUI
|
import OpenInExternalAppUI
|
||||||
|
import AccountContext
|
||||||
|
import AppBundle
|
||||||
|
|
||||||
class WebBrowserItem: ListViewItem, ItemListItem {
|
class WebBrowserItem: ListViewItem, ItemListItem {
|
||||||
let engine: TelegramEngine
|
let context: AccountContext
|
||||||
let presentationData: ItemListPresentationData
|
let presentationData: ItemListPresentationData
|
||||||
let title: String
|
let title: String
|
||||||
let application: OpenInApplication
|
let application: OpenInApplication?
|
||||||
let checked: Bool
|
let checked: Bool
|
||||||
public let sectionId: ItemListSectionId
|
public let sectionId: ItemListSectionId
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
|
||||||
public init(engine: TelegramEngine, presentationData: ItemListPresentationData, title: String, application: OpenInApplication, checked: Bool, sectionId: ItemListSectionId, action: @escaping () -> Void) {
|
public init(context: AccountContext, presentationData: ItemListPresentationData, title: String, application: OpenInApplication?, checked: Bool, sectionId: ItemListSectionId, action: @escaping () -> Void) {
|
||||||
self.engine = engine
|
self.context = context
|
||||||
self.presentationData = presentationData
|
self.presentationData = presentationData
|
||||||
self.title = title
|
self.title = title
|
||||||
self.application = application
|
self.application = application
|
||||||
@ -131,6 +133,7 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
|||||||
let makeIconLayout = self.iconNode.asyncLayout()
|
let makeIconLayout = self.iconNode.asyncLayout()
|
||||||
|
|
||||||
let currentItem = self.item
|
let currentItem = self.item
|
||||||
|
|
||||||
|
|
||||||
return { item, params, neighbors in
|
return { item, params, neighbors in
|
||||||
let leftInset: CGFloat = params.leftInset + 16.0 + 43.0
|
let leftInset: CGFloat = params.leftInset + 16.0 + 43.0
|
||||||
@ -140,18 +143,25 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
|||||||
let imageApply = makeIconLayout(arguments)
|
let imageApply = makeIconLayout(arguments)
|
||||||
|
|
||||||
var updatedIconSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
var updatedIconSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
||||||
if currentItem?.application != item.application {
|
if currentItem == nil {
|
||||||
switch item.application {
|
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:
|
case .safari:
|
||||||
if let image = UIImage(bundleImageName: "Open In/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:
|
case .maps:
|
||||||
if let image = UIImage(bundleImageName: "Open In/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):
|
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 {
|
private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
|
||||||
case browserHeader(PresentationTheme, String)
|
case browserHeader(PresentationTheme, String)
|
||||||
case browser(PresentationTheme, String, OpenInApplication, String?, Bool, Int32)
|
case browser(PresentationTheme, String, OpenInApplication?, String?, Bool, Int32)
|
||||||
|
|
||||||
var section: ItemListSectionId {
|
var section: ItemListSectionId {
|
||||||
switch self {
|
switch self {
|
||||||
@ -71,7 +71,7 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
|
|||||||
case let .browserHeader(_, text):
|
case let .browserHeader(_, text):
|
||||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||||
case let .browser(_, title, application, identifier, selected, _):
|
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)
|
arguments.updateDefaultBrowser(identifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +84,10 @@ private func webBrowserSettingsControllerEntries(context: AccountContext, presen
|
|||||||
let options = availableOpenInOptions(context: context, item: .url(url: "http://telegram.org"))
|
let options = availableOpenInOptions(context: context, item: .url(url: "http://telegram.org"))
|
||||||
|
|
||||||
entries.append(.browserHeader(presentationData.theme, presentationData.strings.WebBrowser_DefaultBrowser))
|
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 {
|
for option in options {
|
||||||
entries.append(.browser(presentationData.theme, option.title, option.application, option.identifier, option.identifier == selectedBrowser, index))
|
entries.append(.browser(presentationData.theme, option.title, option.application, option.identifier, option.identifier == selectedBrowser, index))
|
||||||
index += 1
|
index += 1
|
||||||
|
@ -1044,8 +1044,19 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
|||||||
|
|
||||||
let _ = (settings
|
let _ = (settings
|
||||||
|> deliverOnMainQueue).startStandalone(next: { settings in
|
|> deliverOnMainQueue).startStandalone(next: { settings in
|
||||||
if settings.defaultWebBrowser == nil {
|
if let defaultWebBrowser = settings.defaultWebBrowser, defaultWebBrowser != "inApp" {
|
||||||
if isCompact && context.sharedContext.immediateExperimentalUISettings.browserExperiment {
|
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))
|
let controller = BrowserScreen(context: context, subject: .webPage(url: parsedUrl.absoluteString))
|
||||||
navigationController?.pushViewController(controller)
|
navigationController?.pushViewController(controller)
|
||||||
} else {
|
} else {
|
||||||
@ -1058,17 +1069,6 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
|||||||
context.sharedContext.applicationBindings.openUrl(parsedUrl.absoluteString)
|
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