mirror of
https://github.com/m2049r/xmrwallet
synced 2025-03-23 14:34:21 +01:00
UI bugfixes (#120)
* better wallet load progress new version * dont start LoginFragment if is already started
This commit is contained in:
parent
f5ad07c2b0
commit
347123d961
app
build.gradle
src/main/java/com/m2049r/xmrwallet
@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "com.m2049r.xmrwallet"
|
applicationId "com.m2049r.xmrwallet"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 42
|
versionCode 44
|
||||||
versionName "1.2.2"
|
versionName "1.2.3"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
|
@ -293,5 +293,6 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.wallet_details_menu, menu);
|
inflater.inflate(R.menu.wallet_details_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -132,7 +132,7 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Helper.getWritePermission(this)) {
|
if (Helper.getWritePermission(this)) {
|
||||||
startLoginFragment();
|
if (savedInstanceState == null) startLoginFragment();
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "Waiting for permissions");
|
Log.i(TAG, "Waiting for permissions");
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ import android.util.Log;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.dialog.HelpFragment;
|
|
||||||
import com.m2049r.xmrwallet.dialog.DonationFragment;
|
import com.m2049r.xmrwallet.dialog.DonationFragment;
|
||||||
|
import com.m2049r.xmrwallet.dialog.HelpFragment;
|
||||||
import com.m2049r.xmrwallet.layout.Toolbar;
|
import com.m2049r.xmrwallet.layout.Toolbar;
|
||||||
import com.m2049r.xmrwallet.model.PendingTransaction;
|
import com.m2049r.xmrwallet.model.PendingTransaction;
|
||||||
import com.m2049r.xmrwallet.model.TransactionInfo;
|
import com.m2049r.xmrwallet.model.TransactionInfo;
|
||||||
@ -223,7 +223,7 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
|||||||
|
|
||||||
Fragment walletFragment = new WalletFragment();
|
Fragment walletFragment = new WalletFragment();
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.fragment_container, walletFragment).commit();
|
.add(R.id.fragment_container, walletFragment, WalletFragment.TAG).commit();
|
||||||
Log.d(TAG, "fragment added");
|
Log.d(TAG, "fragment added");
|
||||||
|
|
||||||
startWalletService();
|
startWalletService();
|
||||||
@ -389,12 +389,12 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
|||||||
Log.d(TAG, "onRefreshed()");
|
Log.d(TAG, "onRefreshed()");
|
||||||
try {
|
try {
|
||||||
final WalletFragment walletFragment = (WalletFragment)
|
final WalletFragment walletFragment = (WalletFragment)
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
getSupportFragmentManager().findFragmentByTag(WalletFragment.TAG);
|
||||||
if (wallet.isSynchronized()) {
|
if (wallet.isSynchronized()) {
|
||||||
Log.d(TAG, "onRefreshed() synced");
|
Log.d(TAG, "onRefreshed() synced");
|
||||||
releaseWakeLock(); // the idea is to stay awake until synced
|
releaseWakeLock(); // the idea is to stay awake until synced
|
||||||
if (!synced) {
|
if (!synced) { // first sync
|
||||||
onProgress(null);
|
onProgress(-1);
|
||||||
saveWallet(); // save on first sync
|
saveWallet(); // save on first sync
|
||||||
synced = true;
|
synced = true;
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -523,10 +523,10 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
|||||||
public void onProgress(final String text) {
|
public void onProgress(final String text) {
|
||||||
try {
|
try {
|
||||||
final WalletFragment walletFragment = (WalletFragment)
|
final WalletFragment walletFragment = (WalletFragment)
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
getSupportFragmentManager().findFragmentByTag(WalletFragment.TAG);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
walletFragment.onProgress(text);
|
walletFragment.setProgress(text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (ClassCastException ex) {
|
} catch (ClassCastException ex) {
|
||||||
@ -540,10 +540,10 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
|||||||
public void onProgress(final int n) {
|
public void onProgress(final int n) {
|
||||||
try {
|
try {
|
||||||
final WalletFragment walletFragment = (WalletFragment)
|
final WalletFragment walletFragment = (WalletFragment)
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
getSupportFragmentManager().findFragmentByTag(WalletFragment.TAG);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
walletFragment.onProgress(n);
|
walletFragment.setProgress(n);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (ClassCastException ex) {
|
} catch (ClassCastException ex) {
|
||||||
|
@ -49,7 +49,7 @@ import java.util.List;
|
|||||||
public class WalletFragment extends Fragment
|
public class WalletFragment extends Fragment
|
||||||
implements TransactionInfoAdapter.OnInteractionListener,
|
implements TransactionInfoAdapter.OnInteractionListener,
|
||||||
AsyncExchangeRate.Listener {
|
AsyncExchangeRate.Listener {
|
||||||
private static final String TAG = "WalletFragment";
|
public static final String TAG = "WalletFragment";
|
||||||
private TransactionInfoAdapter adapter;
|
private TransactionInfoAdapter adapter;
|
||||||
private NumberFormat formatter = NumberFormat.getInstance();
|
private NumberFormat formatter = NumberFormat.getInstance();
|
||||||
|
|
||||||
@ -258,27 +258,26 @@ public class WalletFragment extends Fragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgressText(final String text) {
|
private String syncText = null;
|
||||||
|
|
||||||
|
public void setProgress(final String text) {
|
||||||
|
syncText = text;
|
||||||
tvProgress.setText(text);
|
tvProgress.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onProgress(final String text) {
|
private int syncProgress = -1;
|
||||||
if (text != null) {
|
|
||||||
setProgressText(text);
|
|
||||||
pbProgress.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
pbProgress.setVisibility(View.INVISIBLE);
|
|
||||||
setProgressText(getString(R.string.status_working));
|
|
||||||
onProgress(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onProgress(final int n) {
|
public void setProgress(final int n) {
|
||||||
if (n >= 0) {
|
syncProgress = n;
|
||||||
|
if (n > 100) {
|
||||||
|
pbProgress.setIndeterminate(true);
|
||||||
|
pbProgress.setVisibility(View.VISIBLE);
|
||||||
|
} else if (n >= 0) {
|
||||||
pbProgress.setIndeterminate(false);
|
pbProgress.setIndeterminate(false);
|
||||||
pbProgress.setProgress(n);
|
pbProgress.setProgress(n);
|
||||||
} else {
|
pbProgress.setVisibility(View.VISIBLE);
|
||||||
pbProgress.setIndeterminate(true);
|
} else { // <0
|
||||||
|
pbProgress.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +300,6 @@ public class WalletFragment extends Fragment
|
|||||||
Log.d(TAG, "updateStatus()");
|
Log.d(TAG, "updateStatus()");
|
||||||
if (walletTitle == null) {
|
if (walletTitle == null) {
|
||||||
setActivityTitle(wallet);
|
setActivityTitle(wallet);
|
||||||
onProgress(100); // of loading
|
|
||||||
}
|
}
|
||||||
long balance = wallet.getBalance();
|
long balance = wallet.getBalance();
|
||||||
unlockedBalance = wallet.getUnlockedBalance();
|
unlockedBalance = wallet.getUnlockedBalance();
|
||||||
@ -309,8 +307,6 @@ public class WalletFragment extends Fragment
|
|||||||
double amountXmr = Double.parseDouble(Helper.getDisplayAmount(balance - unlockedBalance)); // assume this cannot fail!
|
double amountXmr = Double.parseDouble(Helper.getDisplayAmount(balance - unlockedBalance)); // assume this cannot fail!
|
||||||
String unconfirmed = Helper.getFormattedAmount(amountXmr, true);
|
String unconfirmed = Helper.getFormattedAmount(amountXmr, true);
|
||||||
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, unconfirmed));
|
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, unconfirmed));
|
||||||
//tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount,
|
|
||||||
// Helper.getDisplayAmount(balance - unlockedBalance, Helper.DISPLAY_DIGITS_SHORT)));
|
|
||||||
String sync = "";
|
String sync = "";
|
||||||
if (!activityCallback.hasBoundService())
|
if (!activityCallback.hasBoundService())
|
||||||
throw new IllegalStateException("WalletService not bound.");
|
throw new IllegalStateException("WalletService not bound.");
|
||||||
@ -324,16 +320,18 @@ public class WalletFragment extends Fragment
|
|||||||
firstBlock = wallet.getBlockChainHeight();
|
firstBlock = wallet.getBlockChainHeight();
|
||||||
}
|
}
|
||||||
int x = 100 - Math.round(100f * n / (1f * daemonHeight - firstBlock));
|
int x = 100 - Math.round(100f * n / (1f * daemonHeight - firstBlock));
|
||||||
//onProgress(getString(R.string.status_syncing) + " " + sync);
|
if (x == 0) x = 101; // indeterminate
|
||||||
if (x == 0) x = -1;
|
setProgress(x);
|
||||||
onProgress(x);
|
|
||||||
ivSynced.setVisibility(View.GONE);
|
ivSynced.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
sync = getString(R.string.status_synced) + formatter.format(wallet.getBlockChainHeight());
|
sync = getString(R.string.status_synced) + formatter.format(wallet.getBlockChainHeight());
|
||||||
ivSynced.setVisibility(View.VISIBLE);
|
ivSynced.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sync = getString(R.string.status_wallet_connecting);
|
||||||
|
setProgress(101);
|
||||||
}
|
}
|
||||||
setProgressText(sync);
|
setProgress(sync);
|
||||||
// TODO show connected status somewhere
|
// TODO show connected status somewhere
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +385,8 @@ public class WalletFragment extends Fragment
|
|||||||
Log.d(TAG, "onResume()");
|
Log.d(TAG, "onResume()");
|
||||||
activityCallback.setTitle(walletTitle, walletSubtitle);
|
activityCallback.setTitle(walletTitle, walletSubtitle);
|
||||||
activityCallback.setToolbarButton(Toolbar.BUTTON_CLOSE);
|
activityCallback.setToolbarButton(Toolbar.BUTTON_CLOSE);
|
||||||
|
setProgress(syncProgress);
|
||||||
|
setProgress(syncText);
|
||||||
showReceive();
|
showReceive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ public class WalletService extends Service {
|
|||||||
showProgress(100);
|
showProgress(100);
|
||||||
}
|
}
|
||||||
showProgress(getString(R.string.status_wallet_connecting));
|
showProgress(getString(R.string.status_wallet_connecting));
|
||||||
showProgress(-1);
|
showProgress(101);
|
||||||
// if we try to refresh the history here we get occasional segfaults!
|
// if we try to refresh the history here we get occasional segfaults!
|
||||||
// doesnt matter since we update as soon as we get a new block anyway
|
// doesnt matter since we update as soon as we get a new block anyway
|
||||||
Log.d(TAG, "start() done");
|
Log.d(TAG, "start() done");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user