Skip to content

Commit

Permalink
merge_with_master
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillVolkov committed Nov 30, 2017
2 parents d9fca35 + 94ed1ad commit 4453be1
Show file tree
Hide file tree
Showing 86 changed files with 2,197 additions and 559 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ app/Configs/qa.properties
app/src/dev/google-services.json
app/src/qa/google-services.json
/jks

14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ Designed with stability, modularity and interoperability in mind, Qtum is the fo
1)Clone project<br/>
2)Open with Android Studio

<b>Build Types</b><br/>
Project have several build types:<br/>
![Screenshot](http://www.picshare.ru/uploads/171130/vGf7v0LPBX.jpg)<br/>
You can use ONLY production(debug/release) buildTypes.

<b>Setting Custom Network Parameters</b><br/>
```java
org.qtum.wallet.utils.CurrentNetParams
public static String getUrl(){
package org.qtum.wallet.utils.CurrentNetParams

public static NetworkParameters getNetParams() {
return QtumMainNetParams.get(); // or QtumTestNetParams.get();
}

public static String getUrl() {
return "http://127.0.0.1:5555/";
}
```
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:theme="@style/AppTheme"
tools:targetApi="n">
<provider
android:name="org.qtum.wallet.utils.GenericFileProvider"
android:name="android.support.v4.content.FileProvider"
android:authorities="org.qtum.wallet.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/org/qtum/wallet/QtumApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void onCreate() {
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
BuildConfig
}

private int getCodeVersion() throws PackageManager.NameNotFoundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.android.gms.wearable.WearableListenerService;
import com.google.gson.Gson;

import org.qtum.wallet.dataprovider.rest_api.QtumService;
import org.qtum.wallet.dataprovider.services.update_service.UpdateService;
import org.qtum.wallet.dataprovider.services.update_service.WatchUpdateService;
import org.qtum.wallet.dataprovider.services.update_service.listeners.BalanceChangeListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.qtum.wallet.dataprovider.medium_rss_feed;
package org.qtum.wallet.dataprovider.rest_api.medium;

import org.qtum.wallet.model.news.RssFeed;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.qtum.wallet.dataprovider.medium_rss_feed;
package org.qtum.wallet.dataprovider.rest_api.medium;

import org.qtum.wallet.model.news.RssFeed;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.qtum.wallet.dataprovider.rest_api;
package org.qtum.wallet.dataprovider.rest_api.qtum;

import org.qtum.wallet.model.gson.BlockChainInfo;

