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,7 +211,8 @@ public class ReceiveFragment extends Fragment {
if (qrValid) {
qrCode.setImageBitmap(null);
qrValid = false;
tvQrCode.setVisibility(View.VISIBLE);
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,50 +1,53 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:orientation="vertical">
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/pbProgress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
<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="wrap_content"
android:layout_marginBottom="4dp"
android:indeterminate="true"
android:visibility="gone" />
android:layout_height="match_parent"
android:layout_margin="8dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/pbProgress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:indeterminate="true"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
style="@style/MoneroLabel.Heading"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@string/generate_address_label" />
<ImageButton
android:id="@+id/bCopyAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="80dp"
android:background="?android:selectableItemBackground"
android:enabled="false"
android:src="@drawable/ic_content_nocopy_black_24dp" />
</FrameLayout>
<TextView
style="@style/MoneroLabel.Heading"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@string/generate_address_label" />
<ImageButton
android:id="@+id/bCopyAddress"
android:layout_width="wrap_content"
android:id="@+id/tvAddress"
style="@style/MoneroText.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="80dp"
android:background="?android:selectableItemBackground"
android:enabled="false"
android:src="@drawable/ic_content_nocopy_black_24dp" />
</FrameLayout>
<TextView
android:id="@+id/tvAddress"
style="@style/MoneroText.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
tools:text="9wZnnNctRc7RaLya1rxykH21dUwfQpNGmVLjAvkvqe7nKT2Mw848AJNGMunW5xjoSZ5vCCU3uDnUoVqSSHxzRtQBE3f6crx" />
android:textAlignment="center"
tools:text="9wZnnNctRc7RaLya1rxykH21dUwfQpNGmVLjAvkvqe7nKT2Mw848AJNGMunW5xjoSZ5vCCU3uDnUoVqSSHxzRtQBE3f6crx" />
<com.m2049r.xmrwallet.layout.ExchangeView
android:id="@+id/evAmount"
@ -54,76 +57,85 @@
android:layout_marginTop="16dp"
android:orientation="vertical" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10">
<android.support.design.widget.TextInputLayout
android:id="@+id/etPaymentId"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
app:counterEnabled="true"
app:counterMaxLength="16"
app:errorEnabled="true">
android:orientation="horizontal"
android:weightSum="10">
<android.support.design.widget.TextInputEditText
style="@style/MoneroEdit"
android:layout_width="match_parent"
<android.support.design.widget.TextInputLayout
android:id="@+id/etPaymentId"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:backgroundTint="@color/moneroGray"
android:hint="@string/receive_paymentid_hint"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:textAlignment="textStart" />
android:layout_weight="10"
app:counterEnabled="true"
app:counterMaxLength="16"
app:errorEnabled="true">
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputEditText
style="@style/MoneroEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/moneroGray"
android:hint="@string/receive_paymentid_hint"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:textAlignment="textStart" />
<Button
android:id="@+id/bPaymentId"
style="@style/MoneroText.Button.Small"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:background="?android:selectableItemBackground"
android:drawableTop="@drawable/ic_settings_orange_24dp"
android:text="@string/send_generate_paymentid_hint"
android:textColor="@color/moneroGray"
android:visibility="visible" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/bPaymentId"
style="@style/MoneroText.Button.Small"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:background="?android:selectableItemBackground"
android:drawableTop="@drawable/ic_settings_orange_24dp"
android:text="@string/send_generate_paymentid_hint"
android:textColor="@color/moneroGray"
android:visibility="visible" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvQrCode"
style="@style/MoneroFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_info_outline_gray_24dp"
android:text="@string/label_receive_gen_qr_code"
android:textAlignment="center"
android:textSize="16sp"
android:visibility="invisible"/>
<ImageView
android:id="@+id/qrCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="#00000000" />
</FrameLayout>
<EditText
android:id="@+id/etDummy"
android:layout_width="0dp"
android:layout_height="0dp" />
</LinearLayout>
<FrameLayout
<ImageView
android:id="@+id/qrCodeFull"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvQrCode"
style="@style/MoneroFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_info_outline_gray_24dp"
android:text="@string/label_receive_gen_qr_code"
android:textAlignment="center"
android:textSize="16sp" />
<ImageButton
android:id="@+id/qrCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="#00000000" />
</FrameLayout>
<EditText
android:id="@+id/etDummy"
android:layout_width="0dp"
android:layout_height="0dp" />
</LinearLayout>
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="#dd000000"
android:visibility="gone" />
</FrameLayout>