Skip to content

Commit

Permalink
Add shielding notice dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiokot committed May 24, 2024
1 parent 671ec1a commit a3429d0
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.concordium.wallet.ui.account.accountsoverview

import android.content.ActivityNotFoundException
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getSystemService
import androidx.core.view.isVisible
import com.concordium.wallet.BuildConfig
import com.concordium.wallet.R
import com.concordium.wallet.data.repository.AuthenticationRepository
import com.concordium.wallet.databinding.DialogShieldingNoticeBinding
import com.concordium.wallet.ui.common.delegates.AuthDelegate
import com.concordium.wallet.ui.common.delegates.AuthDelegateImpl
import org.koin.android.ext.android.inject

class ShieldingNoticeDialogFragment :
AppCompatDialogFragment(),
AuthDelegate by AuthDelegateImpl() {

private lateinit var binding: DialogShieldingNoticeBinding

private val authenticationRepository: AuthenticationRepository by inject()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = DialogShieldingNoticeBinding.inflate(layoutInflater)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

authenticationRepository.getSeedPhase().onSuccess { phrase ->
binding.copyPhraseButton.isVisible = true
binding.copyPhraseButton.setOnClickListener {
showAuthentication(
activity = requireActivity() as AppCompatActivity,
authenticated = {
val clipboard: ClipboardManager? =
getSystemService(requireContext(), ClipboardManager::class.java)
val clip = ClipData.newPlainText("Phrase", phrase)
clipboard?.setPrimaryClip(clip)
}
)
}
}

binding.continueWithOldWalletButton.setOnClickListener {
dismiss()
}

binding.installCryptoxButton.setOnClickListener {
val cryptoXPackage =
if (BuildConfig.ENV_NAME == "prod_testnet")
"com.pioneeringtechventures.wallet.testnet"
else
"com.pioneeringtechventures.wallet"

val intent = Intent(Intent.ACTION_VIEW).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
setData(Uri.parse("market://details?id=$cryptoXPackage"))
}
try {
startActivity(intent)
} catch (_: ActivityNotFoundException) {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=$cryptoXPackage")
)
)
}
}
}

override fun onStart() {
super.onStart()
dialog?.window?.apply {
setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
setBackgroundDrawable(
ContextCompat.getDrawable(
requireContext(),
R.drawable.bg_shielding_notice
)
)
}
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/bg_shielding_notice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:radius="16dp" />
</shape>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/ico_unshield.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="86dp"
android:height="85dp"
android:viewportWidth="86"
android:viewportHeight="85">
<path
android:pathData="M43.249,74.066C43.146,74.109 43.062,74.143 42.999,74.169C42.936,74.143 42.852,74.109 42.749,74.066C42.478,73.953 42.075,73.78 41.562,73.546C40.537,73.077 39.078,72.366 37.373,71.407C33.953,69.483 29.595,66.591 25.746,62.697C20.52,57.408 16.344,50.41 16.344,41.571V14.777L42.998,8.191L69.653,14.777V16.541H69.654V41.571C69.654,50.411 65.478,57.409 60.252,62.696L60.252,62.697C56.403,66.591 52.046,69.483 48.625,71.407C46.92,72.366 45.461,73.077 44.436,73.546C43.923,73.78 43.52,73.953 43.249,74.066ZM16.021,14.857L16.021,14.857L16.021,14.857Z"
android:strokeWidth="4.21879"
android:fillColor="#00000000"
android:strokeColor="#4486AB"/>
<path
android:pathData="M43,53.257C50.99,53.257 57.467,46.855 57.467,38.958C57.467,31.061 50.99,24.659 43,24.659C35.01,24.659 28.533,31.061 28.533,38.958C28.533,46.855 35.01,53.257 43,53.257ZM43,56.666C52.895,56.666 60.917,48.738 60.917,38.958C60.917,29.178 52.895,21.25 43,21.25C33.105,21.25 25.083,29.178 25.083,38.958C25.083,48.738 33.105,56.666 43,56.666Z"
android:fillColor="#4486AB"
android:fillType="evenOdd"/>
<path
android:pathData="M53.76,51.988L29.472,27.983L31.959,25.525L56.247,49.53L53.76,51.988Z"
android:fillColor="#4486AB"
android:fillType="evenOdd"/>
</vector>
88 changes: 88 additions & 0 deletions app/src/main/res/layout/dialog_shielding_notice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:fillViewport="true">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:importantForAccessibility="no"
app:srcCompat="@drawable/ico_unshield" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="@string/shielding_notice_title"
android:textColor="#4486AB"
android:textSize="24sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="30dp"
android:gravity="center"
android:text="@string/shielding_notice_message"
android:textColor="#333333"
android:textSize="14sp" />

<Space
android:layout_width="0dp"
android:layout_height="12dp" />

<Button
android:id="@+id/copy_phrase_button"
style="@style/Button.Standard.Transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:drawablePadding="4dp"
android:text="@string/shielding_notice_сopy_phrase"
android:textSize="14sp"
android:visibility="gone"
app:drawableStartCompat="@drawable/ic_copy"
tools:visibility="visible" />

<Button
android:id="@+id/install_cryptox_button"
style="@style/Button.Standard"
android:layout_width="match_parent"
android:layout_marginHorizontal="36dp"
android:layout_marginTop="12dp"
android:text="@string/install_cryptox"
android:textSize="14sp" />

<Button
android:id="@+id/continue_with_old_wallet_button"
style="@style/Button.Standard.Transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/shielding_notice_continue_with_old_wallet"
android:textSize="14sp" />

<Space
android:layout_width="0dp"
android:layout_height="10dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1117,4 +1117,17 @@

<string name="baking_commission_rate_error_transaction_not_in_range">Transaction fee is out of specified range</string>
<string name="baking_commission_rate_error_baking_not_in_range">Baking reward is out of specified range</string>

<string name="shielding_notice_title">Transaction Shielding is going away</string>
<string name="shielding_notice_message">
We recommend that you unshield any Shielded balance today. To do so move your account to the new CryptoX Concordium wallet.\n\n
<b>1. Install the CryptoX Concordium wallet</b>\n
<b>2. Copy your seed phrase</b>\n
<b>3. Insert your seed phrase in the CryptoX wallet</b>\n\n
When that’s done, you will be able to unshield your Shielded balance through the CryptoX wallet, and you can safely delete this one.\n\n
Don’t worry, your wallet will stay here on your device until you uninstall it, but we highly encourage you to migrate today.
</string>
<string name="install_cryptox">Install CryptoX Concordium wallet</string>
<string name="shielding_notice_continue_with_old_wallet">Continue with the old wallet</string>
<string name="shielding_notice_сopy_phrase">Copy your seed phrase</string>
</resources>

0 comments on commit a3429d0

Please sign in to comment.