show new incoming tx in subaddress details (#734)
This commit is contained in:
parent
cf4ff856d5
commit
24fc27b09e
|
@ -7,8 +7,8 @@ android {
|
|||
applicationId "com.m2049r.xmrwallet"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 800
|
||||
versionName "1.18.0 'ChAdOx1'"
|
||||
versionCode 801
|
||||
versionName "1.18.1 'ChAdOx1'"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2021 m2049r
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.m2049r.xmrwallet;
|
||||
|
||||
import com.m2049r.xmrwallet.model.Wallet;
|
||||
|
||||
public interface OnBlockUpdateListener {
|
||||
void onBlockUpdate(final Wallet wallet);
|
||||
}
|
|
@ -45,8 +45,8 @@ import java.util.List;
|
|||
|
||||
import timber.log.Timber;
|
||||
|
||||
// TODO: live update - i.e. use onRefreshed() somehow
|
||||
public class SubaddressInfoFragment extends Fragment implements TransactionInfoAdapter.OnInteractionListener {
|
||||
public class SubaddressInfoFragment extends Fragment
|
||||
implements TransactionInfoAdapter.OnInteractionListener, OnBlockUpdateListener {
|
||||
private TransactionInfoAdapter adapter;
|
||||
|
||||
private Subaddress subaddress;
|
||||
|
@ -123,6 +123,11 @@ public class SubaddressInfoFragment extends Fragment implements TransactionInfoA
|
|||
tvTxLabel.setText(R.string.subaddress_tx_label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockUpdate(Wallet wallet) {
|
||||
onRefreshed(wallet);
|
||||
}
|
||||
|
||||
// Callbacks from TransactionInfoAdapter
|
||||
@Override
|
||||
public void onInteraction(final View view, final TransactionInfo infoItem) {
|
||||
|
|
|
@ -141,6 +141,14 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
return synced;
|
||||
}
|
||||
|
||||
private WalletFragment getWalletFragment() {
|
||||
return (WalletFragment) getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||
}
|
||||
|
||||
private Fragment getCurrentFragment() {
|
||||
return getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStreetMode() {
|
||||
return streetMode > 0;
|
||||
|
@ -152,8 +160,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
} else {
|
||||
streetMode = 0;
|
||||
}
|
||||
final WalletFragment walletFragment = (WalletFragment)
|
||||
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||
final WalletFragment walletFragment = getWalletFragment();
|
||||
if (walletFragment != null) walletFragment.resetDismissedTransactions();
|
||||
forceUpdate();
|
||||
runOnUiThread(() -> {
|
||||
|
@ -220,8 +227,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
|
||||
private void onWalletRescan() {
|
||||
try {
|
||||
final WalletFragment walletFragment = (WalletFragment)
|
||||
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||
final WalletFragment walletFragment = getWalletFragment();
|
||||
getWallet().rescanBlockchainAsync();
|
||||
synced = false;
|
||||
walletFragment.unsync();
|
||||
|
@ -336,8 +342,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
|
||||
public void onWalletChangePassword() {
|
||||
try {
|
||||
GenerateReviewFragment detailsFragment = (GenerateReviewFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
GenerateReviewFragment detailsFragment = (GenerateReviewFragment) getCurrentFragment();
|
||||
AlertDialog dialog = detailsFragment.createChangePasswordDialog();
|
||||
if (dialog != null) {
|
||||
Helper.showKeyboard(dialog);
|
||||
|
@ -571,8 +576,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
runOnUiThread(this::updateAccountsList);
|
||||
}
|
||||
try {
|
||||
final WalletFragment walletFragment = (WalletFragment)
|
||||
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||
final WalletFragment walletFragment = getWalletFragment();
|
||||
if (wallet.isSynchronized()) {
|
||||
Timber.d("onRefreshed() synced");
|
||||
releaseWakeLock(RELEASE_WAKE_LOCK_DELAY); // the idea is to stay awake until synced
|
||||
|
@ -583,7 +587,10 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
runOnUiThread(walletFragment::onSynced);
|
||||
}
|
||||
}
|
||||
runOnUiThread(() -> walletFragment.onRefreshed(wallet, full));
|
||||
runOnUiThread(() -> {
|
||||
walletFragment.onRefreshed(wallet, full);
|
||||
updateCurrentFragment(wallet);
|
||||
});
|
||||
return true;
|
||||
} catch (ClassCastException ex) {
|
||||
// not in wallet fragment (probably send monero)
|
||||
|
@ -593,6 +600,13 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
return false;
|
||||
}
|
||||
|
||||
private void updateCurrentFragment(final Wallet wallet) {
|
||||
final Fragment fragment = getCurrentFragment();
|
||||
if (fragment instanceof OnBlockUpdateListener) {
|
||||
((OnBlockUpdateListener) fragment).onBlockUpdate(wallet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletStored(final boolean success) {
|
||||
runOnUiThread(() -> {
|
||||
|
@ -635,8 +649,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
|
||||
if (requestStreetMode) onEnableStreetMode();
|
||||
|
||||
final WalletFragment walletFragment = (WalletFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
final WalletFragment walletFragment = getWalletFragment();
|
||||
runOnUiThread(() -> {
|
||||
updateAccountsHeader();
|
||||
if (walletFragment != null) {
|
||||
|
@ -649,8 +662,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
@Override
|
||||
public void onTransactionCreated(final String txTag, final PendingTransaction pendingTransaction) {
|
||||
try {
|
||||
final SendFragment sendFragment = (SendFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
final SendFragment sendFragment = (SendFragment) getCurrentFragment();
|
||||
runOnUiThread(() -> {
|
||||
dismissProgressDialog();
|
||||
PendingTransaction.Status status = pendingTransaction.getStatus();
|
||||
|
@ -673,8 +685,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
@Override
|
||||
public void onSendTransactionFailed(final String error) {
|
||||
try {
|
||||
final SendFragment sendFragment = (SendFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
final SendFragment sendFragment = (SendFragment) getCurrentFragment();
|
||||
runOnUiThread(() -> sendFragment.onSendTransactionFailed(error));
|
||||
} catch (ClassCastException ex) {
|
||||
// not in spend fragment
|
||||
|
@ -685,8 +696,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
@Override
|
||||
public void onTransactionSent(final String txId) {
|
||||
try {
|
||||
final SendFragment sendFragment = (SendFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
final SendFragment sendFragment = (SendFragment) getCurrentFragment();
|
||||
runOnUiThread(() -> sendFragment.onTransactionSent(txId));
|
||||
} catch (ClassCastException ex) {
|
||||
// not in spend fragment
|
||||
|
@ -697,8 +707,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
@Override
|
||||
public void onProgress(final String text) {
|
||||
try {
|
||||
final WalletFragment walletFragment = (WalletFragment)
|
||||
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||
final WalletFragment walletFragment = getWalletFragment();
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
walletFragment.setProgress(text);
|
||||
|
@ -715,8 +724,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
public void onProgress(final int n) {
|
||||
runOnUiThread(() -> {
|
||||
try {
|
||||
WalletFragment walletFragment = (WalletFragment)
|
||||
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||
WalletFragment walletFragment = getWalletFragment();
|
||||
if (walletFragment != null)
|
||||
walletFragment.setProgress(n);
|
||||
} catch (ClassCastException ex) {
|
||||
|
@ -857,8 +865,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
|
||||
void onShareTxInfo() {
|
||||
try {
|
||||
TxFragment fragment = (TxFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
TxFragment fragment = (TxFragment) getCurrentFragment();
|
||||
fragment.shareTxInfo();
|
||||
} catch (ClassCastException ex) {
|
||||
// not in wallet fragment
|
||||
|
@ -968,7 +975,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
drawer.closeDrawer(GravityCompat.START);
|
||||
return;
|
||||
}
|
||||
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
final Fragment fragment = getCurrentFragment();
|
||||
if (fragment instanceof OnBackPressedListener) {
|
||||
if (!((OnBackPressedListener) fragment).onBackPressed()) {
|
||||
super.onBackPressed();
|
||||
|
|
|
@ -363,7 +363,6 @@ public class WalletFragment extends Fragment
|
|||
accountIndex = wallet.getAccountIndex();
|
||||
txlist.scrollToPosition(0);
|
||||
}
|
||||
|
||||
}
|
||||
updateStatus(wallet);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue