diff --git a/app/build.gradle b/app/build.gradle index 21d84e889f..3fd0de955d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -259,6 +259,8 @@ dependencies { implementation 'com.journeyapps:zxing-android-embedded:4.3.0' implementation 'com.google.zxing:core:3.5.2' + implementation 'com.gu.android:toolargetool:0.3.0' + // Sugar implementation 'androidx.constraintlayout:constraintlayout:2.1.4' diff --git a/app/src/main/java/com/alphawallet/app/entity/ActionSheetInterface.java b/app/src/main/java/com/alphawallet/app/entity/ActionSheetInterface.java index 740c84e4cf..a2ad3a8d01 100644 --- a/app/src/main/java/com/alphawallet/app/entity/ActionSheetInterface.java +++ b/app/src/main/java/com/alphawallet/app/entity/ActionSheetInterface.java @@ -4,6 +4,8 @@ import com.alphawallet.app.web3.entity.Web3Transaction; +import java.math.BigInteger; + /** * Created by JB on 16/01/2021. */ diff --git a/app/src/main/java/com/alphawallet/app/repository/EthereumNetworkBase.java b/app/src/main/java/com/alphawallet/app/repository/EthereumNetworkBase.java index 909882b453..788973b514 100644 --- a/app/src/main/java/com/alphawallet/app/repository/EthereumNetworkBase.java +++ b/app/src/main/java/com/alphawallet/app/repository/EthereumNetworkBase.java @@ -1051,14 +1051,27 @@ public static String getNodeURLByNetworkId(long networkId) /** * This is used so as not to leak API credentials to web3; XInfuraAPI is the backup API key checked into github * - * @param networkId + * @param chainId * @return */ - public static String getDefaultNodeURL(long networkId) + public static String getDefaultNodeURL(long chainId) { - NetworkInfo info = networkMap.get(networkId); - if (info != null) return info.rpcServerUrl; - else return ""; + NetworkInfo info = networkMap.get(chainId); + + if (info == null) + { + return ""; + } + + int index = info.rpcServerUrl.indexOf(INFURA_ENDPOINT); + if (index > 0) + { + return info.rpcServerUrl.substring(0, index + INFURA_ENDPOINT.length()) + keyProvider.getTertiaryInfuraKey(); + } + else + { + return info.backupNodeUrl != null ? info.backupNodeUrl : info.rpcServerUrl; + } } public static long getNetworkIdFromName(String name) diff --git a/app/src/main/java/com/alphawallet/app/service/AssetDefinitionService.java b/app/src/main/java/com/alphawallet/app/service/AssetDefinitionService.java index c517c71982..3632cd0d7e 100644 --- a/app/src/main/java/com/alphawallet/app/service/AssetDefinitionService.java +++ b/app/src/main/java/com/alphawallet/app/service/AssetDefinitionService.java @@ -57,6 +57,7 @@ import com.alphawallet.token.entity.SigReturnType; import com.alphawallet.token.entity.TSAction; import com.alphawallet.token.entity.TSSelection; +import com.alphawallet.token.entity.TSTokenView; import com.alphawallet.token.entity.TokenScriptResult; import com.alphawallet.token.entity.TokenscriptContext; import com.alphawallet.token.entity.TokenscriptElement; @@ -688,12 +689,15 @@ public Single refreshAllAttributes(Token token) private void updateAttributeResult(Token token, TokenDefinition td, Attribute attr, BigInteger tokenId) { - ContractAddress useAddress = new ContractAddress(attr.function); //always use the function attribute's address - tokenscriptUtility.fetchResultFromEthereum(token, useAddress, attr, tokenId, td, this) // Fetch function result from blockchain - .subscribeOn(Schedulers.io()) - .observeOn(Schedulers.io()) - .subscribe(txResult -> storeAuxData(getWalletAddr(), txResult)) - .isDisposed(); + if (attr != null && attr.function != null) + { + ContractAddress useAddress = new ContractAddress(attr.function); //always use the function attribute's address + tokenscriptUtility.fetchResultFromEthereum(token, useAddress, attr, tokenId, td, this) // Fetch function result from blockchain + .subscribeOn(Schedulers.io()) + .observeOn(Schedulers.io()) + .subscribe(txResult -> storeAuxData(getWalletAddr(), txResult)) + .isDisposed(); + } } public void addLocalRefs(Map refs) @@ -2136,6 +2140,19 @@ public boolean hasTokenView(Token token, String type) } } + public TSTokenView getTSTokenView(Token token, String type) + { + TokenDefinition td = getAssetDefinition(token); + if (td != null) + { + return td.getTSTokenView(type); + } + else + { + return null; + } + } + public String getTokenView(Token token, String type) { String viewHTML = ""; @@ -2652,14 +2669,14 @@ private void addOpenSeaAttributes(StringBuilder attrs, Token token, BigInteger t if (tokenAsset.getBackgroundColor() != null) TokenScriptResult.addPair(attrs, "background_colour", URLEncoder.encode(tokenAsset.getBackgroundColor(), "utf-8")); if (tokenAsset.getThumbnail() != null) - TokenScriptResult.addPair(attrs, "image_preview_url", URLEncoder.encode(tokenAsset.getThumbnail(), "utf-8")); + TokenScriptResult.addPair(attrs, "image_preview_url", tokenAsset.getThumbnail()); if (tokenAsset.getDescription() != null) TokenScriptResult.addPair(attrs, "description", URLEncoder.encode(tokenAsset.getDescription(), "utf-8")); if (tokenAsset.getExternalLink() != null) - TokenScriptResult.addPair(attrs, "external_link", URLEncoder.encode(tokenAsset.getExternalLink(), "utf-8")); + TokenScriptResult.addPair(attrs, "external_link", tokenAsset.getExternalLink()); //if (tokenAsset.getTraits() != null) TokenScriptResult.addPair(attrs, "traits", tokenAsset.getTraits()); if (tokenAsset.getName() != null) - TokenScriptResult.addPair(attrs, "metadata_name", URLEncoder.encode(tokenAsset.getName(), "utf-8")); + TokenScriptResult.addPair(attrs, "metadata_name", tokenAsset.getName()); } catch (UnsupportedEncodingException e) { diff --git a/app/src/main/java/com/alphawallet/app/ui/AssetDisplayActivity.java b/app/src/main/java/com/alphawallet/app/ui/AssetDisplayActivity.java index 5747ba8c75..0c69e19c8d 100644 --- a/app/src/main/java/com/alphawallet/app/ui/AssetDisplayActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/AssetDisplayActivity.java @@ -49,6 +49,7 @@ import com.alphawallet.token.entity.TicketRange; import com.alphawallet.token.entity.ViewType; import com.alphawallet.token.entity.XMLDsigDescriptor; +import com.alphawallet.token.tools.TokenDefinition; import java.math.BigInteger; import java.util.List; @@ -192,10 +193,10 @@ private void viewHeight(int fetchedViewHeight) } } - private void onNewScript(Boolean aBoolean) + private void onNewScript(TokenDefinition td) { //need to reload tokens, now we have an updated/new script - if (viewModel.getAssetDefinitionService().hasDefinition(token)) + if (td != null) { initWebViewCheck(); handler.postDelayed(this, TOKEN_SIZING_DELAY); diff --git a/app/src/main/java/com/alphawallet/app/ui/FunctionActivity.java b/app/src/main/java/com/alphawallet/app/ui/FunctionActivity.java index 481292b0fc..f50015e432 100644 --- a/app/src/main/java/com/alphawallet/app/ui/FunctionActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/FunctionActivity.java @@ -84,6 +84,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import timber.log.Timber; +import com.gu.toolargetool.TooLargeTool; /** * Created by James on 4/04/2019. @@ -282,6 +283,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_script_view); setupViews(); + + TooLargeTool.startLogging(getApplication()); } private void setupViews() @@ -406,13 +409,15 @@ public void unresolvedSymbolError(String value) private void checkTokenScriptElement(CalcJsValueCallback cb, TSAction action, TokenscriptElement e) { - if (e.ref != null && e.ref.length() > 0 && action.attributes != null) + String refName = !TextUtils.isEmpty(e.localRef) ? e.localRef : e.ref; //favour the localRef, then ref + + if (!TextUtils.isEmpty(refName) && action.attributes != null) { - Attribute attr = action.attributes.get(e.ref); + Attribute attr = action.attributes.get(refName); if (attr != null && attr.userInput) { resolveInputCheckCount++; - evaluateJavaScript(cb, e.ref, e, attr); + evaluateJavaScript(cb, refName, e, attr); } } } @@ -461,6 +466,12 @@ else if (confirmationDialog == null || !confirmationDialog.isShowing()) } } + @Override + public BigInteger getTokenId() + { + return tokenId; + } + private void calculateEstimateDialog() { if (alertDialog != null && alertDialog.isShowing()) alertDialog.dismiss(); diff --git a/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java b/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java index 310158e637..69d654015a 100644 --- a/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/HomeActivity.java @@ -91,6 +91,7 @@ import com.journeyapps.barcodescanner.ScanContract; import com.journeyapps.barcodescanner.ScanOptions; import com.walletconnect.android.CoreClient; +import com.gu.toolargetool.TooLargeTool; import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEvent; @@ -277,6 +278,8 @@ public void onPageScrollStateChanged(int state) viewModel.defaultWallet().observe(this, this::onDefaultWallet); viewModel.updateAvailable().observe(this, this::onUpdateAvailable); + TooLargeTool.startLogging(getApplication()); + if (CustomViewSettings.hideDappBrowser()) { removeDappBrowser(); diff --git a/app/src/main/java/com/alphawallet/app/ui/NFTActivity.java b/app/src/main/java/com/alphawallet/app/ui/NFTActivity.java index 05f375ce1a..4c6694ff6a 100644 --- a/app/src/main/java/com/alphawallet/app/ui/NFTActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/NFTActivity.java @@ -49,16 +49,13 @@ public class NFTActivity extends BaseActivity implements StandardFunctionInterface { private NFTViewModel viewModel; - private Wallet wallet; private Token token; private FunctionButtonBar functionBar; private boolean isGridView; - private MenuItem sendMultipleTokensMenuItem; private MenuItem switchToGridViewMenuItem; private MenuItem switchToListViewMenuItem; - private NFTAssetsFragment assetsFragment; private final ActivityResultLauncher handleTransactionSuccess = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), @@ -84,7 +81,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) initViewModel(); getIntentData(); setTitle(token.tokenInfo.name); - isGridView = !hasTokenScriptOverride(token); + isGridView = !hasTokenScriptOverride(token) && token.isERC875(); setupViewPager(); //check NFT events, expedite balance update diff --git a/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java b/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java index b1fd8cf821..efb42bc64d 100644 --- a/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java @@ -172,8 +172,8 @@ public void onResume() @Override protected void onDestroy() { - viewModel.onDestroy(); super.onDestroy(); + viewModel.onDestroy(); tokenImage.onDestroy(); } @@ -184,6 +184,12 @@ public void onPause() tokenImage.onPause(); } + @Override + public void onSaveInstanceState(Bundle bundle) + { + super.onSaveInstanceState(bundle); + } + @Override public boolean onCreateOptionsMenu(@NonNull Menu menu) { @@ -291,7 +297,7 @@ private void setup() if (asset != null && asset.isAttestation()) { - setupAttestation(); + setupAttestation(viewModel.getAssetDefinitionService().getAssetDefinition(token)); } else { @@ -315,11 +321,11 @@ private void initViewModel() viewModel.walletUpdate().observe(this, this::setupFunctionBar); } - private void newScriptFound(Boolean status) + private void newScriptFound(TokenDefinition td) { CertifiedToolbarView certificateToolbar = findViewById(R.id.certified_toolbar); //determinate signature - if (token != null && status) + if (token != null && td != null) { certificateToolbar.stopDownload(); certificateToolbar.setVisibility(View.VISIBLE); @@ -330,12 +336,19 @@ private void newScriptFound(Boolean status) //now re-load the verbs if already called. If wallet is null this won't complete setupFunctionBar(viewModel.getWallet()); - setupAttestation(); + if (token.getInterfaceSpec() == ContractType.ATTESTATION) + { + setupAttestation(td); + } + else + { + displayTokenView(td, tokenId); + } } else { certificateToolbar.stopDownload(); - setupAttestation(); + setupAttestation(null); } } @@ -417,7 +430,10 @@ private void clearRefreshAnimation() private void onNftAsset(NFTAsset asset) { - loadAssetFromMetadata(asset); + if (token != null) + { + loadAssetFromMetadata(asset); + } } private void updateDefaultTokenData() @@ -587,15 +603,9 @@ private void loadFromOpenSeaData(OpenSeaAsset openSeaAsset) clearRefreshAnimation(); } - private void onOpenSeaAsset(OpenSeaAsset openSeaAsset) - { - loadFromOpenSeaData(openSeaAsset); - } - - private void setupAttestation() + private void setupAttestation(TokenDefinition td) { NFTAsset attnAsset = new NFTAsset(); - TokenDefinition td = viewModel.getAssetDefinitionService().getAssetDefinition(token); if (token.getInterfaceSpec() != ContractType.ATTESTATION) { return; @@ -604,7 +614,7 @@ else if (td != null) { attnAsset.setupScriptElements(td); attnAsset.setupScriptAttributes(td, token); - if (!displayTokenView(td)) + if (!displayTokenView(td, BigInteger.ONE)) { tokenImage.setupTokenImage(attnAsset); } @@ -821,7 +831,7 @@ public WalletType getWalletType() /*** * TokenScript view handling */ - private boolean displayTokenView(TokenDefinition td) + private boolean displayTokenView(TokenDefinition td, BigInteger tokenId) { if (!td.hasTokenView()) { @@ -837,7 +847,7 @@ private boolean displayTokenView(TokenDefinition td) scriptView.setChainId(token.tokenInfo.chainId); scriptView.setWalletAddress(new Address(token.getWallet())); - scriptView.renderTokenScriptView(token, new TicketRange(BigInteger.ONE, token.getAddress()), viewModel.getAssetDefinitionService(), ViewType.VIEW); + scriptView.renderTokenScriptView(token, new TicketRange(tokenId, token.getAddress()), viewModel.getAssetDefinitionService(), ViewType.VIEW); } catch (Exception e) { diff --git a/app/src/main/java/com/alphawallet/app/ui/NFTAssetsFragment.java b/app/src/main/java/com/alphawallet/app/ui/NFTAssetsFragment.java index 2527759cae..a9b05acbed 100644 --- a/app/src/main/java/com/alphawallet/app/ui/NFTAssetsFragment.java +++ b/app/src/main/java/com/alphawallet/app/ui/NFTAssetsFragment.java @@ -105,7 +105,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat gridItemDecoration = new ItemOffsetDecoration(requireContext(), R.dimen.grid_divider_offset); - if (hasTokenScriptOverride(token)) + if (hasTokenScriptOverride(token) && token.isERC875()) { showListView(); } @@ -196,7 +196,7 @@ public void showListView() private void initAndAttachAdapter(boolean isGridView) { - if (hasTokenScriptOverride(token)) + if (hasTokenScriptOverride(token) && token.isERC875()) { searchLayout.setVisibility(View.GONE); adapter = new NonFungibleTokenAdapter(this, token, viewModel.getAssetDefinitionService(), viewModel.getOpenseaService(), isGridView); diff --git a/app/src/main/java/com/alphawallet/app/ui/widget/entity/ActionSheetCallback.java b/app/src/main/java/com/alphawallet/app/ui/widget/entity/ActionSheetCallback.java index ff872d1ca7..15fb09cf3b 100644 --- a/app/src/main/java/com/alphawallet/app/ui/widget/entity/ActionSheetCallback.java +++ b/app/src/main/java/com/alphawallet/app/ui/widget/entity/ActionSheetCallback.java @@ -11,6 +11,8 @@ import com.alphawallet.app.web3.entity.Web3Transaction; import com.alphawallet.token.entity.Signable; +import java.math.BigInteger; + /** * Created by JB on 27/11/2020. */ @@ -63,4 +65,9 @@ default void signingFailed(Throwable error, Signable message) } WalletType getWalletType(); + + default BigInteger getTokenId() + { + return BigInteger.ZERO; + } } diff --git a/app/src/main/java/com/alphawallet/app/viewmodel/TokenFunctionViewModel.java b/app/src/main/java/com/alphawallet/app/viewmodel/TokenFunctionViewModel.java index 0d3007ad14..adcec6fe57 100644 --- a/app/src/main/java/com/alphawallet/app/viewmodel/TokenFunctionViewModel.java +++ b/app/src/main/java/com/alphawallet/app/viewmodel/TokenFunctionViewModel.java @@ -111,7 +111,7 @@ public class TokenFunctionViewModel extends BaseViewModel implements Transaction private final MutableLiveData insufficientFunds = new MutableLiveData<>(); private final MutableLiveData invalidAddress = new MutableLiveData<>(); private final MutableLiveData sig = new MutableLiveData<>(); - private final MutableLiveData newScriptFound = new MutableLiveData<>(); + private final MutableLiveData newScriptFound = new MutableLiveData<>(); private final MutableLiveData walletUpdate = new MutableLiveData<>(); private final MutableLiveData transactionFinalised = new MutableLiveData<>(); private final MutableLiveData transactionError = new MutableLiveData<>(); @@ -185,7 +185,7 @@ public LiveData walletUpdate() return walletUpdate; } - public LiveData newScriptFound() + public LiveData newScriptFound() { return newScriptFound; } @@ -601,13 +601,13 @@ private void handleDefinition(TokenDefinition td) switch (td.nameSpace) { case UNCHANGED_SCRIPT: - newScriptFound.postValue(false); + newScriptFound.postValue(null); break; case NO_SCRIPT: scriptUpdateInProgress.postValue(false); break; default: - newScriptFound.postValue(true); + newScriptFound.postValue(td); break; } } @@ -1011,5 +1011,4 @@ private void onAttr(StringBuilder attrs, TokenScriptResult.Attribute attribute) TokenScriptResult.addPair(attrs, attribute); } } - } diff --git a/app/src/main/java/com/alphawallet/app/web3/JsInjectorClient.java b/app/src/main/java/com/alphawallet/app/web3/JsInjectorClient.java index ee55d80ab0..195abb477a 100644 --- a/app/src/main/java/com/alphawallet/app/web3/JsInjectorClient.java +++ b/app/src/main/java/com/alphawallet/app/web3/JsInjectorClient.java @@ -39,7 +39,7 @@ public class JsInjectorClient { private long chainId = 1; private Address walletAddress; - //Note: this default RPC is overriden before injection + //Note: this default RPC is overridden before injection private String rpcUrl = EthereumNetworkRepository.getDefaultNodeURL(MAINNET_ID); public JsInjectorClient(Context context) { diff --git a/app/src/main/java/com/alphawallet/app/web3/Web3TokenView.java b/app/src/main/java/com/alphawallet/app/web3/Web3TokenView.java index feecbeddd1..d9258c489f 100644 --- a/app/src/main/java/com/alphawallet/app/web3/Web3TokenView.java +++ b/app/src/main/java/com/alphawallet/app/web3/Web3TokenView.java @@ -44,6 +44,7 @@ import com.alphawallet.app.web3.entity.Web3Transaction; import com.alphawallet.token.entity.EthereumMessage; import com.alphawallet.token.entity.Signable; +import com.alphawallet.token.entity.TSTokenView; import com.alphawallet.token.entity.TicketRange; import com.alphawallet.token.entity.TokenScriptResult; import com.alphawallet.token.entity.ViewType; @@ -56,6 +57,7 @@ import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.Map; +import java.util.Objects; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; @@ -493,14 +495,19 @@ private void displayTicket(Token token, AssetDefinitionService assetService, Str break; } - String view = assetService.getTokenView(token, viewName); - if (TextUtils.isEmpty(view)) view = buildViewError(token, range, viewName); - String style = assetService.getTokenViewStyle(token, viewName); + TSTokenView tokenView = assetService.getTSTokenView(token, viewName); + + String view = tokenView.getTokenView(); + if (TextUtils.isEmpty(view)) + { + view = buildViewError(token, range, viewName); + } + String style = tokenView.getStyle(); unencodedPage = injectWeb3TokenInit(view, attrs.toString(), range.tokenIds.get(0)); unencodedPage = injectStyleAndWrapper(unencodedPage, style); //style injected last so it comes first String base64 = android.util.Base64.encodeToString(unencodedPage.getBytes(StandardCharsets.UTF_8), Base64.DEFAULT); - loadData(base64, "text/html; charset=utf-8", "base64"); + loadData(base64 + (!Objects.equals(tokenView.getUrlFragment(), "") ? "#" + tokenView.getUrlFragment() : ""), "text/html; charset=utf-8", "base64"); if (realmAuxUpdates != null) realmAuxUpdates.removeAllChangeListeners(); //TODO: Re-do this to use the JavaScript minimal interface diff --git a/app/src/main/java/com/alphawallet/app/widget/ActionSheetDialog.java b/app/src/main/java/com/alphawallet/app/widget/ActionSheetDialog.java index 0aef358f81..557c772cfb 100644 --- a/app/src/main/java/com/alphawallet/app/widget/ActionSheetDialog.java +++ b/app/src/main/java/com/alphawallet/app/widget/ActionSheetDialog.java @@ -32,7 +32,6 @@ import com.alphawallet.app.repository.SharedPreferenceRepository; import com.alphawallet.app.repository.entity.Realm1559Gas; import com.alphawallet.app.repository.entity.RealmTransaction; -import com.alphawallet.app.service.SignatureLookupService; import com.alphawallet.app.service.TokensService; import com.alphawallet.app.ui.HomeActivity; import com.alphawallet.app.ui.TransactionSuccessActivity; @@ -52,11 +51,8 @@ import java.util.Collections; import java.util.List; -import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; -import io.reactivex.schedulers.Schedulers; import io.realm.Realm; -import timber.log.Timber; /** * Created by JB on 17/11/2020. @@ -503,8 +499,18 @@ else if (isSendingTransaction()) private String getERC721TokenId() { - if (!token.isERC721()) return ""; - return token.getTransferValueRaw(transaction.transactionInput).toString(); + if (!token.isERC721()) + { + return ""; + } + else if (actionSheetCallback.getTokenId().compareTo(BigInteger.ZERO) > 0) + { + return actionSheetCallback.getTokenId().toString(); + } + else + { + return token.getTransferValueRaw(transaction.transactionInput).toString(); + } } /** diff --git a/app/src/main/java/com/alphawallet/app/widget/AssetDetailView.java b/app/src/main/java/com/alphawallet/app/widget/AssetDetailView.java index 605e61760c..4c982dca23 100644 --- a/app/src/main/java/com/alphawallet/app/widget/AssetDetailView.java +++ b/app/src/main/java/com/alphawallet/app/widget/AssetDetailView.java @@ -77,7 +77,6 @@ private void setupAssetDetail(NFTAsset asset, ActionSheetInterface actionSheetIn layoutHolder.setVisibility(View.VISIBLE); assetName.setText(asset.getName()); - imageView.setupTokenImage(asset); assetDescription.setText(asset.getDescription()); @@ -88,12 +87,15 @@ private void setupAssetDetail(NFTAsset asset, ActionSheetInterface actionSheetIn { layoutDetails.setVisibility(View.VISIBLE); assetDetails.setImageResource(R.drawable.ic_expand_less_black); + imageView.setupTokenImage(asset); + imageView.setVisibility(View.VISIBLE); if (actionSheetInterface != null) actionSheetInterface.fullExpand(); } else { layoutDetails.setVisibility(View.GONE); assetDetails.setImageResource(R.drawable.ic_expand_more); + imageView.setVisibility(View.GONE); } }); } diff --git a/app/src/main/java/com/alphawallet/app/widget/TransactionDetailWidget.java b/app/src/main/java/com/alphawallet/app/widget/TransactionDetailWidget.java index 3b3d062336..1be190c13e 100644 --- a/app/src/main/java/com/alphawallet/app/widget/TransactionDetailWidget.java +++ b/app/src/main/java/com/alphawallet/app/widget/TransactionDetailWidget.java @@ -75,7 +75,7 @@ public void setupTransaction(Web3Transaction w3tx, long chainId, String symbol, disposable = svc.getFunctionName(w3tx.payload) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) - .subscribe(this::onResult); + .subscribe(this::onResult, error -> { }); layoutHolder.setOnClickListener(v -> { if (layoutDetails.getVisibility() == View.GONE) diff --git a/app/src/main/res/layout/activity_nft_asset_detail.xml b/app/src/main/res/layout/activity_nft_asset_detail.xml index 5223739a8d..5a814ea984 100644 --- a/app/src/main/res/layout/activity_nft_asset_detail.xml +++ b/app/src/main/res/layout/activity_nft_asset_detail.xml @@ -31,42 +31,39 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - + + + + - - - - + android:layout_height="match_parent"> - + - + 0) + { + v = views.values().iterator().next(); + } + + return v; + } } diff --git a/lib/src/main/java/com/alphawallet/token/tools/TokenDefinition.java b/lib/src/main/java/com/alphawallet/token/tools/TokenDefinition.java index 1e69bee944..81b626e4d4 100644 --- a/lib/src/main/java/com/alphawallet/token/tools/TokenDefinition.java +++ b/lib/src/main/java/com/alphawallet/token/tools/TokenDefinition.java @@ -1730,6 +1730,17 @@ public String getTokenView(String viewTag) return tokenViews.getView(viewTag); } + public TSTokenView getTSTokenView(String type) + { + TSTokenView view = tokenViews.views.get(type); + if (view == null && tokenViews.views.size() > 0) + { + view = tokenViews.views.values().iterator().next(); + } + + return view; + } + public String getTokenViewStyle(String viewTag) { return tokenViews.getViewStyle(viewTag);