From 696bc86b7c5f914354f8a5470da9c10a43da5021 Mon Sep 17 00:00:00 2001 From: soup-jingle <65276846+soup-jingle@users.noreply.github.com> Date: Fri, 13 Aug 2021 03:01:53 -0500 Subject: [PATCH] Added QR scanner to wallet send card (#1194) * Added QR scanner to wallet send card * * app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java: Changed orientation of QR scanner, along with some style corrections * Revert "* app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java:" This reverts commit 519c45ae0dfaee556de909bf65cea8c3b38c34ab. * Fixed orientation of QR scanner activity, plus style corrections --- app/build.gradle | 5 ++- app/src/main/AndroidManifest.xml | 8 ++++ .../browser/ui/wallet/WalletFragment.java | 21 +++++++++ .../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(+), 10 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 d07fa8c2..5da4b62d 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' } @@ -122,6 +122,9 @@ dependencies { implementation 'org.bitcoinj:bitcoinj-tools:0.14.7' implementation 'org.java-websocket:Java-WebSocket:1.5.1' + implementation ('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false } + implementation 'com.google.zxing:core:3.3.0' + compileOnly 'org.projectlombok:lombok:1.18.10' annotationProcessor 'org.projectlombok:lombok:1.18.10' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d5aacbb8..3f958fdd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -13,6 +14,8 @@ + + + + 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..af8cf93e 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,13 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W copyReceiveAddress(); } }); + buttonQRScanAddress.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + IntentIntegrator intentIntegrator = IntentIntegrator.forSupportFragment(WalletFragment.this); + intentIntegrator.setOrientationLocked(false).initiateScan(); + } + }); buttonSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -800,4 +813,12 @@ 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); + } + } } 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"> + + + + + + +