private FermatSession createOrCallWalletSession() { FermatSession walletSession = null; try { Bundle bundle = getIntent().getExtras(); if (bundle != null) { if (bundle.containsKey(INSTALLED_WALLET)) { lastWallet = (InstalledWallet) bundle.getSerializable(INSTALLED_WALLET); } else if (bundle.containsKey(WALLET_PUBLIC_KEY)) { String walletPublicKey = (String) bundle.get(WALLET_PUBLIC_KEY); lastWallet = getWalletManager().getInstalledWallet(walletPublicKey); } String publicKey = lastWallet.getAppPublicKey(); // AppConnections fermatAppConnection = // FermatAppConnectionManager.getFermatAppConnection(publicKey, this, // getIntraUserModuleManager().getActiveIntraUserIdentity(), // getAssetIssuerWalletModuleManager().getActiveAssetIssuerIdentity(), // getAssetUserWalletModuleManager().getActiveAssetUserIdentity(), // getAssetRedeemPointWalletModuleManager().getActiveAssetRedeemPointIdentity()); AppConnections fermatAppConnection = FermatAppConnectionManager.getFermatAppConnection(publicKey, this); ModuleManager moduleManager = getModuleManager(fermatAppConnection.getPluginVersionReference()); if (getWalletSessionManager().isWalletOpen(lastWallet.getWalletPublicKey())) { walletSession = getWalletSessionManager().getWalletSession(lastWallet.getWalletPublicKey()); } else { walletSession = getWalletSessionManager() .openWalletSession( lastWallet, getErrorManager(), moduleManager, fermatAppConnection); } } } catch (Exception e) { getErrorManager() .reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, FermatException.wrapException(e)); Toast.makeText( getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG) .show(); } return walletSession; }
@Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { // outState.putSerializable(INSTALLED_WALLET, lastWallet); outState.putString(WALLET_PUBLIC_KEY, lastWallet.getWalletPublicKey()); super.onSaveInstanceState(outState, outPersistentState); }
@Override public void selectWallet(InstalledWallet installedWallet) { Intent intent; try { // Activities activityType = Activities.getValueFromString(this.actionKey); WalletNavigationStructure walletNavigationStructure = getWalletRuntimeManager().getWallet(installedWallet.getWalletPublicKey()); intent = new Intent(this, com.bitdubai.android_core.app.WalletActivity.class); intent.putExtra(WalletActivity.INSTALLED_WALLET, installedWallet); intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); finish(); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } catch (Exception e) { getErrorManager() .reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, new IllegalArgumentException("Error in selectWallet")); Toast.makeText( getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG) .show(); } }
/** * Create a session for the Wallet Store SubApp * * @param wallet the SubApp type * @param errorManager the error manager * @param moduleManager the module of this SubApp */ public CryptoBrokerWalletSession( InstalledWallet wallet, ErrorManager errorManager, WalletResourcesProviderManager resourcesProviderManager, CryptoBrokerWalletModuleManager moduleManager) { super( wallet.getWalletPublicKey(), wallet, errorManager, moduleManager, resourcesProviderManager); this.wallet = wallet; data = new HashMap<>(); this.resourcesProviderManager = resourcesProviderManager; this.errorManager = errorManager; this.moduleManager = moduleManager; }