# Conflicts:
#	app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java
#	app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java
master
Javier Varona 2018-03-18 22:35:53 -04:00
commit 4d10fc984e
9 changed files with 142 additions and 40 deletions

View File

@ -1,7 +1,6 @@
package cy.agorise.crystalwallet.activities;
import android.app.ActivityOptions;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.content.res.Configuration;
@ -27,7 +26,6 @@ import android.widget.ImageView;
import java.util.List;
import java.util.Locale;
import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@ -38,7 +36,6 @@ import cy.agorise.crystalwallet.fragments.ReceiveTransactionFragment;
import cy.agorise.crystalwallet.fragments.SendTransactionFragment;
import cy.agorise.crystalwallet.fragments.TransactionsFragment;
import de.hdodenhof.circleimageview.CircleImageView;
import cy.agorise.crystalwallet.models.CryptoNetBalance;
import cy.agorise.crystalwallet.viewmodels.CryptoNetBalanceListViewModel;
/**
@ -51,9 +48,6 @@ public class BoardActivity extends AppCompatActivity {
@BindView(R.id.pager)
public ViewPager mPager;
//@BindView(R.id.btnGeneralSettings)
//public ImageButton btnGeneralSettings;
@BindView(R.id.fabSend)
public FloatingActionButton fabSend;
@ -184,7 +178,7 @@ public class BoardActivity extends AppCompatActivity {
});
}
/*
/**
* dispatch the user to the accounts fragment
*/
@OnClick(R.id.toolbar_user_img)
@ -223,7 +217,7 @@ public class BoardActivity extends AppCompatActivity {
}
ft.addToBackStack(null);
long receiveCryptoNetAccountId = -1;
long receiveCryptoNetAccountId;
if (this.cryptoNetAccountId != -1){
receiveCryptoNetAccountId = this.cryptoNetAccountId;
} else {
@ -247,7 +241,7 @@ public class BoardActivity extends AppCompatActivity {
}
ft.addToBackStack(null);
long sendCryptoNetAccountId = -1;
long sendCryptoNetAccountId;
if (this.cryptoNetAccountId != -1){
sendCryptoNetAccountId = this.cryptoNetAccountId;
} else {

View File

@ -8,6 +8,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import cy.agorise.crystalwallet.application.constant.BitsharesConstant;
import cy.agorise.crystalwallet.dao.BitsharesAssetDao;
import cy.agorise.crystalwallet.dao.CryptoCoinBalanceDao;
import cy.agorise.crystalwallet.dao.CryptoCurrencyDao;
@ -58,10 +59,7 @@ import cy.agorise.graphenej.operations.TransferOperation;
public abstract class GrapheneApiGenerator {
//TODO network connections
//TODO make to work with all Graphene type, not only bitshares
public static String faucetUrl = "http://185.208.208.147:5010";
private static String equivalentUrl = "wss://bitshares.openledger.info/ws";
// The message broker for bitshares
private static SubscriptionMessagesHub bitsharesSubscriptionHub = new SubscriptionMessagesHub("", "", true, new NodeErrorListener() {
@ -570,7 +568,7 @@ public abstract class GrapheneApiGenerator {
public void onError(BaseResponse.Error error) {
request.getListener().fail(request.getId());
}
}),equivalentUrl);
}), BitsharesConstant.EQUIVALENT_URL); //todo change equivalent url for current server url
thread.start();
}
@ -586,7 +584,7 @@ public abstract class GrapheneApiGenerator {
for(BitsharesAsset quoteAsset : quoteAssets){
WebSocketThread thread = new WebSocketThread(new GetLimitOrders(baseAsset.getBitsharesId(),
quoteAsset.getBitsharesId(), 10, new EquivalentValueListener(baseAsset,
quoteAsset,context)),equivalentUrl);
quoteAsset,context)), BitsharesConstant.EQUIVALENT_URL); //todo change equivalent url for current server url
thread.start();
}
}
@ -666,7 +664,7 @@ public abstract class GrapheneApiGenerator {
Converter converter = new Converter();
order.getSellPrice().base.getAsset().setPrecision(baseAsset.getPrecision());
order.getSellPrice().quote.getAsset().setPrecision(quoteAsset.getPrecision());
double equiValue = converter.getConversionRate(order.getSellPrice(), Converter.QUOTE_TO_BASE);
double equiValue = converter.getConversionRate(order.getSellPrice(), Converter.BASE_TO_QUOTE);
CryptoCurrencyEquivalence equivalence = new CryptoCurrencyEquivalence(baseAsset.getId(), quoteAsset.getId(), (int) (Math.pow(10, baseAsset.getPrecision()) * equiValue), new Date());
CrystalDatabase.getAppDatabase(context).cryptoCurrencyEquivalenceDao().insertCryptoCurrencyEquivalence(equivalence);
break;

View File

@ -0,0 +1,87 @@
package cy.agorise.crystalwallet.application.constant;
import android.content.Context;
import java.util.HashSet;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.BitsharesAsset;
import cy.agorise.crystalwallet.models.BitsharesAssetInfo;
import cy.agorise.crystalwallet.network.CryptoNetManager;
/**
* Created by henry on 15/3/2018.
*/
public abstract class BitsharesConstant {
public final static String BITSHARES_URL[] =
{
"wss://de.palmpay.io/ws", // Custom node
"wss://bitshares.nu/ws",
"wss://dexnode.net/ws", // Dallas, USA
"wss://bitshares.crypto.fans/ws", // Munich, Germany
"wss://bitshares.openledger.info/ws", // Openledger node
"ws://185.208.208.147:8090" // Custom node
};
public final static String BITSHARES_TESTNET_URL[] =
{
"http://185.208.208.147:11012", // Openledger node
};
public final static String FAUCET_URL = "http://185.208.208.147:5010";
public final static String EQUIVALENT_URL = "wss://bitshares.openledger.info/ws";
public final static BitsharesAsset[] SMARTCOINS = new BitsharesAsset[]{
new BitsharesAsset("USD",4,"1.3.121",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("EUR",4,"1.3.120",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("CNY",4,"1.3.113",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("RUBLE",5,"1.3.1325",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("AUD",4,"1.3.117",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("SILVER",4,"1.3.105",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("GOLD",6,"1.3.106",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("JPY",2,"1.3.119",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("CAD",4,"1.3.115",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("MXN",4,"1.3.114",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("GBP",4,"1.3.118",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("ARS",4,"1.3.1017",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("KRW",4,"1.3.102",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("CHF",4,"1.3.116",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("SEK",4,"1.3.111",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("RUB",4,"1.3.110",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("NZD",4,"1.3.112",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("XCD",4,"1.3.2650",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("TRY",4,"1.3.107",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("HKD",4,"1.3.109",BitsharesAsset.Type.SMART_COIN),
new BitsharesAsset("SGD",4,"1.3.108",BitsharesAsset.Type.SMART_COIN)
};
public static void addMainNetUrls(){
for(String url : BITSHARES_URL){
CryptoNetManager.addCryptoNetURL(CryptoNet.BITSHARES,url);
}
}
public static void addTestNetUrls(){
for(String url : BITSHARES_TESTNET_URL){
CryptoNetManager.addCryptoNetURL(CryptoNet.BITSHARES,url);
}
}
public static void addSmartCoins(Context context){
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
for(BitsharesAsset smartcoin : SMARTCOINS){
if(db.cryptoCurrencyDao().getByName(smartcoin.getName())== null){
db.cryptoCurrencyDao().insertCryptoCurrency(smartcoin);
}
long idCurrency = db.cryptoCurrencyDao().getByName(smartcoin.getName()).getId();
BitsharesAssetInfo info = new BitsharesAssetInfo(smartcoin);
info.setCryptoCurrencyId(idCurrency);
db.bitsharesAssetDao().insertBitsharesAssetInfo(info);
}
}
}

View File

@ -6,7 +6,9 @@ import android.arch.lifecycle.ViewModelProviders;
import android.arch.paging.PagedList;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -25,6 +27,10 @@ public class TransactionsFragment extends Fragment {
@BindView(R.id.vTransactionListView)
TransactionListView transactionListView;
RecyclerView balanceRecyclerView;
FloatingActionButton fabSend;
FloatingActionButton fabReceive;
public TransactionsFragment() {
// Required empty public constructor
}
@ -45,8 +51,37 @@ public class TransactionsFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_transactions, container, false);
ButterKnife.bind(this, v);
View view = inflater.inflate(R.layout.fragment_transactions, container, false);
ButterKnife.bind(this, view);
// Gets the Balance RecyclerView
balanceRecyclerView = view.findViewById(R.id.transactionListView);
fabSend = getActivity().findViewById(R.id.fabSend);
fabReceive = getActivity().findViewById(R.id.fabReceive);
// TODO move this listener to the activity, to make this fragment reusable
// Adds listener to the RecyclerView to show and hide buttons at the bottom of the screen
balanceRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx,int dy){
super.onScrolled(recyclerView, dx, dy);
// Scroll Down
if( dy >0 ) {
if( fabSend.isShown() )
fabSend.hide();
if( fabReceive.isShown() )
fabReceive.hide();
}
// Scroll Up
else if( dy <0 ) {
if( !fabSend.isShown() )
fabSend.show();
if( !fabReceive.isShown() )
fabReceive.show();
}
}
});
TransactionListViewModel transactionListViewModel = ViewModelProviders.of(this).get(TransactionListViewModel.class);
LiveData<PagedList<CryptoCoinTransaction>> transactionsLiveData = transactionListViewModel.getTransactionList();
@ -59,6 +94,6 @@ public class TransactionsFragment extends Fragment {
}
});
return v;
return view;
}
}

View File

@ -17,6 +17,7 @@ import cy.agorise.crystalwallet.apigenerator.ApiRequest;
import cy.agorise.crystalwallet.apigenerator.ApiRequestListener;
import cy.agorise.crystalwallet.apigenerator.BitsharesFaucetApiGenerator;
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
import cy.agorise.crystalwallet.application.constant.BitsharesConstant;
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetEquivalentRequest;
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequest;
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestsListener;
@ -103,7 +104,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
new Address(ECKey.fromPublicOnly(grapheneAccount.getOwnerKey(context).getPubKey())).toString(),
new Address(ECKey.fromPublicOnly(grapheneAccount.getActiveKey(context).getPubKey())).toString(),
new Address(ECKey.fromPublicOnly(grapheneAccount.getMemoKey(context).getPubKey())).toString(),
GrapheneApiGenerator.faucetUrl, creationRequest);
BitsharesConstant.FAUCET_URL, creationRequest);
}
}

View File

@ -32,7 +32,7 @@ public class EquivalencesThread extends Thread{
try {
GrapheneApiGenerator.getEquivalenValue(fromAsset, bitsharesAssets, this.service);
Log.i("Equivalences Thread", "In loop");
Thread.sleep(1000);
Thread.sleep(60000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

View File

@ -85,7 +85,7 @@ public class TransactionListView extends RelativeLayout {
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
this.listView.setLayoutManager(linearLayoutManager);
//Prevents the list to start again when scrolling to the end
this.listView.setNestedScrollingEnabled(false);
// this.listView.setNestedScrollingEnabled(false);
/*this.listView.addOnScrollListener(new RecyclerView.OnScrollListener() {

View File

@ -162,7 +162,7 @@
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/colorPrimaryDark"
app:backgroundTint="@color/colorPrimary"
app:srcCompat="@drawable/ic_person_add" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -1,25 +1,12 @@
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="cy.agorise.crystalwallet.fragments.TransactionsFragment">
<RelativeLayout
<cy.agorise.crystalwallet.views.TransactionListView
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:id="@+id/vTransactionListView" />
<!--<TextView
android:id="@+id/tvTransactionSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android: />
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"></Spinner>
-->
<cy.agorise.crystalwallet.views.TransactionListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/vTransactionListView" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>