diff --git a/app/src/main/java/com/alphawallet/app/repository/PreferenceRepositoryType.java b/app/src/main/java/com/alphawallet/app/repository/PreferenceRepositoryType.java index fdbba7fe20..67ca4e4c63 100644 --- a/app/src/main/java/com/alphawallet/app/repository/PreferenceRepositoryType.java +++ b/app/src/main/java/com/alphawallet/app/repository/PreferenceRepositoryType.java @@ -142,4 +142,8 @@ public interface PreferenceRepositoryType boolean isPostNotificationsPermissionRequested(String address); void setPostNotificationsPermissionRequested(String address, boolean hasRequested); + + boolean getUseTSViewer(); + + void setUseTSViewer(boolean toggleState); } diff --git a/app/src/main/java/com/alphawallet/app/repository/SharedPreferenceRepository.java b/app/src/main/java/com/alphawallet/app/repository/SharedPreferenceRepository.java index 128fc76004..fc4e1d7dba 100644 --- a/app/src/main/java/com/alphawallet/app/repository/SharedPreferenceRepository.java +++ b/app/src/main/java/com/alphawallet/app/repository/SharedPreferenceRepository.java @@ -32,6 +32,7 @@ public class SharedPreferenceRepository implements PreferenceRepositoryType { public static final String HIDE_ZERO_BALANCE_TOKENS = "hide_zero_balance_tokens"; public static final String FULL_SCREEN_STATE = "full_screen"; public static final String EXPERIMENTAL_1559_TX = "ex_1559_tx"; + public static final String USE_TOKENSCRIPT_VIEWER = "use_ts_viewer"; public static final String DEVELOPER_OVERRIDE = "developer_override"; public static final String TESTNET_ENABLED = "testnet_enabled"; public static final String PRICE_ALERTS = "price_alerts"; @@ -469,10 +470,23 @@ public boolean isPostNotificationsPermissionRequested(String address) { } @Override - public void setPostNotificationsPermissionRequested(String address, boolean hasRequested) { + public void setPostNotificationsPermissionRequested(String address, boolean hasRequested) + { pref.edit().putBoolean(getAddressKey(POST_NOTIFICATIONS_PERMISSION_REQUESTED, address), hasRequested).apply(); } + @Override + public boolean getUseTSViewer() + { + return pref.getBoolean(USE_TOKENSCRIPT_VIEWER, true); + } + + @Override + public void setUseTSViewer(boolean state) + { + pref.edit().putBoolean(USE_TOKENSCRIPT_VIEWER, state).apply(); + } + @NonNull private String getAddressKey(String key, String address) { diff --git a/app/src/main/java/com/alphawallet/app/ui/AdvancedSettingsActivity.java b/app/src/main/java/com/alphawallet/app/ui/AdvancedSettingsActivity.java index d1ba9cf700..49b4498400 100644 --- a/app/src/main/java/com/alphawallet/app/ui/AdvancedSettingsActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/AdvancedSettingsActivity.java @@ -47,6 +47,7 @@ public class AdvancedSettingsActivity extends BaseActivity private SettingsItemView analytics; private SettingsItemView crashReporting; private SettingsItemView developerOverride; + private SettingsItemView tokenScriptViewer; private AWalletAlertDialog waitDialog = null; @Nullable @@ -57,7 +58,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); viewModel = new ViewModelProvider(this) - .get(AdvancedSettingsViewModel.class); + .get(AdvancedSettingsViewModel.class); setContentView(R.layout.activity_generic_settings); toolbar(); @@ -82,68 +83,74 @@ public void onDestroy() private void initializeSettings() { nodeStatus = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_node_status) - .withTitle(R.string.action_node_status) - .withListener(this::onNodeStatusClicked) - .build(); + .withIcon(R.drawable.ic_settings_node_status) + .withTitle(R.string.action_node_status) + .withListener(this::onNodeStatusClicked) + .build(); console = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_console) - .withTitle(R.string.title_console) - .withListener(this::onConsoleClicked) - .build(); + .withIcon(R.drawable.ic_settings_console) + .withTitle(R.string.title_console) + .withListener(this::onConsoleClicked) + .build(); clearBrowserCache = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_cache) - .withTitle(R.string.title_clear_browser_cache) - .withListener(this::onClearBrowserCacheClicked) - .build(); + .withIcon(R.drawable.ic_settings_cache) + .withTitle(R.string.title_clear_browser_cache) + .withListener(this::onClearBrowserCacheClicked) + .build(); tokenScript = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_tokenscript) - .withTitle(R.string.title_tokenscript) - .withListener(this::onTokenScriptClicked) - .build(); + .withIcon(R.drawable.ic_settings_tokenscript) + .withTitle(R.string.title_tokenscript) + .withListener(this::onTokenScriptClicked) + .build(); //TODO Change Icon tokenScriptManagement = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_tokenscript_manage) - .withTitle(R.string.tokenscript_management) - .withListener(this::onTokenScriptManagementClicked) - .build(); + .withIcon(R.drawable.ic_settings_tokenscript_manage) + .withTitle(R.string.tokenscript_management) + .withListener(this::onTokenScriptManagementClicked) + .build(); + + tokenScriptViewer = new SettingsItemView.Builder(this) + .withType(SettingsItemView.Type.TOGGLE) + .withIcon(R.drawable.ic_tokenscript) + .withTitle(R.string.use_tokenscript_viewer) + .withListener(this::onUseTokenScriptViewer) + .build(); fullScreenSettings = new SettingsItemView.Builder(this) - .withType(SettingsItemView.Type.TOGGLE) - .withIcon(R.drawable.ic_phoneicon) - .withTitle(R.string.fullscreen) - .withListener(this::onFullScreenClicked) - .build(); + .withType(SettingsItemView.Type.TOGGLE) + .withIcon(R.drawable.ic_phoneicon) + .withTitle(R.string.fullscreen) + .withListener(this::onFullScreenClicked) + .build(); refreshTokenDatabase = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_reset_tokens) - .withTitle(R.string.title_reload_token_data) - .withListener(this::onReloadTokenDataClicked) - .build(); + .withIcon(R.drawable.ic_settings_reset_tokens) + .withTitle(R.string.title_reload_token_data) + .withListener(this::onReloadTokenDataClicked) + .build(); eip1559Transactions = new SettingsItemView.Builder(this) - .withType(SettingsItemView.Type.TOGGLE) - .withIcon(R.drawable.ic_icons_settings_1559) - .withTitle(R.string.experimental_1559) -// .withSubtitle(R.string.experimental_1559_tx_sub) - .withListener(this::on1559TransactionsClicked) - .build(); + .withType(SettingsItemView.Type.TOGGLE) + .withIcon(R.drawable.ic_icons_settings_1559) + .withTitle(R.string.experimental_1559) + .withListener(this::on1559TransactionsClicked) + .build(); analytics = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_analytics) - .withTitle(R.string.settings_title_analytics) - .withListener(this::onAnalyticsClicked) - .build(); + .withIcon(R.drawable.ic_settings_analytics) + .withTitle(R.string.settings_title_analytics) + .withListener(this::onAnalyticsClicked) + .build(); crashReporting = new SettingsItemView.Builder(this) - .withIcon(R.drawable.ic_settings_crash_reporting) - .withTitle(R.string.settings_title_crash_reporting) - .withListener(this::onCrashReportingClicked) - .build(); + .withIcon(R.drawable.ic_settings_crash_reporting) + .withTitle(R.string.settings_title_crash_reporting) + .withListener(this::onCrashReportingClicked) + .build(); developerOverride = new SettingsItemView.Builder(this) .withType(SettingsItemView.Type.TOGGLE) @@ -155,6 +162,7 @@ private void initializeSettings() fullScreenSettings.setToggleState(viewModel.getFullScreenState()); eip1559Transactions.setToggleState(viewModel.get1559TransactionsState()); developerOverride.setToggleState(viewModel.getDeveloperOverrideState()); + tokenScriptViewer.setToggleState(viewModel.getTokenScriptViewerState()); } private void onDeveloperOverride() @@ -172,6 +180,11 @@ private void on1559TransactionsClicked() viewModel.toggle1559Transactions(eip1559Transactions.getToggleState()); } + private void onUseTokenScriptViewer() + { + viewModel.toggleUseViewer(tokenScriptViewer.getToggleState()); + } + private void addSettingsToLayout() { LinearLayout advancedSettingsLayout = findViewById(R.id.layout); @@ -186,6 +199,7 @@ private void addSettingsToLayout() advancedSettingsLayout.addView(fullScreenSettings); advancedSettingsLayout.addView(refreshTokenDatabase); advancedSettingsLayout.addView(eip1559Transactions); + advancedSettingsLayout.addView(tokenScriptViewer); advancedSettingsLayout.addView(analytics); advancedSettingsLayout.addView(crashReporting); advancedSettingsLayout.addView(developerOverride); @@ -204,25 +218,25 @@ private void onConsoleClicked() private void onClearBrowserCacheClicked() { Single.fromCallable(() -> - { - WebView webView = new WebView(this); - webView.clearCache(true); - webView.clearFormData(); - webView.clearHistory(); - webView.clearSslPreferences(); - CookieManager cookieManager = CookieManager.getInstance(); - cookieManager.removeAllCookies(null); - WebStorage.getInstance().deleteAllData(); - viewModel.blankFilterSettings(); - Glide.get(this).clearDiskCache(); - return 1; - }).subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(v -> - { - Toast.makeText(this, getString(R.string.toast_browser_cache_cleared), Toast.LENGTH_SHORT).show(); - finish(); - }).isDisposed(); + { + WebView webView = new WebView(this); + webView.clearCache(true); + webView.clearFormData(); + webView.clearHistory(); + webView.clearSslPreferences(); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.removeAllCookies(null); + WebStorage.getInstance().deleteAllData(); + viewModel.blankFilterSettings(); + Glide.get(this).clearDiskCache(); + return 1; + }).subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(v -> + { + Toast.makeText(this, getString(R.string.toast_browser_cache_cleared), Toast.LENGTH_SHORT).show(); + finish(); + }).isDisposed(); } private void onReloadTokenDataClicked() @@ -242,9 +256,9 @@ private void onReloadTokenDataClicked() viewModel.stopChainActivity(); showWaitDialog(); clearTokenCache = viewModel.resetTokenData() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(this::showResetResult); + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(this::showResetResult); viewModel.blankFilterSettings(); }); @@ -340,7 +354,7 @@ private void askWritePermission() private boolean checkWritePermission() { return ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) - == PackageManager.PERMISSION_GRANTED; + == PackageManager.PERMISSION_GRANTED; } @Override 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 fd6480a691..56f2ad7474 100644 --- a/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/NFTAssetDetailActivity.java @@ -114,8 +114,7 @@ public class NFTAssetDetailActivity extends BaseActivity implements StandardFunc private boolean triggeredReload; private long chainId; private Web3TokenView tokenScriptView; - private static final boolean FORCE_EMBEDDED_VIEWER = true; - private boolean useNativeTokenScript = false; + private boolean usingNativeTokenScript = false; @Override protected void onCreate(@Nullable Bundle savedInstanceState) @@ -291,7 +290,7 @@ private void handleShortCut(String walletAddress) token = viewModel.getTokensService().getToken(walletAddress, chainId, tokenAddress); if (token == null) { - ShortcutUtils.showConfirmationDialog(this, singletonList(tokenAddress), getString(R.string.remove_shortcut_while_token_not_found)); + ShortcutUtils.showConfirmationDialog(this, singletonList(tokenAddress), getString(R.string.remove_shortcut_while_token_not_found), null); } else { @@ -307,9 +306,10 @@ private void setup() setTitle(token.tokenInfo.name); updateDefaultTokenData(); - if (!NFTAssetDetailActivity.FORCE_EMBEDDED_VIEWER) { + if (!viewModel.getUseTSViewer()) + { TokenDefinition td = viewModel.getAssetDefinitionService().getAssetDefinition(this.token); - this.useNativeTokenScript = td.nameSpace != null; + this.usingNativeTokenScript = td.nameSpace != null; } if (asset != null && asset.isAttestation()) @@ -319,8 +319,10 @@ private void setup() else { viewModel.getAsset(token, tokenId); - if (this.useNativeTokenScript) + if (this.usingNativeTokenScript) + { viewModel.updateLocalAttributes(token, tokenId); //when complete calls displayTokenView + } } } @@ -352,8 +354,10 @@ private void newScriptFound(TokenDefinition td) setTitle(token.getTokenName(viewModel.getAssetDefinitionService(), 1)); - if (!NFTAssetDetailActivity.FORCE_EMBEDDED_VIEWER) - this.useNativeTokenScript = td.nameSpace != null; + if (!viewModel.getUseTSViewer()) + { + this.usingNativeTokenScript = td.nameSpace != null; + } //now re-load the verbs if already called. If wallet is null this won't complete setupFunctionBar(viewModel.getWallet()); @@ -362,10 +366,9 @@ private void newScriptFound(TokenDefinition td) { setupAttestation(td); } - else + else if (this.usingNativeTokenScript) { - if (this.useNativeTokenScript) - displayTokenView(td); + displayTokenView(td); } } else @@ -402,9 +405,12 @@ private void setupFunctionBar(Wallet wallet) { FunctionButtonBar functionBar = findViewById(R.id.layoutButtons); - if (this.useNativeTokenScript){ + if (this.usingNativeTokenScript) + { functionBar.setupFunctions(this, viewModel.getAssetDefinitionService(), token, null, Collections.singletonList(tokenId)); - } else { + } + else + { functionBar.setupFunctionsForJsViewer(this, R.string.title_tokenscript, this.token, Collections.singletonList(tokenId)); } diff --git a/app/src/main/java/com/alphawallet/app/ui/TokenScriptJsActivity.java b/app/src/main/java/com/alphawallet/app/ui/TokenScriptJsActivity.java index 112503d5d1..6dbefd2298 100644 --- a/app/src/main/java/com/alphawallet/app/ui/TokenScriptJsActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/TokenScriptJsActivity.java @@ -242,7 +242,7 @@ private void handleShortCut(String walletAddress) token = viewModel.getTokenService().getToken(walletAddress, chainId, tokenAddress); if (token == null) { - ShortcutUtils.showConfirmationDialog(this, singletonList(tokenAddress), getString(R.string.remove_shortcut_while_token_not_found)); + ShortcutUtils.showConfirmationDialog(this, singletonList(tokenAddress), getString(R.string.remove_shortcut_while_token_not_found), null); } else { diff --git a/app/src/main/java/com/alphawallet/app/ui/TransferNFTActivity.java b/app/src/main/java/com/alphawallet/app/ui/TransferNFTActivity.java index 3038881dac..2dcb07bb12 100644 --- a/app/src/main/java/com/alphawallet/app/ui/TransferNFTActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/TransferNFTActivity.java @@ -146,16 +146,19 @@ protected void onCreate(@Nullable Bundle savedInstanceState) functionBar.revealButtons(); setupScreen(); - - confirmRemoveShortcuts(assetSelection, token); } - private void confirmRemoveShortcuts(ArrayList> tokenIdList, Token token) + private boolean confirmRemoveShortcuts(ArrayList> tokenIdList, Token token) { List shortcutIds = ShortcutUtils.getShortcutIds(getApplicationContext(), token, tokenIdList); if (!shortcutIds.isEmpty()) { - ShortcutUtils.showConfirmationDialog(this, shortcutIds, getString(R.string.remove_shortcut_reminder)); + ShortcutUtils.showConfirmationDialog(this, shortcutIds, getString(R.string.remove_shortcut_reminder), this); + return true; + } + else + { + return false; } } @@ -334,8 +337,11 @@ public void addressReady(String address, String ensName) @Override public void showTransferToken(List selection) { - KeyboardUtils.hideKeyboard(getCurrentFocus()); - addressInput.getAddress(); + if (!confirmRemoveShortcuts(assetSelection, token)) + { + KeyboardUtils.hideKeyboard(getCurrentFocus()); + addressInput.getAddress(); + } } private void calculateTransactionCost() @@ -381,7 +387,6 @@ private void calculateEstimateDialog() */ private void checkConfirm(GasEstimate estimate, final byte[] transactionBytes, final String txSendAddress, final String resolvedAddress) { - Web3Transaction w3tx = new Web3Transaction( new Address(txSendAddress), new Address(token.getAddress()), diff --git a/app/src/main/java/com/alphawallet/app/ui/widget/entity/NFTAttributeLayout.java b/app/src/main/java/com/alphawallet/app/ui/widget/entity/NFTAttributeLayout.java index 258cc2eebc..b12093a588 100644 --- a/app/src/main/java/com/alphawallet/app/ui/widget/entity/NFTAttributeLayout.java +++ b/app/src/main/java/com/alphawallet/app/ui/widget/entity/NFTAttributeLayout.java @@ -1,6 +1,7 @@ package com.alphawallet.app.ui.widget.entity; import android.content.Context; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; @@ -64,7 +65,7 @@ public void bindTSAttributes(List attrs) private void setAttributeLabel(String tokenName, int size) { - if (size > 0 && tokenName.equalsIgnoreCase("cryptokitties")) + if (size > 0 && !TextUtils.isEmpty(tokenName) && tokenName.equalsIgnoreCase("cryptokitties")) { labelAttributes.setTitle(getContext().getString(R.string.label_cattributes)); labelAttributes.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/alphawallet/app/util/ShortcutUtils.java b/app/src/main/java/com/alphawallet/app/util/ShortcutUtils.java index 2227dcd21e..51ee3b5bd8 100644 --- a/app/src/main/java/com/alphawallet/app/util/ShortcutUtils.java +++ b/app/src/main/java/com/alphawallet/app/util/ShortcutUtils.java @@ -10,6 +10,7 @@ import androidx.core.graphics.drawable.IconCompat; import com.alphawallet.app.R; +import com.alphawallet.app.entity.StandardFunctionInterface; import com.alphawallet.app.entity.nftassets.NFTAsset; import com.alphawallet.app.entity.tokens.Token; import com.alphawallet.app.repository.EthereumNetworkRepository; @@ -59,7 +60,7 @@ public static ArrayList getShortcutIds(Context context, Token token, Lis return ids; } - public static void showConfirmationDialog(Activity activity, List shortcutIds, String message) + public static void showConfirmationDialog(Activity activity, List shortcutIds, String message, StandardFunctionInterface callback) { AWalletAlertDialog confirmationDialog = new AWalletAlertDialog(activity); confirmationDialog.setCancelable(false); @@ -68,7 +69,7 @@ public static void showConfirmationDialog(Activity activity, List shortc confirmationDialog.setButton(R.string.yes_continue, v -> { ShortcutManagerCompat.removeDynamicShortcuts(activity, shortcutIds); confirmationDialog.dismiss(); - activity.finish(); + callback.showTransferToken(new ArrayList<>()); }); confirmationDialog.setSecondaryButtonText(R.string.dialog_cancel_back); confirmationDialog.setSecondaryButtonListener(v -> { diff --git a/app/src/main/java/com/alphawallet/app/viewmodel/AdvancedSettingsViewModel.java b/app/src/main/java/com/alphawallet/app/viewmodel/AdvancedSettingsViewModel.java index 5ac7cea64f..f30c994d8c 100644 --- a/app/src/main/java/com/alphawallet/app/viewmodel/AdvancedSettingsViewModel.java +++ b/app/src/main/java/com/alphawallet/app/viewmodel/AdvancedSettingsViewModel.java @@ -84,4 +84,14 @@ public void stopChainActivity() { transactionsService.stopActivity(); } + + public void toggleUseViewer(boolean state) + { + preferenceRepository.setUseTSViewer(state); + } + + public boolean getTokenScriptViewerState() + { + return preferenceRepository.getUseTSViewer(); + } } 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 9cda86cbce..d4c877daa8 100644 --- a/app/src/main/java/com/alphawallet/app/viewmodel/TokenFunctionViewModel.java +++ b/app/src/main/java/com/alphawallet/app/viewmodel/TokenFunctionViewModel.java @@ -34,6 +34,7 @@ import com.alphawallet.app.interact.FetchTransactionsInteract; import com.alphawallet.app.interact.GenericWalletInteract; import com.alphawallet.app.repository.EthereumNetworkRepositoryType; +import com.alphawallet.app.repository.PreferenceRepositoryType; import com.alphawallet.app.service.AnalyticsServiceType; import com.alphawallet.app.service.AssetDefinitionService; import com.alphawallet.app.service.GasService; @@ -104,11 +105,11 @@ public class TokenFunctionViewModel extends BaseViewModel implements Transaction private final CreateTransactionInteract createTransactionInteract; private final GasService gasService; private final TokensService tokensService; - private final EthereumNetworkRepositoryType ethereumNetworkRepository; private final KeyService keyService; private final GenericWalletInteract genericWalletInteract; private final OpenSeaService openseaService; private final FetchTransactionsInteract fetchTransactionsInteract; + private final PreferenceRepositoryType preferences; private final MutableLiveData insufficientFunds = new MutableLiveData<>(); private final MutableLiveData invalidAddress = new MutableLiveData<>(); private final MutableLiveData sig = new MutableLiveData<>(); @@ -144,23 +145,23 @@ public class TokenFunctionViewModel extends BaseViewModel implements Transaction CreateTransactionInteract createTransactionInteract, GasService gasService, TokensService tokensService, - EthereumNetworkRepositoryType ethereumNetworkRepository, KeyService keyService, GenericWalletInteract genericWalletInteract, OpenSeaService openseaService, FetchTransactionsInteract fetchTransactionsInteract, - AnalyticsServiceType analyticsService) + AnalyticsServiceType analyticsService, + PreferenceRepositoryType prefs) { this.assetDefinitionService = assetDefinitionService; this.createTransactionInteract = createTransactionInteract; this.gasService = gasService; this.tokensService = tokensService; - this.ethereumNetworkRepository = ethereumNetworkRepository; this.keyService = keyService; this.genericWalletInteract = genericWalletInteract; this.openseaService = openseaService; this.fetchTransactionsInteract = fetchTransactionsInteract; setAnalyticsService(analyticsService); + this.preferences = prefs; } public AssetDefinitionService getAssetDefinitionService() @@ -1034,4 +1035,9 @@ public GasService getGasService() { return gasService; } + + public boolean getUseTSViewer() + { + return preferences.getUseTSViewer(); + } } diff --git a/app/src/main/java/com/alphawallet/app/widget/FunctionButtonBar.java b/app/src/main/java/com/alphawallet/app/widget/FunctionButtonBar.java index 8f4b3a5cbe..0435d46079 100644 --- a/app/src/main/java/com/alphawallet/app/widget/FunctionButtonBar.java +++ b/app/src/main/java/com/alphawallet/app/widget/FunctionButtonBar.java @@ -165,7 +165,7 @@ public void setupFunctions(StandardFunctionInterface functionInterface, AssetDef callStandardFunctions = functionInterface; adapter = adp; selection.clear(); - if (tokenIds != null) selection.addAll(tokenIds); + addTokenSelection(tokenIds); resetButtonCount(); this.token = token; functions = assetSvs.getTokenFunctionMap(token); @@ -178,7 +178,7 @@ public void setupFunctionsForJsViewer(StandardFunctionInterface functionInterfac callStandardFunctions = functionInterface; adapter = null; functions = null; - if (tokenIds != null) selection.addAll(tokenIds); + addTokenSelection(tokenIds); resetButtonCount(); //buttonCount = 2; this.token = token; @@ -195,7 +195,7 @@ public void setupAttestationFunctions(StandardFunctionInterface functionInterfac callStandardFunctions = functionInterface; adapter = adp; selection.clear(); - selection.addAll(tokenIds); + addTokenSelection(tokenIds); resetButtonCount(); this.token = token; functions = assetSvs.getAttestationFunctionMap(token); @@ -253,6 +253,20 @@ private void onMoreButtonClick() bottomSheet.show(); } + private void addTokenSelection(List tokenIds) + { + if (tokenIds != null) + { + for (BigInteger tokenId : tokenIds) + { + if (!selection.contains(tokenId)) + { + selection.add(tokenId); + } + } + } + } + private void handleAction(ItemClick action) { if (functions != null && functions.containsKey(action.buttonText)) @@ -410,7 +424,7 @@ public void onTokenClick(View view, Token token, List tokenIds, bool if (maxSelect <= 1) { selection.clear(); - selection.addAll(tokenIds); + addTokenSelection(tokenIds); if (adapter != null) adapter.setRadioButtons(true); } } @@ -422,7 +436,7 @@ public void onLongTokenClick(View view, Token token, List tokenIds) if (adapter != null) adapter.setRadioButtons(true); selection.clear(); - selection.addAll(tokenIds); + addTokenSelection(tokenIds); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); if (vb != null && vb.hasVibrator()) { diff --git a/app/src/main/res/drawable/ic_tokenscript.xml b/app/src/main/res/drawable/ic_tokenscript.xml new file mode 100644 index 0000000000..d2b8a37208 --- /dev/null +++ b/app/src/main/res/drawable/ic_tokenscript.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 82505209c0..b26f4e91f0 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -996,4 +996,5 @@ Anulación del Desarrollador Es posible que esté a punto de firmar una transacción sin saberlo, lo que podría vaciar sus fondos. Es posible que desee firmar el código de bytes como desarrollador y puede anular esta advertencia si configura el modo de desarrollador en la configuración avanzada. Constructor + Visor de TokenScript diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 1278eaed8a..e6bdcd664e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1010,4 +1010,5 @@ Remplacement du Développeur Vous êtes peut-être sur le point de signer sans le savoir une transaction, ce qui pourrait vider vos fonds. Vous souhaiterez peut-être signer le bytecode en tant que développeur et vous pouvez ignorer cet avertissement si vous définissez le mode développeur dans les paramètres avancés. Constructor + Visionneuse TokenScript diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index bee1732771..b3ff80df53 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -1001,4 +1001,5 @@ Penggantian Pengembang Anda mungkin tanpa sadar menandatangani transaksi, yang dapat mengosongkan dana Anda. Anda mungkin ingin menandatangani bytecode sebagai pengembang, dan Anda dapat mengabaikan peringatan ini jika Anda menyetel mode pengembang di Setelan lanjutan. Constructor + Penampil TokenScript diff --git a/app/src/main/res/values-my/strings.xml b/app/src/main/res/values-my/strings.xml index 4f342d8668..0be4e4fedd 100644 --- a/app/src/main/res/values-my/strings.xml +++ b/app/src/main/res/values-my/strings.xml @@ -1031,4 +1031,5 @@ Developer Override သင့်ငွေများကို အချည်းနှီးဖြစ်စေနိုင်သည့် ငွေပေးငွေယူတစ်ခုအား သင်မသိလိုက်ဘဲ လက်မှတ်ထိုးပါတော့မည်။ သင်သည် ဆော့ဖ်ဝဲအင်ဂျင်နီယာတစ်ဦးအနေဖြင့် bytecode ကို လက်မှတ်ထိုးလိုနိုင်ပြီး၊ Advanced ဆက်တင်များတွင် developer မုဒ်ကို သင်သတ်မှတ်ပါက ဤသတိပေးချက်ကို အစားထိုးနိုင်ပါသည်။ Constructor + TokenScript ကြည့်ရှုသူ diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 6efc66ab3b..bf006616dd 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1010,4 +1010,5 @@ Ghi đè Nhà phát triển Bạn có thể sắp vô tình ký một giao dịch, điều này có thể khiến tiền của bạn bị rỗng. Bạn có thể muốn ký mã byte với tư cách là nhà phát triển và bạn có thể ghi đè cảnh báo này nếu bạn đặt chế độ nhà phát triển trong cài đặt Nâng cao. Constructor + Trình xem TokenScript diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index e384267605..d2231121d8 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -997,4 +997,5 @@ 开发者覆盖 您可能会在不知情的情况下签署一项交易,这可能会清空您的资金。 您可能希望以开发人员的身份对字节码进行签名,如果您在高级设置中设置开发人员模式,则可以覆盖此警告。 Constructor + 使用 TokenScript 查看器 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 23ff05a6d3..8874345072 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1073,4 +1073,5 @@ Developer Override You might be about to unknowingly sign a transaction, which could empty your funds. You may want to sign bytecode as a developer, and you can override this warning if you set developer mode in Advanced settings. Constructor + Use TokenScript Viewer