From 2d8d125c3d20e9f18312dc69bd69dfda716ad546 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 23 Jul 2024 16:04:00 +0500 Subject: [PATCH] Updated on 2026-08-14 --- features/disclaimer/impl/build.gradle.kts | 1 + .../impl/local/LocalTermOfServices.kt | 233 ++++++++++++++++++ .../disclaimer/impl/ui/DisclaimerScreen.kt | 91 +++---- .../impl/ui/DisclaimerWebViewClient.kt | 51 +--- 4 files changed, 288 insertions(+), 88 deletions(-) create mode 100644 features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/local/LocalTermOfServices.kt diff --git a/features/disclaimer/impl/build.gradle.kts b/features/disclaimer/impl/build.gradle.kts index bb7ee06e94..1e72ef4a09 100644 --- a/features/disclaimer/impl/build.gradle.kts +++ b/features/disclaimer/impl/build.gradle.kts @@ -21,6 +21,7 @@ dependencies { implementation(deps.compose.ui.tooling) implementation(deps.compose.accompanist.systemUiController) implementation(deps.compose.accompanist.permission) + implementation(deps.compose.accompanist.webView) implementation(deps.compose.material3) implementation(deps.compose.material) diff --git a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/local/LocalTermOfServices.kt b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/local/LocalTermOfServices.kt new file mode 100644 index 0000000000..1d60540d5e --- /dev/null +++ b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/local/LocalTermOfServices.kt @@ -0,0 +1,233 @@ +package com.tangem.features.disclaimer.impl.local + +internal val localTermsOfServices = """ + + + + + + + + Legal Disclaimer + + + + +

TANGEM WALLET AND TANGEM MOBILE APPLICATION

+

Terms of Service

+ +

PLEASE READ THESE TERMS OF SERVICE CAREFULLY. BY CLICKING TO ACCEPT, OR BY ACCESSING OR USING OUR SERVICES, YOU AGREE THAT YOU HAVE READ, UNDERSTOOD, AND ACCEPT ALL OF THE TERMS AND CONDITIONS CONTAINED HEREIN. BY PURCHASE OF TANGEM WALLET (CARD) OR BY USING TANGEM WALLET (CARD) OR BY USING TANGEM MOBILE APPLICATION, YOU DEMONSTRATE YOUR AGREEMENT TO THESE TERMS AND CONDITIONS CONTAINED HEREIN.

+ +

1. DEFINITIONS

+

“Cardholder” refers to an individual who owns a Tangem Card that is used to access the Tangem Wallet and Tangem Mobile Application.

+

“Blockchain Asset” refers to digital assets, including but not limited to cryptocurrencies, that can be managed through the Tangem Wallet.

+

“Blockchain Address” means a unique identifier that serves as a virtual location of the Blockchain Asset in the blockchain.

+

“Card Transaction” means transfer of Blockchain Asset from the Blockchain Address associated with the Public Key stored on the Tangem Wallet (Card).

+

“Official Mobile Application” means an application developed and distributed by Tangem, providing interoperability between Tangem Wallet (Card) and blockchain, and working on NFC-capable smartphones and tablets using Google Android and Apple iOS operation systems.

+

“Private Key” means a secret cryptographic key which provides full control over a Blockchain Asset.

+

“Tangem” means Tangem AG, a company incorporated under the laws of Switzerland (CHE-390.112.525), with a registered address at Baarerstrasse 10, CH-6300 Zug.

+

“Public Key” means a cryptographic key, which provides access to information about a Blockchain Asset, including but not limited to Blockchain Address

+

“Services” means the purchase and/or use of Tangem Wallet (Card) and the services or any other features, technologies or functionalities linked to the Tangem Wallet (Card) provided or operated by Tangem via the website or Official Mobile Applications.

+

“Tangem Wallet (Card) / Tangem Card / Card” means physical card which stores Private Key and Public Key and is used as a backup card.

+ +

2. DISCLAIMER

+

2.1. Bitcoin and other cryptocurrencies are virtual currencies, digital representations of value that are neither issued by a central bank of any state or public authority attached to a conventional currency, but may be used by any natural or legal persons as a means of exchange and can be transferred, stored or traded electronically.

+

2.2. Blockchain technologies and related services are subject to continuous regulatory changes and scrutiny around the world, including but not limited to anti-money laundering and financial regulations. You acknowledge that certain Services, including their availability, could be impacted by one or more regulatory requirements.

+

2.3. No advice. No part of the information herein should be considered to be business, legal, financial or tax advice regarding the Products or Services. You should consult your own legal, financial, tax or other professional advisor regarding the matter. By using the Services, you represent that Tangem is responsible neither for obtaining the information about tax or similar obligations arising in relation to usage of the Services nor for fulfillment of such tax (or similar) obligations.

+ +

3. GENERAL PROVISIONS

+

3.1. These Terms of Service (the “Terms”) govern the use of Tangem Wallet and/or Official Mobile Application provided by Tangem (referred to as "Tangem", "we" or "us" in this document) and the related services or any other features, technologies or functionalities linked to Tangem Wallet (Card). Tangem is a company incorporated under the laws of Switzerland (CHE-390.112.525), with a registered address at Baarerstrasse 10, CH-6300 Zug.

+

3.2. Tangem Cards may be used for storage of Private Key and Public Key to Cardholder’s Blockchain Assets and authentication of Card Transactions with the purpose of “person-to-person” transfer of Blockchain Assets to another blockchain address.

+

3.3. Official Mobile Application is intended for usage only with Tangem Wallet (Card), providing interoperability between the cards and blockchain via NFC interface. Official Mobile Application DOES NOT:

+

3.3.1. Generate, store, transmit, or have access to private (secret) cryptographic keys to blockchain wallets holding Blockchain assets.

+

3.3.2. Generate, store, transmit, or have access to secret keys, passwords, passphrases, recovery phrases that can be used to restore or to copy private (secret) keys to blockchain wallets holding Blockchain assets.

+

3.3.3 Provide exchange, trading, investment services on behalf of Tangem.

+ +

4. RIGHTS AND OBLIGATIONS

+

4.1. Cardholder agrees that these Terms are binding.

+

4.2. Cardholder shall be the only person having physical access to Tangem Wallet.

+

4.3. Cardholder acknowledges and agrees that Tangem does not provide backup or recovery of Private Key and Public Key stored by Tangem Wallet (Card).

+

4.4. Tangem does not keep records of Cardholder’s personal data, the amount of Blockchain Asset stored on the Card, the Private Key, or personalized history of Card usage.

+ +

5. COSTS

+

5.1. Costs, fees and commission (the “Costs”) may be charged in connection with the use of Card. These Costs are disclosed in Official Mobile Applications to Cardholder.

+

5.2. Amendments to Costs due to changing expenses or market conditions may be made at any time via adjustments to the fee schedules. Such amendments shall be communicated to Cardholder in an appropriate manner. Upon notification and in the event of the objection, Cardholder may cancel the Card with immediate effect.

+ +

6. CARDHOLDER’S DUTIES OF CARE

+

6.1. In particular, Cardholder shall exercise the following duties of care:

+

6.1.1. Upon receiving the Card, Cardholder should download Official Mobile Applications in order to create the backup and if applicable determine the amount of Blockchain Asset stored through Official Mobile Applications.

+

6.1.2. Cardholder shall keep the means of access and Tangem Wallet (Card) with care and all Cards separate from each other.

+

6.1.3. Cardholder must always know where Tangem Wallet (Card) is and regularly ensure that it is still in his/her possession. He/she shall avoid even temporary possession of Tangem Wallet (Card) by any other person.

+

6.1.4. Cardholder shall treat Tangem Wallet in the same manner as physical money (cash) and keep it safe. If any of the Card is lost, stolen or destroyed, control over the corresponding Blockchain Asset may be permanently lost.

+

6.1.5. Before using the Card with Official Mobile Applications, Cardholder shall locate Official Mobile Applications in Google Play or Apple app store and install it as instructed in the Card box.

+

6.1.6. Card shall be used only with Official Mobile Applications and as instructed in the Card box.

+

6.1.7. Official Mobile Application shall be the only source of information about the Blockchain Address of the Blockchain Asset and corresponding Public Key stored on Tangem Wallet (Card).

+

6.1.8. Cardholder shall only use Near-Field Devices (the “NFC”) devices that are capable of running Official Mobile Applications. He/she shall avoid leaving Tangem Wallet (Card) in the proximity of the NFC devices of other persons.

+

6.1.9. Tangem Wallet (Card) shall be used only for physically tapping and holding near Cardholder’s NFC device when Official Mobile Application requests it.

+

6.1.10. Cardholder shall keep Tangem Wallet (Card) with care and protect Tangem Wallet (Card) from mechanical damage, high temperatures, strong electromagnetic fields, and other harmful factors.

+

6.2. No retrieval of Private Keys. Tangem operates non-custodial services, which means that we do not store, nor do we have access to your Blockchain Assets nor your Private Keys. Tangem does not have access to or store passwords, 24-word Recovery Phrase, Private Keys, passphrases, transaction history, PIN, or other credentials associated with your use of the Services. You are solely responsible for remembering, storing, and keeping your credentials in a secure location, away from prying eyes. Any third party with knowledge of one or more of your 24-word Recovery Phrase can gain control of the Private Keys associated with your Tangem Wallet (Card) or of the 24-word Recovery Phrase, and therefore steal your Blockchain Assets, without any possibility for you or Tangem to retrieve them.

+ +

7. RIGHTS AND RESPONSIBILITIES OF CARDHOLDER

+

7.1. Cardholder is liable for all liabilities arising from the use of Tangem Wallet (Card) and/or Tangem Official Mobile Application. Any disputes in relation to discrepancies and complaints about goods or services and any resulting claims must be settled directly by Cardholder with the respective Reseller.

+

7.2. As a matter of principle, Cardholder is liable for any risks resulting from the misuse of Tangem Wallet (Card) and/or Official Mobile Application. In any case, Cardholder is solely liable for all transactions authorized using a means of access.

+

7.3. Any loss or damage resulting from the forwarding of Tangem Wallet (Card) and/or means of access shall be borne by Cardholder.

+

7.4. Loss or damage incurred by Cardholder in connection with the possession or use of Tangem Wallet (Card) and/or Official Mobile Application shall be borne solely by Cardholder. Tangem assumes no liability if Tangem Wallet (Card) and/or Official Mobile Application cannot be used due to a technical defect or because it has been canceled, blocked or the spending limit has been adjusted.

+

7.5. Cardholder is only permitted to use Tangem Wallet (Card) and Official Mobile Application for his personal, non-commercial use. Cardholder is not allowed to resell Tangem Wallet (Card).

+

7.6. Cardholder is solely responsible to determinate what, if any, taxes apply to Card Transactions. Tangem or contributors to Official Mobile Applications are NOT responsible for determining the taxes that apply to Card Transactions.

+

7.7. Before Cardholder engages in transactions using an electronic system, Cardholder should carefully review the rules and regulations of the exchanges offering the system and/or listing the instruments Cardholder intends to trade. Online trading has inherent risk due to system response and access times that may vary due to market conditions, system performance, and other factors. Cardholder should understand, fully accept and take on these and additional risks before trading.

+

7.8. There is considerable exposure to risk in the Blockchain Asset exchange transaction. Any transaction involving the Blockchain Asset involves risks including, but not limited to, the potential for changing economic conditions that may substantially affect the price or liquidity of the Blockchain Asset. Investments in the Blockchain Asset exchange speculation may also be susceptible to sharp rises and falls as the relevant market values fluctuate. It is for this reason that when speculating in such markets it is advisable to use only risk capital.

+

7.9. Before initiating any transactions through third-party resources via widgets or links within the application, Cardholder is expressly advised to meticulously review and comprehend the terms, rules, and regulations governing such resources. It is imperative for Cardholder to be cognizant of the inherent risks associated with online trading, including variations in system response times, access delays influenced by market conditions, system performance, and other pertinent factors.

+

7.10. Cardholder unequivocally assumes sole responsibility for all actions undertaken, encompassing but not limited to swap transactions, on-ramp, and off-ramp activities, when transitioning to third-party resources through widgets or links within the application. This responsibility extends to compliance with the terms and conditions of the relevant third-party resources and adherence to applicable laws and regulations.

+

7.11. Cardholder acknowledges and accepts that the use of third-party resources involves inherent risks, and Tangem shall bear no liability for the consequences arising from Cardholder's independent actions on these external platforms.

+

7.12. Cardholder is responsible for implementing adequate security measures and precautions when interacting with third-party resources to safeguard personal information, financial assets, and to mitigate potential risks associated with such engagements.

+

7.13. Cardholder agrees to indemnify and hold Tangem, its affiliates, and service providers harmless from any claims, losses, or damages incurred as a result of their actions on third-party platforms, as outlined in the Terms of Services.

+

7.14. Tangem explicitly disclaims any affiliation, endorsement, or responsibility for the content, policies, or transactions on third-party resources, and Cardholder interactions with such resources are entirely at their own risk.

+ +

8. THIRD-PARTY SERVICES

+

8.1. We may incorporate, reference and/or provide access to Third Party Services. For instance, buy, sell and crypto to crypto exchange (“swap”) services are Third Party Services. You agree that your use of Third-Party Services is subject to separate terms and conditions between you and the third-party identified in Tangem.

+

8.2. Tangem is not responsible for the content, accuracy, security, availability, any performance, or failure to perform of the Third-Party Services or any issue in relation with the use of Third-Party Services. Tangem does not provide any guarantees that access to Third-Party Services will not be interrupted or that there will be no delays, failures, errors, omissions, corruption or loss of transmitted information, data or funds, and Tangem shall not be liable for any such Third-Party Services. You agree to use the Third-Party Services at your own risk. It is your responsibility to review the third party’s terms and policies before using a Third-Party Service. Third-Party Services may not be available in all languages and may not be appropriate or available for use in any particular location. To the extent you choose to use such Third-Party Services, you are solely responsible for compliance with any applicable laws in relation to such use. In addition, Tangem reserves the right to block access to these Third-Party Services through Tangem Live in particular, but not exclusively, in the event of non-compliance with the applicable regulations by the Third-Party partner. We retain the exclusive right to suspend, remove, or cancel the availability of any such Third-Party Service for any reason and without prior notice.

+ +

9. RESPONSIBILITIES AND LIABILITIES OF TANGEM

+

9.1. Tangem does not warrant or make any representations regarding the use, the inability to use or operate, or the results of the use or operation of Tangem Wallet (Card) and/or Official Mobile Application.

+

9.2. Tangem does not keep any records of Cardholder information, the amount of Blockchain Asset stored on Tangem Wallet (Card), the Private Key, or personalized history of cards usage.

+

9.3. Tangem does not provide any backup or recovery of Private Key and Public Key stored on Tangem Wallet (Card).

+

9.4. Tangem shall not be held liable for any failure to be able to use Tangem Wallet (Card) and/or Official Mobile Application, for any reason whatsoever, nor will Tangem be held liable for the loss of the Blockchain Asset resulting from a malfunction or inoperability of the blockchain network hosting Blockchain Asset, as well as the inaccessibility of its public servers and services.

+

9.5. Tangem does not guarantee that the operation of Tangem Wallet (Card) and/or Official Mobile Application will be secure, accurate, complete, uninterrupted, without error or free of viruses, worms, other harmful components or other program limitations. Tangem may, at its sole discretion and without obligation to do so, correct, modify, amend, enhance, improve and make any other changes to Tangem Wallet and/or Official Mobile Application, change, update or suspend the Services, temporarily or indefinitely, so as to carry out works including, but not limited to: firmware and software updates, maintenance operations, amendments to the servers, bug fixes, etc. We will make reasonable efforts to give you prior notice of any significant disruption of the Services. Tangem does not guarantee the correct functioning of the Services in the event of the installation or use of programs or applications that do not conform to Service specifications and technical standards.

+

9.6. Tangem shall not be held liable for the loss of profits, income, value or any indirect, extraordinary, consequential, exemplary or punitive damages.

+

9.7. Tangem shall not be held liable for loss or breakdown of Tangem Wallet (Card).

+

9.8. Tangem shall not be held liable for any loss of Blockchain Asset in the event of loss or total breakdown of Tangem Wallet (Card).

+ +

10. GUARANTEES

+

10.1. Under the condition that Cardholder exercises the duties of care as stated in Clause 5, Tangem guarantees that Tangem Wallet (Card) will function properly and without restriction for a period of 2 (two) years. In the event of a breakdown of Tangem Wallet (Card) without it being the fault of Cardholder due to reasons mentioned in Clause 5 of these Terms, Tangem will replace Tangem Wallet with a new one. Cardholder shall inform Tangem on the event of a breakdown by sending an e-mail to support@tangem.com. If failed to resolve with support team of Tangem, Cardholder shall wait for instructions on safe shipping of Tangem Wallet (Card).

+

10.2. Tangem guarantees that Tangem Wallet (Card) prevents duplication of the Private Key and that Cardholder has exclusive control over the Blockchain Asset unless the contrary is imposed by specific blockchain network rules, e.g. two or more private keys can be used to control the same Blockchain Asset.

+ +

11. LIMITATION OF LIABILITY

+

11.1. Tangem Wallet (Card), including without limitation any content, data and information related thereto, is provided on an “as is” basis and “as available” basis, without any warranties of any kind, express or implied warranties of use, merchantability or suitability for a certain purpose or use, including without limitation, the quality of products and services provided by users, third-party services, and/or exchanges (except for the guarantees set forth in Section 9).

+

11.2. Official Mobile Application is provided on an “as is” basis and “as available” basis without any warranties of any kind regarding Official Mobile Application and/or any content, data, materials and/or services provided on Official Mobile Application.

+

11.3. Tangem and its affiliates, including any of their officers, directors, shareholders, employees, sub-contractors, agents, parent companies, subsidiaries and other affiliates (collectively, the “Tangem Affiliates”), jointly and severally, disclaim and make no representations or warranties as to the usability, accuracy, quality, availability, reliability, suitability, completeness, truthfulness, usefulness or effectiveness of any content, data, results or other information obtained or generated by Tangem and/or any user related to you or any other user of Tangem Wallet (Card), and Official Mobile Applications.

+

11.4. In no event shall Tangem and/or any of Tangem Affiliates be liable for any damages whatsoever, including direct, indirect, extraordinary, incidental or consequential damages of any kind, but not limited to, resulting from or arising out of the use of Tangem Wallet (Card) and/or Official Mobile Applications or inability to use Tangem Wallet (Card) and/or Official Mobile Applications, failure of Tangem Wallet (Card) and/or Official Mobile Applications to perform as represented or expected, loss of goodwill or profits, or loss of data arising out of or in any way connected with the use of Tangem Wallet (Card) and/or Official Mobile Applications. In no event shall Tangem and/or any of Tangem Affiliates be liable for the performance or failure of Tangem Wallet (Card) and/ or Official Mobile Applications to perform under these Terms of Use and any other act or omission by Tangem by any cause whatsoever including without limitation damages arising from the conduct of any users, third party services and/or exchanges. In no way Tangem or contributors to Official Mobile Application are responsible for the actions, decisions, or other behavior taken or not taken by Cardholder in reliance upon Tangem Official Mobile Application.

+

11.5. You hereby acknowledge and agree that these limitations of liability are agreed allocations of risk constituting in part the consideration for using Tangem Wallet (Card) and Official Mobile Applications and such limitations will apply notwithstanding the failure of essential purpose of any limited remedy, and even if Tangem and/or any Tangem Affiliates has been advised of the possibility of such liabilities and/or damages.

+

11.6. Tangem will not be responsible for any losses, damages or claims arising from events falling within the scope of the following five categories:

+

11.6.1. Mistakes made by Cardholder, e.g., forgotten passwords, payments sent to wrong addresses, and accidental deletion of blockchain wallets on Tangem Wallet (Card).

+

11.6.2. Problems of Official Mobile Application and/or any blockchain- or cryptocurrency- related software or service, e.g., corrupted files, incorrectly constructed transactions, unsafe cryptographic libraries, malware.

+

11.6.3. Technical failures in the hardware of Cardholder, including cards, of any blockchain- or cryptocurrency- related software or service, e.g., data loss due to a faulty or damaged storage device.

+

11.6.4. Security problems experienced by Cardholder, e.g., unauthorized access to Cardholders' wallets and/or accounts.

+

11.6.5. Actions or inactions of third parties and/or events experienced by third parties, e.g., bankruptcy of service providers, information security attacks on service providers, and fraud conducted by third parties.

+ +

12. GOVERNING LAW AND DISPUTE RESOLUTION

+

12.1. Unless otherwise required by a mandatory law of a member state of the European Union or any other jurisdiction these Terms of Service and any separate agreements whereby we provide you Services shall be governed by the laws of Switzerland without regard to its conflict of laws principles.

+

12.2. You can submit a claim in written form regarding the operation of the Services to us via email at store@tangem.com. You may also reach us in writing at the following address: Tangem AG, Baarerstrasse 10, Zug, CH-6300 Switzerland. In case of failure to resolve disputes and disagreements by way of negotiations the settlement shall be in accordance with claim procedure. Claims shall be reviewed within 30 calendar days.

+

12.3. Subject to compulsory legal provisions, any use of the Services and all legal disputes arising out of or in connection therewith shall be submitted to the exclusive jurisdiction of the courts of the Canton of Zug.

+ +

13. COMMUNICATION

+

13.1. In the event when under the Terms Tangem provides the User with any information that relates to the Services provided hereunder, this information may be given to the Client through the Website without sending said information directly to the User’s address and / or using other secure means.

+

13.2. Tangem shall respond to requests from the User promptly and within 7 calendar days following the date of receipt of the request. The response time may in some cases may exceed 7 calendar days.

+ +

14. MISCELLANEOUS

+

14.1. Entire agreement. These Terms and any policies or operating rules posted by us on the Website or in respect to the Services constitutes the entire agreement and understanding between you and us and govern your use of the Services, superseding any prior or contemporaneous agreements, communications and proposals, whether oral or written, between you and us (including, but not limited to, any prior versions of the Terms).

+

14.2. Severability. In the event that any provision of these Terms is determined to be unlawful, void or unenforceable, such provision will nonetheless be enforceable to the fullest extent permitted by applicable law, and the unenforceable portion will be deemed to be severed from these Terms of Service, such determination will not affect the validity and enforceability of any other remaining provisions.

+

14.3. Assignment. You may not assign your rights or obligations under these Terms in whole or in part to any third party. You acknowledge and agree that Tangem may assign its rights and obligations under these Terms, including rights and obligations concerning insurance, and, in such context, share or transfer information provided by you while using the Services to a third party.

+

14.4. No waiver. The failure of us to exercise or enforce any right or provision of these Terms will not constitute a waiver of such right or provision.

+

14.5. Any ambiguities in the interpretation of these Terms will not be construed against the drafting party.

+

14.6. Errors, Inaccuracies, And Omissions. Occasionally there may be information in the Services that contains typographical errors, inaccuracies or omissions that may relate to product descriptions, pricing, promotions, offers, product shipping charges, transit times and availability. We reserve the right to correct any errors, inaccuracies or omissions, and to change or update information or cancel orders if any information in the Services or on any related website is inaccurate at any time without prior notice (including after you have submitted your order).

+

14.7. Terms concerning Recovery Phrase apply to Tangem Wallet (Card) supporting this feature.

+

14.8. We undertake no obligation to update, amend or clarify information in the Services, including without limitation, pricing information, except as required by law. No specified update or refresh date applied in the Services or on any related website, should be taken to indicate that all information in the Services has been modified or updated.

+

14.9. These Terms may be drawn up in different languages. In case of any inconsistency the English version of the Terms shall prevail.

+ +

Last amended on: March 1st, 2024

+ + + +""".trimIndent() \ No newline at end of file diff --git a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerScreen.kt b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerScreen.kt index fddb1a255b..b3740659cc 100644 --- a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerScreen.kt +++ b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerScreen.kt @@ -2,26 +2,28 @@ package com.tangem.features.disclaimer.impl.ui import android.annotation.SuppressLint import android.content.res.Configuration -import android.view.View -import android.view.ViewGroup -import android.webkit.WebView +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.CircularProgressIndicator import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.viewinterop.AndroidView import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted import com.google.accompanist.permissions.rememberPermissionState +import com.google.accompanist.web.WebView +import com.google.accompanist.web.rememberWebViewState +import com.google.accompanist.web.rememberWebViewStateWithHTMLData import com.tangem.core.ui.components.BottomFade import com.tangem.core.ui.components.NavigationBar3ButtonsScrim import com.tangem.core.ui.components.PrimaryButton @@ -35,6 +37,7 @@ import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.disclaimer.impl.R import com.tangem.features.disclaimer.impl.entity.DisclaimerUM import com.tangem.features.disclaimer.impl.entity.DummyDisclaimer +import com.tangem.features.disclaimer.impl.local.localTermsOfServices import com.tangem.features.pushnotifications.api.utils.getPushPermissionOrNull @Composable @@ -63,6 +66,7 @@ internal fun DisclaimerScreen(state: DisclaimerUM) { iconRes = R.drawable.ic_back_24, onIconClicked = state.popBack, ).takeIf { state.isTosAccepted }, + titleAlignment = Alignment.CenterHorizontally, textColor = textColor, iconTint = iconColor, ) @@ -81,52 +85,51 @@ internal fun DisclaimerScreen(state: DisclaimerUM) { @SuppressLint("SetJavaScriptEnabled") @Composable private fun DisclaimerContent(url: String, isTosAccepted: Boolean) { - val progressState = remember { mutableStateOf(ProgressState.Loading) } - val webClient = remember { DisclaimerWebViewClient(progressState) } - val transparent = Color.Transparent val backgroundColor = if (isTosAccepted) TangemTheme.colors.background.primary else TangemColorPalette.Dark6 - Box( - modifier = Modifier, - ) { - AndroidView( - factory = { - WebView(it).apply { - layoutParams = ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT, - ) - setBackgroundColor(transparent.toArgb()) - settings.allowFileAccess = false - // to inject css style to display only in dark theme - settings.javaScriptEnabled = !isTosAccepted - overScrollMode = View.OVER_SCROLL_NEVER - webViewClient = webClient - clearHistory() - clearFormData() - clearCache(true) + val webViewStateUrl = rememberWebViewState(url) + val webViewStateData = + rememberWebViewStateWithHTMLData(data = localTermsOfServices, mimeType = "text/html", encoding = "UTF-8") - loadUrl(url) - } + val webViewState by remember { + derivedStateOf { + if (webViewStateUrl.errorsForCurrentRequest.isNotEmpty()) { + webViewStateData + } else { + webViewStateUrl + } + } + } + + Box { + WebView( + state = webViewState, + captureBackPresses = false, + onCreated = { + it.settings.javaScriptEnabled = !isTosAccepted + it.setBackgroundColor(backgroundColor.toArgb()) }, + client = remember { DisclaimerWebViewClient() }, ) - when (progressState.value) { - ProgressState.Loading -> { - Box( + AnimatedVisibility( + visible = webViewState.isLoading, + label = "Loading state change animation", + enter = fadeIn(), + exit = fadeOut(), + ) { + Box( + modifier = Modifier + .fillMaxSize() + .background(backgroundColor), + ) { + CircularProgressIndicator( + color = TangemTheme.colors.icon.informative, modifier = Modifier - .fillMaxSize() - .background(backgroundColor), - ) { - CircularProgressIndicator( - color = TangemTheme.colors.icon.informative, - modifier = Modifier - .align(Alignment.Center) - .padding(TangemTheme.dimens.spacing8), - ) - } + .align(Alignment.Center) + .padding(TangemTheme.dimens.spacing8), + ) } - else -> Unit } } } diff --git a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerWebViewClient.kt b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerWebViewClient.kt index 5ad8aedb8f..c3046d0855 100644 --- a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerWebViewClient.kt +++ b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/ui/DisclaimerWebViewClient.kt @@ -1,8 +1,8 @@ package com.tangem.features.disclaimer.impl.ui import android.graphics.Bitmap -import android.webkit.* -import androidx.compose.runtime.MutableState +import android.webkit.WebView +import com.google.accompanist.web.AccompanistWebViewClient internal enum class ProgressState { Loading, @@ -26,57 +26,20 @@ private fun WebView.injectCSS() { evaluateJavascript(code, null) } -internal class DisclaimerWebViewClient(private val progressState: MutableState) : WebViewClient() { - - private var loadingUrl: String? = null - private var loadedUrl: String? = null - - fun reset() { - loadingUrl = null - loadedUrl = null - progressState.value = ProgressState.Loading - } +internal class DisclaimerWebViewClient : AccompanistWebViewClient() { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { view?.injectCSS() super.onPageStarted(view, url, favicon) + } - if (loadingUrl != url && progressState.value != ProgressState.Error) progressState.value = ProgressState.Loading - loadingUrl = url + override fun onPageCommitVisible(view: WebView?, url: String?) { + view?.injectCSS() + super.onPageCommitVisible(view, url) } override fun onPageFinished(view: WebView?, url: String?) { view?.injectCSS() super.onPageFinished(view, url) - - if (loadedUrl != url && progressState.value != ProgressState.Error) progressState.value = ProgressState.Done - loadedUrl = url - } - - override fun onReceivedError(view: WebView?, resourceRequest: WebResourceRequest?, error: WebResourceError?) { - view?.injectCSS() - super.onReceivedError(view, resourceRequest, error) - error?.let { progressState.value = ProgressState.Error } - } - - override fun onReceivedHttpError( - view: WebView?, - resourceRequest: WebResourceRequest?, - errorResponse: WebResourceResponse?, - ) { - view?.injectCSS() - super.onReceivedHttpError(view, resourceRequest, errorResponse) - - if (resourceRequest != null && errorResponse != null) { - val isDifferentUrl = resourceRequest.url?.toString() != loadingUrl - val isSuccessCode = errorResponse.statusCode < RESPONSE_USER_ERROR_STATUS_CODE - val isNotDone = progressState.value != ProgressState.Done - if (isDifferentUrl || isSuccessCode || isNotDone) return - progressState.value = ProgressState.Error - } - } - - companion object { - private const val RESPONSE_USER_ERROR_STATUS_CODE = 400 } } \ No newline at end of file