import org.qtum.wallet.model.gson.CallSmartContractRequest;
import org.qtum.wallet.model.gson.ContractParams;
import org.qtum.wallet.model.gson.DGPInfo;
import org.qtum.wallet.model.gson.FeePerKb;
import org.qtum.wallet.model.gson.QstoreContractType;
Expand Down Expand Up @@ -94,4 +95,7 @@ interface QtumRestService {

@GET("/blockchain/dgpinfo")
Observable<DGPInfo> getDGPInfo();

@GET("/contracts/{addressContract}/params?keys=symbol,decimals,name,totalSupply")
Observable<ContractParams> getContractParams(@Path("addressContract") String addressContract);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.qtum.wallet.dataprovider.rest_api;
package org.qtum.wallet.dataprovider.rest_api.qtum;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.qtum.wallet.model.gson.BlockChainInfo;

import org.qtum.wallet.model.gson.CallSmartContractRequest;
import org.qtum.wallet.model.gson.ContractParams;
import org.qtum.wallet.model.gson.DGPInfo;
import org.qtum.wallet.model.gson.FeePerKb;
import org.qtum.wallet.model.gson.QstoreContractType;
Expand Down Expand Up @@ -210,4 +211,9 @@ public Observable<QstoreByteCodeResponse> getByteCode(String contractId, String
public Observable<List<QstoreContractType>> getContractTypes() {
return mServiceApi.getContractTypes();
}

public Observable<ContractParams> getContractParams(String contractAddress) {
return mServiceApi.getContractParams(contractAddress);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
import org.qtum.wallet.QtumApplication;
import org.qtum.wallet.dataprovider.firebase.FirebaseSharedPreferences;
import org.qtum.wallet.dataprovider.firebase.listeners.FireBaseTokenRefreshListener;
import org.qtum.wallet.dataprovider.rest_api.QtumService;
import org.qtum.wallet.dataprovider.rest_api.qtum.QtumService;
import org.qtum.wallet.dataprovider.services.update_service.listeners.BalanceChangeListener;
import org.qtum.wallet.datastorage.QStoreStorage;
import org.qtum.wallet.datastorage.TinyDB;
import org.qtum.wallet.model.gson.history.HistoryResponse;
import org.qtum.wallet.model.gson.history.Vin;
import org.qtum.wallet.model.gson.history.Vout;
import org.qtum.wallet.model.gson.qstore.PurchaseItem;
import org.qtum.wallet.model.gson.token_balance.Balance;
import org.qtum.wallet.model.gson.token_balance.TokenBalance;
import org.qtum.wallet.ui.activity.main_activity.MainActivity;
import org.qtum.wallet.utils.BoughtContractBuilder;
Expand Down Expand Up @@ -92,7 +93,7 @@ public class UpdateService extends Service implements GoogleApiClient.Connection
private NotificationManager notificationManager;
private TransactionListener mTransactionListener = null;
private List<BalanceChangeListener> mBalanceChangeListeners = new ArrayList<>();
private HashMap<String, TokenBalanceChangeListener> mStringTokenBalanceChangeListenerHashMap = new HashMap<>();
private HashMap<String, List<TokenBalanceChangeListener>> mStringTokenBalanceChangeListenerHashMap = new HashMap<>();
private HashMap<String, TokenBalance> mAllTokenBalanceList = new HashMap<>();
private TokenListener mTokenListener;
private ContractPurchaseListener mContractPurchaseListener;
Expand Down Expand Up @@ -407,14 +408,22 @@ private BigDecimal calculateVout(History history, List<String> addresses) {
private void updateTokenBalance(TokenBalance tokenBalance) {
TokenBalance tokenBalanceFromList = mAllTokenBalanceList.get(tokenBalance.getContractAddress());
if (tokenBalanceFromList != null) {
tokenBalanceFromList.setBalances(tokenBalance.getBalances());
for(Balance balance : tokenBalance.getBalances()) {
for (Balance balanceFromList : tokenBalanceFromList.getBalances()) {
if(balance.getAddress().equals(balanceFromList.getAddress())){
balanceFromList.setBalance(balance.getBalance());
}
}
}
} else {
mAllTokenBalanceList.put(tokenBalance.getContractAddress(), tokenBalance);
}

TokenBalanceChangeListener tokenBalanceChangeListener = mStringTokenBalanceChangeListenerHashMap.get(tokenBalance.getContractAddress());
if (tokenBalanceChangeListener != null) {
tokenBalanceChangeListener.onBalanceChange(tokenBalance);
List<TokenBalanceChangeListener> tokenBalanceChangeListeners = mStringTokenBalanceChangeListenerHashMap.get(tokenBalance.getContractAddress());
if(tokenBalanceChangeListeners!=null) {
for (TokenBalanceChangeListener tokenBalanceChangeListener : tokenBalanceChangeListeners) {
tokenBalanceChangeListener.onBalanceChange(mAllTokenBalanceList.get(tokenBalance.getContractAddress()));
}
}
}

Expand Down Expand Up @@ -679,7 +688,10 @@ public void removeContractPurchaseListener() {
}

public void addTokenBalanceChangeListener(String address, TokenBalanceChangeListener tokenBalanceChangeListener) {
mStringTokenBalanceChangeListenerHashMap.put(address, tokenBalanceChangeListener);
if(mStringTokenBalanceChangeListenerHashMap.get(address)==null){
mStringTokenBalanceChangeListenerHashMap.put(address, new ArrayList<TokenBalanceChangeListener>());
}
mStringTokenBalanceChangeListenerHashMap.get(address).add(tokenBalanceChangeListener);
TokenBalance tokenBalance = mAllTokenBalanceList.get(address);
if (tokenBalance != null) {
tokenBalanceChangeListener.onBalanceChange(tokenBalance);
Expand All @@ -690,8 +702,8 @@ public TokenBalance getTokenBalance(String address) {
return mAllTokenBalanceList.get(address);
}

public void removeTokenBalanceChangeListener(String address) {
mStringTokenBalanceChangeListenerHashMap.remove(address);
public void removeTokenBalanceChangeListener(String address, TokenBalanceChangeListener tokenBalanceChangeListener) {
mStringTokenBalanceChangeListenerHashMap.get(address).remove(tokenBalanceChangeListener);
}

public void removeBalanceChangeListener(BalanceChangeListener balanceChangeListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.json.JSONObject;
import org.qtum.wallet.dataprovider.firebase.FirebaseSharedPreferences;
import org.qtum.wallet.dataprovider.firebase.listeners.FireBaseTokenRefreshListener;
import org.qtum.wallet.dataprovider.rest_api.QtumService;
import org.qtum.wallet.dataprovider.rest_api.qtum.QtumService;
import org.qtum.wallet.dataprovider.services.update_service.listeners.BalanceChangeListener;
import org.qtum.wallet.model.gson.history.History;
import org.qtum.wallet.model.gson.history.HistoryResponse;
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/org/qtum/wallet/model/contract/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class Token extends Contract {
@SerializedName("decimal_units")
private Integer decimalUnits;

@SerializedName("name")
private String name;

public Token(String contractAddress, String templateUiid, Boolean hasBeenCreated, String date, String senderAddress, String contractName) {
super(contractAddress, templateUiid, hasBeenCreated, date, senderAddress, contractName);
this.mIsSubscribe = true;
Expand Down Expand Up @@ -100,4 +103,12 @@ public BigDecimal getTokenBalanceWithDecimalUnits() {
return mLastBalance.divide(new BigDecimal(10).pow((decimalUnits != null) ? decimalUnits.intValue() : 0), MathContext.DECIMAL128);
}

}
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}
54 changes: 54 additions & 0 deletions app/src/main/java/org/qtum/wallet/model/gson/ContractParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.qtum.wallet.model.gson;


import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class ContractParams {

@SerializedName("symbol")
@Expose
private String symbol;
@SerializedName("decimals")
@Expose
private String decimals;
@SerializedName("name")
@Expose
private String name;
@SerializedName("totalSupply")
@Expose
private String totalSupply;

public String getSymbol() {
return symbol;
}

public void setSymbol(String symbol) {
this.symbol = symbol;
}

public String getDecimals() {
return decimals;
}

public void setDecimals(String decimals) {
this.decimals = decimals;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getTotalSupply() {
return totalSupply;
}

public void setTotalSupply(String totalSupply) {
this.totalSupply = totalSupply;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import android.content.Context;

import org.qtum.wallet.dataprovider.rest_api.QtumService;
import org.qtum.wallet.dataprovider.rest_api.qtum.QtumService;
import org.qtum.wallet.datastorage.HistoryList;
import org.qtum.wallet.datastorage.KeyStorage;
import org.qtum.wallet.datastorage.QtumSharedPreference;
import org.qtum.wallet.datastorage.listeners.LanguageChangeListener;
import org.qtum.wallet.model.gson.DGPInfo;
import org.qtum.wallet.model.gson.FeePerKb;

import java.math.BigDecimal;

import rx.Observable;

class MainActivityInteractorImpl implements MainActivityInteractor {
Expand Down Expand Up @@ -73,6 +75,6 @@ public void setDGPInfo(DGPInfo dgpInfo) {
@Override
public void setFeePerKb(FeePerKb feePerKb) {
isFeePerkbLoaded = true;
QtumSharedPreference.getInstance().setFeePerKb(mContext, feePerKb.getFeePerKb().toPlainString());
QtumSharedPreference.getInstance().setFeePerKb(mContext, feePerKb.getFeePerKb().setScale(5, BigDecimal.ROUND_HALF_DOWN).toPlainString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public void onNext(File file) {
public void permissionGrantedForChooseShareMethod() {
if (mBackUpFile.exists()) {
String authority = "org.qtum.wallet.FileProvider";
getView()
.chooseShareMethod(
getView().chooseShareMethod(
FileProvider.getUriForFile(
getView().getContext(),
authority,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.content.Context;

import org.bitcoinj.script.Script;
import org.qtum.wallet.dataprovider.rest_api.QtumService;
import org.qtum.wallet.dataprovider.rest_api.qtum.QtumService;
import org.qtum.wallet.datastorage.KeyStorage;
import org.qtum.wallet.datastorage.QtumSharedPreference;
import org.qtum.wallet.datastorage.TinyDB;
Expand Down
Loading

0 comments on commit 4453be1

Please sign in to comment.