Merge pull request #1934 from michalsrutek/feature/encoding-enum-type-inference
Use enum type inference for encoding
This commit is contained in:
commit
ad3fe2a1b2
|
@ -153,7 +153,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
|
||||||
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
||||||
do {
|
do {
|
||||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
let blockRules = String(data: jsonData, encoding: .utf8)
|
||||||
WKContentRuleListStore.default().compileContentRuleList(
|
WKContentRuleListStore.default().compileContentRuleList(
|
||||||
forIdentifier: "ContentBlockingRules",
|
forIdentifier: "ContentBlockingRules",
|
||||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
|
||||||
if let contentBlockers = webView.settings?.contentBlockers, contentBlockers.count > 0 {
|
if let contentBlockers = webView.settings?.contentBlockers, contentBlockers.count > 0 {
|
||||||
do {
|
do {
|
||||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
let blockRules = String(data: jsonData, encoding: .utf8)
|
||||||
WKContentRuleListStore.default().compileContentRuleList(
|
WKContentRuleListStore.default().compileContentRuleList(
|
||||||
forIdentifier: "ContentBlockingRules",
|
forIdentifier: "ContentBlockingRules",
|
||||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||||
|
|
|
@ -1250,7 +1250,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
if contentBlockers.count > 0 {
|
if contentBlockers.count > 0 {
|
||||||
do {
|
do {
|
||||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
let blockRules = String(data: jsonData, encoding: .utf8)
|
||||||
WKContentRuleListStore.default().compileContentRuleList(
|
WKContentRuleListStore.default().compileContentRuleList(
|
||||||
forIdentifier: "ContentBlockingRules",
|
forIdentifier: "ContentBlockingRules",
|
||||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||||
|
@ -1368,7 +1368,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
var jsToInject = source
|
var jsToInject = source
|
||||||
if let wrapper = jsWrapper {
|
if let wrapper = jsWrapper {
|
||||||
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
||||||
let sourceArrayString = String(data: jsonData!, encoding: String.Encoding.utf8)
|
let sourceArrayString = String(data: jsonData!, encoding: .utf8)
|
||||||
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
||||||
jsToInject = String(format: wrapper, sourceString!)
|
jsToInject = String(format: wrapper, sourceString!)
|
||||||
}
|
}
|
||||||
|
@ -1400,7 +1400,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
var jsToInject = source
|
var jsToInject = source
|
||||||
if let wrapper = jsWrapper {
|
if let wrapper = jsWrapper {
|
||||||
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
||||||
let sourceArrayString = String(data: jsonData!, encoding: String.Encoding.utf8)
|
let sourceArrayString = String(data: jsonData!, encoding: .utf8)
|
||||||
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
||||||
jsToInject = String(format: wrapper, sourceString!)
|
jsToInject = String(format: wrapper, sourceString!)
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
|
||||||
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
||||||
do {
|
do {
|
||||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
let blockRules = String(data: jsonData, encoding: .utf8)
|
||||||
WKContentRuleListStore.default().compileContentRuleList(
|
WKContentRuleListStore.default().compileContentRuleList(
|
||||||
forIdentifier: "ContentBlockingRules",
|
forIdentifier: "ContentBlockingRules",
|
||||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class FlutterWebViewController: NSObject, /*FlutterPlatformView,*/ Dispos
|
||||||
if let contentBlockers = webView.settings?.contentBlockers, contentBlockers.count > 0 {
|
if let contentBlockers = webView.settings?.contentBlockers, contentBlockers.count > 0 {
|
||||||
do {
|
do {
|
||||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
let blockRules = String(data: jsonData, encoding: .utf8)
|
||||||
WKContentRuleListStore.default().compileContentRuleList(
|
WKContentRuleListStore.default().compileContentRuleList(
|
||||||
forIdentifier: "ContentBlockingRules",
|
forIdentifier: "ContentBlockingRules",
|
||||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||||
|
|
|
@ -711,7 +711,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
if contentBlockers.count > 0 {
|
if contentBlockers.count > 0 {
|
||||||
do {
|
do {
|
||||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
let blockRules = String(data: jsonData, encoding: .utf8)
|
||||||
WKContentRuleListStore.default().compileContentRuleList(
|
WKContentRuleListStore.default().compileContentRuleList(
|
||||||
forIdentifier: "ContentBlockingRules",
|
forIdentifier: "ContentBlockingRules",
|
||||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||||
|
@ -806,7 +806,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
var jsToInject = source
|
var jsToInject = source
|
||||||
if let wrapper = jsWrapper {
|
if let wrapper = jsWrapper {
|
||||||
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
||||||
let sourceArrayString = String(data: jsonData!, encoding: String.Encoding.utf8)
|
let sourceArrayString = String(data: jsonData!, encoding: .utf8)
|
||||||
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
||||||
jsToInject = String(format: wrapper, sourceString!)
|
jsToInject = String(format: wrapper, sourceString!)
|
||||||
}
|
}
|
||||||
|
@ -838,7 +838,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
var jsToInject = source
|
var jsToInject = source
|
||||||
if let wrapper = jsWrapper {
|
if let wrapper = jsWrapper {
|
||||||
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
||||||
let sourceArrayString = String(data: jsonData!, encoding: String.Encoding.utf8)
|
let sourceArrayString = String(data: jsonData!, encoding: .utf8)
|
||||||
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.count ?? 0) - 2))
|
||||||
jsToInject = String(format: wrapper, sourceString!)
|
jsToInject = String(format: wrapper, sourceString!)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue