Browser improvements

This commit is contained in:
Ilya Laktyushin 2024-07-22 20:03:13 +04:00
parent 345616704a
commit 4e46697a66
7 changed files with 119 additions and 83 deletions

View File

@ -12553,6 +12553,8 @@ Sorry for the inconvenience.";
"Stars.Gift.Sent.Title" = "Sent Gift";
"Stars.Gift.Sent.Text" = "With Stars, %@ will be able to unlock content and services on Telegram. [See Examples >]()";
"WebBrowser.Reload" = "Reload";
"WebBrowser.Share" = "Share";
"WebBrowser.AddBookmark" = "Add Bookmark";
"WebBrowser.LinkAddedToBookmarks" = "Link added to [Bookmarks]() and **Saved Messages**.";
@ -12578,3 +12580,5 @@ Sorry for the inconvenience.";
"WebBrowser.Exceptions.Create.Title" = "Add Website";
"WebBrowser.Exceptions.Create.Text" = "Enter a domain that you don't want to be opened in the in-app browser.";
"WebBrowser.Exceptions.Create.Placeholder" = "Enter URL";
"WebBrowser.Done" = "Done";

View File

@ -109,10 +109,7 @@ private final class BrowserScreenComponent: CombinedComponent {
component: AnyComponent(
Button(
content: AnyComponent(
BundleIconComponent(
name: "Instant View/CloseIcon",
tintColor: environment.theme.rootController.navigationBar.accentTextColor
)
MultilineTextComponent(text: .plain(NSAttributedString(string: environment.strings.WebBrowser_Done, font: Font.regular(17.0), textColor: environment.theme.rootController.navigationBar.accentTextColor, paragraphAlignment: .center)), horizontalAlignment: .left, maximumNumberOfLines: 1)
),
action: {
performAction.invoke(.close)
@ -122,7 +119,6 @@ private final class BrowserScreenComponent: CombinedComponent {
)
]
let isLoading = (context.component.contentState?.estimatedProgress ?? 1.0) < 1.0
navigationRightItems = [
AnyComponentWithIdentity(
id: "settings",
@ -145,27 +141,6 @@ private final class BrowserScreenComponent: CombinedComponent {
)
)
]
if case .webPage = context.component.contentState?.contentType {
navigationRightItems.insert(
AnyComponentWithIdentity(
id: isLoading ? "stop" : "reload",
component: AnyComponent(
ReferenceButtonComponent(
content: AnyComponent(
BundleIconComponent(
name: isLoading ? "Instant View/Close" : "Chat/Context Menu/Reload",
tintColor: environment.theme.rootController.navigationBar.primaryTextColor
)
),
action: {
performAction.invoke(isLoading ? .stop : .reload)
}
)
)
),
at: 0
)
}
}
let collapseFraction = context.component.presentationState.isSearching ? 0.0 : context.component.panelCollapseFraction
@ -817,15 +792,24 @@ public class BrowserScreen: ViewController, MinimizableController {
.action(ContextMenuActionItem(text: self.presentationData.strings.InstantPage_FontSanFrancisco, icon: forceIsSerif ? emptyIcon : checkIcon, action: { (controller, action) in
performAction.invoke(.updateFontIsSerif(false))
action(.default)
})), .action(ContextMenuActionItem(text: self.presentationData.strings.InstantPage_FontNewYork, textFont: .custom(font: Font.with(size: 17.0, design: .serif, traits: []), height: nil, verticalOffset: nil), icon: forceIsSerif ? checkIcon : emptyIcon, action: { (controller, action) in
})),
.action(ContextMenuActionItem(text: self.presentationData.strings.InstantPage_FontNewYork, textFont: .custom(font: Font.with(size: 17.0, design: .serif, traits: []), height: nil, verticalOffset: nil), icon: forceIsSerif ? checkIcon : emptyIcon, action: { (controller, action) in
performAction.invoke(.updateFontIsSerif(true))
action(.default)
})),
.separator,
.action(ContextMenuActionItem(text: self.presentationData.strings.WebBrowser_Reload, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Instant View/Settings/Reload"), color: theme.contextMenu.primaryColor) }, action: { (controller, action) in
performAction.invoke(.reload)
action(.default)
})),
.action(ContextMenuActionItem(text: self.presentationData.strings.InstantPage_Search, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Instant View/Settings/Search"), color: theme.contextMenu.primaryColor) }, action: { (controller, action) in
performAction.invoke(.updateSearchActive(true))
action(.default)
})),
.action(ContextMenuActionItem(text: self.presentationData.strings.WebBrowser_Share, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Share"), color: theme.contextMenu.primaryColor) }, action: { (controller, action) in
performAction.invoke(.share)
action(.default)
})),
.action(ContextMenuActionItem(text: self.presentationData.strings.WebBrowser_AddBookmark, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Fave"), color: theme.contextMenu.primaryColor) }, action: { (controller, action) in
performAction.invoke(.addBookmark)
action(.default)

View File

@ -17,7 +17,6 @@ import LinkPresentation
private final class WebBrowserSettingsControllerArguments {
let context: AccountContext
let updateDefaultBrowser: (String?) -> Void
let updateAutologin: (Bool) -> Void
let clearCookies: () -> Void
let addException: () -> Void
let clearExceptions: () -> Void
@ -25,14 +24,12 @@ private final class WebBrowserSettingsControllerArguments {
init(
context: AccountContext,
updateDefaultBrowser: @escaping (String?) -> Void,
updateAutologin: @escaping (Bool) -> Void,
clearCookies: @escaping () -> Void,
addException: @escaping () -> Void,
clearExceptions: @escaping () -> Void
) {
self.context = context
self.updateDefaultBrowser = updateDefaultBrowser
self.updateAutologin = updateAutologin
self.clearCookies = clearCookies
self.addException = addException
self.clearExceptions = clearExceptions
@ -41,7 +38,6 @@ private final class WebBrowserSettingsControllerArguments {
private enum WebBrowserSettingsSection: Int32 {
case browsers
case autologin
case clearCookies
case exceptions
}
@ -50,9 +46,6 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
case browserHeader(PresentationTheme, String)
case browser(PresentationTheme, String, OpenInApplication?, String?, Bool, Int32)
case autologin(PresentationTheme, String, Bool)
case autologinInfo(PresentationTheme, String)
case clearCookies(PresentationTheme, String)
case clearCookiesInfo(PresentationTheme, String)
@ -66,8 +59,6 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
switch self {
case .browserHeader, .browser:
return WebBrowserSettingsSection.browsers.rawValue
case .autologin, .autologinInfo:
return WebBrowserSettingsSection.autologin.rawValue
case .clearCookies, .clearCookiesInfo:
return WebBrowserSettingsSection.clearCookies.rawValue
case .exceptionsHeader, .exceptionsAdd, .exception, .exceptionsClear, .exceptionsInfo:
@ -81,10 +72,6 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
return 0
case let .browser(_, _, _, _, _, index):
return 1 + index
case .autologin:
return 100
case .autologinInfo:
return 101
case .clearCookies:
return 102
case .clearCookiesInfo:
@ -116,18 +103,6 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .autologin(lhsTheme, lhsText, lhsValue):
if case let .autologin(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue {
return true
} else {
return false
}
case let .autologinInfo(lhsTheme, lhsText):
if case let .autologinInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .clearCookies(lhsTheme, lhsText):
if case let .clearCookies(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
@ -186,12 +161,6 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
return WebBrowserItem(context: arguments.context, presentationData: presentationData, title: title, application: application, checked: selected, sectionId: self.section) {
arguments.updateDefaultBrowser(identifier)
}
case let .autologin(_, text, value):
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { updatedValue in
arguments.updateAutologin(updatedValue)
})
case let .autologinInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .clearCookies(_, text):
return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.accentDeleteIconImage(presentationData.theme), title: text, sectionId: self.section, height: .generic, color: .accent, editing: false, action: {
arguments.clearCookies()
@ -231,9 +200,6 @@ private func webBrowserSettingsControllerEntries(context: AccountContext, presen
}
if settings.defaultWebBrowser == nil {
entries.append(.autologin(presentationData.theme, presentationData.strings.WebBrowser_AutoLogin, settings.autologin))
entries.append(.autologinInfo(presentationData.theme, presentationData.strings.WebBrowser_AutoLogin_Info))
entries.append(.clearCookies(presentationData.theme, presentationData.strings.WebBrowser_ClearCookies))
entries.append(.clearCookiesInfo(presentationData.theme, presentationData.strings.WebBrowser_ClearCookies_Info))
@ -268,11 +234,6 @@ public func webBrowserSettingsController(context: AccountContext) -> ViewControl
$0.withUpdatedDefaultWebBrowser(identifier)
}).start()
},
updateAutologin: { autologin in
let _ = updateWebBrowserSettingsInteractively(accountManager: context.sharedContext.accountManager, {
$0.withUpdatedAutologin(autologin)
}).start()
},
clearCookies: {
clearCookiesImpl?()
},

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "scheduled.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,86 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 3.334991 3.334991 cm
0.000000 0.000000 0.000000 scn
8.665000 17.330002 m
8.297730 17.330002 8.000000 17.032270 8.000000 16.665001 c
8.000000 16.297733 8.297730 16.000002 8.665000 16.000002 c
12.716009 16.000002 16.000000 12.716011 16.000000 8.665002 c
16.000000 4.613993 12.716009 1.330002 8.665000 1.330002 c
4.613991 1.330002 1.330000 4.613993 1.330000 8.665002 c
1.330000 11.380140 2.805339 13.751918 5.000000 15.020325 c
5.000000 13.165002 l
5.000000 12.797732 5.297730 12.500002 5.665000 12.500002 c
6.032269 12.500002 6.330000 12.797732 6.330000 13.165002 c
6.330000 16.665001 l
6.330000 17.032270 6.032269 17.330002 5.665000 17.330002 c
2.165000 17.330002 l
1.797731 17.330002 1.500000 17.032270 1.500000 16.665001 c
1.500000 16.297733 1.797731 16.000002 2.165000 16.000002 c
4.050117 16.000002 l
1.617408 14.466265 0.000000 11.755083 0.000000 8.665002 c
0.000000 3.879455 3.879452 0.000000 8.665000 0.000000 c
13.450547 0.000000 17.330002 3.879455 17.330002 8.665002 c
17.330002 13.450549 13.450547 17.330002 8.665000 17.330002 c
h
f*
n
Q
endstream
endobj
3 0 obj
1114
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 24.000000 24.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000001204 00000 n
0000001227 00000 n
0000001400 00000 n
0000001474 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
1533
%%EOF

View File

@ -1033,7 +1033,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
}
if accessChallengeData.data.isLockable {
if passcodeSettings.autolockTimeout != nil && settings.defaultWebBrowser == nil {
settings = WebBrowserSettings(defaultWebBrowser: "safari", autologin: false, exceptions: [])
settings = WebBrowserSettings(defaultWebBrowser: "safari", exceptions: [])
}
}
return settings

View File

@ -29,16 +29,14 @@ public struct WebBrowserException: Codable, Equatable {
public struct WebBrowserSettings: Codable, Equatable {
public let defaultWebBrowser: String?
public let autologin: Bool
public let exceptions: [WebBrowserException]
public static var defaultSettings: WebBrowserSettings {
return WebBrowserSettings(defaultWebBrowser: nil, autologin: true, exceptions: [])
return WebBrowserSettings(defaultWebBrowser: nil, exceptions: [])
}
public init(defaultWebBrowser: String?, autologin: Bool, exceptions: [WebBrowserException]) {
public init(defaultWebBrowser: String?, exceptions: [WebBrowserException]) {
self.defaultWebBrowser = defaultWebBrowser
self.autologin = autologin
self.exceptions = exceptions
}
@ -46,7 +44,6 @@ public struct WebBrowserSettings: Codable, Equatable {
let container = try decoder.container(keyedBy: StringCodingKey.self)
self.defaultWebBrowser = try? container.decodeIfPresent(String.self, forKey: "defaultWebBrowser")
self.autologin = (try? container.decodeIfPresent(Bool.self, forKey: "autologin")) ?? true
self.exceptions = (try? container.decodeIfPresent([WebBrowserException].self, forKey: "exceptions")) ?? []
}
@ -54,7 +51,6 @@ public struct WebBrowserSettings: Codable, Equatable {
var container = encoder.container(keyedBy: StringCodingKey.self)
try container.encodeIfPresent(self.defaultWebBrowser, forKey: "defaultWebBrowser")
try container.encode(self.autologin, forKey: "autologin")
try container.encode(self.exceptions, forKey: "exceptions")
}
@ -62,9 +58,6 @@ public struct WebBrowserSettings: Codable, Equatable {
if lhs.defaultWebBrowser != rhs.defaultWebBrowser {
return false
}
if lhs.autologin != rhs.autologin {
return false
}
if lhs.exceptions != rhs.exceptions {
return false
}
@ -72,15 +65,11 @@ public struct WebBrowserSettings: Codable, Equatable {
}
public func withUpdatedDefaultWebBrowser(_ defaultWebBrowser: String?) -> WebBrowserSettings {
return WebBrowserSettings(defaultWebBrowser: defaultWebBrowser, autologin: self.autologin, exceptions: self.exceptions)
return WebBrowserSettings(defaultWebBrowser: defaultWebBrowser, exceptions: self.exceptions)
}
public func withUpdatedAutologin(_ autologin: Bool) -> WebBrowserSettings {
return WebBrowserSettings(defaultWebBrowser: self.defaultWebBrowser, autologin: autologin, exceptions: self.exceptions)
}
public func withUpdatedExceptions(_ exceptions: [WebBrowserException]) -> WebBrowserSettings {
return WebBrowserSettings(defaultWebBrowser: self.defaultWebBrowser, autologin: self.autologin, exceptions: exceptions)
return WebBrowserSettings(defaultWebBrowser: self.defaultWebBrowser, exceptions: exceptions)
}
}