zoom into qr code on touch (#140)

This commit is contained in:
m2049r 2017-11-19 20:25:02 +01:00 committed by GitHub
parent 7c36ccfd9c
commit c35deab283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 137 additions and 107 deletions

View File

@ -19,6 +19,7 @@ package com.m2049r.xmrwallet;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
@ -65,7 +66,8 @@ public class ReceiveFragment extends Fragment {
private ExchangeView evAmount;
private Button bPaymentId;
private TextView tvQrCode;
private ImageButton qrCode;
private ImageView qrCode;
private ImageView qrCodeFull;
private EditText etDummy;
private ImageButton bCopyAddress;
@ -90,8 +92,9 @@ public class ReceiveFragment extends Fragment {
etPaymentId = (TextInputLayout) view.findViewById(R.id.etPaymentId);
evAmount = (ExchangeView) view.findViewById(R.id.evAmount);
bPaymentId = (Button) view.findViewById(R.id.bPaymentId);
qrCode = (ImageButton) view.findViewById(R.id.qrCode);
qrCode = (ImageView) view.findViewById(R.id.qrCode);
tvQrCode = (TextView) view.findViewById(R.id.tvQrCode);
qrCodeFull = (ImageView) view.findViewById(R.id.qrCodeFull);
etDummy = (EditText) view.findViewById(R.id.etDummy);
bCopyAddress = (ImageButton) view.findViewById(R.id.bCopyAddress);
@ -163,12 +166,23 @@ public class ReceiveFragment extends Fragment {
qrCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (checkPaymentId()) {
if (qrValid) {
qrCodeFull.setImageBitmap(((BitmapDrawable) qrCode.getDrawable()).getBitmap());
qrCodeFull.setVisibility(View.VISIBLE);
} else if (checkPaymentId()) {
evAmount.doExchange();
}
}
});
qrCodeFull.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
qrCodeFull.setImageBitmap(null);
qrCodeFull.setVisibility(View.GONE);
}
});
showProgress();
clearQR();
@ -197,6 +211,7 @@ public class ReceiveFragment extends Fragment {
if (qrValid) {
qrCode.setImageBitmap(null);
qrValid = false;
if (isLoaded)
tvQrCode.setVisibility(View.VISIBLE);
}
}
@ -218,8 +233,11 @@ public class ReceiveFragment extends Fragment {
generateQr();
}
private boolean isLoaded = false;
private void show(String name, String address) {
Log.d(TAG, "name=" + name);
isLoaded = true;
listenerCallback.setTitle(name);
tvAddress.setText(address);
etPaymentId.setEnabled(true);

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -110,9 +113,10 @@
android:drawableStart="@drawable/ic_info_outline_gray_24dp"
android:text="@string/label_receive_gen_qr_code"
android:textAlignment="center"
android:textSize="16sp" />
android:textSize="16sp"
android:visibility="invisible"/>
<ImageButton
<ImageView
android:id="@+id/qrCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -125,5 +129,13 @@
android:id="@+id/etDummy"
android:layout_width="0dp"
android:layout_height="0dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/qrCodeFull"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="#dd000000"
android:visibility="gone" />
</FrameLayout>