Bugfixes (#82)

* cache getAddress()

* savedInstanceState handling

* v0.8.0.2
This commit is contained in:
m2049r 2017-09-23 14:16:30 +02:00 committed by GitHub
parent be236cce1b
commit cc46dc06c4
4 changed files with 17 additions and 12 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "com.m2049r.xmrwallet" applicationId "com.m2049r.xmrwallet"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 25 targetSdkVersion 25
versionCode 14 versionCode 15
versionName "0.8.0.1" versionName "0.8.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild { externalNativeBuild {
cmake { cmake {

View File

@ -75,13 +75,13 @@ public class LoginActivity extends AppCompatActivity
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.login_activity);
setContentView(R.layout.login_activity);
if (savedInstanceState != null) { if (savedInstanceState != null) {
return; // we don't store anything ourselves
} }
setContentView(R.layout.login_activity);
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);

View File

@ -150,14 +150,16 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()"); Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.wallet_activity);
if (savedInstanceState != null) { if (savedInstanceState != null) {
return; // we don't store anything ourselves
} }
setContentView(R.layout.wallet_activity);
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.app_name);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
toolbar.setTitle(R.string.app_name);
boolean testnet = WalletManager.getInstance().isTestNet(); boolean testnet = WalletManager.getInstance().isTestNet();
if (testnet) { if (testnet) {
toolbar.setBackgroundResource(R.color.colorPrimaryDark); toolbar.setBackgroundResource(R.color.colorPrimaryDark);

View File

@ -36,6 +36,7 @@ public class Wallet {
Wallet(long handle) { Wallet(long handle) {
this.handle = handle; this.handle = handle;
getAddress(); // cache address for later
} }
public enum Status { public enum Status {
@ -50,8 +51,6 @@ public class Wallet {
ConnectionStatus_WrongVersion ConnectionStatus_WrongVersion
} }
//public native long createWalletListenerJ();
public native String getSeed(); public native String getSeed();
public native String getSeedLanguage(); public native String getSeedLanguage();
@ -68,11 +67,15 @@ public class Wallet {
public native boolean setPassword(String password); public native boolean setPassword(String password);
private String address = null;
public String getAddress() { public String getAddress() {
String address = getAddressJ(); if (address == null) {
address = getAddressJ();
}
if (!Wallet.isAddressValid(address, WalletManager.getInstance().isTestNet())) { if (!Wallet.isAddressValid(address, WalletManager.getInstance().isTestNet())) {
// just die! // just die!
throw new IllegalStateException("Wallet returned invalid address!"); throw new IllegalStateException("Wallet returned invalid address: " + address);
} }
return address; return address;
} }