NCUtility.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. //
  2. // NCUtility.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 25/06/18.
  6. // Copyright © 2018 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import Foundation
  24. import SVGKit
  25. import KTVHTTPCache
  26. import NCCommunication
  27. import PDFKit
  28. import Accelerate
  29. class NCUtility: NSObject {
  30. @objc static let shared: NCUtility = {
  31. let instance = NCUtility()
  32. return instance
  33. }()
  34. private var activityIndicator: UIActivityIndicatorView?
  35. private var viewActivityIndicator: UIView?
  36. private var viewBackgroundActivityIndicator: UIView?
  37. func setLayoutForView(key: String, serverUrl: String, layoutForView: NCGlobal.layoutForViewType) {
  38. let string = layoutForView.layout + "|" + layoutForView.sort + "|" + "\(layoutForView.ascending)" + "|" + layoutForView.groupBy + "|" + "\(layoutForView.directoryOnTop)" + "|" + layoutForView.titleButtonHeader + "|" + "\(layoutForView.itemForLine)" + "|" + layoutForView.imageBackgroud + "|" + layoutForView.imageBackgroudContentMode + "|" + layoutForView.colorBackground
  39. var keyStore = key
  40. if serverUrl != "" {
  41. keyStore = serverUrl
  42. }
  43. UICKeyChainStore.setString(string, forKey: keyStore, service: NCGlobal.shared.serviceShareKeyChain)
  44. }
  45. func setLayoutForView(key: String, serverUrl: String, layout: String?) {
  46. var layoutForView: NCGlobal.layoutForViewType = NCUtility.shared.getLayoutForView(key: key, serverUrl: serverUrl)
  47. if let layout = layout {
  48. layoutForView.layout = layout
  49. setLayoutForView(key: key, serverUrl: serverUrl, layoutForView: layoutForView)
  50. }
  51. }
  52. func setBackgroundForView(key: String, serverUrl: String, imageBackgroud: String, imageBackgroudContentMode: String, colorBackground: String) {
  53. var layoutForView: NCGlobal.layoutForViewType = NCUtility.shared.getLayoutForView(key: key, serverUrl: serverUrl)
  54. layoutForView.imageBackgroud = imageBackgroud
  55. layoutForView.imageBackgroudContentMode = imageBackgroudContentMode
  56. layoutForView.colorBackground = colorBackground
  57. setLayoutForView(key: key, serverUrl: serverUrl, layoutForView: layoutForView)
  58. }
  59. func getLayoutForView(key: String, serverUrl: String, sort: String = "fileName", ascending: Bool = true, titleButtonHeader: String = "_sorted_by_name_a_z_") -> (NCGlobal.layoutForViewType) {
  60. var keyStore = key
  61. var layoutForView: NCGlobal.layoutForViewType = NCGlobal.layoutForViewType(layout: NCGlobal.shared.layoutList, sort: sort, ascending: ascending, groupBy: "none", directoryOnTop: true, titleButtonHeader: titleButtonHeader, itemForLine: 3, imageBackgroud: "", imageBackgroudContentMode: "", colorBackground: "")
  62. if serverUrl != "" {
  63. keyStore = serverUrl
  64. }
  65. guard let string = UICKeyChainStore.string(forKey: keyStore, service: NCGlobal.shared.serviceShareKeyChain) else {
  66. setLayoutForView(key: key, serverUrl: serverUrl, layoutForView: layoutForView)
  67. return layoutForView
  68. }
  69. let array = string.components(separatedBy: "|")
  70. if array.count >= 7 {
  71. layoutForView.layout = array[0]
  72. layoutForView.sort = array[1]
  73. layoutForView.ascending = NSString(string: array[2]).boolValue
  74. layoutForView.groupBy = array[3]
  75. layoutForView.directoryOnTop = NSString(string: array[4]).boolValue
  76. layoutForView.titleButtonHeader = array[5]
  77. layoutForView.itemForLine = Int(NSString(string: array[6]).intValue)
  78. if array.count > 8 {
  79. layoutForView.imageBackgroud = array[7]
  80. layoutForView.imageBackgroudContentMode = array[8]
  81. layoutForView.colorBackground = array[9]
  82. }
  83. }
  84. return layoutForView
  85. }
  86. func convertSVGtoPNGWriteToUserData(svgUrlString: String, fileName: String?, width: CGFloat?, rewrite: Bool, account: String, closure: @escaping (String?) -> ()) {
  87. var fileNamePNG = ""
  88. guard let svgUrlString = svgUrlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
  89. return closure(nil)
  90. }
  91. guard let iconURL = URL(string: svgUrlString) else {
  92. return closure(nil)
  93. }
  94. if fileName == nil {
  95. fileNamePNG = iconURL.deletingPathExtension().lastPathComponent + ".png"
  96. } else {
  97. fileNamePNG = fileName!
  98. }
  99. let imageNamePath = CCUtility.getDirectoryUserData() + "/" + fileNamePNG
  100. if !FileManager.default.fileExists(atPath: imageNamePath) || rewrite == true {
  101. NCCommunication.shared.downloadContent(serverUrl: iconURL.absoluteString) { (account, data, errorCode, errorMessage) in
  102. if errorCode == 0 && data != nil {
  103. if let image = UIImage.init(data: data!) {
  104. var newImage: UIImage = image
  105. if width != nil {
  106. let ratio = image.size.height / image.size.width
  107. let newSize = CGSize(width: width!, height: width! * ratio)
  108. let renderFormat = UIGraphicsImageRendererFormat.default()
  109. renderFormat.opaque = false
  110. let renderer = UIGraphicsImageRenderer(size: CGSize(width: newSize.width, height: newSize.height), format: renderFormat)
  111. newImage = renderer.image {
  112. (context) in
  113. image.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height))
  114. }
  115. }
  116. guard let pngImageData = newImage.pngData() else {
  117. return closure(nil)
  118. }
  119. try? pngImageData.write(to: URL(fileURLWithPath:imageNamePath))
  120. return closure(imageNamePath)
  121. } else {
  122. guard let svgImage: SVGKImage = SVGKImage(data: data) else {
  123. return closure(nil)
  124. }
  125. if width != nil {
  126. let scale = svgImage.size.height / svgImage.size.width
  127. svgImage.size = CGSize(width: width!, height: width! * scale)
  128. }
  129. guard let image: UIImage = svgImage.uiImage else {
  130. return closure(nil)
  131. }
  132. guard let pngImageData = image.pngData() else {
  133. return closure(nil)
  134. }
  135. try? pngImageData.write(to: URL(fileURLWithPath:imageNamePath))
  136. return closure(imageNamePath)
  137. }
  138. } else {
  139. return closure(nil)
  140. }
  141. }
  142. } else {
  143. return closure(imageNamePath)
  144. }
  145. }
  146. @objc func isSimulatorOrTestFlight() -> Bool {
  147. guard let path = Bundle.main.appStoreReceiptURL?.path else {
  148. return false
  149. }
  150. return path.contains("CoreSimulator") || path.contains("sandboxReceipt")
  151. }
  152. @objc func isSimulator() -> Bool {
  153. guard let path = Bundle.main.appStoreReceiptURL?.path else {
  154. return false
  155. }
  156. return path.contains("CoreSimulator")
  157. }
  158. @objc func isRichDocument(_ metadata: tableMetadata) -> Bool {
  159. guard let mimeType = CCUtility.getMimeType(metadata.fileNameView) else {
  160. return false
  161. }
  162. guard let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes) else {
  163. return false
  164. }
  165. if richdocumentsMimetypes.count > 0 && mimeType.components(separatedBy: ".").count > 2 {
  166. let mimeTypeArray = mimeType.components(separatedBy: ".")
  167. let mimeType = mimeTypeArray[mimeTypeArray.count - 2] + "." + mimeTypeArray[mimeTypeArray.count - 1]
  168. for richdocumentMimetype: String in richdocumentsMimetypes {
  169. if richdocumentMimetype.contains(mimeType) {
  170. return true
  171. }
  172. }
  173. }
  174. return false
  175. }
  176. @objc func isDirectEditing(account: String, contentType: String) -> String? {
  177. var editor: String?
  178. guard let results = NCManageDatabase.shared.getDirectEditingEditors(account: account) else {
  179. return editor
  180. }
  181. for result: tableDirectEditingEditors in results {
  182. for mimetype in result.mimetypes {
  183. if mimetype == contentType {
  184. editor = result.editor
  185. }
  186. // HARDCODE
  187. // https://github.com/nextcloud/text/issues/913
  188. if mimetype == "text/markdown" && contentType == "text/x-markdown" {
  189. editor = result.editor
  190. }
  191. }
  192. for mimetype in result.optionalMimetypes {
  193. if mimetype == contentType {
  194. editor = result.editor
  195. }
  196. }
  197. }
  198. // HARDCODE
  199. if editor == "" {
  200. editor = NCGlobal.shared.editorText
  201. }
  202. return editor
  203. }
  204. @objc func removeAllSettings() {
  205. URLCache.shared.memoryCapacity = 0
  206. URLCache.shared.diskCapacity = 0
  207. KTVHTTPCache.cacheDeleteAllCaches()
  208. NCManageDatabase.shared.clearDatabase(account: nil, removeAccount: true)
  209. CCUtility.removeGroupDirectoryProviderStorage()
  210. CCUtility.removeGroupLibraryDirectory()
  211. CCUtility.removeDocumentsDirectory()
  212. CCUtility.removeTemporaryDirectory()
  213. CCUtility.createDirectoryStandard()
  214. CCUtility.deleteAllChainStore()
  215. }
  216. @objc func permissionsContainsString(_ metadataPermissions: String, permissions: String) -> Bool {
  217. for char in permissions {
  218. if metadataPermissions.contains(char) == false {
  219. return false
  220. }
  221. }
  222. return true
  223. }
  224. @objc func getCustomUserAgentOnlyOffice() -> String {
  225. let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")!
  226. if UIDevice.current.userInterfaceIdiom == .pad {
  227. return "Mozilla/5.0 (iPad) Nextcloud-iOS/\(appVersion)"
  228. }else{
  229. return "Mozilla/5.0 (iPhone) Mobile Nextcloud-iOS/\(appVersion)"
  230. }
  231. }
  232. @objc func pdfThumbnail(url: URL, width: CGFloat = 240) -> UIImage? {
  233. guard let data = try? Data(contentsOf: url), let page = PDFDocument(data: data)?.page(at: 0) else {
  234. return nil
  235. }
  236. let pageSize = page.bounds(for: .mediaBox)
  237. let pdfScale = width / pageSize.width
  238. // Apply if you're displaying the thumbnail on screen
  239. let scale = UIScreen.main.scale * pdfScale
  240. let screenSize = CGSize(width: pageSize.width * scale, height: pageSize.height * scale)
  241. return page.thumbnail(of: screenSize, for: .mediaBox)
  242. }
  243. @objc func isQuickLookDisplayable(metadata: tableMetadata) -> Bool {
  244. return true
  245. }
  246. @objc func ocIdToFileId(ocId: String?) -> String? {
  247. guard let ocId = ocId else { return nil }
  248. let items = ocId.components(separatedBy: "oc")
  249. if items.count < 2 { return nil }
  250. guard let intFileId = Int(items[0]) else { return nil }
  251. return String(intFileId)
  252. }
  253. func getUserStatus(userIcon: String?, userStatus: String?, userMessage: String?) -> (onlineStatus: UIImage?, statusMessage: String) {
  254. var onlineStatus: UIImage?
  255. var statusMessage: String = ""
  256. var messageUserDefined: String = ""
  257. if userStatus?.lowercased() == "online" {
  258. onlineStatus = UIImage.init(named: "userStatusOnline")!.image(color: UIColor(red: 103.0/255.0, green: 176.0/255.0, blue: 134.0/255.0, alpha: 1.0), size: 50)
  259. messageUserDefined = NSLocalizedString("_online_", comment: "")
  260. }
  261. if userStatus?.lowercased() == "away" {
  262. onlineStatus = UIImage.init(named: "userStatusAway")!.image(color: UIColor(red: 233.0/255.0, green: 166.0/255.0, blue: 75.0/255.0, alpha: 1.0), size: 50)
  263. messageUserDefined = NSLocalizedString("_away_", comment: "")
  264. }
  265. if userStatus?.lowercased() == "dnd" {
  266. onlineStatus = UIImage.init(named: "userStatusDnd")?.resizeImage(size: CGSize(width: 100, height: 100), isAspectRation: false)
  267. messageUserDefined = NSLocalizedString("_dnd_", comment: "")
  268. }
  269. if userStatus?.lowercased() == "offline" || userStatus?.lowercased() == "invisible" {
  270. onlineStatus = UIImage.init(named: "userStatusOffline")!.image(color: .black, size: 50)
  271. messageUserDefined = NSLocalizedString("_invisible_", comment: "")
  272. }
  273. if let userIcon = userIcon {
  274. statusMessage = userIcon + " "
  275. }
  276. if let userMessage = userMessage {
  277. statusMessage = statusMessage + userMessage
  278. }
  279. statusMessage = statusMessage.trimmingCharacters(in: .whitespaces)
  280. if statusMessage == "" {
  281. statusMessage = messageUserDefined
  282. }
  283. return(onlineStatus, statusMessage)
  284. }
  285. func imageFromVideo(url: URL, at time: TimeInterval) -> UIImage? {
  286. let asset = AVURLAsset(url: url)
  287. let assetIG = AVAssetImageGenerator(asset: asset)
  288. assetIG.appliesPreferredTrackTransform = true
  289. assetIG.apertureMode = AVAssetImageGenerator.ApertureMode.encodedPixels
  290. let cmTime = CMTime(seconds: time, preferredTimescale: 60)
  291. let thumbnailImageRef: CGImage
  292. do {
  293. thumbnailImageRef = try assetIG.copyCGImage(at: cmTime, actualTime: nil)
  294. } catch let error {
  295. print("Error: \(error)")
  296. return nil
  297. }
  298. return UIImage(cgImage: thumbnailImageRef)
  299. }
  300. func createImageFrom(fileName: String, ocId: String, etag: String, typeFile: String) {
  301. var originalImage, scaleImagePreview, scaleImageIcon: UIImage?
  302. let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
  303. let fileNamePathPreview = CCUtility.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)!
  304. let fileNamePathIcon = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)!
  305. if FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return }
  306. if !CCUtility.fileProviderStorageExists(ocId, fileNameView: fileName) { return }
  307. if typeFile != NCGlobal.shared.metadataTypeFileImage && typeFile != NCGlobal.shared.metadataTypeFileVideo { return }
  308. if typeFile == NCGlobal.shared.metadataTypeFileImage {
  309. originalImage = UIImage.init(contentsOfFile: fileNamePath)
  310. scaleImagePreview = originalImage?.resizeImage(size: CGSize(width: NCGlobal.shared.sizePreview, height: NCGlobal.shared.sizePreview), isAspectRation: false)
  311. scaleImageIcon = originalImage?.resizeImage(size: CGSize(width: NCGlobal.shared.sizeIcon, height: NCGlobal.shared.sizeIcon), isAspectRation: false)
  312. try? scaleImagePreview?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathPreview))
  313. try? scaleImageIcon?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathIcon))
  314. } else if typeFile == NCGlobal.shared.metadataTypeFileVideo {
  315. let videoPath = NSTemporaryDirectory()+"tempvideo.mp4"
  316. NCUtilityFileSystem.shared.linkItem(atPath: fileNamePath, toPath: videoPath)
  317. originalImage = imageFromVideo(url: URL(fileURLWithPath: videoPath), at: 0)
  318. try? originalImage?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathPreview))
  319. try? originalImage?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathIcon))
  320. }
  321. }
  322. @objc func getVersionApp() -> String {
  323. if let dictionary = Bundle.main.infoDictionary {
  324. if let version = dictionary["CFBundleShortVersionString"], let build = dictionary["CFBundleVersion"] {
  325. return "\(version).\(build)"
  326. }
  327. }
  328. return ""
  329. }
  330. func loadImage(named: String, color: UIColor = NCBrandColor.shared.gray, size: CGFloat = 50, symbolConfiguration: Any? = nil) -> UIImage {
  331. var image: UIImage?
  332. if #available(iOS 13.0, *) {
  333. if let symbolConfiguration = symbolConfiguration {
  334. image = UIImage(systemName: named, withConfiguration: symbolConfiguration as? UIImage.Configuration)?.imageColor(color)
  335. } else {
  336. image = UIImage(systemName: named)?.imageColor(color)
  337. }
  338. if image == nil {
  339. image = UIImage(named: named)?.image(color: color, size: size)
  340. }
  341. } else {
  342. image = UIImage(named: named)?.image(color: color, size: size)
  343. }
  344. if image != nil {
  345. return image!
  346. }
  347. return UIImage(named: "file")!.image(color: color, size: size)
  348. }
  349. @objc func createAvatar(image: UIImage, size: CGFloat) -> UIImage {
  350. var avatarImage = image
  351. let rect = CGRect(x: 0, y: 0, width: size, height: size)
  352. UIGraphicsBeginImageContextWithOptions(rect.size, false, 3.0)
  353. UIBezierPath.init(roundedRect: rect, cornerRadius: rect.size.height).addClip()
  354. avatarImage.draw(in: rect)
  355. avatarImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
  356. UIGraphicsEndImageContext()
  357. return avatarImage
  358. }
  359. // MARK: -
  360. @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0, style: UIActivityIndicatorView.Style = .whiteLarge) {
  361. if self.activityIndicator != nil {
  362. stopActivityIndicator()
  363. }
  364. self.activityIndicator = UIActivityIndicatorView(style: style)
  365. guard let activityIndicator = self.activityIndicator else { return }
  366. DispatchQueue.main.async {
  367. if self.viewBackgroundActivityIndicator != nil { return }
  368. activityIndicator.color = NCBrandColor.shared.label
  369. activityIndicator.hidesWhenStopped = true
  370. activityIndicator.translatesAutoresizingMaskIntoConstraints = false
  371. let sizeActivityIndicator = activityIndicator.frame.height + 50
  372. self.viewActivityIndicator = UIView.init(frame: CGRect(x: 0, y: 0, width: sizeActivityIndicator, height: sizeActivityIndicator))
  373. self.viewActivityIndicator?.translatesAutoresizingMaskIntoConstraints = false
  374. self.viewActivityIndicator?.layer.cornerRadius = 10
  375. self.viewActivityIndicator?.layer.masksToBounds = true
  376. self.viewActivityIndicator?.backgroundColor = .clear
  377. #if !EXTENSION
  378. if backgroundView == nil {
  379. if let window = UIApplication.shared.keyWindow {
  380. self.viewBackgroundActivityIndicator?.removeFromSuperview()
  381. self.viewBackgroundActivityIndicator = NCViewActivityIndicator(frame: window.bounds)
  382. window.addSubview(self.viewBackgroundActivityIndicator!)
  383. self.viewBackgroundActivityIndicator?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  384. self.viewBackgroundActivityIndicator?.backgroundColor = .clear
  385. }
  386. } else {
  387. self.viewBackgroundActivityIndicator = backgroundView
  388. }
  389. #else
  390. self.viewBackgroundActivityIndicator = backgroundView
  391. #endif
  392. // VIEW ACTIVITY INDICATOR
  393. guard let viewActivityIndicator = self.viewActivityIndicator else { return }
  394. viewActivityIndicator.addSubview(activityIndicator)
  395. if blurEffect {
  396. let blurEffect = UIBlurEffect(style: .regular)
  397. let blurEffectView = UIVisualEffectView(effect: blurEffect)
  398. blurEffectView.frame = viewActivityIndicator.frame
  399. viewActivityIndicator.insertSubview(blurEffectView, at: 0)
  400. }
  401. NSLayoutConstraint.activate([
  402. viewActivityIndicator.widthAnchor.constraint(equalToConstant: sizeActivityIndicator),
  403. viewActivityIndicator.heightAnchor.constraint(equalToConstant: sizeActivityIndicator),
  404. activityIndicator.centerXAnchor.constraint(equalTo: viewActivityIndicator.centerXAnchor),
  405. activityIndicator.centerYAnchor.constraint(equalTo: viewActivityIndicator.centerYAnchor)
  406. ])
  407. // BACKGROUD VIEW ACTIVITY INDICATOR
  408. guard let viewBackgroundActivityIndicator = self.viewBackgroundActivityIndicator else { return }
  409. viewBackgroundActivityIndicator.addSubview(viewActivityIndicator)
  410. var verticalConstant: CGFloat = 0
  411. if bottom > 0 {
  412. verticalConstant = (viewBackgroundActivityIndicator.frame.size.height / 2) - bottom
  413. }
  414. NSLayoutConstraint.activate([
  415. viewActivityIndicator.centerXAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerXAnchor),
  416. viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor, constant: verticalConstant)
  417. ])
  418. activityIndicator.startAnimating()
  419. }
  420. }
  421. @objc func stopActivityIndicator() {
  422. DispatchQueue.main.async {
  423. self.activityIndicator?.stopAnimating()
  424. self.activityIndicator?.removeFromSuperview()
  425. self.activityIndicator = nil
  426. self.viewActivityIndicator?.removeFromSuperview()
  427. self.viewActivityIndicator = nil
  428. if self.viewBackgroundActivityIndicator is NCViewActivityIndicator {
  429. self.viewBackgroundActivityIndicator?.removeFromSuperview()
  430. }
  431. self.viewBackgroundActivityIndicator = nil
  432. }
  433. }
  434. }
  435. // MARK: -
  436. class NCViewActivityIndicator: UIView {
  437. // MARK: - View Life Cycle
  438. override init(frame: CGRect) {
  439. super.init(frame: frame)
  440. }
  441. required init?(coder: NSCoder) {
  442. fatalError("init(coder:) has not been implemented")
  443. }
  444. }