Add clear dapp browser cache action to Settings tab

pull/1246/head
Hwee-Boon Yar 5 years ago
parent b94253e7cf
commit 737726d80c
  1. 8
      AlphaWallet.xcodeproj/project.pbxproj
  2. 1
      AlphaWallet/Localization/en.lproj/Localizable.strings
  3. 1
      AlphaWallet/Localization/es.lproj/Localizable.strings
  4. 1
      AlphaWallet/Localization/ja.lproj/Localizable.strings
  5. 1
      AlphaWallet/Localization/ko.lproj/Localizable.strings
  6. 1
      AlphaWallet/Localization/zh-Hans.lproj/Localizable.strings
  7. 27
      AlphaWallet/Settings/Coordinators/ClearDappBrowserCacheCoordinator.swift
  8. 8
      AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift
  9. 1
      AlphaWallet/Settings/Types/SettingsAction.swift
  10. 7
      AlphaWallet/Settings/ViewControllers/SettingsViewController.swift
  11. 15
      AlphaWallet/Tokens/Views/WKWebViewExtension.swift

@ -231,6 +231,7 @@
5E7C700A0B11504AC44718DD /* CanScanQRCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C74159ED115D14384A1CB /* CanScanQRCode.swift */; };
5E7C701BFF4469B35A074EB9 /* RequestViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C767497AD8DEE83F384D7 /* RequestViewModel.swift */; };
5E7C702C4B29AF2B8D61CCA4 /* DappsAutoCompletionViewControllerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7D19E3CF96929FB8CEA3 /* DappsAutoCompletionViewControllerViewModel.swift */; };
5E7C70397E7E3A9C88E995B1 /* WKWebViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7BEDC786FB048A1DD9A8 /* WKWebViewExtension.swift */; };
5E7C705B311BB36C950ECE1D /* AssetDefinitionsOverridesViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C73CAB804322C4A631C67 /* AssetDefinitionsOverridesViewCell.swift */; };
5E7C70861A499FF79B7DA903 /* DiscoverDappCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7B54826BFDD53DF3E5BF /* DiscoverDappCell.swift */; };
5E7C708D05DBC08C8304F274 /* GetIsERC875Encode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7DCB0BDDD30D10130AE7 /* GetIsERC875Encode.swift */; };
@ -316,6 +317,7 @@
5E7C74C1C2AB84F9AFAC630E /* TokenCardRowViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7C12E88EB0B73AA1E562 /* TokenCardRowViewModelProtocol.swift */; };
5E7C74C6110D4E93C759D5DB /* ConfirmSignMessageTableViewCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7B080E387A79058430B9 /* ConfirmSignMessageTableViewCellViewModel.swift */; };
5E7C74DBAE43954C185057B3 /* ChooseTokenCardTransferModeViewControllerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7BA578BE5FB0E613A6D6 /* ChooseTokenCardTransferModeViewControllerViewModel.swift */; };
5E7C74E1ECC13899FA369E1C /* ClearDappBrowserCacheCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C72571AB0FECB26FEB1B1 /* ClearDappBrowserCacheCoordinator.swift */; };
5E7C74E7DC2D79785240D757 /* GetERC875Balance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7251DB61EB9468910C81 /* GetERC875Balance.swift */; };
5E7C74F21FAD632085C6C3C8 /* AssetImplicitAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C736F4E3F93F374F821C9 /* AssetImplicitAttributes.swift */; };
5E7C7507CC97BDE973FD4F0E /* GetENSOwnerCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7E9A5E7D36AA3BC108A4 /* GetENSOwnerCoordinatorTests.swift */; };
@ -905,6 +907,7 @@
5E7C7228C9BEB801D4CD34DE /* EtherTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EtherTests.swift; sourceTree = "<group>"; };
5E7C722CD3CFB0C9BAE9989F /* AssetInternalValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssetInternalValue.swift; sourceTree = "<group>"; };
5E7C7251DB61EB9468910C81 /* GetERC875Balance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC875Balance.swift; sourceTree = "<group>"; };
5E7C72571AB0FECB26FEB1B1 /* ClearDappBrowserCacheCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClearDappBrowserCacheCoordinator.swift; sourceTree = "<group>"; };
5E7C727433F7B8E322B3C68A /* SetTransferTokensCardExpiryDateViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetTransferTokensCardExpiryDateViewController.swift; sourceTree = "<group>"; };
5E7C727CF8549291E71C1640 /* Ether.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Ether.swift; sourceTree = "<group>"; };
5E7C7281A6AB5155CD42DD7A /* TokenScriptSignatureVerifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenScriptSignatureVerifier.swift; sourceTree = "<group>"; };
@ -1080,6 +1083,7 @@
5E7C7BCC02D0FFACA811EFCF /* AssetFunctionCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssetFunctionCall.swift; sourceTree = "<group>"; };
5E7C7BCCCFE7B99162518FB7 /* ConvertSVGToPNG.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConvertSVGToPNG.swift; sourceTree = "<group>"; };
5E7C7BD9B4BDAFC2D9EBD741 /* StatusViewControllerViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusViewControllerViewModel.swift; sourceTree = "<group>"; };
5E7C7BEDC786FB048A1DD9A8 /* WKWebViewExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKWebViewExtension.swift; sourceTree = "<group>"; };
5E7C7BF09AD68C113D58344C /* LocalesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalesViewController.swift; sourceTree = "<group>"; };
5E7C7BF5551BF64D2AE8AD66 /* AssetDefinitionDiskBackingStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssetDefinitionDiskBackingStore.swift; sourceTree = "<group>"; };
5E7C7BF7C9B44B3C2D5330CE /* CustomUrlSchemeCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomUrlSchemeCoordinator.swift; sourceTree = "<group>"; };
@ -1708,6 +1712,7 @@
5E7C76C895E7BFA47233068C /* LocalesCoordinator.swift */,
5E7C7C7CB95B7EE4B2547585 /* EnabledServersCoordinator.swift */,
5E7C7C51CEC4AAFDFBD75482 /* ConsoleCoordinator.swift */,
5E7C72571AB0FECB26FEB1B1 /* ClearDappBrowserCacheCoordinator.swift */,
);
path = Coordinators;
sourceTree = "<group>";
@ -1835,6 +1840,7 @@
5E7C74E29F4C16A074A62698 /* TokenViewControllerTransactionCell.swift */,
5E7C79C2CA884C78B24A97FB /* TokenViewControllerHeaderView.swift */,
5E7C704499C81ACA3B08A752 /* TokenInstanceWebView.swift */,
5E7C7BEDC786FB048A1DD9A8 /* WKWebViewExtension.swift */,
);
path = Views;
sourceTree = "<group>";
@ -4153,6 +4159,8 @@
5E7C7648BFF9AE93CD97A1BE /* ConsoleViewController.swift in Sources */,
5E7C73092E428F9519787284 /* Core.swift in Sources */,
5E7C7BF4350EE7829838E237 /* TokenScriptSignatureVerifier.swift in Sources */,
5E7C70397E7E3A9C88E995B1 /* WKWebViewExtension.swift in Sources */,
5E7C74E1ECC13899FA369E1C /* ClearDappBrowserCacheCoordinator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -258,6 +258,7 @@
"a.wallet.address.title" = "My %@ Wallet Address";
"a.settings.navigation.title" = "Settings";
"a.settings.contents.myWalletAddress" = "My Wallet Address";
"a.settings.contents.clearDappBrowserCache" = "Clear Dapp Browser cache";
"a.welcome.navigation.title" = "Welcome";
"a.welcome.onboarding.1" = "Hold all your Crypto assets in one place";
"a.welcome.onboarding.2" = "Powered by blockchain technology, smart tickets, fraud free";

@ -258,6 +258,7 @@
"a.wallet.address.title" = "La dirección de mi monedero de %@";
"a.settings.navigation.title" = "Ajustes";
"a.settings.contents.myWalletAddress" = "La dirección de mi monedero";
"a.settings.contents.clearDappBrowserCache" = "Clear Dapp Browser cache";
"a.welcome.navigation.title" = "Bienvenido";
"a.welcome.onboarding.1" = "Almacena todos tus activos criptográficos en un solo lugar";
"a.welcome.onboarding.2" = "Con tecnología de cadena de bloques, tickets inteligentes, sin fraudes";

@ -258,6 +258,7 @@
"a.wallet.address.title" = "私の %@ ウォレットのアドレス";
"a.settings.navigation.title" = "設定";
"a.settings.contents.myWalletAddress" = "私のウォレットのアドレス";
"a.settings.contents.clearDappBrowserCache" = "Clear Dapp Browser cache";
"a.welcome.navigation.title" = "ようこそ";
"a.welcome.onboarding.1" = "あなたのすべての暗号資産を1か所に保持します";
"a.welcome.onboarding.2" = "ブロッキチェーン技術、スマート チケットを使用、不正行為なし";

@ -258,6 +258,7 @@
"a.wallet.address.title" = "내 %@ 지갑 주소";
"a.settings.navigation.title" = "설정";
"a.settings.contents.myWalletAddress" = "내 지갑 주소";
"a.settings.contents.clearDappBrowserCache" = "Clear Dapp Browser cache";
"a.welcome.navigation.title" = "환영합니다";
"a.welcome.onboarding.1" = "모든 암호화폐 자산을 한 곳에서 관리하십시오";
"a.welcome.onboarding.2" = "블록체인 기술 기반, 스마트 티켓, 사기 방지";

@ -258,6 +258,7 @@
"a.wallet.address.title" = "我的以太坊钱包地址";
"a.settings.navigation.title" = "我的设置";
"a.settings.contents.myWalletAddress" = "我的钱包地址";
"a.settings.contents.clearDappBrowserCache" = "Clear Dapp Browser cache";
"a.welcome.navigation.title" = "欢迎";
"a.welcome.onboarding.1" = "支持调用各种数字资产";
"a.welcome.onboarding.2" = "基于区块链技术,智能门票,杜绝欺诈";

@ -0,0 +1,27 @@
// Copyright © 2018 Stormbird PTE. LTD.
import UIKit
import WebKit
class ClearDappBrowserCacheCoordinator: Coordinator {
private let viewController: UIViewController
var coordinators: [Coordinator] = []
init(inViewController viewController: UIViewController) {
self.viewController = viewController
}
func start() {
UIAlertController.alert(title: "\(R.string.localizable.aSettingsContentsClearDappBrowserCache())?",
message: nil,
alertButtonTitles: [R.string.localizable.oK(), R.string.localizable.cancel()],
alertButtonStyles: [.destructive, .cancel],
viewController: viewController,
completion: { [weak self] choice in
guard let strongSelf = self else { return }
guard choice == 0 else { return }
WKWebView.clearCache()
})
}
}

@ -76,6 +76,12 @@ class SettingsCoordinator: Coordinator {
navigationController.pushViewController(coordinator.localesViewController, animated: true)
}
func clearDappBrowserCache() {
let coordinator = ClearDappBrowserCacheCoordinator(inViewController: rootViewController)
coordinator.start()
addCoordinator(coordinator)
}
func showEnabledServers() {
let coordinator = EnabledServersCoordinator(selectedServers: config.enabledServers)
coordinator.delegate = self
@ -100,6 +106,8 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
showLocales()
case .enabledServers:
showEnabledServers()
case .clearDappBrowserCache:
clearDappBrowserCache()
}
}

@ -8,4 +8,5 @@ enum AlphaWalletSettingsAction {
case wallets
case locales
case enabledServers
case clearDappBrowserCache
}

@ -130,6 +130,13 @@ class SettingsViewController: FormViewController {
cell.textLabel?.text = " \(R.string.localizable.aConsoleTitle())"
cell.accessoryType = .disclosureIndicator
}
<<< AppFormAppearance.alphaWalletSettingsButton {
$0.title = " \(R.string.localizable.aSettingsContentsClearDappBrowserCache())"
}.onCellSelection { [unowned self] _, _ in
self.delegate?.didAction(action: .clearDappBrowserCache, in: self)
}.cellSetup { cell, _ in
cell.imageView?.tintColor = Colors.appBackground
}
+++ createSection(withTitle: R.string.localizable.settingsContactUsTitle())

@ -0,0 +1,15 @@
// Copyright © 2018 Stormbird PTE. LTD.
import Foundation
import WebKit
extension WKWebView {
static func clearCache() {
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
records.forEach { record in
WKWebsiteDataStore.default().removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {})
}
}
}
}
Loading…
Cancel
Save