From 6e3e16e647c7c04eaa3849a7409a4d3f84362a5e Mon Sep 17 00:00:00 2001 From: mint-chime Date: Wed, 26 May 2021 02:38:09 -0500 Subject: [PATCH] Added QR scanner to wallet send card --- app/build.gradle | 7 ++- app/src/main/AndroidManifest.xml | 5 ++- .../browser/ui/wallet/WalletFragment.java | 27 ++++++++++-- .../res/drawable-anydpi/ic_qr_scanner.xml | 10 +++++ .../main/res/drawable-hdpi/ic_qr_scanner.png | Bin 0 -> 217 bytes .../main/res/drawable-mdpi/ic_qr_scanner.png | Bin 0 -> 145 bytes .../main/res/drawable-xhdpi/ic_qr_scanner.png | Bin 0 -> 159 bytes .../res/drawable-xxhdpi/ic_qr_scanner.png | Bin 0 -> 176 bytes .../res/layout/card_wallet_send_credits.xml | 41 ++++++++++++++---- 9 files changed, 75 insertions(+), 15 deletions(-) create mode 100755 app/src/main/res/drawable-anydpi/ic_qr_scanner.xml create mode 100755 app/src/main/res/drawable-hdpi/ic_qr_scanner.png create mode 100755 app/src/main/res/drawable-mdpi/ic_qr_scanner.png create mode 100755 app/src/main/res/drawable-xhdpi/ic_qr_scanner.png create mode 100755 app/src/main/res/drawable-xxhdpi/ic_qr_scanner.png diff --git a/app/build.gradle b/app/build.gradle index 0d9a362b..6870adc5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,7 +21,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - packagingOptions { + packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'lib/x86_64/darwin/libscrypt.dylib' } @@ -134,7 +134,10 @@ dependencies { __32bitImplementation 'io.lbry:lbrysdk32:0.94.1' __64bitImplementation 'io.lbry:lbrysdk64:0.94.1' + + implementation ('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false } + implementation 'com.google.zxing:core:3.3.0' } apply plugin: 'com.google.gms.google-services' -GoogleServicesPlugin.config.disableVersionCheck = true +GoogleServicesPlugin.config.disableVersionCheck = true \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d5aacbb8..da4b5252 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -13,6 +14,8 @@ + + - \ No newline at end of file + diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java index 089977ca..bcb07f14 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java @@ -3,6 +3,7 @@ package io.lbry.browser.ui.wallet; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Color; import android.net.Uri; @@ -60,6 +61,9 @@ import java.util.concurrent.Future; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import com.google.zxing.integration.android.IntentIntegrator; +import com.google.zxing.integration.android.IntentResult; + import io.lbry.browser.MainActivity; import io.lbry.browser.R; import io.lbry.browser.adapter.TransactionListAdapter; @@ -117,6 +121,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W private ImageButton buttonCopyReceiveAddress; private MaterialButton buttonGetNewAddress; private TextInputEditText inputSendAddress; + private ImageButton buttonQRScanAddress; private TextInputEditText inputSendAmount; private MaterialButton buttonSend; private TextView textConnectedEmail; @@ -162,6 +167,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W buttonCopyReceiveAddress = root.findViewById(R.id.wallet_copy_receive_address); buttonGetNewAddress = root.findViewById(R.id.wallet_get_new_address); inputSendAddress = root.findViewById(R.id.wallet_input_send_address); + buttonQRScanAddress = root.findViewById(R.id.wallet_qr_scan_address); inputSendAmount = root.findViewById(R.id.wallet_input_amount); buttonSend = root.findViewById(R.id.wallet_send); textConnectedEmail = root.findViewById(R.id.wallet_connected_email); @@ -368,6 +374,12 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W copyReceiveAddress(); } }); + buttonQRScanAddress.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + IntentIntegrator.forSupportFragment(WalletFragment.this).initiateScan(); + } + }); buttonSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -715,8 +727,8 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W } else { firstDatasetNotification = false; if (!detailRows.get(0).detailAmount.equals(earnedBalance.detailAmount) - || detailRows.get(0).isInProgress != earnedBalance.isInProgress - || detailRows.get(0).isUnlockable != earnedBalance.isUnlockable) { + || detailRows.get(0).isInProgress != earnedBalance.isInProgress + || detailRows.get(0).isUnlockable != earnedBalance.isUnlockable) { detailRows.set(0, earnedBalance); needNotifyAdapter = true; } @@ -800,4 +812,13 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W checkRewardsDriverCard(rewardsDriverText, 0); } } -} + + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == IntentIntegrator.REQUEST_CODE) { + IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); + String code = intentResult.getContents(); + inputSendAddress.setText(code); + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable-anydpi/ic_qr_scanner.xml b/app/src/main/res/drawable-anydpi/ic_qr_scanner.xml new file mode 100755 index 00000000..597e8d7b --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_qr_scanner.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_qr_scanner.png b/app/src/main/res/drawable-hdpi/ic_qr_scanner.png new file mode 100755 index 0000000000000000000000000000000000000000..fa734a63edf5adde98fea17ddd7c42d4782aa475 GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xb3?wz0qptudo&cW^S0Mc#1}qL(uK@B{N`m}? z8UF9DU-zbGEs$T~>Eakt!FY5EBijK39@qaN@24vB{Hxk@clq=imAkTfL;_}hdHC4z zl1DRd%A}@)j-Pr040KjD%Uy?Sf3iG65;yW1+JHB4rjx3xq*EA)3AHw!%QD$Huy z6{}JyMWO0{i?=*#I<+M$$}+b!%4hA1fO+|%^^A)u8DqKDMBdr)<}A<+44$rjF6*2U FngIIjS6Ki6 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_qr_scanner.png b/app/src/main/res/drawable-mdpi/ic_qr_scanner.png new file mode 100755 index 0000000000000000000000000000000000000000..e04904a7a01c4bfaaf5ceabf1bf5cf160b7ef416 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZA`BpB)|k7xlYrjj7PUE|`U7oIfF6*2UngGZ8Ed>Ao literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_qr_scanner.png b/app/src/main/res/drawable-xhdpi/ic_qr_scanner.png new file mode 100755 index 0000000000000000000000000000000000000000..495e3da3828955d36b13be52b2852f65fb311a5d GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^2_Vb}Bp6OT_L>T$m`Z~Df*BafCZDwc@*+H4978G? zk6vbEV^H8>y>OAyDk%KDhpa+ftrW+U`@ekT)<|yNz|iZ@CU-c@Z$divG!9eKYiz|g z%zrFkaye?hHkMUy@tH}DYxx=2%?bjxi9L8EcIcgn7Bj26pU36H+&@4zd%F6$taD0e F0swz@F~tA? literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_qr_scanner.png b/app/src/main/res/drawable-xxhdpi/ic_qr_scanner.png new file mode 100755 index 0000000000000000000000000000000000000000..b5e5d7fa900c4cba630a1b078a3ddd1ecdba8fbe GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^6F`^|NHCnYy)O!+m`Z~Df*BafCZDwc@-jVL978G? z-(F*6J7B=m`q13gp?{C;TK89+zs{#{I4s<>hTp$dVXe|HSFH$kz}e^&hJ+g>HM?2;m=M+ XbP0l+XkKUgtnb literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/card_wallet_send_credits.xml b/app/src/main/res/layout/card_wallet_send_credits.xml index 9cbd3f5d..82210fed 100644 --- a/app/src/main/res/layout/card_wallet_send_credits.xml +++ b/app/src/main/res/layout/card_wallet_send_credits.xml @@ -19,18 +19,41 @@ android:text="@string/send_credits" android:textSize="20sp"/> - - + + - + android:layout_weight="1" + android:hint="@string/recipient_address" + android:layout_toStartOf="@id/wallet_qr_scan_address"> + + + + + + +