Repository: alphawallet/alpha-wallet-android
Issue: TokenScript cards should take the localised name defined in the TokenScript

At the moment it is taking the name from the smart contract, instead it should take the name defined in the tokenscript file and fallback to english if the user's language is not there. 

Useful for Devcon because we renamed the discovery card to devcon5 goodies but not a show stopper. 

Changed files:
app/src/main/java/com/alphawallet/app/entity/tokens/Token.java, app/src/main/java/com/alphawallet/app/entity/tokens/ERC721Token.java

diff --git a/app/src/main/java/com/alphawallet/app/entity/tokens/ERC721Token.java b/app/src/main/java/com/alphawallet/app/entity/tokens/ERC721Token.java
index 9ee45e25b..369746cb7 100644
--- a/app/src/main/java/com/alphawallet/app/entity/tokens/ERC721Token.java
+++ b/app/src/main/java/com/alphawallet/app/entity/tokens/ERC721Token.java
@@ -129,7 +129,7 @@ public class ERC721Token extends Token implements Parcelable
 
         holder.balanceEth.setVisibility(View.VISIBLE);
 
-        addTokenName(holder);
+        addTokenName(holder, definition);
     }
 
     @Override
diff --git a/app/src/main/java/com/alphawallet/app/entity/tokens/Token.java b/app/src/main/java/com/alphawallet/app/entity/tokens/Token.java
index 53c308e0c..05cba885c 100644
--- a/app/src/main/java/com/alphawallet/app/entity/tokens/Token.java
+++ b/app/src/main/java/com/alphawallet/app/entity/tokens/Token.java
@@ -216,6 +216,7 @@ public class Token implements Parcelable
     public String getAddress() {
         return tokenInfo.address;
     }
+
     public String getFullName()
     {
         if (isTerminated()) return SetupTokensInteract.EXPIRED_CONTRACT;
@@ -227,11 +228,14 @@ public class Token implements Parcelable
 
     public String getFullName(AssetDefinitionService assetDefinition, int count)
     {
-        String name = getFullName();
-        String tokenTypeName = assetDefinition.getTokenName(tokenInfo.chainId, tokenInfo.address, count);
-        if (name != null && tokenTypeName != null && !name.contains(tokenTypeName)) name = name + " " + tokenTypeName;
-
-        return name;
+        //override contract name with TS defined name
+        String name = assetDefinition.getTokenName(tokenInfo.chainId, tokenInfo.address, count);
+        if (name != null) {
+            String symbol = (tokenInfo.symbol == null || tokenInfo.symbol.length() == 0) ? "" : " (" + tokenInfo.symbol.toUpperCase() + ")";
+            return name + symbol;
+        } else {
+            return getFullName();
+        }
     }
 
     public void clickReact(BaseViewModel viewModel, Context context)
@@ -281,7 +285,7 @@ public class Token implements Parcelable
             holder.layoutValueDetails.setVisibility(View.GONE);
         }
 
-        addTokenName(holder);
+        addTokenName(holder, definition);
 
         //populate ticker if we have it
         if (ticker != null)
@@ -306,13 +310,13 @@ public class Token implements Parcelable
         holder.balanceEth.setVisibility(View.VISIBLE);
     }
 
-    void addTokenName(TokenHolder holder)
+    void addTokenName(TokenHolder holder, AssetDefinitionService definitionService)
     {
         String balance = holder.balanceEth.getText().toString();
         String symbolStr = tokenInfo.symbol != null ? tokenInfo.symbol.toUpperCase() : "";
         String nameTxt = TextUtils.isEmpty(tokenInfo.name)
                          ? symbolStr
-                         : getFullName();
+                         : getFullName(definitionService, getTicketCount());
 
         String composite = balance + " " + nameTxt;
         holder.balanceEth.setText(composite);