Skip to content

Commit 13974bc

Browse files
committed
253 crypto warning
1 parent a132a2a commit 13974bc

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

app/src/main/java/uk/co/sentinelweb/cuer/app/ui/common/dialog/AlertDialogCreator.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,36 @@ package uk.co.sentinelweb.cuer.app.ui.common.dialog
22

33
import android.content.Context
44
import android.content.DialogInterface
5+
import android.widget.TextView
56
import androidx.appcompat.app.AlertDialog
7+
import androidx.core.view.setPadding
68
import com.google.android.material.dialog.MaterialAlertDialogBuilder
9+
import uk.co.sentinelweb.cuer.app.R
710

811
class AlertDialogCreator(
912
private val context: Context
1013
) {
1114

1215
fun create(model: AlertDialogModel): AlertDialog {
13-
1416
val builder = MaterialAlertDialogBuilder(context)
1517
.setTitle(model.title)
16-
.setMessage(model.message)
1718
.setPositiveButton(model.confirm.label, object : DialogInterface.OnClickListener {
1819
override fun onClick(dialog: DialogInterface?, p1: Int) {
1920
model.confirm.action()
2021
dialog?.dismiss()
2122
}
2223
})
24+
val msg = context.getString(model.message)
25+
if (msg.indexOf("\n")>-1) {
26+
TextView(context,null, 0, R.style.TextAppearance_App_Body1)
27+
.apply {
28+
text = msg
29+
setPadding(context.resources.getDimensionPixelSize(R.dimen.page_margin))
30+
}
31+
.apply { builder.setView(this) }
32+
} else {
33+
builder.setMessage(model.message)
34+
}
2335
model.neutral?.apply {
2436
builder
2537
.setNeutralButton(label, object : DialogInterface.OnClickListener {

app/src/main/java/uk/co/sentinelweb/cuer/app/ui/common/dialog/support/SupportComposables.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object SupportComposables : KoinComponent {
7575
contentDescription = null,
7676
tint = MaterialTheme.colors.onPrimary,
7777
modifier = Modifier
78-
.padding(start = 8.dp, top = 16.dp)
78+
.padding(start = 8.dp)
7979
.size(24.dp)
8080
.align(CenterVertically)
8181
)

app/src/main/java/uk/co/sentinelweb/cuer/app/ui/common/dialog/support/SupportDialogFragment.kt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import org.koin.android.scope.AndroidScopeComponent
1717
import org.koin.core.qualifier.named
1818
import org.koin.core.scope.Scope
1919
import org.koin.dsl.module
20+
import uk.co.sentinelweb.cuer.app.R
2021
import uk.co.sentinelweb.cuer.app.databinding.FragmentComposeBinding
22+
import uk.co.sentinelweb.cuer.app.ui.common.dialog.AlertDialogCreator
23+
import uk.co.sentinelweb.cuer.app.ui.common.dialog.AlertDialogModel
2124
import uk.co.sentinelweb.cuer.app.ui.common.dialog.appselect.AppSelectorBottomSheet
2225
import uk.co.sentinelweb.cuer.app.ui.common.navigation.NavigationModel.Param.MEDIA
2326
import uk.co.sentinelweb.cuer.app.ui.common.navigation.navigationRouter
@@ -48,6 +51,7 @@ class SupportDialogFragment : DialogFragment(), AndroidScopeComponent {
4851
private val cryptoLauncher: CryptoLauncher by inject()
4952
private val ytLauncher: YoutubeJavaApiWrapper by inject()
5053
private val toast: ToastWrapper by inject()
54+
private val alertDialogCreator: AlertDialogCreator by inject()
5155

5256
private var _binding: FragmentComposeBinding? = null
5357
private val binding get() = _binding!!
@@ -108,16 +112,31 @@ class SupportDialogFragment : DialogFragment(), AndroidScopeComponent {
108112
}
109113
is Crypto -> cryptoLauncher.launch(label.link)
110114
.also {
111-
AppSelectorBottomSheet.show(
112-
requireActivity(),
113-
cryptoLauncher.cryptoAppWhiteList
114-
)
115+
alertDialogCreator.create(
116+
AlertDialogModel(
117+
R.string.support_crypto_warning_title,
118+
R.string.support_crypto_warning_message,
119+
AlertDialogModel.Button(
120+
R.string.support_crypto_warning_ok,
121+
{ showCryptoAppLauncher() }
122+
),
123+
// AlertDialogModel.Button(
124+
// R.string.support_crypto_warning_dont_show,
125+
// { showCryptoAppLauncher() }
126+
// ),
127+
AlertDialogModel.Button(R.string.cancel, {})
128+
)
129+
).show()
115130
}
116131
}
117132
}
118133
})
119134
}
120135

136+
private fun showCryptoAppLauncher() {
137+
AppSelectorBottomSheet.show(requireActivity(), cryptoLauncher.cryptoAppWhiteList)
138+
}
139+
121140
class SupportStrings(private val res: ResourceWrapper) : SupportContract.Strings
122141

123142
companion object {
@@ -156,6 +175,7 @@ class SupportDialogFragment : DialogFragment(), AndroidScopeComponent {
156175
scoped<CryptoLauncher> {
157176
AndroidCryptoLauncher(this.getFragmentActivity(), get(), get())
158177
}
178+
scoped { AlertDialogCreator(this.getFragmentActivity()) }
159179
scoped { navigationRouter(true, this.getFragmentActivity()) }
160180
}
161181
}

app/src/main/java/uk/co/sentinelweb/cuer/app/util/wrapper/AndroidCryptoLauncher.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class AndroidCryptoLauncher(
2222
activity.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
2323
val clipData = ClipData.newPlainText(link.type.toString(), link.address)
2424
clipboardManager.setPrimaryClip(clipData)
25-
// todo show warning dialog
2625
toast.show("${link.type.name} address copied")
2726
}
2827

app/src/main/res/values/strings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,15 @@
198198
<string name="menu_sort_category">Categories</string>
199199
<string name="support_no_links">No links in the description</string>
200200
<string name="support_links_loading">Loading …</string>
201+
<string name="support_crypto_warning_title">About crypto</string>
202+
<string name="support_crypto_warning_message">TRANSACTIONS ARE NON REVERSIBLE
203+
\n\n・ These addresses are just scanned from the description and NOT VALIDATED.
204+
\n・ETH style addresses (starting 0x) can represent lots of different tokens.
205+
\n・Please check the address with the channel first.
206+
\n・Consider making a small payment first to check it goes through properly.
207+
\n\nSelected address was copied to the clipboard, the following apps are the whitelisted apps but you can use any on your device.
208+
</string>
209+
<string name="support_crypto_warning_ok">OK</string>
210+
<string name="support_crypto_warning_dont_show">I know don\'t show this</string>
201211

202212
</resources>

0 commit comments

Comments
 (0)