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 00000000..fa734a63 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_qr_scanner.png differ 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 00000000..e04904a7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_qr_scanner.png differ 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 00000000..495e3da3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_qr_scanner.png differ 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 00000000..b5e5d7fa Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_qr_scanner.png differ 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"> + + + + + + +