@@ -10,6 +10,7 @@ import android.os.Build
1010import android.util.Log
1111import androidx.annotation.ColorInt
1212import androidx.core.app.NotificationCompat
13+ import androidx.core.content.ContextCompat
1314import com.walletconnect.android.Core
1415import com.walletconnect.web3.modal.client.Modal
1516import com.walletconnect.web3.modal.client.Web3Modal
@@ -61,7 +62,7 @@ object DoraFund {
6162 * Platform ERC20 wallet address.
6263 * @since 2.0
6364 */
64- private const val ERC20_ADDRESS = " 0xcBa852Ef29a43a7542B88F60C999eD9cB66f6000"
65+ const val ERC20_ADDRESS = " 0xcBa852Ef29a43a7542B88F60C999eD9cB66f6000"
6566
6667 /* *
6768 * Success.
@@ -431,7 +432,7 @@ object DoraFund {
431432 val (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) = nativeGetGasParametersEIP1559(context, TRANSFER_TYPE_NATIVE )
432433 val chain = getCurrentChain()
433434 if (chain == null ) {
434- ToastUtils .showShort(context.getString( R .string.please_connect_wallet_first) )
435+ ToastUtils .showShort(R .string.please_connect_wallet_first)
435436 return
436437 }
437438 // supports EIP-1559
@@ -553,7 +554,7 @@ object DoraFund {
553554 val (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) = nativeGetGasParametersEIP1559(context, TRANSFER_TYPE_NATIVE )
554555 val chain = getCurrentChain()
555556 if (chain == null ) {
556- ToastUtils .showShort(context.getString( R .string.please_connect_wallet_first) )
557+ ToastUtils .showShort(R .string.please_connect_wallet_first)
557558 return
558559 }
559560 // supports EIP-1559
@@ -631,10 +632,10 @@ object DoraFund {
631632 orderListener : OrderListener
632633 ) {
633634 if (payListener == null ) throw PaymentException (" No PayListener is set." )
634- DoraAlertDialog (context).show(" $goodsDesc \n\n ${context .getString(R .string.dorafund_provides_technical_support)} " ) {
635+ DoraAlertDialog (context).show(" $goodsDesc \n\n ${ContextCompat .getString(context, R .string.dorafund_provides_technical_support)} " ) {
635636 title(orderTitle)
636637 themeColor(themeColor)
637- positiveButton(context .getString(R .string.pay))
638+ positiveButton(ContextCompat .getString(context, R .string.pay))
638639 positiveListener {
639640 Web3Modal .getAccount()?.let { session ->
640641 sendTransactionRequest(context, accessKey, secretKey, session.address, account,
@@ -676,10 +677,11 @@ object DoraFund {
676677 orderListener : OrderListener
677678 ) {
678679 if (payListener == null ) throw PaymentException (" No PayListener is set." )
679- DoraAlertDialog (context).show(" $goodsDesc \n\n ${context.getString(R .string.dorafund_provides_technical_support)} " ) {
680+ DoraAlertDialog (context).show(" $goodsDesc \n\n ${ContextCompat .getString(context,
681+ R .string.dorafund_provides_technical_support)} " ) {
680682 title(orderTitle)
681683 themeColor(themeColor)
682- positiveButton(context .getString(R .string.pay))
684+ positiveButton(ContextCompat .getString(context, R .string.pay))
683685 positiveListener {
684686 Web3Modal .getAccount()?.let { session ->
685687 sendNativeTransactionRequest(context, accessKey, secretKey, session.address, account,
@@ -721,10 +723,11 @@ object DoraFund {
721723 orderListener : OrderListener
722724 ) {
723725 if (payListener == null ) throw PaymentException (" No PayListener is set." )
724- DoraAlertDialog (context).show(" $goodsDesc \n\n ${context.getString(R .string.dorafund_provides_technical_support)} " ) {
726+ DoraAlertDialog (context).show(" $goodsDesc \n\n ${ContextCompat .getString(context,
727+ R .string.dorafund_provides_technical_support)} " ) {
725728 title(orderTitle)
726729 themeColor(themeColor)
727- positiveButton(context .getString(R .string.pay))
730+ positiveButton(ContextCompat .getString(context, R .string.pay))
728731 positiveListener {
729732 Web3Modal .getAccount()?.let { session ->
730733 sendNativeTransactionRequest(context, accessKey, secretKey, session.address, account,
@@ -766,11 +769,11 @@ object DoraFund {
766769 val (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) = nativeGetGasParametersEIP1559(context, TRANSFER_TYPE_ERC20 )
767770 val chain = getCurrentChain()
768771 if (chain == null ) {
769- ToastUtils .showShort(context.getString( R .string.please_connect_wallet_first) )
772+ ToastUtils .showShort(R .string.please_connect_wallet_first)
770773 return
771774 }
772775 if (chain.id != token.chain.id) {
773- ToastUtils .showShort(context.getString( R .string.please_switch_correct_chain_to_pay_with_tokens) )
776+ ToastUtils .showShort(R .string.please_switch_correct_chain_to_pay_with_tokens)
774777 return
775778 }
776779 val isEIP1559Chain = when (token.chain) {
@@ -782,11 +785,11 @@ object DoraFund {
782785 }
783786 if (payListener == null ) throw PaymentException (" No PayListener is set." )
784787 DoraAlertDialog (context).show(
785- " $goodsDesc \n\n ${context .getString(R .string.dorafund_provides_technical_support)} "
788+ " $goodsDesc \n\n ${ContextCompat .getString(context, R .string.dorafund_provides_technical_support)} "
786789 ) {
787790 title(orderTitle)
788791 themeColor(themeColor)
789- positiveButton(context .getString(R .string.pay))
792+ positiveButton(ContextCompat .getString(context, R .string.pay))
790793 positiveListener {
791794 Web3Modal .getAccount()?.let { session ->
792795 val status = if (isEIP1559Chain) {
@@ -1012,45 +1015,45 @@ object DoraFund {
10121015 val notificationManager =
10131016 context.getSystemService(Context .NOTIFICATION_SERVICE ) as NotificationManager
10141017 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
1015- var name = context .getString(R .string.channel_name_background)
1018+ var name = ContextCompat .getString(context, R .string.channel_name_background)
10161019 var channel = NotificationChannel (
10171020 OpenVPNService .NOTIFICATION_CHANNEL_BG_ID ,
10181021 name,
10191022 NotificationManager .IMPORTANCE_MIN
10201023 ).apply {
1021- description = context .getString(R .string.channel_description_background)
1024+ description = ContextCompat .getString(context, R .string.channel_description_background)
10221025 enableLights(false )
10231026 lightColor = Color .DKGRAY
10241027 }
10251028 notificationManager.createNotificationChannel(channel)
10261029
1027- name = context .getString(R .string.channel_name_status)
1030+ name = ContextCompat .getString(context, R .string.channel_name_status)
10281031 channel = NotificationChannel (
10291032 OpenVPNService .NOTIFICATION_CHANNEL_NEWSTATUS_ID ,
10301033 name,
10311034 NotificationManager .IMPORTANCE_LOW
10321035 ).apply {
1033- description = context .getString(R .string.channel_description_status)
1036+ description = ContextCompat .getString(context, R .string.channel_description_status)
10341037 enableLights(true )
10351038 lightColor = Color .BLUE
10361039 }
10371040 notificationManager.createNotificationChannel(channel)
10381041
1039- name = context .getString(R .string.channel_name_userreq)
1042+ name = ContextCompat .getString(context, R .string.channel_name_userreq)
10401043 channel = NotificationChannel (
10411044 OpenVPNService .NOTIFICATION_CHANNEL_USERREQ_ID ,
10421045 name,
10431046 NotificationManager .IMPORTANCE_HIGH
10441047 ).apply {
1045- description = context .getString(R .string.channel_description_userreq)
1048+ description = ContextCompat .getString(context, R .string.channel_description_userreq)
10461049 enableVibration(true )
10471050 lightColor = Color .CYAN
10481051 }
10491052 notificationManager.createNotificationChannel(channel)
10501053 } else {
10511054 val notification = NotificationCompat .Builder (context)
1052- .setContentTitle(context .getString(R .string.channel_name_status))
1053- .setContentText(context .getString(R .string.channel_description_status))
1055+ .setContentTitle(ContextCompat .getString(context, R .string.channel_name_status))
1056+ .setContentText(ContextCompat .getString(context, R .string.channel_description_status))
10541057 .setSmallIcon(android.R .drawable.stat_sys_warning)
10551058 .setPriority(NotificationCompat .PRIORITY_LOW )
10561059 .build()
0 commit comments