Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add jetpack compose #1280

Merged
merged 9 commits into from
Apr 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun MenuItem(
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
.background(Color.Gray, RoundedCornerShape(8.dp))
.background(Color.White, RoundedCornerShape(8.dp))
.clickable { action?.invoke() }
.padding(10.dp),
verticalAlignment = Alignment.CenterVertically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class RoomConverters {
fun dateToTimestamp(date: Date?): Long? {
return date?.time
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ class EncryptWalletLiveData(
@SuppressLint("StaticFieldLeak")
internal inner class EncryptWalletTask : AsyncTask<Any, Void, Resource<Wallet>>() {

@Deprecated("Deprecated in Java")
override fun onPreExecute() {
Comment on lines +77 to 78
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were added after running the 1.8 to 1.9 migration tool.

value = Resource.loading(null)
}

@Deprecated("Deprecated in Java")
override fun doInBackground(vararg args: Any): Resource<Wallet> {
val initialize = args[0] as Boolean
val wallet = walletApplication.wallet!!
Expand Down Expand Up @@ -111,6 +113,7 @@ class EncryptWalletLiveData(
}
}

@Deprecated("Deprecated in Java")
override fun onPostExecute(result: Resource<Wallet>) {
value = result
encryptWalletTask = null
Expand All @@ -120,10 +123,12 @@ class EncryptWalletLiveData(
@SuppressLint("StaticFieldLeak")
internal inner class DecryptWalletTask : AsyncTask<String, Void, Resource<Wallet>>() {

@Deprecated("Deprecated in Java")
override fun onPreExecute() {
value = Resource.loading(null)
}

@Deprecated("Deprecated in Java")
override fun doInBackground(vararg args: String): Resource<Wallet> {
val password = args[0]
val wallet = walletApplication.wallet!!
Expand All @@ -137,6 +142,7 @@ class EncryptWalletLiveData(
}
}

@Deprecated("Deprecated in Java")
override fun onPostExecute(result: Resource<Wallet>) {
value = result
decryptWalletTask = null
Expand Down
2 changes: 2 additions & 0 deletions wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.view.View
import android.view.ViewConfiguration
import android.view.animation.AnimationUtils
import android.view.inputmethod.InputMethodManager
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -476,6 +477,7 @@ open class LockScreenActivity : SecureActivity() {
}
}

@Deprecated("Deprecated in Java")
override fun onBackPressed() {
if (!lockScreenDisplayed) {
super.onBackPressed()
Expand Down
1 change: 1 addition & 0 deletions wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class OnboardingActivity : RestoreFromFileActivity() {
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class RestoreWalletFromSeedActivity : RestoreFromFileActivity() {
).show(this)
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == SET_PIN_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Expand Down
1 change: 1 addition & 0 deletions wallet/src/de/schildbach/wallet/ui/SetPinActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ class SetPinActivity : InteractionAwareActivity() {
return super.onOptionsItemSelected(item)
}

@Deprecated("Deprecated in Java")
override fun onBackPressed() {
when {
pin.size > 0 -> setState(state)
Expand Down
24 changes: 21 additions & 3 deletions wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package de.schildbach.wallet.ui

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import de.schildbach.wallet.Constants
Expand All @@ -27,6 +30,7 @@ import de.schildbach.wallet.data.PaymentIntent
import de.schildbach.wallet.integration.android.BitcoinIntegration
import de.schildbach.wallet.ui.buy_sell.IntegrationOverviewFragment
import de.schildbach.wallet.ui.main.WalletActivity
import de.schildbach.wallet.ui.send.SendCoinsActivity
import de.schildbach.wallet.ui.send.SendCoinsActivity.Companion.sendFromWalletUri
import de.schildbach.wallet.ui.util.InputParser.WalletUriParser
import de.schildbach.wallet.ui.util.WalletUri
Expand All @@ -49,11 +53,23 @@ class WalletUriHandlerActivity : AppCompatActivity() {
}

private var wallet: Wallet? = null
private lateinit var walletUriResultLauncher: ActivityResultLauncher<Intent>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
wallet = (application as WalletApplication).wallet
handleIntent(intent)
walletUriResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
var resultIntent: Intent? = null
if (result.resultCode == Activity.RESULT_OK) {
val data = result.data
val requestData = intent.data
val transactionHash = BitcoinIntegration.transactionHashFromResult(data)
resultIntent = WalletUri.createPaymentResult(requestData, transactionHash)
}
setResult(result.resultCode, resultIntent)
finish()
}
Comment on lines +61 to +71
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaces deprecated onActiivtyResult

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used internally, but when apps externally request data using dashwallet://...

}

override fun onNewIntent(intent: Intent) {
Expand Down Expand Up @@ -90,9 +106,10 @@ class WalletUriHandlerActivity : AppCompatActivity() {
} else {
object : WalletUriParser(intentUri) {
override fun handlePaymentIntent(paymentIntent: PaymentIntent, forceInstantSend: Boolean) {
sendFromWalletUri(
this@WalletUriHandlerActivity, REQUEST_CODE_SEND_FROM_WALLET_URI, paymentIntent
)
val intent = Intent(this@WalletUriHandlerActivity, SendCoinsActivity::class.java)
intent.action = SendCoinsActivity.ACTION_SEND_FROM_WALLET_URI
intent.putExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT, paymentIntent)
walletUriResultLauncher.launch(intent)
}

override fun handleMasterPublicKeyRequest(sender: String) {
Expand Down Expand Up @@ -140,6 +157,7 @@ class WalletUriHandlerActivity : AppCompatActivity() {
confirmationAlertDialogBuilder.buildAlertDialog().show()
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ open class RestoreFromFileActivity : SecureActivity(), AbstractPINDialogFragment
viewModel.restoreWallet(walletBuffer, password)
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == SET_PIN_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Expand Down
Loading