mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Browser improvements
This commit is contained in:
parent
3e99101e07
commit
2eeb3be2b2
@ -12602,3 +12602,6 @@ Sorry for the inconvenience.";
|
|||||||
"Story.Privacy.ChooseCoverInfo" = "Choose a frame from the story to show in your Profile.";
|
"Story.Privacy.ChooseCoverInfo" = "Choose a frame from the story to show in your Profile.";
|
||||||
"Story.Privacy.ChooseCoverChannelInfo" = "Choose a frame from the story to show in channel profile.";
|
"Story.Privacy.ChooseCoverChannelInfo" = "Choose a frame from the story to show in channel profile.";
|
||||||
"Story.Privacy.ChooseCoverGroupInfo" = "Choose a frame from the story to show in group profile.";
|
"Story.Privacy.ChooseCoverGroupInfo" = "Choose a frame from the story to show in group profile.";
|
||||||
|
|
||||||
|
"WebBrowser.Download.Confirmation" = "Do you want to download \"%@\"?";
|
||||||
|
"WebBrowser.Download.Download" = "Download";
|
||||||
|
@ -46,6 +46,7 @@ swift_library(
|
|||||||
"//submodules/TelegramUI/Components/Chat/ChatHistorySearchContainerNode",
|
"//submodules/TelegramUI/Components/Chat/ChatHistorySearchContainerNode",
|
||||||
"//submodules/SearchUI",
|
"//submodules/SearchUI",
|
||||||
"//submodules/SearchBarNode",
|
"//submodules/SearchBarNode",
|
||||||
|
"//submodules/TelegramUI/Components/SaveProgressScreen",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
@ -280,6 +280,7 @@ final class AddressBarContentComponent: Component {
|
|||||||
}
|
}
|
||||||
title = title.idnaDecoded ?? title
|
title = title.idnaDecoded ?? title
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update(theme: component.theme, strings: component.strings, size: availableSize, isActive: isActive, title: title.lowercased(), isSecure: component.isSecure, collapseFraction: collapseFraction, transition: transition)
|
self.update(theme: component.theme, strings: component.strings, size: availableSize, isActive: isActive, title: title.lowercased(), isSecure: component.isSecure, collapseFraction: collapseFraction, transition: transition)
|
||||||
|
|
||||||
return availableSize
|
return availableSize
|
||||||
@ -438,7 +439,25 @@ final class AddressBarContentComponent: Component {
|
|||||||
textField.addTarget(self, action: #selector(self.textFieldChanged(_:)), for: .editingChanged)
|
textField.addTarget(self, action: #selector(self.textFieldChanged(_:)), for: .editingChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
textField.text = self.component?.url ?? ""
|
var address = self.component?.url ?? ""
|
||||||
|
if let components = URLComponents(string: address) {
|
||||||
|
if #available(iOS 16.0, *), let encodedHost = components.encodedHost {
|
||||||
|
if let decodedHost = components.host, encodedHost != decodedHost {
|
||||||
|
address = address.replacingOccurrences(of: encodedHost, with: decodedHost)
|
||||||
|
}
|
||||||
|
} else if let encodedHost = components.host {
|
||||||
|
if let decodedHost = components.host?.idnaDecoded, encodedHost != decodedHost {
|
||||||
|
address = address.replacingOccurrences(of: encodedHost, with: decodedHost)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if textField.text != address {
|
||||||
|
textField.text = address
|
||||||
|
self.clearIconView.isHidden = address.isEmpty
|
||||||
|
self.clearIconButton.isHidden = address.isEmpty
|
||||||
|
self.placeholderContent.view?.isHidden = !address.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
textField.textColor = theme.rootController.navigationSearchBar.inputTextColor
|
textField.textColor = theme.rootController.navigationSearchBar.inputTextColor
|
||||||
transition.setFrame(view: textField, frame: CGRect(origin: CGPoint(x: backgroundFrame.minX + sideInset, y: backgroundFrame.minY - UIScreenPixel), size: CGSize(width: backgroundFrame.width - sideInset - 32.0, height: backgroundFrame.height)))
|
transition.setFrame(view: textField, frame: CGRect(origin: CGPoint(x: backgroundFrame.minX + sideInset, y: backgroundFrame.minY - UIScreenPixel), size: CGSize(width: backgroundFrame.width - sideInset - 32.0, height: backgroundFrame.height)))
|
||||||
|
@ -245,6 +245,7 @@ final class BrowserNavigationBarComponent: CombinedComponent {
|
|||||||
if !leftItemList.isEmpty || !rightItemList.isEmpty {
|
if !leftItemList.isEmpty || !rightItemList.isEmpty {
|
||||||
availableWidth -= 20.0
|
availableWidth -= 20.0
|
||||||
}
|
}
|
||||||
|
availableWidth -= context.component.sideInset * 2.0
|
||||||
|
|
||||||
let environment = BrowserNavigationBarEnvironment(fraction: context.component.collapseFraction)
|
let environment = BrowserNavigationBarEnvironment(fraction: context.component.collapseFraction)
|
||||||
|
|
||||||
|
@ -1189,7 +1189,7 @@ public class BrowserScreen: ViewController, MinimizableController {
|
|||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
private let subject: Subject
|
private let subject: Subject
|
||||||
|
|
||||||
var openPreviousOnClose = false
|
private var openPreviousOnClose = false
|
||||||
|
|
||||||
private var validLayout: ContainerViewLayout?
|
private var validLayout: ContainerViewLayout?
|
||||||
|
|
||||||
@ -1205,9 +1205,10 @@ public class BrowserScreen: ViewController, MinimizableController {
|
|||||||
// "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
// "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
||||||
]
|
]
|
||||||
|
|
||||||
public init(context: AccountContext, subject: Subject) {
|
public init(context: AccountContext, subject: Subject, openPreviousOnClose: Bool = false) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.subject = subject
|
self.subject = subject
|
||||||
|
self.openPreviousOnClose = openPreviousOnClose
|
||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
@ -1243,9 +1244,18 @@ public class BrowserScreen: ViewController, MinimizableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func requestMinimize(topEdgeOffset: CGFloat?, initialVelocity: CGFloat?) {
|
public func requestMinimize(topEdgeOffset: CGFloat?, initialVelocity: CGFloat?) {
|
||||||
|
self.openPreviousOnClose = false
|
||||||
self.node.minimize(topEdgeOffset: topEdgeOffset, damping: 180.0, initialVelocity: initialVelocity)
|
self.node.minimize(topEdgeOffset: topEdgeOffset, damping: 180.0, initialVelocity: initialVelocity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override func viewWillDisappear(_ animated: Bool) {
|
||||||
|
super.viewWillDisappear(animated)
|
||||||
|
|
||||||
|
if self.openPreviousOnClose, let navigationController = self.navigationController as? NavigationController, let minimizedContainer = navigationController.minimizedContainer, let controller = minimizedContainer.controllers.last {
|
||||||
|
navigationController.maximizeViewController(controller, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public var isMinimized = false {
|
public var isMinimized = false {
|
||||||
didSet {
|
didSet {
|
||||||
if let webContent = self.node.content.last as? BrowserWebContent {
|
if let webContent = self.node.content.last as? BrowserWebContent {
|
||||||
|
@ -19,6 +19,7 @@ import LottieComponent
|
|||||||
import MultilineTextComponent
|
import MultilineTextComponent
|
||||||
import UrlEscaping
|
import UrlEscaping
|
||||||
import UrlHandling
|
import UrlHandling
|
||||||
|
import SaveProgressScreen
|
||||||
|
|
||||||
private final class TonSchemeHandler: NSObject, WKURLSchemeHandler {
|
private final class TonSchemeHandler: NSObject, WKURLSchemeHandler {
|
||||||
private final class PendingTask {
|
private final class PendingTask {
|
||||||
@ -157,16 +158,12 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
|
|
||||||
let configuration = WKWebViewConfiguration()
|
let configuration = WKWebViewConfiguration()
|
||||||
|
|
||||||
// let bundle = Bundle.main
|
|
||||||
// let bundleVersion = bundle.infoDictionary?["CFBundleShortVersionString"] ?? ""
|
|
||||||
//
|
|
||||||
var proxyServerHost = "magic.org"
|
var proxyServerHost = "magic.org"
|
||||||
if let data = context.currentAppConfiguration.with({ $0 }).data, let hostValue = data["ton_proxy_address"] as? String {
|
if let data = context.currentAppConfiguration.with({ $0 }).data, let hostValue = data["ton_proxy_address"] as? String {
|
||||||
proxyServerHost = hostValue
|
proxyServerHost = hostValue
|
||||||
}
|
}
|
||||||
configuration.setURLSchemeHandler(TonSchemeHandler(proxyServerHost: proxyServerHost), forURLScheme: "tonsite")
|
configuration.setURLSchemeHandler(TonSchemeHandler(proxyServerHost: proxyServerHost), forURLScheme: "tonsite")
|
||||||
configuration.allowsInlineMediaPlayback = true
|
configuration.allowsInlineMediaPlayback = true
|
||||||
// configuration.applicationNameForUserAgent = "Telegram-iOS/\(bundleVersion)"
|
|
||||||
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
||||||
configuration.mediaTypesRequiringUserActionForPlayback = []
|
configuration.mediaTypesRequiringUserActionForPlayback = []
|
||||||
} else {
|
} else {
|
||||||
@ -580,19 +577,50 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
self.ignoreUpdatesUntilScrollingStopped = true
|
self.ignoreUpdatesUntilScrollingStopped = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(iOS 13.0, *)
|
||||||
|
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, preferences: WKWebpagePreferences, decisionHandler: @escaping (WKNavigationActionPolicy, WKWebpagePreferences) -> Void) {
|
||||||
|
if #available(iOS 14.5, *), navigationAction.shouldPerformDownload {
|
||||||
|
self.presentDownloadConfirmation(fileName: navigationAction.request.mainDocumentURL?.lastPathComponent ?? "file", proceed: { download in
|
||||||
|
if download {
|
||||||
|
decisionHandler(.download, preferences)
|
||||||
|
} else {
|
||||||
|
decisionHandler(.cancel, preferences)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if let url = navigationAction.request.url?.absoluteString {
|
||||||
|
if isTelegramMeLink(url) || isTelegraPhLink(url) {
|
||||||
|
decisionHandler(.cancel, preferences)
|
||||||
|
self.minimize()
|
||||||
|
self.openAppUrl(url)
|
||||||
|
} else {
|
||||||
|
decisionHandler(.allow, preferences)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
decisionHandler(.allow, preferences)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||||
|
if navigationResponse.canShowMIMEType {
|
||||||
|
decisionHandler(.allow)
|
||||||
|
} else if #available(iOS 14.5, *) {
|
||||||
|
decisionHandler(.download)
|
||||||
|
} else {
|
||||||
|
decisionHandler(.cancel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
if let url = navigationAction.request.url?.absoluteString {
|
if let url = navigationAction.request.url?.absoluteString {
|
||||||
if isTelegramMeLink(url) || isTelegraPhLink(url) {
|
if isTelegramMeLink(url) || isTelegraPhLink(url) {
|
||||||
decisionHandler(.cancel)
|
decisionHandler(.cancel)
|
||||||
self.minimize()
|
self.minimize()
|
||||||
self.openAppUrl(url)
|
self.openAppUrl(url)
|
||||||
} else {
|
|
||||||
if #available(iOS 14.5, *), navigationAction.shouldPerformDownload {
|
|
||||||
decisionHandler(.download)
|
|
||||||
} else {
|
} else {
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
}
|
}
|
||||||
@ -636,7 +664,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
self.close()
|
self.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOSApplicationExtension 15.0, iOS 15.0, *)
|
@available(iOS 15.0, *)
|
||||||
func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) {
|
func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) {
|
||||||
decisionHandler(.prompt)
|
decisionHandler(.prompt)
|
||||||
}
|
}
|
||||||
@ -739,12 +767,37 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
completionHandler(configuration)
|
completionHandler(configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func presentDownloadConfirmation(fileName: String, proceed: @escaping (Bool) -> Void) {
|
||||||
|
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
var completed = false
|
||||||
|
let alertController = textAlertController(context: self.context, updatedPresentationData: nil, title: nil, text: presentationData.strings.WebBrowser_Download_Confirmation(fileName).string, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
|
||||||
|
if !completed {
|
||||||
|
completed = true
|
||||||
|
proceed(false)
|
||||||
|
}
|
||||||
|
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.WebBrowser_Download_Download, action: {
|
||||||
|
if !completed {
|
||||||
|
completed = true
|
||||||
|
proceed(true)
|
||||||
|
}
|
||||||
|
})])
|
||||||
|
alertController.dismissed = { byOutsideTap in
|
||||||
|
if byOutsideTap {
|
||||||
|
if !completed {
|
||||||
|
completed = true
|
||||||
|
proceed(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.present(alertController, nil)
|
||||||
|
}
|
||||||
|
|
||||||
private func open(url: String, new: Bool) {
|
private func open(url: String, new: Bool) {
|
||||||
let subject: BrowserScreen.Subject = .webPage(url: url)
|
let subject: BrowserScreen.Subject = .webPage(url: url)
|
||||||
if new, let navigationController = self.getNavigationController() {
|
if new, let navigationController = self.getNavigationController() {
|
||||||
navigationController._keepModalDismissProgress = true
|
navigationController._keepModalDismissProgress = true
|
||||||
self.minimize()
|
self.minimize()
|
||||||
let controller = BrowserScreen(context: self.context, subject: subject)
|
let controller = BrowserScreen(context: self.context, subject: subject, openPreviousOnClose: true)
|
||||||
navigationController._keepModalDismissProgress = true
|
navigationController._keepModalDismissProgress = true
|
||||||
navigationController.pushViewController(controller)
|
navigationController.pushViewController(controller)
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,6 +64,7 @@ swift_library(
|
|||||||
"//submodules/WebsiteType",
|
"//submodules/WebsiteType",
|
||||||
"//submodules/UrlEscaping",
|
"//submodules/UrlEscaping",
|
||||||
"//submodules/DeviceLocationManager",
|
"//submodules/DeviceLocationManager",
|
||||||
|
"//submodules/TelegramUI/Components/SaveProgressScreen",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
@ -48,6 +48,7 @@ import StickerPackEditTitleController
|
|||||||
import StickerPickerScreen
|
import StickerPickerScreen
|
||||||
import UIKitRuntimeUtils
|
import UIKitRuntimeUtils
|
||||||
import ImageObjectSeparation
|
import ImageObjectSeparation
|
||||||
|
import SaveProgressScreen
|
||||||
|
|
||||||
private let playbackButtonTag = GenericComponentViewTag()
|
private let playbackButtonTag = GenericComponentViewTag()
|
||||||
private let muteButtonTag = GenericComponentViewTag()
|
private let muteButtonTag = GenericComponentViewTag()
|
||||||
|
@ -30,6 +30,7 @@ swift_library(
|
|||||||
"//submodules/SaveToCameraRoll",
|
"//submodules/SaveToCameraRoll",
|
||||||
"//submodules/ShareController",
|
"//submodules/ShareController",
|
||||||
"//submodules/OpenInExternalAppUI",
|
"//submodules/OpenInExternalAppUI",
|
||||||
|
"//submodules/TelegramUI/Components/SaveProgressScreen",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
@ -14,7 +14,7 @@ import ChatTitleView
|
|||||||
import BottomButtonPanelComponent
|
import BottomButtonPanelComponent
|
||||||
import UndoUI
|
import UndoUI
|
||||||
import MoreHeaderButton
|
import MoreHeaderButton
|
||||||
import MediaEditorScreen
|
import SaveProgressScreen
|
||||||
import SaveToCameraRoll
|
import SaveToCameraRoll
|
||||||
|
|
||||||
final class PeerInfoStoryGridScreenComponent: Component {
|
final class PeerInfoStoryGridScreenComponent: Component {
|
||||||
|
@ -14,7 +14,6 @@ import ChatTitleView
|
|||||||
import BottomButtonPanelComponent
|
import BottomButtonPanelComponent
|
||||||
import UndoUI
|
import UndoUI
|
||||||
import MoreHeaderButton
|
import MoreHeaderButton
|
||||||
import MediaEditorScreen
|
|
||||||
import SaveToCameraRoll
|
import SaveToCameraRoll
|
||||||
import ShareController
|
import ShareController
|
||||||
import OpenInExternalAppUI
|
import OpenInExternalAppUI
|
||||||
|
24
submodules/TelegramUI/Components/SaveProgressScreen/BUILD
Normal file
24
submodules/TelegramUI/Components/SaveProgressScreen/BUILD
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||||
|
|
||||||
|
swift_library(
|
||||||
|
name = "SaveProgressScreen",
|
||||||
|
module_name = "SaveProgressScreen",
|
||||||
|
srcs = glob([
|
||||||
|
"Sources/**/*.swift",
|
||||||
|
]),
|
||||||
|
copts = [
|
||||||
|
"-warnings-as-errors",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
"//submodules/Display",
|
||||||
|
"//submodules/ComponentFlow",
|
||||||
|
"//submodules/Components/ViewControllerComponent",
|
||||||
|
"//submodules/Components/MultilineTextComponent",
|
||||||
|
"//submodules/Components/BundleIconComponent",
|
||||||
|
"//submodules/Components/LottieAnimationComponent",
|
||||||
|
"//submodules/AccountContext",
|
||||||
|
],
|
||||||
|
visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
],
|
||||||
|
)
|
@ -98,6 +98,7 @@ swift_library(
|
|||||||
"//submodules/TelegramUI/Components/Stories/StoryQualityUpgradeSheetScreen",
|
"//submodules/TelegramUI/Components/Stories/StoryQualityUpgradeSheetScreen",
|
||||||
"//submodules/TelegramUI/Components/SliderContextItem",
|
"//submodules/TelegramUI/Components/SliderContextItem",
|
||||||
"//submodules/TelegramUI/Components/InteractiveTextComponent",
|
"//submodules/TelegramUI/Components/InteractiveTextComponent",
|
||||||
|
"//submodules/TelegramUI/Components/SaveProgressScreen",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
@ -43,6 +43,7 @@ import TelegramUIPreferences
|
|||||||
import StoryFooterPanelComponent
|
import StoryFooterPanelComponent
|
||||||
import TelegramNotices
|
import TelegramNotices
|
||||||
import SliderContextItem
|
import SliderContextItem
|
||||||
|
import SaveProgressScreen
|
||||||
|
|
||||||
public final class StoryAvailableReactions: Equatable {
|
public final class StoryAvailableReactions: Equatable {
|
||||||
let reactionItems: [ReactionItem]
|
let reactionItems: [ReactionItem]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user