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

View File

@ -1,50 +1,53 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout 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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:layout_margin="8dp"
android:orientation="vertical">
<ProgressBar <LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/pbProgress" xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginBottom="4dp" android:layout_margin="8dp"
android:indeterminate="true" android:orientation="vertical">
android:visibility="gone" />
<FrameLayout <ProgressBar
android:layout_width="match_parent" android:id="@+id/pbProgress"
android:layout_height="wrap_content"> 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 <TextView
style="@style/MoneroLabel.Heading" android:id="@+id/tvAddress"
android:layout_width="wrap_content" style="@style/MoneroText.Medium"
android:layout_height="match_parent" android:layout_width="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_height="wrap_content"
android:layout_gravity="end" android:textAlignment="center"
android:layout_marginEnd="80dp" tools:text="9wZnnNctRc7RaLya1rxykH21dUwfQpNGmVLjAvkvqe7nKT2Mw848AJNGMunW5xjoSZ5vCCU3uDnUoVqSSHxzRtQBE3f6crx" />
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" />
<com.m2049r.xmrwallet.layout.ExchangeView <com.m2049r.xmrwallet.layout.ExchangeView
android:id="@+id/evAmount" android:id="@+id/evAmount"
@ -54,76 +57,85 @@
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:orientation="vertical" /> android:orientation="vertical" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" 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"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="10" android:orientation="horizontal"
app:counterEnabled="true" android:weightSum="10">
app:counterMaxLength="16"
app:errorEnabled="true">
<android.support.design.widget.TextInputEditText <android.support.design.widget.TextInputLayout
style="@style/MoneroEdit" android:id="@+id/etPaymentId"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/moneroGray" android:layout_weight="10"
android:hint="@string/receive_paymentid_hint" app:counterEnabled="true"
android:imeOptions="actionDone" app:counterMaxLength="16"
android:inputType="textMultiLine" app:errorEnabled="true">
android:textAlignment="textStart" />
</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.support.design.widget.TextInputLayout>
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" />
<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> </LinearLayout>
<FrameLayout <ImageView
android:id="@+id/qrCodeFull"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:adjustViewBounds="true"
<TextView android:background="#dd000000"
android:id="@+id/tvQrCode" android:visibility="gone" />
style="@style/MoneroFab" </FrameLayout>
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>