new subaddress bump effect (#327)

This commit is contained in:
m2049r 2018-06-20 18:33:28 +02:00 committed by GitHub
parent 7aad941dab
commit 520d151f3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 12 deletions

View File

@ -62,6 +62,7 @@ import timber.log.Timber;
public class ReceiveFragment extends Fragment { public class ReceiveFragment extends Fragment {
private ProgressBar pbProgress; private ProgressBar pbProgress;
private View llAddress;
private TextView tvAddressLabel; private TextView tvAddressLabel;
private TextView tvAddress; private TextView tvAddress;
private TextInputLayout etPaymentId; private TextInputLayout etPaymentId;
@ -92,6 +93,7 @@ public class ReceiveFragment extends Fragment {
View view = inflater.inflate(R.layout.fragment_receive, container, false); View view = inflater.inflate(R.layout.fragment_receive, container, false);
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress); pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
llAddress = view.findViewById(R.id.llAddress);
tvAddressLabel = (TextView) view.findViewById(R.id.tvAddressLabel); tvAddressLabel = (TextView) view.findViewById(R.id.tvAddressLabel);
tvAddress = (TextView) view.findViewById(R.id.tvAddress); tvAddress = (TextView) view.findViewById(R.id.tvAddress);
etPaymentId = (TextInputLayout) view.findViewById(R.id.etPaymentId); etPaymentId = (TextInputLayout) view.findViewById(R.id.etPaymentId);
@ -113,7 +115,7 @@ public class ReceiveFragment extends Fragment {
copyAddress(); copyAddress();
} }
}); });
bCopyAddress.setClickable(false); enableCopyAddress(false);
evAmount.setOnNewAmountListener(new ExchangeView.OnNewAmountListener() { evAmount.setOnNewAmountListener(new ExchangeView.OnNewAmountListener() {
@Override @Override
@ -173,11 +175,30 @@ public class ReceiveFragment extends Fragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
enableSubaddressButton(false); enableSubaddressButton(false);
tvAddress.setText(wallet.getNewSubaddress()); enableCopyAddress(false);
tvAddressLabel.setText(getString(R.string.generate_address_label_sub,
wallet.getNumSubaddresses() - 1)); final Runnable resetSize = new Runnable() {
storeWallet(); public void run() {
generateQr(); tvAddress.animate().setDuration(125).scaleX(1).scaleY(1).start();
}
};
final Runnable newAddress = new Runnable() {
public void run() {
tvAddressLabel.setText(getString(R.string.generate_address_label_sub,
wallet.getNumSubaddresses() - 1));
tvAddress.setText(wallet.getNewSubaddress());
storeWallet();
generateQr();
enableCopyAddress(true);
tvAddress.animate().alpha(1).setDuration(125)
.scaleX(1.2f).scaleY(1.2f)
.withEndAction(resetSize).start();
}
};
tvAddress.animate().alpha(0).setDuration(250)
.withEndAction(newAddress).start();
} }
}); });
@ -226,9 +247,9 @@ public class ReceiveFragment extends Fragment {
void enableSubaddressButton(boolean enable) { void enableSubaddressButton(boolean enable) {
bSubaddress.setEnabled(enable); bSubaddress.setEnabled(enable);
if (enable) { if (enable) {
bSubaddress.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_settings_orange_24dp,0,0); bSubaddress.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_settings_orange_24dp, 0, 0);
} else { } else {
bSubaddress.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_settings_gray_24dp,0,0); bSubaddress.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_settings_gray_24dp, 0, 0);
} }
} }
@ -261,8 +282,13 @@ public class ReceiveFragment extends Fragment {
super.onResume(); super.onResume();
Timber.d("onResume()"); Timber.d("onResume()");
listenerCallback.setToolbarButton(Toolbar.BUTTON_BACK); listenerCallback.setToolbarButton(Toolbar.BUTTON_BACK);
listenerCallback.setSubtitle(wallet.getAccountLabel()); if (wallet != null) {
generateQr(); listenerCallback.setSubtitle(wallet.getAccountLabel());
generateQr();
} else {
listenerCallback.setSubtitle(getString(R.string.status_wallet_loading));
clearQR();
}
} }
private boolean isLoaded = false; private boolean isLoaded = false;
@ -271,15 +297,23 @@ public class ReceiveFragment extends Fragment {
Timber.d("name=%s", wallet.getName()); Timber.d("name=%s", wallet.getName());
isLoaded = true; isLoaded = true;
listenerCallback.setTitle(wallet.getName()); listenerCallback.setTitle(wallet.getName());
listenerCallback.setSubtitle(wallet.getAccountLabel());
tvAddress.setText(wallet.getAddress()); tvAddress.setText(wallet.getAddress());
etPaymentId.setEnabled(true); etPaymentId.setEnabled(true);
bPaymentId.setEnabled(true); bPaymentId.setEnabled(true);
bCopyAddress.setClickable(true); enableCopyAddress(true);
bCopyAddress.setImageResource(R.drawable.ic_content_copy_black_24dp);
hideProgress(); hideProgress();
generateQr(); generateQr();
} }
private void enableCopyAddress(boolean enable) {
bCopyAddress.setClickable(enable);
if (enable)
bCopyAddress.setImageResource(R.drawable.ic_content_copy_black_24dp);
else
bCopyAddress.setImageResource(R.drawable.ic_content_nocopy_black_24dp);
}
private void loadAndShow(String walletPath, String password) { private void loadAndShow(String walletPath, String password) {
new AsyncShow().executeOnExecutor(MoneroThreadPoolExecutor.MONERO_THREAD_POOL_EXECUTOR, new AsyncShow().executeOnExecutor(MoneroThreadPoolExecutor.MONERO_THREAD_POOL_EXECUTOR,
walletPath, password); walletPath, password);

View File

@ -25,6 +25,7 @@
android:visibility="gone" /> android:visibility="gone" />
<LinearLayout <LinearLayout
android:id="@+id/llAddress"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"> android:gravity="center">