Merge pull request #4 from TanguyHerbron/FragmentRework
Fragment rework
This commit is contained in:
commit
0cd2053bb4
21
.idea/statistic.xml
generated
Normal file
21
.idea/statistic.xml
generated
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Statistic">
|
||||||
|
<option name="fileTypes" value="class;svn-base;svn-work;Extra;gif;png;jpg;jpeg;bmp;tga;tiff;ear;war;zip;jar;iml;iws;ipr;bz2;gz;gitignore;gradle;md;pro;properties;" />
|
||||||
|
<option name="excludedDirectories">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/build" />
|
||||||
|
<option value="$PROJECT_DIR$/export" />
|
||||||
|
<option value="$PROJECT_DIR$/gource" />
|
||||||
|
<option value="$PROJECT_DIR$/gradle" />
|
||||||
|
<option value="$PROJECT_DIR$/libs" />
|
||||||
|
<option value="$PROJECT_DIR$/.idea" />
|
||||||
|
<option value="$PROJECT_DIR$/.gradle" />
|
||||||
|
<option value="$PROJECT_DIR$/app/build" />
|
||||||
|
<option value="$PROJECT_DIR$/app/release" />
|
||||||
|
<option value="$PROJECT_DIR$/app/src/androidTest" />
|
||||||
|
<option value="$PROJECT_DIR$/app/src/test" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,2 +1,7 @@
|
|||||||
# Coinfolio
|
# Coinfolio ![State](https://img.shields.io/badge/State-in%20development-red.svg)
|
||||||
<img src="https://github.com/TanguyHerbron/Coinfolio/blob/master/app/src/main/icon_coinfolio-web.png" width="100">
|
This repository contains the source code of Coinfolio
|
||||||
|
<!--<img src="https://github.com/TanguyHerbron/Coinfolio/blob/master/app/src/main/icon_coinfolio-web.png" width="100">-->
|
||||||
|
|
||||||
|
# What is coinfolio ?
|
||||||
|
|
||||||
|
Coinfolio is a handy cryptocurrency and ICO portfolio tracker. With its easy to use interface, you can easily watch your cryptocurrencies and ICOs fluctuate during the day/week/month or year. Coinfolio allows you to keep up with the Global Market Capitalization as well and Exchanges statistics.
|
||||||
|
@ -32,7 +32,6 @@ dependencies {
|
|||||||
implementation 'com.android.support:support-v4:27.1.0'
|
implementation 'com.android.support:support-v4:27.1.0'
|
||||||
implementation 'com.android.support:palette-v7:27.1.0'
|
implementation 'com.android.support:palette-v7:27.1.0'
|
||||||
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
|
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
|
||||||
implementation 'com.github.armcha:SpaceNavigationView:1.6.0'
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
|
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
|
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
|
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
|
||||||
@ -42,7 +41,7 @@ dependencies {
|
|||||||
implementation 'org.apache.commons:commons-lang3:3.6'
|
implementation 'org.apache.commons:commons-lang3:3.6'
|
||||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||||
implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
||||||
//implementation 'com.github.lecho:hellocharts-library:1.5.8@aar'
|
implementation 'com.wdullaer:materialdatetimepicker:3.5.2'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
||||||
|
Binary file not shown.
@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.nauk.coinfolio","split":"","minSdkVersion":"21"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.nauk.coinfolio","split":"","minSdkVersion":"23"}}]
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +1,39 @@
|
|||||||
package com.nauk.coinfolio.Activities;
|
package com.nauk.coinfolio.Activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.Transformation;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
import com.nauk.coinfolio.LayoutManagers.CurrencyAdapter;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
|
||||||
|
import com.nauk.coinfolio.DataManagers.DatabaseManager;
|
||||||
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
|
import com.nauk.coinfolio.LayoutManagers.CurrencyListAdapter;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CurrencySelectionActivity extends AppCompatActivity implements SearchView.OnQueryTextListener{
|
public class CurrencySelectionActivity extends AppCompatActivity implements SearchView.OnQueryTextListener{
|
||||||
|
|
||||||
private String[] currencySymbols;
|
private CurrencyListAdapter adapter;
|
||||||
private String[] currencyNames;
|
|
||||||
private CurrencyAdapter adapter;
|
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private android.widget.Filter filter;
|
private android.widget.Filter filter;
|
||||||
|
private CurrencyDetailsList currencyDetailsList;
|
||||||
|
private boolean isWatchList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -35,17 +44,19 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
|
|||||||
|
|
||||||
setContentView(R.layout.activity_add_currency);
|
setContentView(R.layout.activity_add_currency);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
currencyDetailsList = new CurrencyDetailsList(this);
|
||||||
|
|
||||||
currencySymbols = intent.getStringArrayExtra("currencyListSymbols");
|
|
||||||
currencyNames = intent.getStringArrayExtra("currencyListNames");
|
|
||||||
|
|
||||||
setTitle("Select a coin");
|
setTitle("Select a coin");
|
||||||
|
|
||||||
setupAdapter();
|
Intent intent = getIntent();
|
||||||
|
isWatchList = intent.getBooleanExtra("isWatchList", false);
|
||||||
|
|
||||||
setupList();
|
ListLoader listLoader = new ListLoader();
|
||||||
|
listLoader.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupSearchView()
|
||||||
|
{
|
||||||
SearchView searchView = findViewById(R.id.search_bar);
|
SearchView searchView = findViewById(R.id.search_bar);
|
||||||
|
|
||||||
searchView.setIconifiedByDefault(false);
|
searchView.setIconifiedByDefault(false);
|
||||||
@ -56,21 +67,17 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
|
|||||||
|
|
||||||
private void setupAdapter()
|
private void setupAdapter()
|
||||||
{
|
{
|
||||||
String[] currencyFullname = new String[currencyNames.length];
|
List<String> currencyNames = currencyDetailsList.getCurrenciesName();
|
||||||
|
List<String> currencySymbols = currencyDetailsList.getCurrenciesSymbol();
|
||||||
for(int i = 0; i < currencyFullname.length; i++)
|
|
||||||
{
|
|
||||||
currencyFullname[i] = currencyNames[i] + " " + currencySymbols[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<Currency> currencyArrayList = new ArrayList<>();
|
ArrayList<Currency> currencyArrayList = new ArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < currencyNames.length; i++)
|
for(int i = 0; i < currencyNames.size(); i++)
|
||||||
{
|
{
|
||||||
currencyArrayList.add(new Currency(currencyNames[i], currencySymbols[i]));
|
currencyArrayList.add(new Currency(currencyNames.get(i), currencySymbols.get(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter = new CurrencyAdapter(this, currencyArrayList);
|
adapter = new CurrencyListAdapter(this, currencyArrayList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupList()
|
private void setupList()
|
||||||
@ -84,10 +91,23 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
Currency selectedCurrency = (Currency) adapterView.getItemAtPosition(i);
|
Currency selectedCurrency = (Currency) adapterView.getItemAtPosition(i);
|
||||||
Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class);
|
|
||||||
intent.putExtra("coin", selectedCurrency.getName());
|
if(isWatchList)
|
||||||
intent.putExtra("symbol", selectedCurrency.getSymbol());
|
{
|
||||||
startActivity(intent);
|
PreferencesManager preferencesManager = new PreferencesManager(getApplicationContext());
|
||||||
|
DatabaseManager databaseManager = new DatabaseManager(getApplicationContext());
|
||||||
|
|
||||||
|
databaseManager.addCurrencyToWatchlist(selectedCurrency);
|
||||||
|
preferencesManager.setMustUpdateWatchlist(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class);
|
||||||
|
intent.putExtra("coin", selectedCurrency.getName());
|
||||||
|
intent.putExtra("symbol", selectedCurrency.getSymbol());
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -95,27 +115,32 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
|
|||||||
filter = adapter.getFilter();
|
filter = adapter.getFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static void expand(final View v) {
|
||||||
public boolean onCreateOptionsMenu(Menu menu)
|
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
|
||||||
{
|
final int targetHeight = v.getMeasuredHeight();
|
||||||
/*final AutoCompleteTextView searchAutoComplete = findViewById(R.id.search_bar);
|
|
||||||
|
|
||||||
searchAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
|
||||||
|
v.getLayoutParams().height = 1;
|
||||||
|
v.setVisibility(View.VISIBLE);
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
Currency selectedCurrency = (Currency) adapterView.getItemAtPosition(i);
|
v.getLayoutParams().height = interpolatedTime == 1
|
||||||
Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class);
|
? CardView.LayoutParams.WRAP_CONTENT
|
||||||
intent.putExtra("coin", selectedCurrency.getName());
|
: (int)(targetHeight * interpolatedTime);
|
||||||
intent.putExtra("symbol", selectedCurrency.getSymbol());
|
v.requestLayout();
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
searchAutoComplete.setAdapter(adapter);
|
@Override
|
||||||
searchAutoComplete.setThreshold(0);*/
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return true;
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -136,4 +161,55 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ListLoader extends AsyncTask<Void, Integer, Void>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute()
|
||||||
|
{
|
||||||
|
super.onPreExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Integer... values)
|
||||||
|
{
|
||||||
|
super.onProgressUpdate(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params)
|
||||||
|
{
|
||||||
|
if(Looper.myLooper() == null)
|
||||||
|
{
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
currencyDetailsList.update(new BalanceManager.IconCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
setupAdapter();
|
||||||
|
|
||||||
|
setupList();
|
||||||
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setupSearchView();
|
||||||
|
|
||||||
|
expand(findViewById(R.id.listContainerLayout));
|
||||||
|
findViewById(R.id.currencyListProgressBar).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,245 @@
|
|||||||
|
package com.nauk.coinfolio.Activities.HomeActivityFragments;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.PieChart;
|
||||||
|
import com.github.mikephil.charting.data.PieData;
|
||||||
|
import com.github.mikephil.charting.data.PieDataSet;
|
||||||
|
import com.github.mikephil.charting.data.PieEntry;
|
||||||
|
import com.github.mikephil.charting.formatter.PercentFormatter;
|
||||||
|
import com.nauk.coinfolio.DataManagers.MarketCapManager;
|
||||||
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tiji on 13/04/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MarketCapitalization extends Fragment {
|
||||||
|
|
||||||
|
private int marketCapCounter;
|
||||||
|
|
||||||
|
private MarketCapManager marketCapManager;
|
||||||
|
private HashMap<String, Integer> dominantCurrenciesColors;
|
||||||
|
private SwipeRefreshLayout refreshLayout;
|
||||||
|
private long lastTimestamp;
|
||||||
|
|
||||||
|
private View view;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
view = inflater.inflate(R.layout.fragment_marketcap_homeactivity, container, false);
|
||||||
|
|
||||||
|
setupDominantCurrenciesColors();
|
||||||
|
|
||||||
|
marketCapManager = new MarketCapManager(getContext());
|
||||||
|
refreshLayout = view.findViewById(R.id.swiperefreshmarketcap);
|
||||||
|
|
||||||
|
refreshLayout.setOnRefreshListener(
|
||||||
|
new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
updateMarketCap();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
lastTimestamp = 0;
|
||||||
|
|
||||||
|
updateMarketCap();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDominantCurrenciesColors()
|
||||||
|
{
|
||||||
|
dominantCurrenciesColors = new HashMap<>();
|
||||||
|
|
||||||
|
dominantCurrenciesColors.put("BTC", -489456);
|
||||||
|
dominantCurrenciesColors.put("ETH", -13619152);
|
||||||
|
dominantCurrenciesColors.put("XRP", -16744256);
|
||||||
|
dominantCurrenciesColors.put("BCH", -1011696);
|
||||||
|
dominantCurrenciesColors.put("LTC", -4671304);
|
||||||
|
dominantCurrenciesColors.put("EOS", -1513240);
|
||||||
|
dominantCurrenciesColors.put("ADA", -16773080);
|
||||||
|
dominantCurrenciesColors.put("XLM", -11509656);
|
||||||
|
dominantCurrenciesColors.put("MIOTA", -1513240);
|
||||||
|
dominantCurrenciesColors.put("NEO", -9390048);
|
||||||
|
dominantCurrenciesColors.put("XMR", -499712);
|
||||||
|
dominantCurrenciesColors.put("DASH", -15175496);
|
||||||
|
dominantCurrenciesColors.put("XEM", -7829368);
|
||||||
|
dominantCurrenciesColors.put("TRX", -7829360);
|
||||||
|
dominantCurrenciesColors.put("ETC", -10448784);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMarketCap()
|
||||||
|
{
|
||||||
|
if(System.currentTimeMillis() / 1000 - lastTimestamp > 60)
|
||||||
|
{
|
||||||
|
if(!refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
marketCapCounter = 0;
|
||||||
|
|
||||||
|
lastTimestamp = System.currentTimeMillis() / 1000;
|
||||||
|
|
||||||
|
marketCapManager.updateTopCurrencies(new MarketCapManager.VolleyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess()
|
||||||
|
{
|
||||||
|
countCompletedMarketCapRequest();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
marketCapManager.updateMarketCap(new MarketCapManager.VolleyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
countCompletedMarketCapRequest();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
private void countCompletedMarketCapRequest()
|
||||||
|
{
|
||||||
|
marketCapCounter++;
|
||||||
|
|
||||||
|
if(marketCapCounter == 2)
|
||||||
|
{
|
||||||
|
setupTextViewMarketCap();
|
||||||
|
|
||||||
|
view.findViewById(R.id.progressBarMarketCap).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.layoutProgressMarketCap).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
List<PieEntry> entries = new ArrayList<>();
|
||||||
|
|
||||||
|
ArrayList<Integer> colors = new ArrayList<>();
|
||||||
|
|
||||||
|
float otherCurrenciesDominance = 0;
|
||||||
|
|
||||||
|
for(Iterator i = marketCapManager.getDominance().keySet().iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
String key = (String) i.next();
|
||||||
|
entries.add(new PieEntry(marketCapManager.getDominance().get(key), key));
|
||||||
|
otherCurrenciesDominance += marketCapManager.getDominance().get(key);
|
||||||
|
colors.add(dominantCurrenciesColors.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
entries.add(new PieEntry(100-otherCurrenciesDominance, "Others"));
|
||||||
|
colors.add(-12369084);
|
||||||
|
|
||||||
|
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
|
||||||
|
set.setColors(colors);
|
||||||
|
set.setSliceSpace(1);
|
||||||
|
set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
|
||||||
|
set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
|
||||||
|
|
||||||
|
PieData data = new PieData(set);
|
||||||
|
data.setValueTextSize(10);
|
||||||
|
data.setValueFormatter(new PercentFormatter());
|
||||||
|
|
||||||
|
setupPieChart(data);
|
||||||
|
|
||||||
|
if(refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupPieChart(PieData data)
|
||||||
|
{
|
||||||
|
PieChart pieChart = view.findViewById(R.id.marketCapPieChart);
|
||||||
|
|
||||||
|
pieChart.setData(data);
|
||||||
|
pieChart.setDrawSlicesUnderHole(false);
|
||||||
|
pieChart.setUsePercentValues(true);
|
||||||
|
pieChart.setTouchEnabled(true);
|
||||||
|
|
||||||
|
pieChart.setEntryLabelColor(Color.parseColor("#FF000000"));
|
||||||
|
|
||||||
|
pieChart.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
|
switch (motionEvent.getAction())
|
||||||
|
{
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
refreshLayout.setEnabled(false);
|
||||||
|
getActivity().findViewById(R.id.viewPager).setEnabled(false);
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
refreshLayout.setEnabled(true);
|
||||||
|
getActivity().findViewById(R.id.viewPager).setEnabled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pieChart.getDescription().setEnabled(false);
|
||||||
|
pieChart.getLegend().setEnabled(false);
|
||||||
|
pieChart.setCenterText(generateCenterSpannableText());
|
||||||
|
pieChart.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SpannableString generateCenterSpannableText() {
|
||||||
|
|
||||||
|
SpannableString spannableString = new SpannableString("Market Capitalization Dominance");
|
||||||
|
return spannableString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupTextViewMarketCap()
|
||||||
|
{
|
||||||
|
DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.UK);
|
||||||
|
DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
|
||||||
|
|
||||||
|
symbols.setGroupingSeparator(' ');
|
||||||
|
formatter.setDecimalFormatSymbols(symbols);
|
||||||
|
|
||||||
|
((TextView) view.findViewById(R.id.marketCapTextView)).setText(getActivity().getResources().getString(R.string.market_cap_textview, formatter.format(marketCapManager.getMarketCap())));
|
||||||
|
|
||||||
|
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap)).setText(getActivity().getResources().getString(R.string.volume_market_cap_textview, formatter.format(marketCapManager.getDayVolume())));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,685 @@
|
|||||||
|
package com.nauk.coinfolio.Activities.HomeActivityFragments;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.support.design.widget.CollapsingToolbarLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.graphics.Palette;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.Activities.CurrencySelectionActivity;
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivity;
|
||||||
|
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
|
import com.nauk.coinfolio.LayoutManagers.HomeLayoutGenerator;
|
||||||
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tiji on 13/04/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Summary extends Fragment {
|
||||||
|
|
||||||
|
private LinearLayout currencyLayout;
|
||||||
|
private PreferencesManager preferencesManager;
|
||||||
|
private BalanceManager balanceManager;
|
||||||
|
private HomeLayoutGenerator layoutGenerator;
|
||||||
|
private View view;
|
||||||
|
private SwipeRefreshLayout refreshLayout;
|
||||||
|
private Dialog loadingDialog;
|
||||||
|
|
||||||
|
private TextView toolbarSubtitle;
|
||||||
|
private CollapsingToolbarLayout toolbarLayout;
|
||||||
|
private Handler handler;
|
||||||
|
|
||||||
|
private Runnable updateRunnable;
|
||||||
|
|
||||||
|
private int coinCounter;
|
||||||
|
private int iconCounter;
|
||||||
|
private float totalValue;
|
||||||
|
private boolean detailsChecker;
|
||||||
|
protected float totalFluctuation;
|
||||||
|
private long lastTimestamp;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
view = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false);
|
||||||
|
|
||||||
|
currencyLayout = view.findViewById(R.id.currencyListLayout);
|
||||||
|
preferencesManager = new PreferencesManager(getActivity());
|
||||||
|
balanceManager = new BalanceManager(getActivity());
|
||||||
|
layoutGenerator = new HomeLayoutGenerator(getActivity());
|
||||||
|
refreshLayout = view.findViewById(R.id.swiperefreshsummary);
|
||||||
|
toolbarSubtitle = getActivity().findViewById(R.id.toolbarSubtitle);
|
||||||
|
toolbarLayout = getActivity().findViewById(R.id.toolbar_layout);
|
||||||
|
|
||||||
|
totalValue = 0;
|
||||||
|
totalFluctuation = 0;
|
||||||
|
lastTimestamp = 0;
|
||||||
|
|
||||||
|
handler = new Handler();
|
||||||
|
updateRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
|
showErrorSnackbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingDialog.isShowing())
|
||||||
|
{
|
||||||
|
loadingDialog.dismiss();
|
||||||
|
|
||||||
|
showErrorSnackbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
refreshLayout.setOnRefreshListener(
|
||||||
|
new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
updateAll(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
handler.postDelayed(updateRunnable, 10000);
|
||||||
|
|
||||||
|
Button addCurrencyButton = view.findViewById(R.id.buttonAddTransaction);
|
||||||
|
|
||||||
|
addCurrencyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent addIntent = new Intent(getActivity(), CurrencySelectionActivity.class);
|
||||||
|
|
||||||
|
startActivity(addIntent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageButton detailsButton = getActivity().findViewById(R.id.switch_button);
|
||||||
|
detailsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
preferencesManager.setDetailOption(!preferencesManager.getDetailOption());
|
||||||
|
updateViewButtonIcon();
|
||||||
|
switchView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
|
updateAll(true);
|
||||||
|
|
||||||
|
generateSplashScreen();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateSplashScreen()
|
||||||
|
{
|
||||||
|
LinearLayout loadingLayout = new LinearLayout(getActivity());
|
||||||
|
|
||||||
|
loadingLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
loadingLayout.setGravity(Gravity.CENTER);
|
||||||
|
loadingLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
|
loadingDialog = new Dialog(getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
||||||
|
|
||||||
|
TextView txtView = new TextView(getActivity());
|
||||||
|
txtView.setText("Loading data...");
|
||||||
|
txtView.setTextSize(20);
|
||||||
|
txtView.setGravity(Gravity.CENTER);
|
||||||
|
txtView.setTextColor(this.getResources().getColor(R.color.cardview_light_background));
|
||||||
|
|
||||||
|
ProgressBar progressBar = new ProgressBar(getActivity());
|
||||||
|
progressBar.setIndeterminate(true);
|
||||||
|
|
||||||
|
loadingLayout.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark));
|
||||||
|
loadingLayout.addView(txtView);
|
||||||
|
loadingLayout.addView(progressBar);
|
||||||
|
|
||||||
|
loadingDialog.setContentView(loadingLayout);
|
||||||
|
loadingDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
updateAll(preferencesManager.mustUpdateSummary());
|
||||||
|
|
||||||
|
updateViewButtonIcon();
|
||||||
|
|
||||||
|
displayBalance(preferencesManager.isBalanceHidden());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAll(boolean mustUpdate)
|
||||||
|
{
|
||||||
|
if(System.currentTimeMillis()/1000 - lastTimestamp > 60 || mustUpdate)
|
||||||
|
{
|
||||||
|
if(!refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastTimestamp = System.currentTimeMillis() / 1000;
|
||||||
|
balanceManager.updateExchangeKeys();
|
||||||
|
refreshLayout.setRefreshing(true);
|
||||||
|
|
||||||
|
resetCounters();
|
||||||
|
DataUpdater updater = new DataUpdater();
|
||||||
|
updater.execute();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showErrorSnackbar()
|
||||||
|
{
|
||||||
|
/*Snackbar.make(getActivity().findViewById(R.id.viewFlipperSummary), "Error while updating data", Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Update", new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetCounters()
|
||||||
|
{
|
||||||
|
coinCounter = 0;
|
||||||
|
iconCounter = 0;
|
||||||
|
detailsChecker = false;
|
||||||
|
|
||||||
|
totalValue = 0;
|
||||||
|
totalFluctuation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchView()
|
||||||
|
{
|
||||||
|
if(preferencesManager.getDetailOption())
|
||||||
|
{
|
||||||
|
adaptView();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
adaptView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adaptView()
|
||||||
|
{
|
||||||
|
currencyLayout.removeAllViews();
|
||||||
|
|
||||||
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
|
{
|
||||||
|
final Currency currency = balanceManager.getTotalBalance().get(i);
|
||||||
|
|
||||||
|
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
|
||||||
|
{
|
||||||
|
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, preferencesManager.getDetailOption(), totalValue, preferencesManager.isBalanceHidden()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void countCoins(boolean isCoin, boolean isDetails)
|
||||||
|
{
|
||||||
|
if(isCoin)
|
||||||
|
{
|
||||||
|
coinCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isDetails)
|
||||||
|
{
|
||||||
|
detailsChecker = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(balanceManager.getTotalBalance() != null)
|
||||||
|
{
|
||||||
|
if(coinCounter == balanceManager.getTotalBalance().size() && detailsChecker)
|
||||||
|
{
|
||||||
|
IconDownloader iconDownloader = new IconDownloader();
|
||||||
|
iconDownloader.execute();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(balanceManager.getTotalBalance().size() == 0)
|
||||||
|
{
|
||||||
|
countIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void countIcons()
|
||||||
|
{
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
|
{
|
||||||
|
if(balanceManager.getTotalBalance().get(i).getSymbol().equals("USD"))
|
||||||
|
{
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iconCounter++;
|
||||||
|
|
||||||
|
if(balanceManager.getTotalBalance() != null)
|
||||||
|
{
|
||||||
|
if(balanceManager.getTotalBalance().size() == 0)
|
||||||
|
{
|
||||||
|
updateNoBalance();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(iconCounter == balanceManager.getTotalBalance().size() - offset)
|
||||||
|
{
|
||||||
|
Log.d(getResources().getString(R.string.debug), "Loading heavy");
|
||||||
|
|
||||||
|
UiHeavyLoadCalculator uiHeavyLoadCalculator = new UiHeavyLoadCalculator();
|
||||||
|
uiHeavyLoadCalculator.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateNoBalance()
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
|
currencyLayout.removeAllViews();
|
||||||
|
|
||||||
|
if(loadingDialog.isShowing())
|
||||||
|
{
|
||||||
|
loadingDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateTitle()
|
||||||
|
{
|
||||||
|
float totalFluctuationPercentage = totalFluctuation / (totalValue - totalFluctuation) * 100;
|
||||||
|
|
||||||
|
if(preferencesManager.isBalanceHidden())
|
||||||
|
{
|
||||||
|
toolbarLayout.setTitle(getResources().getString(R.string.currencyPercentagePlaceholder, String.format("%.2f", totalFluctuationPercentage)));
|
||||||
|
toolbarSubtitle.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if(totalFluctuation > 0)
|
||||||
|
{
|
||||||
|
toolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.increase));
|
||||||
|
toolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.increase));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.decrease));
|
||||||
|
toolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.decrease));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolbarLayout.setTitle(getResources().getString(R.string.currencyDollarPlaceholder, String.format("%.2f", totalValue)));
|
||||||
|
toolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
|
||||||
|
toolbarLayout.setExpandedTitleColor(Color.WHITE);
|
||||||
|
|
||||||
|
toolbarSubtitle.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
if(totalFluctuation > 0)
|
||||||
|
{
|
||||||
|
toolbarSubtitle.setTextColor(getResources().getColor(R.color.increase));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolbarSubtitle.setTextColor(getResources().getColor(R.color.decrease));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(totalFluctuation == 0)
|
||||||
|
{
|
||||||
|
toolbarSubtitle.setText(getResources().getString(R.string.currencyDollarPlaceholder, "0.00"));
|
||||||
|
toolbarSubtitle.setTextColor(-1275068417);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolbarSubtitle.setText("US$" + String.format("%.2f", totalFluctuation) + " (" + String.format("%.2f", totalFluctuationPercentage) + "%)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UiHeavyLoadCalculator extends AsyncTask<Void, Integer, Void>
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute()
|
||||||
|
{
|
||||||
|
super.onPreExecute();
|
||||||
|
|
||||||
|
totalValue = 0;
|
||||||
|
totalFluctuation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Integer... values)
|
||||||
|
{
|
||||||
|
super.onProgressUpdate(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateChartColor(Currency currency)
|
||||||
|
{
|
||||||
|
if(currency.getIcon() != null)
|
||||||
|
{
|
||||||
|
Palette.Builder builder = Palette.from(currency.getIcon());
|
||||||
|
|
||||||
|
currency.setChartColor(builder.generate().getDominantColor(0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currency.setChartColor(12369084);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCurrency(Currency currency)
|
||||||
|
{
|
||||||
|
if(!currency.getSymbol().equals("USD") && (currency.getBalance() * currency.getValue()) > 0.001)
|
||||||
|
{
|
||||||
|
currency.setName(balanceManager.getCurrencyName(currency.getSymbol()));
|
||||||
|
currency.setId(balanceManager.getCurrencyId(currency.getSymbol()));
|
||||||
|
totalValue += currency.getValue() * currency.getBalance();
|
||||||
|
totalFluctuation += (currency.getValue() * currency.getBalance()) * (currency.getDayFluctuationPercentage() / 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCurrencyList()
|
||||||
|
{
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
currencyLayout.removeAllViews();
|
||||||
|
|
||||||
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
|
{
|
||||||
|
Currency currency = balanceManager.getTotalBalance().get(i);
|
||||||
|
|
||||||
|
if(!currency.getSymbol().equals("USD") && (currency.getBalance() * currency.getValue()) > 0.001) {
|
||||||
|
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, preferencesManager.getDetailOption(), totalValue, preferencesManager.isBalanceHidden()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adaptView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params)
|
||||||
|
{
|
||||||
|
if(Looper.myLooper() == null)
|
||||||
|
{
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
balanceManager.sortCoins();
|
||||||
|
|
||||||
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
|
{
|
||||||
|
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
||||||
|
|
||||||
|
updateChartColor(localCurrency);
|
||||||
|
|
||||||
|
loadCurrency(localCurrency);
|
||||||
|
|
||||||
|
balanceManager.getTotalBalance().set(i, localCurrency);
|
||||||
|
}
|
||||||
|
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateTitle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(loadingDialog.isShowing())
|
||||||
|
{
|
||||||
|
loadingDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result)
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
refreshCurrencyList();
|
||||||
|
handler.removeCallbacks(updateRunnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getBitmapFromURL(String src, HomeActivity.IconCallBack callBack) {
|
||||||
|
Bitmap result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
java.net.URL url = new java.net.URL(src);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url
|
||||||
|
.openConnection();
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.connect();
|
||||||
|
InputStream input = connection.getInputStream();
|
||||||
|
result = BitmapFactory.decodeStream(input);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
result = BitmapFactory.decodeResource(this.getResources(),
|
||||||
|
R.mipmap.icon_coinfolio);
|
||||||
|
result = Bitmap.createScaledBitmap(result, 50, 50, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
callBack.onSuccess(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateViewButtonIcon()
|
||||||
|
{
|
||||||
|
ImageButton imgButton = getActivity().findViewById(R.id.switch_button);
|
||||||
|
|
||||||
|
imgButton.setBackgroundColor(this.getResources().getColor(R.color.buttonColor));
|
||||||
|
|
||||||
|
if(preferencesManager.getDetailOption())
|
||||||
|
{
|
||||||
|
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_unfold_less_black_24dp));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_details_black_24dp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayBalance(boolean hideBalance)
|
||||||
|
{
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
|
if(hideBalance)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < currencyLayout.getChildCount(); i++)
|
||||||
|
{
|
||||||
|
currencyLayout.getChildAt(i).findViewById(R.id.currencyPortfolioDominance).setVisibility(View.VISIBLE);
|
||||||
|
currencyLayout.getChildAt(i).findViewById(R.id.percentageOwnedTextView).setVisibility(View.VISIBLE);
|
||||||
|
currencyLayout.getChildAt(i).findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i = 0; i < currencyLayout.getChildCount(); i++)
|
||||||
|
{
|
||||||
|
currencyLayout.getChildAt(i).findViewById(R.id.currencyPortfolioDominance).setVisibility(View.INVISIBLE);
|
||||||
|
currencyLayout.getChildAt(i).findViewById(R.id.percentageOwnedTextView).setVisibility(View.GONE);
|
||||||
|
currencyLayout.getChildAt(i).findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class IconDownloader extends AsyncTask<Void, Integer, Void>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute()
|
||||||
|
{
|
||||||
|
super.onPreExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Integer... values)
|
||||||
|
{
|
||||||
|
super.onProgressUpdate(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
|
{
|
||||||
|
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
||||||
|
|
||||||
|
if(balanceManager.getIconUrl(localCurrency.getSymbol()) != null)
|
||||||
|
{
|
||||||
|
getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), new HomeActivity.IconCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Bitmap bitmapIcon) {
|
||||||
|
localCurrency.setIcon(bitmapIcon);
|
||||||
|
countIcons();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class DataUpdater extends AsyncTask<Void, Integer, Void>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params)
|
||||||
|
{
|
||||||
|
balanceManager.updateDetails(new BalanceManager.IconCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess()
|
||||||
|
{
|
||||||
|
countCoins(false, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
balanceManager.updateTotalBalance(new BalanceManager.VolleyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
|
||||||
|
final List<Currency> balance = balanceManager.getTotalBalance();
|
||||||
|
|
||||||
|
if(balanceManager.getTotalBalance().size() > 0)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
|
{
|
||||||
|
balance.get(i).updateHistoryMinutes(getActivity(), new Currency.CurrencyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Currency currency) {
|
||||||
|
countCoins(true, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
countCoins(false, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onError(String error)
|
||||||
|
{
|
||||||
|
/*switch (error)
|
||||||
|
{
|
||||||
|
case "com.android.volley.AuthFailureError":
|
||||||
|
preferencesManager.disableHitBTC();
|
||||||
|
Snackbar.make(findViewById(R.id.viewFlipperSummary), "HitBTC synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||||
|
.show();
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
updateAll(true);
|
||||||
|
break;
|
||||||
|
case "API-key format invalid.":
|
||||||
|
preferencesManager.disableBinance();
|
||||||
|
Snackbar.make(findViewById(R.id.viewFlipperSummary), "Binance synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||||
|
.show();
|
||||||
|
updateAll(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Snackbar.make(findViewById(R.id.viewFlipperSummary), "Unexpected error", Snackbar.LENGTH_LONG)
|
||||||
|
.show();
|
||||||
|
Log.d("coinfolio", error);
|
||||||
|
updateAll(true);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,449 @@
|
|||||||
|
package com.nauk.coinfolio.Activities.HomeActivityFragments;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.graphics.Palette;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.Transformation;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
|
import com.github.mikephil.charting.data.Entry;
|
||||||
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
import com.nauk.coinfolio.Activities.CurrencyDetailsActivity;
|
||||||
|
import com.nauk.coinfolio.Activities.CurrencySelectionActivity;
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivity;
|
||||||
|
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
|
||||||
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
|
import com.nauk.coinfolio.DataManagers.WatchlistManager;
|
||||||
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tiji on 13/04/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Watchlist extends Fragment {
|
||||||
|
|
||||||
|
private WatchlistManager watchlistManager;
|
||||||
|
private View view;
|
||||||
|
private int watchlistCounter;
|
||||||
|
private CurrencyDetailsList currencyDetailsList;
|
||||||
|
private SwipeRefreshLayout refreshLayout;
|
||||||
|
private long lastTimestamp;
|
||||||
|
private PreferencesManager preferencesManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
view = inflater.inflate(R.layout.fragment_watchlist_homeactivity, container, false);
|
||||||
|
|
||||||
|
refreshLayout = view.findViewById(R.id.swiperefreshwatchlist);
|
||||||
|
currencyDetailsList = new CurrencyDetailsList(getContext());
|
||||||
|
preferencesManager = new PreferencesManager(getContext());
|
||||||
|
|
||||||
|
lastTimestamp = 0;
|
||||||
|
|
||||||
|
watchlistManager = new WatchlistManager(getContext());
|
||||||
|
|
||||||
|
updateWatchlist(true);
|
||||||
|
|
||||||
|
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
updateWatchlist(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button addWatchlistButton = view.findViewById(R.id.buttonAddWatchlist);
|
||||||
|
addWatchlistButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent selectionIntent = new Intent(getActivity(), CurrencySelectionActivity.class);
|
||||||
|
selectionIntent.putExtra("isWatchList", true);
|
||||||
|
startActivity(selectionIntent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void collapseView(View view)
|
||||||
|
{
|
||||||
|
collapse(view.findViewById(R.id.collapsableLayout));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extendView(View view)
|
||||||
|
{
|
||||||
|
expand(view.findViewById(R.id.collapsableLayout));
|
||||||
|
view.findViewById(R.id.LineChartView).invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void expand(final View v) {
|
||||||
|
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
|
||||||
|
final int targetHeight = v.getMeasuredHeight();
|
||||||
|
|
||||||
|
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
|
||||||
|
v.getLayoutParams().height = 1;
|
||||||
|
v.setVisibility(View.VISIBLE);
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
|
v.getLayoutParams().height = interpolatedTime == 1
|
||||||
|
? CardView.LayoutParams.WRAP_CONTENT
|
||||||
|
: (int)(targetHeight * interpolatedTime);
|
||||||
|
v.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void collapse(final View v) {
|
||||||
|
final int initialHeight = v.getMeasuredHeight();
|
||||||
|
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
|
if(interpolatedTime == 1){
|
||||||
|
v.setVisibility(View.GONE);
|
||||||
|
}else{
|
||||||
|
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
|
||||||
|
v.requestLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
updateWatchlist(preferencesManager.mustUpdateWatchlist());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWatchlist(boolean mustUpdate)
|
||||||
|
{
|
||||||
|
if(System.currentTimeMillis()/1000 - lastTimestamp > 60 || mustUpdate)
|
||||||
|
{
|
||||||
|
if(!refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastTimestamp = System.currentTimeMillis()/1000;
|
||||||
|
|
||||||
|
watchlistManager.updateWatchlist();
|
||||||
|
|
||||||
|
currencyDetailsList.update(new BalanceManager.IconCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
WatchlistUpdater watchlistUpdater = new WatchlistUpdater();
|
||||||
|
watchlistUpdater.execute();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void countWatchlist()
|
||||||
|
{
|
||||||
|
watchlistCounter++;
|
||||||
|
|
||||||
|
if(watchlistCounter >= watchlistManager.getWatchlist().size())
|
||||||
|
{
|
||||||
|
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).removeAllViews();
|
||||||
|
|
||||||
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
|
{
|
||||||
|
View card = LayoutInflater.from(getContext()).inflate(R.layout.cardview_watchlist, null);
|
||||||
|
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView)).setText(getResources().getString(R.string.currencyPercentagePlaceholder, numberConformer(currency.getDayFluctuationPercentage())));
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setText(getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
|
((TextView) card.findViewById(R.id.currencyNameTextView)).setText(currency.getName());
|
||||||
|
((TextView) card.findViewById(R.id.currencySymbolTextView)).setText(getResources().getString(R.string.currencySymbolPlaceholder, currency.getSymbol()));
|
||||||
|
((ImageView) card.findViewById(R.id.currencyIcon)).setImageBitmap(currency.getIcon());
|
||||||
|
((TextView) card.findViewById(R.id.currencyValueTextView)).setText(getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
|
||||||
|
Drawable arrowDrawable = ((ImageView) card.findViewById(R.id.detailsArrow)).getDrawable();
|
||||||
|
arrowDrawable.mutate();
|
||||||
|
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
|
arrowDrawable.invalidateSelf();
|
||||||
|
|
||||||
|
updateColor(card, currency);
|
||||||
|
|
||||||
|
card.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
card.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if(view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE)
|
||||||
|
{
|
||||||
|
collapseView(view);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extendView(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
card.findViewById(R.id.LineChartView).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(getActivity(), CurrencyDetailsActivity.class);
|
||||||
|
intent.putExtra("currency", currency);
|
||||||
|
getActivity().getApplicationContext().startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(currency.getHistoryMinutes() != null)
|
||||||
|
{
|
||||||
|
setupLineChart(card, currency);
|
||||||
|
}
|
||||||
|
|
||||||
|
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(card, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private LineData generateData(Currency currency)
|
||||||
|
{
|
||||||
|
LineDataSet dataSet;
|
||||||
|
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
||||||
|
ArrayList<Entry> values = new ArrayList<>();
|
||||||
|
|
||||||
|
Log.d("coinfolio", "Generating data for " + currency.getSymbol());
|
||||||
|
for(int i = 0; i < dataChartList.size(); i+=10)
|
||||||
|
{
|
||||||
|
values.add(new Entry(i, (float) dataChartList.get(i).getOpen()));
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSet = new LineDataSet(values, "History");
|
||||||
|
dataSet.setDrawIcons(false);
|
||||||
|
dataSet.setColor(currency.getChartColor());
|
||||||
|
dataSet.setLineWidth(1);
|
||||||
|
dataSet.setDrawFilled(true);
|
||||||
|
dataSet.setFillColor(getColorWithAplha(currency.getChartColor(), 0.5f));
|
||||||
|
dataSet.setFormLineWidth(1);
|
||||||
|
dataSet.setFormSize(15);
|
||||||
|
dataSet.setDrawCircles(false);
|
||||||
|
dataSet.setDrawValues(false);
|
||||||
|
dataSet.setHighlightEnabled(false);
|
||||||
|
|
||||||
|
return new LineData(dataSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getColorWithAplha(int color, float ratio)
|
||||||
|
{
|
||||||
|
int transColor;
|
||||||
|
int alpha = Math.round(Color.alpha(color) * ratio);
|
||||||
|
int r = Color.red(color);
|
||||||
|
int g = Color.green(color);
|
||||||
|
int b = Color.blue(color);
|
||||||
|
|
||||||
|
transColor = Color.argb(alpha, r, g, b);
|
||||||
|
|
||||||
|
return transColor ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLineChart(View view, final Currency currency)
|
||||||
|
{
|
||||||
|
LineChart lineChart = view.findViewById(R.id.LineChartView);
|
||||||
|
|
||||||
|
lineChart.setDrawGridBackground(false);
|
||||||
|
lineChart.setDrawBorders(false);
|
||||||
|
lineChart.setDrawMarkers(false);
|
||||||
|
lineChart.setDoubleTapToZoomEnabled(false);
|
||||||
|
lineChart.setPinchZoom(false);
|
||||||
|
lineChart.setScaleEnabled(false);
|
||||||
|
lineChart.setDragEnabled(false);
|
||||||
|
lineChart.getDescription().setEnabled(false);
|
||||||
|
lineChart.getAxisLeft().setEnabled(false);
|
||||||
|
lineChart.getAxisRight().setEnabled(false);
|
||||||
|
lineChart.getLegend().setEnabled(false);
|
||||||
|
lineChart.getXAxis().setEnabled(false);
|
||||||
|
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
||||||
|
lineChart.setData(generateData(currency));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateColor(View card, Currency currency)
|
||||||
|
{
|
||||||
|
if(currency.getDayFluctuation() > 0)
|
||||||
|
{
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView)).setTextColor(getResources().getColor(R.color.increase));
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setTextColor(getResources().getColor(R.color.increase));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView)).setTextColor(getResources().getColor(R.color.decrease));
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setTextColor(getResources().getColor(R.color.decrease));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getIconUrl(String symbol)
|
||||||
|
{
|
||||||
|
String url;
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||||
|
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Log.d(getContext().getResources().getString(R.string.debug), symbol + " has no icon URL");
|
||||||
|
url = null;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.d(getContext().getResources().getString(R.string.debug), "Url parsing error for " + symbol);
|
||||||
|
url = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getBitmapFromURL(String src, HomeActivity.IconCallBack callBack) {
|
||||||
|
Bitmap result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
java.net.URL url = new java.net.URL(src);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url
|
||||||
|
.openConnection();
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.connect();
|
||||||
|
InputStream input = connection.getInputStream();
|
||||||
|
result = BitmapFactory.decodeStream(input);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
result = BitmapFactory.decodeResource(this.getResources(),
|
||||||
|
R.mipmap.icon_coinfolio);
|
||||||
|
result = Bitmap.createScaledBitmap(result, 50, 50, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
callBack.onSuccess(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateChartColor(Currency currency)
|
||||||
|
{
|
||||||
|
if(currency.getIcon() != null)
|
||||||
|
{
|
||||||
|
Palette.Builder builder = Palette.from(currency.getIcon());
|
||||||
|
|
||||||
|
currency.setChartColor(builder.generate().getDominantColor(0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currency.setChartColor(12369084);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class WatchlistUpdater extends AsyncTask<Void, Integer, Void>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute()
|
||||||
|
{
|
||||||
|
watchlistCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
|
{
|
||||||
|
currency.updateHistoryMinutes(getActivity(), new Currency.CurrencyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(final Currency sucessCurrency) {
|
||||||
|
if(getIconUrl(sucessCurrency.getSymbol()) != null)
|
||||||
|
{
|
||||||
|
getBitmapFromURL(getIconUrl(sucessCurrency.getSymbol()), new HomeActivity.IconCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Bitmap bitmapIcon) {
|
||||||
|
sucessCurrency.setIcon(bitmapIcon);
|
||||||
|
updateChartColor(currency);
|
||||||
|
countWatchlist();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String numberConformer(double number)
|
||||||
|
{
|
||||||
|
String str;
|
||||||
|
|
||||||
|
if(abs(number) > 1)
|
||||||
|
{
|
||||||
|
str = String.format( Locale.UK, "%.2f", number);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = String.format( Locale.UK, "%.4f", number);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
@ -3,21 +3,35 @@ package com.nauk.coinfolio.Activities;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
import com.nauk.coinfolio.DataManagers.DatabaseManager;
|
import com.nauk.coinfolio.DataManagers.DatabaseManager;
|
||||||
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
public class RecordTransactionActivity extends AppCompatActivity {
|
public class RecordTransactionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private String coin;
|
private String coin;
|
||||||
private String symbol;
|
private String symbol;
|
||||||
private TextView symbolTxtView;
|
private EditText amountTxtView;
|
||||||
private TextView amountTxtView;
|
private TextView purchasedDate;
|
||||||
private Button validateButton;
|
private Button validateButton;
|
||||||
private DatabaseManager databaseManager;
|
private DatabaseManager databaseManager;
|
||||||
|
private Calendar calendar;
|
||||||
|
private SimpleDateFormat sdf;
|
||||||
|
private PreferencesManager preferenceManager;
|
||||||
|
private EditText purchasedPrice;
|
||||||
|
private Currency currency;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -30,22 +44,93 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
setTitle("Add " + coin + " transaction");
|
setTitle("Add " + coin + " transaction");
|
||||||
|
|
||||||
|
sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy");
|
||||||
|
|
||||||
|
calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
currency = new Currency(coin, symbol);
|
||||||
|
|
||||||
databaseManager = new DatabaseManager(this);
|
databaseManager = new DatabaseManager(this);
|
||||||
|
preferenceManager = new PreferencesManager(this);
|
||||||
|
|
||||||
validateButton = findViewById(R.id.validateButton);
|
validateButton = findViewById(R.id.validateButton);
|
||||||
|
|
||||||
amountTxtView = findViewById(R.id.currencyAmount);
|
amountTxtView = findViewById(R.id.currencyAmount);
|
||||||
|
purchasedDate = findViewById(R.id.purchaseDate);
|
||||||
|
purchasedPrice = findViewById(R.id.purchasePrice);
|
||||||
|
|
||||||
|
//purchasedPrice.setText();
|
||||||
|
purchasedDate.setText(sdf.format(calendar.getTime()));
|
||||||
|
|
||||||
|
purchasedDate.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
createDatePicker();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
validateButton.setOnClickListener(new View.OnClickListener() {
|
validateButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString()));
|
databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString()), calendar.getTime(), purchasedPrice.getText().toString());
|
||||||
|
preferenceManager.setMustUpdateSummary(true);
|
||||||
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
||||||
intent.putExtra("update", true);
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
currency.getTimestampPrice(this, new Currency.PriceCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String price) {
|
||||||
|
purchasedPrice.setText(price);
|
||||||
|
}
|
||||||
|
}, calendar.getTimeInMillis() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDatePicker()
|
||||||
|
{
|
||||||
|
new android.app.DatePickerDialog(
|
||||||
|
RecordTransactionActivity.this,
|
||||||
|
new android.app.DatePickerDialog.OnDateSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
|
||||||
|
calendar.set(Calendar.YEAR, year);
|
||||||
|
calendar.set(Calendar.MONTH, month);
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||||
|
purchasedDate.setText(sdf.format(calendar.getTime()));
|
||||||
|
createTimePicker();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
calendar.get(Calendar.YEAR),
|
||||||
|
calendar.get(Calendar.MONTH),
|
||||||
|
calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTimePicker()
|
||||||
|
{
|
||||||
|
new android.app.TimePickerDialog(
|
||||||
|
RecordTransactionActivity.this,
|
||||||
|
new android.app.TimePickerDialog.OnTimeSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onTimeSet(TimePicker view, int hour, int minute) {
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
|
calendar.set(Calendar.MINUTE, minute);
|
||||||
|
purchasedDate.setText(sdf.format(calendar.getTime()));
|
||||||
|
|
||||||
|
currency.getTimestampPrice(RecordTransactionActivity.this, new Currency.PriceCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String price) {
|
||||||
|
purchasedPrice.setText(price);
|
||||||
|
}
|
||||||
|
}, calendar.getTimeInMillis() / 1000);
|
||||||
|
Log.d("coinfolio", "Time : " + calendar.getTimeInMillis());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
calendar.get(Calendar.HOUR_OF_DAY),
|
||||||
|
calendar.get(Calendar.MINUTE),
|
||||||
|
true
|
||||||
|
).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import android.preference.PreferenceActivity;
|
|||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.RingtonePreference;
|
import android.preference.RingtonePreference;
|
||||||
|
import android.preference.SwitchPreference;
|
||||||
import android.security.keystore.KeyGenParameterSpec;
|
import android.security.keystore.KeyGenParameterSpec;
|
||||||
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||||
import android.security.keystore.KeyProperties;
|
import android.security.keystore.KeyProperties;
|
||||||
@ -131,8 +132,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("coinfolio", "hello");
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +197,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
*/
|
*/
|
||||||
protected boolean isValidFragment(String fragmentName) {
|
protected boolean isValidFragment(String fragmentName) {
|
||||||
return PreferenceFragment.class.getName().equals(fragmentName)
|
return PreferenceFragment.class.getName().equals(fragmentName)
|
||||||
//|| GeneralPreferenceFragment.class.getName().equals(fragmentName)
|
|| GeneralPreferenceFragment.class.getName().equals(fragmentName)
|
||||||
|| DataSyncPreferenceFragment.class.getName().equals(fragmentName)
|
|| DataSyncPreferenceFragment.class.getName().equals(fragmentName)
|
||||||
|| NotificationPreferenceFragment.class.getName().equals(fragmentName)
|
|| NotificationPreferenceFragment.class.getName().equals(fragmentName)
|
||||||
|| ExchangePreferenceFragment.class.getName().equals(fragmentName);
|
|| ExchangePreferenceFragment.class.getName().equals(fragmentName);
|
||||||
@ -216,12 +215,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
addPreferencesFromResource(R.xml.pref_general);
|
addPreferencesFromResource(R.xml.pref_general);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
|
findPreference("hide_balance").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
// to their values. When their values change, their summaries are
|
@Override
|
||||||
// updated to reflect the new value, per the Android Design
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
// guidelines.
|
boolean isChecked = ((SwitchPreference) findPreference("hide_balance")).isChecked();
|
||||||
bindPreferenceSummaryToValue(findPreference("example_text"));
|
|
||||||
bindPreferenceSummaryToValue(findPreference("example_list"));
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
|
editor.putBoolean("hide_balance", isChecked);
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
return isChecked;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -259,6 +267,38 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
bindPreferenceSummaryToValue(findPreference("hitbtc_privatekey"));
|
bindPreferenceSummaryToValue(findPreference("hitbtc_privatekey"));
|
||||||
bindPreferenceSummaryToValue(findPreference("binance_privatekey"));
|
bindPreferenceSummaryToValue(findPreference("binance_privatekey"));
|
||||||
|
|
||||||
|
findPreference("enable_hitbtc").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
boolean isChecked = ((SwitchPreference) findPreference("enable_hitbtc")).isChecked();
|
||||||
|
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
|
editor.putBoolean("mustUpdateSummary", true);
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
return isChecked;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
findPreference("enable_binance").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
boolean isChecked = ((SwitchPreference) findPreference("enable_binance")).isChecked();
|
||||||
|
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
|
editor.putBoolean("mustUpdateSummary", true);
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
return isChecked;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
startFingerprintProtocol();
|
startFingerprintProtocol();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +320,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
|
|
||||||
if(preferences.getBoolean("enable_fingerprint", false))
|
if(preferences.getBoolean("enable_fingerprint", false))
|
||||||
{
|
{
|
||||||
|
|
||||||
newFragment.setCancelable(false);
|
newFragment.setCancelable(false);
|
||||||
newFragment.show(getFragmentManager(), "dialog");
|
newFragment.show(getFragmentManager(), "dialog");
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import com.android.volley.VolleyError;
|
|||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.android.volley.toolbox.Volley;
|
import com.android.volley.toolbox.Volley;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
|
||||||
import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager;
|
import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager;
|
||||||
import com.nauk.coinfolio.DataManagers.ExchangeManager.HitBtcManager;
|
import com.nauk.coinfolio.DataManagers.ExchangeManager.HitBtcManager;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
@ -46,6 +47,7 @@ public class BalanceManager {
|
|||||||
private LinkedHashMap<String, String> coinInfosHashmap;
|
private LinkedHashMap<String, String> coinInfosHashmap;
|
||||||
private PreferencesManager preferenceManager;
|
private PreferencesManager preferenceManager;
|
||||||
private DatabaseManager databaseManager;
|
private DatabaseManager databaseManager;
|
||||||
|
private CurrencyDetailsList currencyDetailsList;
|
||||||
|
|
||||||
private int balanceCounter;
|
private int balanceCounter;
|
||||||
|
|
||||||
@ -65,37 +67,20 @@ public class BalanceManager {
|
|||||||
databaseManager = new DatabaseManager(context);
|
databaseManager = new DatabaseManager(context);
|
||||||
hitBtcManagers = new ArrayList<>();
|
hitBtcManagers = new ArrayList<>();
|
||||||
binanceManagers = new ArrayList<>();
|
binanceManagers = new ArrayList<>();
|
||||||
|
currencyDetailsList = new CurrencyDetailsList(context);
|
||||||
|
|
||||||
balanceCounter = 0;
|
balanceCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCurrenciesName()
|
|
||||||
{
|
|
||||||
List<String> currenciesName = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String symbol : coinInfosHashmap.keySet())
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
|
|
||||||
currenciesName.add(jsonObject.getString("CoinName"));
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return currenciesName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getBiggestCurrencies()
|
public List<String> getBiggestCurrencies()
|
||||||
{
|
{
|
||||||
List<String> currenciesDetails = new ArrayList<>();
|
List<String> currenciesDetails = new ArrayList<>();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
Iterator<String> coinIterator = coinInfosHashmap.keySet().iterator();
|
Iterator<String> coinIterator = currencyDetailsList.getCoinInfosHashmap().keySet().iterator();
|
||||||
|
|
||||||
while(index < 11)
|
while(index < 11)
|
||||||
{
|
{
|
||||||
//currenciesDetails.add(index, coinInfosHashmap.keySet().iterator().next());
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
Log.d("coinfolio", "For " + index + " : " + coinIterator.next());
|
Log.d("coinfolio", "For " + index + " : " + coinIterator.next());
|
||||||
@ -104,28 +89,6 @@ public class BalanceManager {
|
|||||||
return currenciesDetails;
|
return currenciesDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getOrders()
|
|
||||||
{
|
|
||||||
List<String> currenciesOrder = new ArrayList<>();
|
|
||||||
|
|
||||||
for(String symbol : coinInfosHashmap.keySet())
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
|
|
||||||
currenciesOrder.add(jsonObject.getString("SortOrder"));
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return currenciesOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getCurrenciesSymbol()
|
|
||||||
{
|
|
||||||
return new ArrayList<>(coinInfosHashmap.keySet());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateExchangeKeys()
|
public void updateExchangeKeys()
|
||||||
{
|
{
|
||||||
String publicKey = preferenceManager.getHitBTCPublicKey();
|
String publicKey = preferenceManager.getHitBTCPublicKey();
|
||||||
@ -158,7 +121,7 @@ public class BalanceManager {
|
|||||||
{
|
{
|
||||||
boolean isUpdated = false;
|
boolean isUpdated = false;
|
||||||
|
|
||||||
manualBalances = databaseManager.getAllCurrencyFromManualCurrency();
|
manualBalances = databaseManager.getAllCurrenciesFromManualCurrency();
|
||||||
|
|
||||||
if(binanceManagers.size() > 0)
|
if(binanceManagers.size() > 0)
|
||||||
{
|
{
|
||||||
@ -290,7 +253,8 @@ public class BalanceManager {
|
|||||||
|
|
||||||
public void updateDetails(final IconCallBack callBack)
|
public void updateDetails(final IconCallBack callBack)
|
||||||
{
|
{
|
||||||
StringRequest strRequest = new StringRequest(Request.Method.GET, detailUrl,
|
currencyDetailsList.update(callBack);
|
||||||
|
/*StringRequest strRequest = new StringRequest(Request.Method.GET, detailUrl,
|
||||||
new Response.Listener<String>() {
|
new Response.Listener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(String response) {
|
public void onResponse(String response) {
|
||||||
@ -306,7 +270,7 @@ public class BalanceManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
requestQueue.add(strRequest);
|
requestQueue.add(strRequest);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIconUrl(String symbol)
|
public String getIconUrl(String symbol)
|
||||||
@ -314,7 +278,7 @@ public class BalanceManager {
|
|||||||
String url;
|
String url;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
|
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||||
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL");
|
Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL");
|
||||||
@ -332,7 +296,7 @@ public class BalanceManager {
|
|||||||
String currencyName = null;
|
String currencyName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
|
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||||
currencyName = jsonObject.getString("CoinName");
|
currencyName = jsonObject.getString("CoinName");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -346,7 +310,7 @@ public class BalanceManager {
|
|||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
|
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||||
id = jsonObject.getInt("Id");
|
id = jsonObject.getInt("Id");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -355,32 +319,6 @@ public class BalanceManager {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processDetailResult(String response, final IconCallBack callBack)
|
|
||||||
{
|
|
||||||
response = response.substring(response.indexOf("\"Data\"") + 7, response.lastIndexOf("},\"Type\":100}"));
|
|
||||||
String[] tab = response.split(Pattern.quote("},"));
|
|
||||||
|
|
||||||
coinInfosHashmap = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
for(int i = 0; i < tab.length; i++)
|
|
||||||
{
|
|
||||||
tab[i] = tab[i].substring(tab[i].indexOf("\":{")+2, tab[i].length()) + "}";
|
|
||||||
try {
|
|
||||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
|
||||||
StrictMode.setThreadPolicy(policy);
|
|
||||||
JSONObject jsonObject = new JSONObject(tab[i]);
|
|
||||||
|
|
||||||
coinInfosHashmap.put(jsonObject.getString("Symbol"), tab[i]);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sortDetails();
|
|
||||||
|
|
||||||
callBack.onSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortDetails()
|
private void sortDetails()
|
||||||
{
|
{
|
||||||
LinkedHashMap<String, String> sortedHashmap = new LinkedHashMap<>();
|
LinkedHashMap<String, String> sortedHashmap = new LinkedHashMap<>();
|
||||||
|
@ -3,6 +3,12 @@ package com.nauk.coinfolio.DataManagers.CurrencyData;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,21 +34,12 @@ public class Currency implements Parcelable {
|
|||||||
private CurrencyDataRetriever dataRetriver;
|
private CurrencyDataRetriever dataRetriver;
|
||||||
private Bitmap icon;
|
private Bitmap icon;
|
||||||
private int chartColor;
|
private int chartColor;
|
||||||
|
private int circulatingSupply;
|
||||||
public Currency(Currency currency)
|
private int totalSupply;
|
||||||
{
|
private double marketCapitalization;
|
||||||
this.id = currency.id;
|
private List<String> socialMediaLinks;
|
||||||
this.name = currency.name;
|
private String algorithm;
|
||||||
this.symbol = currency.symbol;
|
//private String proofType
|
||||||
this.value = currency.value;
|
|
||||||
this.balance = currency.balance;
|
|
||||||
this.dayFluctuationPercentage = currency.getDayFluctuationPercentage();
|
|
||||||
this.dayFluctuation = currency.getDayFluctuation();
|
|
||||||
this.historyMinutes = currency.historyMinutes;
|
|
||||||
this.dataRetriver = currency.getDataRetriver();
|
|
||||||
this.icon = currency.icon;
|
|
||||||
this.chartColor = currency.chartColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Currency(String symbol, double balance)
|
public Currency(String symbol, double balance)
|
||||||
{
|
{
|
||||||
@ -63,6 +60,41 @@ public class Currency implements Parcelable {
|
|||||||
this.symbol = symbol;
|
this.symbol = symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public Currency(int id, String symbol, String name, String algorithm, String proofType, )
|
||||||
|
|
||||||
|
public void getTimestampPrice(android.content.Context context, final PriceCallBack callBack, long timestamp)
|
||||||
|
{
|
||||||
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
|
||||||
|
dataRetriver.getPriceTimestamp(symbol, new CurrencyDataRetriever.DataChartCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<CurrencyDataChart> dataChart) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String price) {
|
||||||
|
callBack.onSuccess(price);
|
||||||
|
}
|
||||||
|
}, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIconUrl(String currencyDetails)
|
||||||
|
{
|
||||||
|
String url;
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(currencyDetails);
|
||||||
|
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
//Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL");
|
||||||
|
url = null;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//Log.d(context.getResources().getString(R.string.debug), "Url parsing error for " + symbol);
|
||||||
|
url = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateHistoryMinutes(android.content.Context context, final CurrencyCallBack callBack)
|
public void updateHistoryMinutes(android.content.Context context, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
@ -84,6 +116,9 @@ public class Currency implements Parcelable {
|
|||||||
|
|
||||||
callBack.onSuccess(Currency.this);
|
callBack.onSuccess(Currency.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String result){}
|
||||||
}, CurrencyDataRetriever.MINUTES);
|
}, CurrencyDataRetriever.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +132,9 @@ public class Currency implements Parcelable {
|
|||||||
|
|
||||||
callBack.onSuccess(Currency.this);
|
callBack.onSuccess(Currency.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String price) {}
|
||||||
}, CurrencyDataRetriever.HOURS);
|
}, CurrencyDataRetriever.HOURS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,9 +148,18 @@ public class Currency implements Parcelable {
|
|||||||
|
|
||||||
callBack.onSuccess(Currency.this);
|
callBack.onSuccess(Currency.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String price) {}
|
||||||
}, CurrencyDataRetriever.DAYS);
|
}, CurrencyDataRetriever.DAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateDetails(android.content.Context context, final CurrencyCallBack callBack)
|
||||||
|
{
|
||||||
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void setId(int id)
|
public void setId(int id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -237,6 +284,9 @@ public class Currency implements Parcelable {
|
|||||||
void onSuccess(Currency currency);
|
void onSuccess(Currency currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface PriceCallBack {
|
||||||
|
void onSuccess(String price);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
|
@ -9,19 +9,23 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
public class CurrencyDataChart implements Parcelable {
|
public class CurrencyDataChart implements Parcelable {
|
||||||
|
|
||||||
long timestamp;
|
private long timestamp;
|
||||||
double close;
|
private double close;
|
||||||
double high;
|
private double high;
|
||||||
double low;
|
private double low;
|
||||||
double open;
|
private double open;
|
||||||
|
private double volumeFrom;
|
||||||
|
private double volumeTo;
|
||||||
|
|
||||||
public CurrencyDataChart(long timestamp, double close, double high, double low, double open)
|
public CurrencyDataChart(long timestamp, double close, double high, double low, double open, double volumeFrom, double volumeTo)
|
||||||
{
|
{
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.close = close;
|
this.close = close;
|
||||||
this.high = high;
|
this.high = high;
|
||||||
this.low = low;
|
this.low = low;
|
||||||
this.open = open;
|
this.open = open;
|
||||||
|
this.volumeFrom = volumeFrom;
|
||||||
|
this.volumeTo = volumeTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOpen()
|
public double getOpen()
|
||||||
@ -34,11 +38,41 @@ public class CurrencyDataChart implements Parcelable {
|
|||||||
return close;
|
return close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getVolumeTo()
|
||||||
|
{
|
||||||
|
return volumeTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getVolumeFrom()
|
||||||
|
{
|
||||||
|
return volumeFrom;
|
||||||
|
}
|
||||||
|
|
||||||
public long getTimestamp()
|
public long getTimestamp()
|
||||||
{
|
{
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClose(double close) {
|
||||||
|
this.close = close;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getHigh() {
|
||||||
|
return high;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHigh(double high) {
|
||||||
|
this.high = high;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLow() {
|
||||||
|
return low;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLow(double low) {
|
||||||
|
this.low = low;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
@ -51,6 +85,8 @@ public class CurrencyDataChart implements Parcelable {
|
|||||||
dest.writeDouble(this.high);
|
dest.writeDouble(this.high);
|
||||||
dest.writeDouble(this.low);
|
dest.writeDouble(this.low);
|
||||||
dest.writeDouble(this.open);
|
dest.writeDouble(this.open);
|
||||||
|
dest.writeDouble(this.volumeFrom);
|
||||||
|
dest.writeDouble(this.volumeTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CurrencyDataChart(Parcel in) {
|
protected CurrencyDataChart(Parcel in) {
|
||||||
@ -59,6 +95,8 @@ public class CurrencyDataChart implements Parcelable {
|
|||||||
this.high = in.readDouble();
|
this.high = in.readDouble();
|
||||||
this.low = in.readDouble();
|
this.low = in.readDouble();
|
||||||
this.open = in.readDouble();
|
this.open = in.readDouble();
|
||||||
|
this.volumeFrom = in.readDouble();
|
||||||
|
this.volumeTo = in.readDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<CurrencyDataChart> CREATOR = new Parcelable.Creator<CurrencyDataChart>() {
|
public static final Parcelable.Creator<CurrencyDataChart> CREATOR = new Parcelable.Creator<CurrencyDataChart>() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.nauk.coinfolio.DataManagers.CurrencyData;
|
package com.nauk.coinfolio.DataManagers.CurrencyData;
|
||||||
|
|
||||||
|
import android.provider.ContactsContract;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
@ -42,7 +43,58 @@ public class CurrencyDataRetriever {
|
|||||||
requestQueue = Volley.newRequestQueue(context);
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getPriceTimestamp(final String symbolCurrencyFrom, String symbolCurrencyTo, final DataChartCallBack callBack, long timestamp)
|
||||||
|
{
|
||||||
|
final String requestUrl = "https://min-api.cryptocompare.com/data/pricehistorical?fsym=" + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo + "&ts=" + timestamp;
|
||||||
|
|
||||||
|
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
||||||
|
new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
Log.d("coinfolio", response + " " + requestUrl);
|
||||||
|
callBack.onSuccess(processPriceTimestampResult(response));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestQueue.add(stringRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processPriceTimestampResult(String result)
|
||||||
|
{
|
||||||
|
result = result.substring(result.lastIndexOf(':')+1);
|
||||||
|
result = result.substring(0, result.indexOf('}'));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateHistory(final String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
|
private void updateHistory(final String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
|
||||||
|
{
|
||||||
|
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
||||||
|
|
||||||
|
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
||||||
|
new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
callBack.onSuccess(processHistoryResult(response));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
callBack.onSuccess((List<CurrencyDataChart>) null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestQueue.add(stringRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRequestUrl(int timeUnit, String symbolCurrencyFrom, String symbolCyrrencyTo)
|
||||||
{
|
{
|
||||||
String requestUrl = null;
|
String requestUrl = null;
|
||||||
|
|
||||||
@ -59,21 +111,7 @@ public class CurrencyDataRetriever {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
return requestUrl;
|
||||||
new Response.Listener<String>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(String response) {
|
|
||||||
callBack.onSuccess(processHistoryResult(response));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Response.ErrorListener() {
|
|
||||||
@Override
|
|
||||||
public void onErrorResponse(VolleyError error) {
|
|
||||||
callBack.onSuccess(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
requestQueue.add(stringRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CurrencyDataChart> processHistoryResult(String response)
|
private List<CurrencyDataChart> processHistoryResult(String response)
|
||||||
@ -99,13 +137,7 @@ public class CurrencyDataRetriever {
|
|||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(tab[i]);
|
JSONObject jsonObject = new JSONObject(tab[i]);
|
||||||
|
|
||||||
long timestamp = Long.parseLong(jsonObject.getString("time"));
|
dataChart.add(parseJSON(jsonObject));
|
||||||
double close = Double.parseDouble(jsonObject.getString("close"));
|
|
||||||
double high = Double.parseDouble(jsonObject.getString("high"));
|
|
||||||
double low = Double.parseDouble(jsonObject.getString("low"));
|
|
||||||
double open = Double.parseDouble(jsonObject.getString("open"));
|
|
||||||
|
|
||||||
dataChart.add(new CurrencyDataChart(timestamp, close, high, low, open));
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.d(context.getResources().getString(R.string.debug_volley), "API Request error: " + e + " index: " + i);
|
Log.d(context.getResources().getString(R.string.debug_volley), "API Request error: " + e + " index: " + i);
|
||||||
@ -120,11 +152,29 @@ public class CurrencyDataRetriever {
|
|||||||
return dataChart;
|
return dataChart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateHistory(String symbolCurrencyFrom, final DataChartCallBack callBack, int timeUnit)
|
private CurrencyDataChart parseJSON(JSONObject jsonObject) throws JSONException {
|
||||||
|
|
||||||
|
long timestamp = Long.parseLong(jsonObject.getString("time"));
|
||||||
|
double close = Double.parseDouble(jsonObject.getString("close"));
|
||||||
|
double high = Double.parseDouble(jsonObject.getString("high"));
|
||||||
|
double low = Double.parseDouble(jsonObject.getString("low"));
|
||||||
|
double open = Double.parseDouble(jsonObject.getString("open"));
|
||||||
|
double volumeFrom = Double.parseDouble(jsonObject.getString("volumefrom"));
|
||||||
|
double volumeTo = Double.parseDouble(jsonObject.getString("volumeto"));
|
||||||
|
|
||||||
|
return new CurrencyDataChart(timestamp, close, high, low, open, volumeFrom, volumeTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getPriceTimestamp(String symbolCurrencyFrom, final DataChartCallBack callBack, long timestamp)
|
||||||
|
{
|
||||||
|
getPriceTimestamp(symbolCurrencyFrom, "USD", callBack, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateHistory(String symbolCurrencyFrom, final DataChartCallBack callBack, int timeUnit)
|
||||||
{
|
{
|
||||||
if(symbolCurrencyFrom.equals("USD"))
|
if(symbolCurrencyFrom.equals("USD"))
|
||||||
{
|
{
|
||||||
callBack.onSuccess(null);
|
callBack.onSuccess((List<CurrencyDataChart>) null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -132,7 +182,34 @@ public class CurrencyDataRetriever {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public void updateCryptocompareDetails(int id, final Currency.CurrencyCallBack callBack)
|
||||||
|
{
|
||||||
|
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
||||||
|
|
||||||
|
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
||||||
|
new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
callBack.onSuccess();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
callBack.onSuccess();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestQueue.add(stringRequest);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void updateCoinMarketCapDetails()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public interface DataChartCallBack {
|
public interface DataChartCallBack {
|
||||||
void onSuccess(List<CurrencyDataChart> dataChart);
|
void onSuccess(List<CurrencyDataChart> dataChart);
|
||||||
|
void onSuccess(String price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,149 @@
|
|||||||
|
package com.nauk.coinfolio.DataManagers.CurrencyData;
|
||||||
|
|
||||||
|
import android.os.StrictMode;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivity;
|
||||||
|
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||||
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tiji on 11/04/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CurrencyDetailsList {
|
||||||
|
|
||||||
|
final private static String DETAILURL = "https://www.cryptocompare.com/api/data/coinlist/";
|
||||||
|
private RequestQueue requestQueue;
|
||||||
|
private LinkedHashMap<String, String> coinInfosHashmap;
|
||||||
|
private android.content.Context context;
|
||||||
|
|
||||||
|
public CurrencyDetailsList(android.content.Context context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(final BalanceManager.IconCallBack callBack)
|
||||||
|
{
|
||||||
|
StringRequest strRequest = new StringRequest(Request.Method.GET, DETAILURL,
|
||||||
|
new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
if (response.length() > 0) {
|
||||||
|
processDetailResult(response, callBack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestQueue.add(strRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void processDetailResult(String response, final BalanceManager.IconCallBack callBack)
|
||||||
|
{
|
||||||
|
response = response.substring(response.indexOf("\"Data\"") + 7, response.lastIndexOf("},\"Type\":100}"));
|
||||||
|
String[] tab = response.split(Pattern.quote("},"));
|
||||||
|
|
||||||
|
coinInfosHashmap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for(int i = 0; i < tab.length; i++)
|
||||||
|
{
|
||||||
|
tab[i] = tab[i].substring(tab[i].indexOf("\":{")+2, tab[i].length()) + "}";
|
||||||
|
try {
|
||||||
|
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||||
|
StrictMode.setThreadPolicy(policy);
|
||||||
|
JSONObject jsonObject = new JSONObject(tab[i]);
|
||||||
|
|
||||||
|
coinInfosHashmap.put(jsonObject.getString("Symbol"), tab[i]);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sortDetails();
|
||||||
|
|
||||||
|
callBack.onSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sortDetails()
|
||||||
|
{
|
||||||
|
LinkedHashMap<String, String> sortedHashmap = new LinkedHashMap<>();
|
||||||
|
List<String> listInfos = new ArrayList<>(coinInfosHashmap.values());
|
||||||
|
List<String> listSymbols = new ArrayList<>(coinInfosHashmap.keySet());
|
||||||
|
|
||||||
|
for(int i = 0; i < coinInfosHashmap.keySet().size(); i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(listInfos.get(i));
|
||||||
|
int index = jsonObject.getInt("SortOrder");
|
||||||
|
|
||||||
|
listInfos.add(index, listInfos.get(i));
|
||||||
|
listSymbols.add(index, listSymbols.get(i));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < listInfos.size(); i++)
|
||||||
|
{
|
||||||
|
sortedHashmap.put(listSymbols.get(i), listInfos.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
coinInfosHashmap = sortedHashmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedHashMap<String, String> getCoinInfosHashmap() {
|
||||||
|
return coinInfosHashmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCurrenciesName()
|
||||||
|
{
|
||||||
|
List<String> currenciesName = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String symbol : coinInfosHashmap.keySet())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
|
||||||
|
currenciesName.add(jsonObject.getString("CoinName"));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return currenciesName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Currency getCurrencyDetailsFromSymbol(String symbol)
|
||||||
|
{
|
||||||
|
//Currency currency = new Currency();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCurrenciesSymbol()
|
||||||
|
{
|
||||||
|
return new ArrayList<>(coinInfosHashmap.keySet());
|
||||||
|
}
|
||||||
|
}
|
@ -9,14 +9,17 @@ public class Transaction {
|
|||||||
private int transactionId;
|
private int transactionId;
|
||||||
private String symbol;
|
private String symbol;
|
||||||
private double amount;
|
private double amount;
|
||||||
|
private long timestamp;
|
||||||
private double purchasedPrice;
|
private double purchasedPrice;
|
||||||
private boolean isMined;
|
private boolean isMined;
|
||||||
|
|
||||||
public Transaction(int transactionId, String symbol, double amount)
|
public Transaction(int transactionId, String symbol, double amount, long timestamp, double purchasedPrice)
|
||||||
{
|
{
|
||||||
this.transactionId = transactionId;
|
this.transactionId = transactionId;
|
||||||
this.symbol = symbol;
|
this.symbol = symbol;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.purchasedPrice = purchasedPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTransactionId() {
|
public int getTransactionId() {
|
||||||
@ -39,7 +42,22 @@ public class Transaction {
|
|||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTimestamp()
|
||||||
|
{
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAmount(double amount) {
|
public void setAmount(double amount) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPurchasedPrice(double purchasedPrice)
|
||||||
|
{
|
||||||
|
this.purchasedPrice = purchasedPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPurchasedPrice()
|
||||||
|
{
|
||||||
|
return purchasedPrice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,13 @@ import android.content.Context;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Transaction;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Transaction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,12 +20,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DatabaseManager extends SQLiteOpenHelper{
|
public class DatabaseManager extends SQLiteOpenHelper{
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 5;
|
private static final int DATABASE_VERSION = 6;
|
||||||
|
|
||||||
private static final String DATABASE_NAME = "Currencies.db";
|
private static final String DATABASE_NAME = "Currencies.db";
|
||||||
|
|
||||||
private static final String TABLE_MANUAL_CURRENCIES = "ManualCurrencies";
|
private static final String TABLE_MANUAL_CURRENCIES = "ManualCurrencies";
|
||||||
private static final String TABLE_EXCHANGE_KEYS = "ExchangeKeys";
|
private static final String TABLE_EXCHANGE_KEYS = "ExchangeKeys";
|
||||||
|
private static final String TABLE_WATCHLIST = "Watchlist";
|
||||||
|
|
||||||
private static final String KEY_CURRENCY_ID = "idCurrency";
|
private static final String KEY_CURRENCY_ID = "idCurrency";
|
||||||
private static final String KEY_CURRENCY_SYMBOL = "symbol";
|
private static final String KEY_CURRENCY_SYMBOL = "symbol";
|
||||||
@ -38,6 +41,11 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
private static final String KEY_EXCHANGE_PUBLIC_KEY = "publicKey";
|
private static final String KEY_EXCHANGE_PUBLIC_KEY = "publicKey";
|
||||||
private static final String KEY_EXCHANGE_SECRET_KEY = "secretKey";
|
private static final String KEY_EXCHANGE_SECRET_KEY = "secretKey";
|
||||||
|
|
||||||
|
private static final String KEY_WATCHLIST_ID = "idWatchlist";
|
||||||
|
private static final String KEY_WATCHLIST_SYMBOL = "symbol";
|
||||||
|
private static final String KEY_WATCHLIST_NAME = "name";
|
||||||
|
private static final String KEY_WATCHLIST_POSITION = "position";
|
||||||
|
|
||||||
public DatabaseManager(Context context)
|
public DatabaseManager(Context context)
|
||||||
{
|
{
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
@ -51,8 +59,8 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
+ KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
|
+ KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
|
||||||
+ KEY_CURRENCY_NAME + " VARCHAR(45),"
|
+ KEY_CURRENCY_NAME + " VARCHAR(45),"
|
||||||
+ KEY_CURRENCY_BALANCE + " TEXT,"
|
+ KEY_CURRENCY_BALANCE + " TEXT,"
|
||||||
+ KEY_CURRENCY_DATE + " DATE,"
|
+ KEY_CURRENCY_DATE + " TEXT,"
|
||||||
+ KEY_CURRENCY_PURCHASED_PRICE + " TEXT,"
|
+ KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
|
||||||
+ KEY_CURRENCY_IS_MINED + " INTEGER"
|
+ KEY_CURRENCY_IS_MINED + " INTEGER"
|
||||||
+ ");");
|
+ ");");
|
||||||
|
|
||||||
@ -63,6 +71,13 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
+ KEY_EXCHANGE_SECRET_KEY + " TEXT"
|
+ KEY_EXCHANGE_SECRET_KEY + " TEXT"
|
||||||
+ ");");
|
+ ");");
|
||||||
|
|
||||||
|
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_WATCHLIST + "("
|
||||||
|
+ KEY_WATCHLIST_ID + " INTEGER PRIMARY KEY,"
|
||||||
|
+ KEY_WATCHLIST_SYMBOL + " VARCHAR(4),"
|
||||||
|
+ KEY_WATCHLIST_NAME + " TEXT,"
|
||||||
|
+ KEY_WATCHLIST_POSITION + " INTEGER"
|
||||||
|
+ ");");
|
||||||
|
|
||||||
//loadSample(db);
|
//loadSample(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,25 +86,55 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
{
|
{
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_MANUAL_CURRENCIES);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_MANUAL_CURRENCIES);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_EXCHANGE_KEYS);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_EXCHANGE_KEYS);
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_WATCHLIST);
|
||||||
|
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCurrencyToManualCurrency(String symbol, double balance)
|
public void addCurrencyToWatchlist(Currency currency)
|
||||||
|
{
|
||||||
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
|
||||||
|
values.put(KEY_WATCHLIST_SYMBOL, currency.getSymbol());
|
||||||
|
values.put(KEY_WATCHLIST_NAME, currency.getName());
|
||||||
|
|
||||||
|
db.insert(TABLE_WATCHLIST, null, values);
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Currency> getAllCurrenciesFromWatchlist()
|
||||||
|
{
|
||||||
|
String searchQuerry = "SELECT * FROM " + TABLE_WATCHLIST;
|
||||||
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
|
Cursor resultatList = db.rawQuery(searchQuerry, null);
|
||||||
|
|
||||||
|
List<Currency> currencyList = new ArrayList<>();
|
||||||
|
|
||||||
|
while(resultatList.moveToNext())
|
||||||
|
{
|
||||||
|
currencyList.add(new Currency(resultatList.getString(2), resultatList.getString(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return currencyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCurrencyToManualCurrency(String symbol, double balance, Date date, String purchasedPrice)
|
||||||
{
|
{
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
|
|
||||||
values.put(KEY_CURRENCY_SYMBOL, symbol);
|
values.put(KEY_CURRENCY_SYMBOL, symbol);
|
||||||
values.put(KEY_CURRENCY_BALANCE, balance);
|
values.put(KEY_CURRENCY_BALANCE, balance);
|
||||||
//values.put(KEY_CURRENCY_DATE, getDate());
|
values.put(KEY_CURRENCY_DATE, date.getTime());
|
||||||
|
values.put(KEY_CURRENCY_PURCHASED_PRICE, purchasedPrice);
|
||||||
//values.put(KEY_CURRENCY_PURCHASED_PRICE, something);
|
//values.put(KEY_CURRENCY_PURCHASED_PRICE, something);
|
||||||
|
|
||||||
db.insert(TABLE_MANUAL_CURRENCIES, null, values);
|
db.insert(TABLE_MANUAL_CURRENCIES, null, values);
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Currency> getAllCurrencyFromManualCurrency()
|
public List<Currency> getAllCurrenciesFromManualCurrency()
|
||||||
{
|
{
|
||||||
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_CURRENCIES;
|
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_CURRENCIES;
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
@ -100,6 +145,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
while(resultatList.moveToNext())
|
while(resultatList.moveToNext())
|
||||||
{
|
{
|
||||||
currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3)));
|
currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3)));
|
||||||
|
Log.d("coinfolio", "Database output : " + resultatList.getString(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
resultatList.close();
|
resultatList.close();
|
||||||
@ -109,20 +155,17 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
return currencyList;
|
return currencyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public HashMap<Integer, Double> getCurrencyTransactions(String symbol)
|
|
||||||
public List<Transaction> getCurrencyTransactions(String symbol)
|
public List<Transaction> getCurrencyTransactions(String symbol)
|
||||||
{
|
{
|
||||||
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_CURRENCIES + " WHERE symbol='" + symbol.toUpperCase() + "'";
|
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_CURRENCIES + " WHERE symbol='" + symbol.toUpperCase() + "'";
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
Cursor resultatList = db.rawQuery(searchQuerry, null);
|
Cursor resultatList = db.rawQuery(searchQuerry, null);
|
||||||
|
|
||||||
//HashMap<Integer, Double> transactionList = new HashMap<>();
|
|
||||||
List<Transaction> transactionList = new ArrayList<>();
|
List<Transaction> transactionList = new ArrayList<>();
|
||||||
|
|
||||||
while(resultatList.moveToNext())
|
while(resultatList.moveToNext())
|
||||||
{
|
{
|
||||||
//transactionList.put(resultatList.getInt(0), resultatList.getDouble(3));
|
transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(3), resultatList.getLong(4), resultatList.getLong(5)));
|
||||||
transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(3)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultatList.close();
|
resultatList.close();
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
package com.nauk.coinfolio.DataManagers.ExchangeManager;
|
package com.nauk.coinfolio.DataManagers.ExchangeManager;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.binance.api.client.BinanceApiClientFactory;
|
import com.binance.api.client.BinanceApiClientFactory;
|
||||||
import com.binance.api.client.BinanceApiRestClient;
|
import com.binance.api.client.BinanceApiRestClient;
|
||||||
import com.binance.api.client.domain.account.Account;
|
import com.binance.api.client.domain.account.Account;
|
||||||
import com.binance.api.client.domain.account.AssetBalance;
|
import com.binance.api.client.domain.account.AssetBalance;
|
||||||
|
import com.binance.api.client.domain.account.Order;
|
||||||
|
import com.binance.api.client.domain.account.Trade;
|
||||||
|
import com.binance.api.client.domain.account.request.OrderRequest;
|
||||||
import com.binance.api.client.exception.BinanceApiException;
|
import com.binance.api.client.exception.BinanceApiException;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -21,8 +27,7 @@ public class BinanceManager {
|
|||||||
private String privateKey;
|
private String privateKey;
|
||||||
|
|
||||||
private List<Currency> balance;
|
private List<Currency> balance;
|
||||||
|
private HashMap<String, List<Trade>> trades;
|
||||||
public BinanceManager(){}
|
|
||||||
|
|
||||||
public BinanceManager(String publicKey, String privateKey)
|
public BinanceManager(String publicKey, String privateKey)
|
||||||
{
|
{
|
||||||
@ -32,7 +37,6 @@ public class BinanceManager {
|
|||||||
|
|
||||||
public void updateBalance(BinanceCallBack callBack)
|
public void updateBalance(BinanceCallBack callBack)
|
||||||
{
|
{
|
||||||
Map<String, AssetBalance> accountBalanceCache;
|
|
||||||
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey);
|
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey);
|
||||||
BinanceApiRestClient client = factory.newRestClient();
|
BinanceApiRestClient client = factory.newRestClient();
|
||||||
|
|
||||||
@ -56,14 +60,46 @@ public class BinanceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPublicKey(String publicKey)
|
public void updateTrades(BinanceCallBack callBack, String symbol)
|
||||||
{
|
{
|
||||||
this.publicKey = publicKey;
|
trades = new HashMap<>();
|
||||||
|
|
||||||
|
trades.put("BTC", updateTrades(null, symbol, "BTC"));
|
||||||
|
|
||||||
|
trades.put("ETH", updateTrades(null, symbol, "ETH"));
|
||||||
|
|
||||||
|
trades.put("USDT", updateTrades(null, symbol, "USDT"));
|
||||||
|
|
||||||
|
callBack.onSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrivateKey(String privateKey)
|
public List<Trade> updateTrades(BinanceCallBack callBack, String symbol, String pairSymbol)
|
||||||
{
|
{
|
||||||
this.privateKey = privateKey;
|
List<Trade> presentTrades = new ArrayList<>();
|
||||||
|
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey);
|
||||||
|
BinanceApiRestClient client = factory.newRestClient();
|
||||||
|
|
||||||
|
if(!symbol.equals(pairSymbol))
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
presentTrades = client.getMyTrades(symbol + pairSymbol);
|
||||||
|
|
||||||
|
} catch (BinanceApiException e) {
|
||||||
|
try {
|
||||||
|
presentTrades = client.getMyTrades(pairSymbol + symbol);
|
||||||
|
|
||||||
|
} catch (BinanceApiException f) {
|
||||||
|
f.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(callBack != null)
|
||||||
|
{
|
||||||
|
callBack.onSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
return presentTrades;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Currency> getBalance()
|
public List<Currency> getBalance()
|
||||||
@ -71,6 +107,11 @@ public class BinanceManager {
|
|||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<String, List<Trade>> getTrades()
|
||||||
|
{
|
||||||
|
return trades;
|
||||||
|
}
|
||||||
|
|
||||||
public interface BinanceCallBack {
|
public interface BinanceCallBack {
|
||||||
void onSuccess();
|
void onSuccess();
|
||||||
void onError(String error);
|
void onError(String error);
|
||||||
|
@ -36,12 +36,6 @@ public class HitBtcManager {
|
|||||||
private List<Currency> balance;
|
private List<Currency> balance;
|
||||||
private android.content.Context context;
|
private android.content.Context context;
|
||||||
|
|
||||||
public HitBtcManager(android.content.Context context)
|
|
||||||
{
|
|
||||||
this.context = context;
|
|
||||||
requestQueue = Volley.newRequestQueue(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HitBtcManager(android.content.Context context, String publicKey, String privateKey)
|
public HitBtcManager(android.content.Context context, String publicKey, String privateKey)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@ -53,27 +47,9 @@ public class HitBtcManager {
|
|||||||
|
|
||||||
public void updateBalance(final HitBtcCallBack callBack)
|
public void updateBalance(final HitBtcCallBack callBack)
|
||||||
{
|
{
|
||||||
JsonArrayRequest arrayRequest = new JsonArrayRequest(Request.Method.GET, hitBalanceUrl,
|
JsonArrayRequest arrayRequest = new JsonArrayRequest(Request.Method.GET, hitBalanceUrl
|
||||||
new Response.Listener<JSONArray>() {
|
, getResponseListener(callBack), getErrorResponseListener(callBack))
|
||||||
@Override
|
{
|
||||||
public void onResponse(JSONArray response) {
|
|
||||||
if (response.length() > 0) {
|
|
||||||
parseBalance(response);
|
|
||||||
} else {
|
|
||||||
//No balance
|
|
||||||
}
|
|
||||||
|
|
||||||
callBack.onSuccess();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Response.ErrorListener() {
|
|
||||||
@Override
|
|
||||||
public void onErrorResponse(VolleyError error) {
|
|
||||||
Log.e(context.getResources().getString(R.string.debug), "API Error : " + error);
|
|
||||||
callBack.onError(error.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getHeaders() throws AuthFailureError {
|
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
@ -89,6 +65,31 @@ public class HitBtcManager {
|
|||||||
requestQueue.add(arrayRequest);
|
requestQueue.add(arrayRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response.Listener<JSONArray> getResponseListener(final HitBtcCallBack callBack)
|
||||||
|
{
|
||||||
|
return new Response.Listener<JSONArray>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(JSONArray response) {
|
||||||
|
if (response.length() > 0) {
|
||||||
|
parseBalance(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
callBack.onSuccess();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response.ErrorListener getErrorResponseListener(final HitBtcCallBack callBack)
|
||||||
|
{
|
||||||
|
return new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(context.getResources().getString(R.string.debug), "API Error : " + error);
|
||||||
|
callBack.onError(error.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void parseBalance(JSONArray response)
|
private void parseBalance(JSONArray response)
|
||||||
{
|
{
|
||||||
balance = new ArrayList<>();
|
balance = new ArrayList<>();
|
||||||
@ -109,16 +110,6 @@ public class HitBtcManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPublicKey(String publicKey)
|
|
||||||
{
|
|
||||||
this.publicKey = publicKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPrivateKey(String privateKey)
|
|
||||||
{
|
|
||||||
this.privateKey = privateKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Currency> getBalance()
|
public List<Currency> getBalance()
|
||||||
{
|
{
|
||||||
return balance;
|
return balance;
|
||||||
|
@ -24,7 +24,6 @@ public class MarketCapManager {
|
|||||||
|
|
||||||
private static final String topCurrenciesUrl = "https://api.coinmarketcap.com/v1/ticker/?limit=9";
|
private static final String topCurrenciesUrl = "https://api.coinmarketcap.com/v1/ticker/?limit=9";
|
||||||
private static final String marketCapUrl = "https://api.coinmarketcap.com/v1/global/";
|
private static final String marketCapUrl = "https://api.coinmarketcap.com/v1/global/";
|
||||||
private android.content.Context context;
|
|
||||||
private RequestQueue requestQueue;
|
private RequestQueue requestQueue;
|
||||||
private String topRequestResult[];
|
private String topRequestResult[];
|
||||||
private long marketCap;
|
private long marketCap;
|
||||||
@ -32,8 +31,6 @@ public class MarketCapManager {
|
|||||||
|
|
||||||
public MarketCapManager(android.content.Context context)
|
public MarketCapManager(android.content.Context context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
requestQueue = Volley.newRequestQueue(context);
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +124,8 @@ public class MarketCapManager {
|
|||||||
|
|
||||||
for(int i = 0; i < topRequestResult.length; i++)
|
for(int i = 0; i < topRequestResult.length; i++)
|
||||||
{
|
{
|
||||||
try {
|
topRequestResult[i] += "}";
|
||||||
topRequestResult[i] += "}";
|
/*try {
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject(topRequestResult[i]);
|
JSONObject jsonObject = new JSONObject(topRequestResult[i]);
|
||||||
|
|
||||||
@ -136,7 +133,7 @@ public class MarketCapManager {
|
|||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,23 +14,14 @@ public class PreferencesManager {
|
|||||||
private SharedPreferences settingPreferences;
|
private SharedPreferences settingPreferences;
|
||||||
private SharedPreferences currencyList;
|
private SharedPreferences currencyList;
|
||||||
private SharedPreferences preferencesList;
|
private SharedPreferences preferencesList;
|
||||||
android.content.Context context;
|
|
||||||
|
|
||||||
public PreferencesManager(android.content.Context context)
|
public PreferencesManager(android.content.Context context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
|
||||||
settingPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
settingPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
currencyList = context.getSharedPreferences(currencyListFile, 0);
|
currencyList = context.getSharedPreferences(currencyListFile, 0);
|
||||||
preferencesList = context.getSharedPreferences(preferencesFile, 0);
|
preferencesList = context.getSharedPreferences(preferencesFile, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCurrency(String symbol, double balance)
|
|
||||||
{
|
|
||||||
SharedPreferences.Editor editor = currencyList.edit();
|
|
||||||
editor.putString(symbol, String.valueOf(balance));
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDetailOption(boolean isExtended)
|
public void setDetailOption(boolean isExtended)
|
||||||
{
|
{
|
||||||
SharedPreferences.Editor editor = preferencesList.edit();
|
SharedPreferences.Editor editor = preferencesList.edit();
|
||||||
@ -58,6 +49,11 @@ public class PreferencesManager {
|
|||||||
return settingPreferences.getBoolean("enable_hitbtc", false);
|
return settingPreferences.getBoolean("enable_hitbtc", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBalanceHidden()
|
||||||
|
{
|
||||||
|
return settingPreferences.getBoolean("hide_balance", false);
|
||||||
|
}
|
||||||
|
|
||||||
public void disableHitBTC()
|
public void disableHitBTC()
|
||||||
{
|
{
|
||||||
SharedPreferences.Editor editor = settingPreferences.edit();
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
@ -86,4 +82,42 @@ public class PreferencesManager {
|
|||||||
editor.putBoolean("enable_binance", false);
|
editor.putBoolean("enable_binance", false);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMustUpdateWatchlist(boolean mustUpdate)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
|
editor.putBoolean("mustUpdateWatchlist", mustUpdate);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mustUpdateWatchlist()
|
||||||
|
{
|
||||||
|
boolean mustUpdate = settingPreferences.getBoolean("mustUpdateWatchlist", false);
|
||||||
|
|
||||||
|
if(mustUpdate)
|
||||||
|
{
|
||||||
|
setMustUpdateWatchlist(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mustUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMustUpdateSummary(boolean mustUpdate)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
|
editor.putBoolean("mustUpdateSummary", mustUpdate);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mustUpdateSummary()
|
||||||
|
{
|
||||||
|
boolean mustUpdate = settingPreferences.getBoolean("mustUpdateSummary", false);
|
||||||
|
|
||||||
|
if(mustUpdate)
|
||||||
|
{
|
||||||
|
setMustUpdateSummary(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mustUpdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.nauk.coinfolio.DataManagers;
|
||||||
|
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tiji on 13/04/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class WatchlistManager {
|
||||||
|
|
||||||
|
private android.content.Context context;
|
||||||
|
private RequestQueue requestQueue;
|
||||||
|
private DatabaseManager databaseManager;
|
||||||
|
private List<Currency> watchlistCurrencies;
|
||||||
|
|
||||||
|
public WatchlistManager(android.content.Context context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
|
||||||
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
|
databaseManager = new DatabaseManager(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateWatchlist()
|
||||||
|
{
|
||||||
|
watchlistCurrencies = databaseManager.getAllCurrenciesFromWatchlist();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Currency> getWatchlist()
|
||||||
|
{
|
||||||
|
return watchlistCurrencies;
|
||||||
|
}
|
||||||
|
}
|
@ -32,8 +32,6 @@ public class FingerprintDialogFragment extends DialogFragment{
|
|||||||
|
|
||||||
View view = inflater.inflate(R.layout.fragment_fingerprint_scanner, container);
|
View view = inflater.inflate(R.layout.fragment_fingerprint_scanner, container);
|
||||||
|
|
||||||
//getDialog().getWindow().setLayout(getResources().getDimensionPixelSize(R.dimen.fingerprint_dialog_width), getResources().getDimensionPixelSize(R.dimen.fingerprint_dialog_height));
|
|
||||||
|
|
||||||
view.findViewById(R.id.cancelButton).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.cancelButton).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -37,7 +37,6 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationError(int errMsgId, CharSequence errString)
|
public void onAuthenticationError(int errMsgId, CharSequence errString)
|
||||||
{
|
{
|
||||||
//Toast.makeText(context, "Authentification error\n" + errString, Toast.LENGTH_LONG).show();
|
|
||||||
if(dialogFragment.isVisible())
|
if(dialogFragment.isVisible())
|
||||||
{
|
{
|
||||||
dialogFragment.wrongFingerprint("Error");
|
dialogFragment.wrongFingerprint("Error");
|
||||||
@ -56,7 +55,6 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationFailed()
|
public void onAuthenticationFailed()
|
||||||
{
|
{
|
||||||
//Toast.makeText(context, "Authentification failed", Toast.LENGTH_LONG).show();
|
|
||||||
if(dialogFragment.isVisible())
|
if(dialogFragment.isVisible())
|
||||||
{
|
{
|
||||||
dialogFragment.wrongFingerprint("Wrong fingerprint");
|
dialogFragment.wrongFingerprint("Wrong fingerprint");
|
||||||
@ -75,8 +73,6 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationHelp(int helpMsgIf, CharSequence helpString)
|
public void onAuthenticationHelp(int helpMsgIf, CharSequence helpString)
|
||||||
{
|
{
|
||||||
//Toast.makeText(context, "Authentification help\n" + helpString, Toast.LENGTH_LONG).show();
|
|
||||||
|
|
||||||
if(dialogFragment.isVisible())
|
if(dialogFragment.isVisible())
|
||||||
{
|
{
|
||||||
dialogFragment.wrongFingerprint(helpString.toString());
|
dialogFragment.wrongFingerprint(helpString.toString());
|
||||||
@ -95,9 +91,6 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)
|
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)
|
||||||
{
|
{
|
||||||
//Toast.makeText(context, "Success !", Toast.LENGTH_LONG).show();
|
|
||||||
//dialogFragment.dismiss();
|
|
||||||
|
|
||||||
dialogFragment.correctFingerprint();
|
dialogFragment.correctFingerprint();
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,12 +17,12 @@ import java.util.ArrayList;
|
|||||||
* Created by Guitoune on 17/01/2018.
|
* Created by Guitoune on 17/01/2018.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CurrencyAdapter extends ArrayAdapter<Currency> {
|
public class CurrencyListAdapter extends ArrayAdapter<Currency> {
|
||||||
|
|
||||||
private ArrayList<Currency> tempCurrency, suggestions;
|
private ArrayList<Currency> tempCurrency, suggestions;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public CurrencyAdapter(Context context, ArrayList<Currency> objects) {
|
public CurrencyListAdapter(Context context, ArrayList<Currency> objects) {
|
||||||
super(context, android.R.layout.simple_list_item_1, objects);
|
super(context, android.R.layout.simple_list_item_1, objects);
|
||||||
this.tempCurrency = new ArrayList<Currency>(objects);
|
this.tempCurrency = new ArrayList<Currency>(objects);
|
||||||
this.suggestions = new ArrayList<Currency>(objects);
|
this.suggestions = new ArrayList<Currency>(objects);
|
||||||
@ -31,20 +31,25 @@ public class CurrencyAdapter extends ArrayAdapter<Currency> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent)
|
||||||
|
{
|
||||||
Currency currency = getItem(position);
|
Currency currency = getItem(position);
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom_currency_row, parent, false);
|
convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom_currency_row, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView currencyName = convertView.findViewById(R.id.currencyName);
|
TextView currencyName = convertView.findViewById(R.id.currencyName);
|
||||||
TextView currencySymbol = convertView.findViewById(R.id.currencySymbol);
|
TextView currencySymbol = convertView.findViewById(R.id.currencySymbol);
|
||||||
|
|
||||||
if (currencyName != null)
|
if (currencyName != null)
|
||||||
currencyName.setText(currency.getName());
|
currencyName.setText(currency.getName());
|
||||||
|
|
||||||
if(currencySymbol != null)
|
if(currencySymbol != null)
|
||||||
{
|
{
|
||||||
currencySymbol.setText(currency.getSymbol());
|
currencySymbol.setText(currency.getSymbol());
|
||||||
}
|
}
|
||||||
// Now assign alternate color for rows
|
|
||||||
if (position % 2 == 0)
|
if (position % 2 == 0)
|
||||||
convertView.setBackgroundColor(context.getResources().getColor(R.color.listBackground2));
|
convertView.setBackgroundColor(context.getResources().getColor(R.color.listBackground2));
|
||||||
else
|
else
|
||||||
@ -74,7 +79,7 @@ public class CurrencyAdapter extends ArrayAdapter<Currency> {
|
|||||||
int found = 0;
|
int found = 0;
|
||||||
String temp = constraint.toString().toLowerCase();
|
String temp = constraint.toString().toLowerCase();
|
||||||
|
|
||||||
while(i < tempCurrency.size() && found < 25)
|
while(i < tempCurrency.size() && found < 50)
|
||||||
{
|
{
|
||||||
Currency currency = tempCurrency.get(i);
|
Currency currency = tempCurrency.get(i);
|
||||||
if (currency.getName().toLowerCase().startsWith(temp)
|
if (currency.getName().toLowerCase().startsWith(temp)
|
||||||
@ -85,14 +90,6 @@ public class CurrencyAdapter extends ArrayAdapter<Currency> {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*for (Currency currency : tempCurrency) {
|
|
||||||
if (currency.getName().toLowerCase().startsWith(temp)
|
|
||||||
|| currency.getSymbol().toLowerCase().startsWith(temp)) {
|
|
||||||
suggestions.add(currency);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
FilterResults filterResults = new FilterResults();
|
FilterResults filterResults = new FilterResults();
|
||||||
filterResults.values = suggestions;
|
filterResults.values = suggestions;
|
||||||
filterResults.count = suggestions.size();
|
filterResults.count = suggestions.size();
|
@ -5,16 +5,17 @@ import android.content.Intent;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.Transformation;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.db.chart.model.ChartSet;
|
|
||||||
import com.db.chart.model.LineSet;
|
|
||||||
import com.db.chart.renderer.AxisRenderer;
|
|
||||||
import com.db.chart.view.LineChartView;
|
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
@ -24,9 +25,8 @@ import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
|||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -38,32 +38,141 @@ import static java.lang.Math.abs;
|
|||||||
|
|
||||||
public class HomeLayoutGenerator {
|
public class HomeLayoutGenerator {
|
||||||
|
|
||||||
android.content.Context context;
|
private android.content.Context context;
|
||||||
|
|
||||||
public HomeLayoutGenerator(Context context)
|
public HomeLayoutGenerator(Context context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getInfoLayout(final Currency currency, boolean isExtended)
|
public View getInfoLayout(final Currency currency, boolean isExtended, float totalValue, boolean isBalanceHidden)
|
||||||
{
|
{
|
||||||
|
View view = LayoutInflater.from(context).inflate(R.layout.cardview_currency, null, true);
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.cardview_currency, null);
|
|
||||||
|
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(view.findViewById(R.id.LineChartView).getVisibility() == View.VISIBLE || view.findViewById(R.id.errorTextView).getVisibility() == View.VISIBLE)
|
if(view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE)
|
||||||
{
|
{
|
||||||
collapseView(view);
|
collapseView(view);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
extendView(currency, view);
|
extendView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateCardViewInfos(view, currency, totalValue, isBalanceHidden);
|
||||||
|
|
||||||
|
view.findViewById(R.id.LineChartView).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
||||||
|
intent.putExtra("currency", currency);
|
||||||
|
context.getApplicationContext().startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(currency.getHistoryMinutes() != null)
|
||||||
|
{
|
||||||
|
setupLineChart(view, currency);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isExtended)
|
||||||
|
{
|
||||||
|
extendView(view);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
collapseView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateColor(view, currency);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void expand(final View v) {
|
||||||
|
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
|
||||||
|
final int targetHeight = v.getMeasuredHeight();
|
||||||
|
|
||||||
|
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
|
||||||
|
v.getLayoutParams().height = 1;
|
||||||
|
v.setVisibility(View.VISIBLE);
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
|
v.getLayoutParams().height = interpolatedTime == 1
|
||||||
|
? CardView.LayoutParams.WRAP_CONTENT
|
||||||
|
: (int)(targetHeight * interpolatedTime);
|
||||||
|
v.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void collapse(final View v) {
|
||||||
|
final int initialHeight = v.getMeasuredHeight();
|
||||||
|
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
|
if(interpolatedTime == 1){
|
||||||
|
v.setVisibility(View.GONE);
|
||||||
|
}else{
|
||||||
|
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
|
||||||
|
v.requestLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLineChart(View view, final Currency currency)
|
||||||
|
{
|
||||||
|
LineChart lineChart = view.findViewById(R.id.LineChartView);
|
||||||
|
|
||||||
|
lineChart.setDrawGridBackground(false);
|
||||||
|
lineChart.setDrawBorders(false);
|
||||||
|
lineChart.setDrawMarkers(false);
|
||||||
|
lineChart.setDoubleTapToZoomEnabled(false);
|
||||||
|
lineChart.setPinchZoom(false);
|
||||||
|
lineChart.setScaleEnabled(false);
|
||||||
|
lineChart.setDragEnabled(false);
|
||||||
|
lineChart.getDescription().setEnabled(false);
|
||||||
|
lineChart.getAxisLeft().setEnabled(false);
|
||||||
|
lineChart.getAxisRight().setEnabled(false);
|
||||||
|
lineChart.getLegend().setEnabled(false);
|
||||||
|
lineChart.getXAxis().setEnabled(false);
|
||||||
|
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
||||||
|
lineChart.setData(generateData(currency));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCardViewInfos(View view, Currency currency, float totalValue, boolean isBalanceHidden)
|
||||||
|
{
|
||||||
|
double value = currency.getValue() * currency.getBalance();
|
||||||
|
double percentage = value / totalValue * 100;
|
||||||
|
DecimalFormat df = new DecimalFormat(".##");
|
||||||
|
|
||||||
((ImageView) view.findViewById(R.id.currencyIcon))
|
((ImageView) view.findViewById(R.id.currencyIcon))
|
||||||
.setImageBitmap(currency.getIcon());
|
.setImageBitmap(currency.getIcon());
|
||||||
((TextView) view.findViewById(R.id.currencyNameTextView))
|
((TextView) view.findViewById(R.id.currencyNameTextView))
|
||||||
@ -81,114 +190,43 @@ public class HomeLayoutGenerator {
|
|||||||
.setText(context.getResources().getString(R.string.currencyPercentagePlaceholder, numberConformer(currency.getDayFluctuationPercentage())));
|
.setText(context.getResources().getString(R.string.currencyPercentagePlaceholder, numberConformer(currency.getDayFluctuationPercentage())));
|
||||||
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||||
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
((ImageView) view.findViewById(R.id.detailsArrow))
|
|
||||||
.getDrawable().setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
|
||||||
|
|
||||||
view.findViewById(R.id.errorTextView).setOnClickListener(new View.OnClickListener() {
|
Drawable arrowDrawable = ((ImageView) view.findViewById(R.id.detailsArrow)).getDrawable();
|
||||||
@Override
|
arrowDrawable.mutate();
|
||||||
public void onClick(View v) {
|
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
arrowDrawable.invalidateSelf();
|
||||||
intent.putExtra("currency", currency);
|
|
||||||
context.getApplicationContext().startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(currency.getHistoryMinutes() != null)
|
Drawable progressBarDrawable = ((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).getProgressDrawable();
|
||||||
|
progressBarDrawable.mutate();
|
||||||
|
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
|
progressBarDrawable.invalidateSelf();
|
||||||
|
|
||||||
|
((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).setProgress((int) Math.round(percentage));
|
||||||
|
((TextView) view.findViewById(R.id.percentageOwnedTextView)).setText(context.getResources().getString(R.string.currencyPercentagePlaceholder, df.format(percentage)));
|
||||||
|
|
||||||
|
if(isBalanceHidden)
|
||||||
{
|
{
|
||||||
LineChart lineChart = view.findViewById(R.id.LineChartView);
|
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.VISIBLE);
|
||||||
|
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.VISIBLE);
|
||||||
lineChart.setDrawGridBackground(false);
|
view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.GONE);
|
||||||
lineChart.setDrawBorders(false);
|
|
||||||
lineChart.setDrawMarkers(false);
|
|
||||||
lineChart.setDoubleTapToZoomEnabled(false);
|
|
||||||
lineChart.setPinchZoom(false);
|
|
||||||
lineChart.setScaleEnabled(false);
|
|
||||||
lineChart.setDragEnabled(false);
|
|
||||||
lineChart.getDescription().setEnabled(false);
|
|
||||||
lineChart.getAxisLeft().setEnabled(false);
|
|
||||||
lineChart.getAxisRight().setEnabled(false);
|
|
||||||
lineChart.getLegend().setEnabled(false);
|
|
||||||
lineChart.getXAxis().setEnabled(false);
|
|
||||||
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
|
||||||
lineChart.setData(generateData(currency));
|
|
||||||
|
|
||||||
lineChart.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
|
||||||
intent.putExtra("currency", currency);
|
|
||||||
context.getApplicationContext().startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isExtended)
|
|
||||||
{
|
|
||||||
extendView(currency, view);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
collapseView(view);
|
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.INVISIBLE);
|
||||||
|
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateColor(view, currency);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collapseView(View view)
|
private void collapseView(View view)
|
||||||
{
|
{
|
||||||
view.findViewById(R.id.separationLayout).setVisibility(View.GONE);
|
collapse(view.findViewById(R.id.collapsableLayout));
|
||||||
view.findViewById(R.id.frameLayoutChart).setVisibility(View.GONE);
|
|
||||||
view.findViewById(R.id.LineChartView).setVisibility(View.GONE);
|
|
||||||
view.findViewById(R.id.errorTextView).setVisibility(View.GONE);
|
|
||||||
view.findViewById(R.id.detailsArrow).setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extendView(Currency currency, View view)
|
private void extendView(View view)
|
||||||
{
|
{
|
||||||
view.findViewById(R.id.separationLayout).setVisibility(View.VISIBLE);
|
expand(view.findViewById(R.id.collapsableLayout));
|
||||||
view.findViewById(R.id.detailsArrow).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.LineChartView).invalidate();
|
||||||
view.findViewById(R.id.frameLayoutChart).setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if(currency.getHistoryMinutes() != null)
|
|
||||||
{
|
|
||||||
view.findViewById(R.id.LineChartView).setVisibility(View.VISIBLE);
|
|
||||||
((LineChart) view.findViewById(R.id.LineChartView)).invalidate();
|
|
||||||
view.findViewById(R.id.errorTextView).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
view.findViewById(R.id.LineChartView).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
view.findViewById(R.id.errorTextView).setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Double> getAxisBorders(Currency currency)
|
|
||||||
{
|
|
||||||
List<Double> borders = new ArrayList<>();
|
|
||||||
|
|
||||||
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
|
||||||
|
|
||||||
borders.add(0, currency.getHistoryMinutes().get(0).getOpen());
|
|
||||||
borders.add(1, currency.getHistoryMinutes().get(0).getOpen());
|
|
||||||
|
|
||||||
for(int i = 0; i < dataChartList.size(); i++)
|
|
||||||
{
|
|
||||||
if(borders.get(0) > dataChartList.get(i).getOpen())
|
|
||||||
{
|
|
||||||
borders.set(0, dataChartList.get(i).getOpen());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(borders.get(1) < dataChartList.get(i).getOpen())
|
|
||||||
{
|
|
||||||
borders.set(1, dataChartList.get(i).getOpen());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return borders;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColor(View view, Currency currency)
|
private void updateColor(View view, Currency currency)
|
||||||
@ -215,6 +253,7 @@ public class HomeLayoutGenerator {
|
|||||||
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
||||||
ArrayList<Entry> values = new ArrayList<>();
|
ArrayList<Entry> values = new ArrayList<>();
|
||||||
|
|
||||||
|
Log.d("coinfolio", "Generating data for " + currency.getSymbol());
|
||||||
for(int i = 0; i < dataChartList.size(); i+=10)
|
for(int i = 0; i < dataChartList.size(); i+=10)
|
||||||
{
|
{
|
||||||
values.add(new Entry(i, (float) dataChartList.get(i).getOpen()));
|
values.add(new Entry(i, (float) dataChartList.get(i).getOpen()));
|
||||||
@ -242,7 +281,9 @@ public class HomeLayoutGenerator {
|
|||||||
int r = Color.red(color);
|
int r = Color.red(color);
|
||||||
int g = Color.green(color);
|
int g = Color.green(color);
|
||||||
int b = Color.blue(color);
|
int b = Color.blue(color);
|
||||||
|
|
||||||
transColor = Color.argb(alpha, r, g, b);
|
transColor = Color.argb(alpha, r, g, b);
|
||||||
|
|
||||||
return transColor ;
|
return transColor ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,11 +293,11 @@ public class HomeLayoutGenerator {
|
|||||||
|
|
||||||
if(abs(number) > 1)
|
if(abs(number) > 1)
|
||||||
{
|
{
|
||||||
str = String.format( Locale.UK, "%.2f", number);
|
str = String.format( Locale.UK, "%.2f", number).replaceAll("\\.?0*$", "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str = String.format( Locale.UK, "%.4f", number);
|
str = String.format( Locale.UK, "%.4f", number).replaceAll("\\.?0*$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
49
app/src/main/java/com/nauk/coinfolio/PagerAdapter.java
Normal file
49
app/src/main/java/com/nauk/coinfolio/PagerAdapter.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package com.nauk.coinfolio;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivityFragments.MarketCapitalization;
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivityFragments.Summary;
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivityFragments.Watchlist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tiji on 13/04/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
private int numOfTabs;
|
||||||
|
|
||||||
|
public PagerAdapter(FragmentManager fm, int numOfTabs)
|
||||||
|
{
|
||||||
|
super(fm);
|
||||||
|
this.numOfTabs = numOfTabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
switch (position)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
Watchlist watchlist = new Watchlist();
|
||||||
|
return watchlist;
|
||||||
|
case 1:
|
||||||
|
Summary summary = new Summary();
|
||||||
|
return summary;
|
||||||
|
case 2:
|
||||||
|
MarketCapitalization marketCapitalization = new MarketCapitalization();
|
||||||
|
return marketCapitalization;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return numOfTabs;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_checked="true" android:color="@color/colorAccent" />
|
<item android:state_checked="true" android:color="@color/colorAccent" />
|
||||||
<item android:state_checked="false" android:color="@color/colorPrimary" />
|
<item android:state_checked="false" android:color="@color/colorPrimaryDark" />
|
||||||
</selector>
|
</selector>
|
14
app/src/main/res/drawable/button_dashed_background.xml
Normal file
14
app/src/main/res/drawable/button_dashed_background.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/transparent"/>
|
||||||
|
<corners android:radius="2dp"/>
|
||||||
|
<stroke
|
||||||
|
android:color="@color/separationColor"
|
||||||
|
android:width="2dp"
|
||||||
|
android:dashGap="4dp"
|
||||||
|
android:dashWidth="9dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
5
app/src/main/res/drawable/drop_shadow_cardview.xml
Normal file
5
app/src/main/res/drawable/drop_shadow_cardview.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#42000000" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
</shape>
|
@ -0,0 +1,5 @@
|
|||||||
|
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:oneshot="true">
|
||||||
|
<item android:drawable="@drawable/ic_unfold_less_black_24dp" android:duration="200" />
|
||||||
|
<item android:drawable="@drawable/ic_details_black_24dp" android:duration="200" />
|
||||||
|
</animation-list>
|
@ -1,9 +1,7 @@
|
|||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
<gradient
|
<gradient
|
||||||
android:type="linear"
|
android:type="linear"
|
||||||
android:centerX="60%"
|
android:startColor="@color/colorPrimary"
|
||||||
android:startColor="#FF1CB5E0"
|
android:endColor="@color/colorPrimaryDark"
|
||||||
android:centerColor="#FF000046"
|
android:angle="0"/>
|
||||||
android:endColor="#FF111124"
|
|
||||||
android:angle="90"/>
|
|
||||||
</shape>
|
</shape>
|
@ -4,6 +4,6 @@
|
|||||||
android:viewportWidth="24.0"
|
android:viewportWidth="24.0"
|
||||||
android:viewportHeight="24.0">
|
android:viewportHeight="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FFFFFFFF"
|
android:fillColor="#FF000000"
|
||||||
android:pathData="M4,14h4v-4L4,10v4zM4,19h4v-4L4,15v4zM4,9h4L8,5L4,5v4zM9,14h12v-4L9,10v4zM9,19h12v-4L9,15v4zM9,5v4h12L21,5L9,5z"/>
|
android:pathData="M4,14h4v-4L4,10v4zM4,19h4v-4L4,15v4zM4,9h4L8,5L4,5v4zM9,14h12v-4L9,10v4zM9,19h12v-4L9,15v4zM9,5v4h12L21,5L9,5z"/>
|
||||||
</vector>
|
</vector>
|
10
app/src/main/res/drawable/linear_chart_gradient.xml
Normal file
10
app/src/main/res/drawable/linear_chart_gradient.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:type="linear"
|
||||||
|
android:startColor="#00ff0000"
|
||||||
|
android:centerColor="#00ff0000"
|
||||||
|
android:endColor="#ffffffff"
|
||||||
|
android:centerY="1%" />
|
||||||
|
</shape>
|
@ -19,10 +19,30 @@
|
|||||||
android:layout_gravity="center|top"
|
android:layout_gravity="center|top"
|
||||||
android:background="@color/listBackground"/>
|
android:background="@color/listBackground"/>
|
||||||
|
|
||||||
<ListView
|
<LinearLayout
|
||||||
android:id="@+id/coinsPreview"
|
android:id="@+id/listContainerLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/coinsPreview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/currencyListProgressBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -18,11 +18,33 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="Line chart"
|
||||||
|
android:id="@+id/lineChartButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:enabled="false"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="Candle stick chart"
|
||||||
|
android:id="@+id/candleStickChartButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/progressLayoutChart"
|
android:id="@+id/progressLayoutChart"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="300dp"
|
android:layout_height="305dp"
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
@ -37,10 +59,55 @@
|
|||||||
|
|
||||||
|
|
||||||
<com.github.mikephil.charting.charts.LineChart
|
<com.github.mikephil.charting.charts.LineChart
|
||||||
android:id="@+id/chartView"
|
android:id="@+id/chartPriceView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="300dp"
|
android:layout_height="250dp"/>
|
||||||
android:layout_marginTop="15dp" />
|
|
||||||
|
<com.github.mikephil.charting.charts.CandleStickChart
|
||||||
|
android:id="@+id/chartCandleStickView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="250dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timestampHightlight"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_weight="0.33"
|
||||||
|
android:text="\n" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/priceHightlight"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_weight="0.33"
|
||||||
|
android:text="\n" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/volumeHightlight"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_weight="0.33"
|
||||||
|
android:text="\n"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.github.mikephil.charting.charts.BarChart
|
||||||
|
android:id="@+id/chartVolumeView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginTop="5dp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layoutChartButtons"
|
android:id="@+id/layoutChartButtons"
|
||||||
@ -114,44 +181,151 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!--<ScrollView
|
|
||||||
android:id="@+id/svCharts"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
</ScrollView>-->
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/llCharts"
|
android:id="@+id/llCharts"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal">
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/txtViewPriceStart"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0.33"
|
android:orientation="vertical"
|
||||||
android:gravity="center"/>
|
android:layout_weight="0.16">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtViewPriceNow"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:text="Beginning price"
|
||||||
android:layout_weight="0.33"
|
android:layout_weight="0.5"
|
||||||
android:gravity="center"/>
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtViewPercentage"
|
android:id="@+id/txtViewPriceStart"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0.33"
|
android:orientation="vertical"
|
||||||
android:gravity="center"/>
|
android:layout_weight="0.16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Current price"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewPriceNow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Delta"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewPercentage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Total volume"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/totalVolume"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Highest price"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/highestPrice"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Lowest price"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lowestPrice"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -163,70 +337,152 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/infosLayout"
|
android:id="@+id/infosLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/currencyPortfolioDominance"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
android:layout_gravity="center"
|
android:visibility="invisible"
|
||||||
android:background="@drawable/circular_progress_bar" />
|
android:background="@color/colorAccent"
|
||||||
|
android:padding="@dimen/mdtp_ampm_left_padding"/>
|
||||||
|
|
||||||
<!--<ScrollView
|
<LinearLayout
|
||||||
android:id="@+id/svInfos"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
<ProgressBar
|
<TextView
|
||||||
android:id="@+id/progressBar"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
android:text="Total supply"
|
||||||
android:layout_gravity="center"
|
android:textStyle="bold"/>
|
||||||
android:background="@drawable/circular_progress_bar" />
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewTotalSupply"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>-->
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Circulating supply"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewCirculatingSupply"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Market capitalizaion"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewMarketCapitalization"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/transactionsLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Transaction history"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="@dimen/cardview_elevation"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/listTransactions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Trade history"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="@dimen/cardview_elevation" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/svTransactions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/listTrades"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/tradeProgressBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/svTransactions"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/listTransactions"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<!--<ScrollView
|
|
||||||
android:id="@+id/svTransactions"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/transactionsLinearLayout"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>-->
|
|
||||||
|
|
||||||
</ViewFlipper>
|
</ViewFlipper>
|
||||||
|
|
||||||
<android.support.design.widget.BottomNavigationView
|
<android.support.design.widget.BottomNavigationView
|
||||||
@ -243,24 +499,3 @@
|
|||||||
android:layout_alignParentBottom="true"/>
|
android:layout_alignParentBottom="true"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<!--<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context="com.nauk.coinfolio.Activities.CurrencyDetailsActivity">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/message"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
|
||||||
android:text="@string/title_home"
|
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
|
||||||
-->
|
|
@ -1,114 +1,110 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/coordinatorLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context="com.nauk.coinfolio.Activities.HomeActivity">
|
tools:context="com.nauk.coinfolio.Activities.HomeActivity">
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout
|
|
||||||
android:id="@+id/coordinatorLayout"
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:id="@+id/app_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="@dimen/app_bar_height"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
android:background="@drawable/gradient_background">
|
||||||
|
|
||||||
|
<android.support.design.widget.CollapsingToolbarLayout
|
||||||
<android.support.design.widget.AppBarLayout
|
android:id="@+id/toolbar_layout"
|
||||||
android:id="@+id/app_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/app_bar_height"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay"
|
|
||||||
android:background="@drawable/gradient_background"
|
|
||||||
app:elevation="0dp">
|
|
||||||
|
|
||||||
<android.support.design.widget.CollapsingToolbarLayout
|
|
||||||
android:id="@+id/toolbar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
app:contentScrim="@drawable/gradient_background"
|
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
|
||||||
app:toolbarId="@+id/toolbar">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/toolbarSubtitle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center|bottom"
|
|
||||||
android:layout_marginBottom="35dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="20dp"
|
|
||||||
app:layout_collapseMode="parallax"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="left"
|
|
||||||
android:layout_margin="10dp">
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/switch_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/quick_button"
|
|
||||||
android:visibility="visible"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="right"
|
|
||||||
android:layout_margin="10dp">
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/settings_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/action_settings"
|
|
||||||
android:visibility="visible"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</android.support.design.widget.CollapsingToolbarLayout>
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/content_currency_summary" />
|
|
||||||
|
|
||||||
<com.luseen.spacenavigation.SpaceNavigationView
|
|
||||||
android:id="@+id/space"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="bottom"/>
|
android:fitsSystemWindows="true"
|
||||||
|
app:contentScrim="@drawable/gradient_background"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||||
|
app:toolbarId="@+id/toolbar"
|
||||||
|
app:collapsedTitleGravity="center"
|
||||||
|
app:expandedTitleGravity="center"
|
||||||
|
app:titleEnabled="true">
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
<TextView
|
||||||
|
android:id="@+id/toolbarSubtitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center|bottom"
|
||||||
|
android:layout_marginBottom="35dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="20sp"
|
||||||
|
app:layout_collapseMode="parallax"/>
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/floatingAddButton"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:layout_collapseMode="pin"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
android:layout_marginStart="-30dp">
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_collapseMode="pin"
|
||||||
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/switch_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/quick_button"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:contentDescription="Switch view"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/settings_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/action_settings"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:contentDescription="Settings"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</android.support.design.widget.CollapsingToolbarLayout>
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/masterLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:layout_marginBottom="56dp"
|
||||||
|
android:background="@color/summary_background">
|
||||||
|
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
android:id="@+id/viewPager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.BottomNavigationView
|
||||||
|
android:id="@+id/navigationSummary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:elevation="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
app:borderWidth="0dp"
|
android:layout_marginStart="0dp"
|
||||||
android:background="@color/cardview_light_background"
|
android:background="?android:attr/windowBackground"
|
||||||
android:src="@drawable/ic_add_white_24dp"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:layout_gravity="bottom|center_horizontal"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
android:clickable="true"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
android:focusable="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_margin="8dp"
|
app:menu="@menu/navigation_home"
|
||||||
android:visibility="visible"/>
|
android:layout_gravity="bottom" />
|
||||||
|
|
||||||
</FrameLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
@ -22,7 +22,16 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/activity_add_amount"/>
|
android:hint="@string/activity_add_amount"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/purchaseDate"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/activity_purchased_date"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="10dp" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
android:id="@+id/purchasePrice"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/activity_purchased_price"/>
|
android:hint="@string/activity_purchased_price"/>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:card_view="http://schemas.android.com/tools"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:paddingBottom="4dp">
|
android:paddingBottom="4dp">
|
||||||
@ -12,9 +13,10 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:backgroundTint="@color/listBackground2"
|
android:backgroundTint="@color/cardview_background"
|
||||||
app:cardCornerRadius="8dp"
|
app:cardCornerRadius="2dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent">
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
card_view:cardElevation="@dimen/cardview_elevation">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/mainLinear"
|
android:id="@+id/mainLinear"
|
||||||
@ -24,6 +26,13 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:tag="mainLinear">
|
android:tag="mainLinear">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/currencyPortfolioDominance"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/currencyInfoLayout"
|
android:id="@+id/currencyInfoLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -78,27 +87,44 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/currencyOwnedTextView"
|
android:id="@+id/percentageOwnedTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left"
|
android:gravity="start"
|
||||||
android:textColor="@color/mainTextViewColor"
|
|
||||||
android:textSize="@dimen/cardViewMainText" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/currencyValueOwnedTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="2dp"
|
|
||||||
android:gravity="left"
|
|
||||||
android:textColor="@color/secondaryTextViewColor"
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
android:textSize="@dimen/cardViewSecondaryText" />
|
android:textSize="@dimen/cardViewMainText"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/currencyOwnedInfoLayout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencyOwnedTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/mainTextViewColor"
|
||||||
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencyValueOwnedTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="2dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/secondaryLayout"
|
android:id="@+id/secondaryLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="right"
|
android:gravity="end"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -120,66 +146,57 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/separationLayout"
|
android:id="@+id/collapsableLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"
|
android:visibility="gone"
|
||||||
android:visibility="gone">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/separationLayout"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Day history"
|
|
||||||
android:textSize="@dimen/cardViewSecondaryText" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_margin="5dp">
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginRight="10dp"
|
<TextView
|
||||||
android:background="@color/separationLine" />
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Day history"
|
||||||
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/separationLineSize"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:background="@color/separationColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frameLayoutChart"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/cardViewChartSize"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
|
<com.github.mikephil.charting.charts.LineChart
|
||||||
|
android:id="@+id/LineChartView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="150dp"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/detailsArrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
||||||
|
android:layout_gravity="center_vertical|end"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/frameLayoutChart"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/cardViewChartSize"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<!--<com.db.chart.view.LineChartView
|
|
||||||
android:id="@+id/LineChartView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/cardViewChartSize"
|
|
||||||
android:visibility="gone" />-->
|
|
||||||
|
|
||||||
<com.github.mikephil.charting.charts.LineChart
|
|
||||||
android:id="@+id/LineChartView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="150dp"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/errorTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/cardViewChartSize"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="Error"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/detailsArrow"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_gravity="center_vertical|end"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
164
app/src/main/res/layout/cardview_watchlist.xml
Normal file
164
app/src/main/res/layout/cardview_watchlist.xml
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
|
<android.support.v7.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:backgroundTint="@color/listBackground2"
|
||||||
|
app:cardCornerRadius="2dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/mainLinear"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="false"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:tag="mainLinear">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/currencyInfoLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/topLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/currencyIcon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="1dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencyNameTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/mainTextViewColor"
|
||||||
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencySymbolTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="2dp"
|
||||||
|
android:gravity="left"
|
||||||
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/bottomLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencyValueTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
|
android:textSize="@dimen/cardViewMainText"
|
||||||
|
android:layout_weight="0.5"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/secondaryLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencyFluctuationPercentageTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currencyFluctuationTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/collapsableLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/separationLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Day history"
|
||||||
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/separationLineSize"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:background="@color/separationColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frameLayoutChart"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/cardViewChartSize"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
|
<com.github.mikephil.charting.charts.LineChart
|
||||||
|
android:id="@+id/LineChartView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="150dp"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/detailsArrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
||||||
|
android:layout_gravity="center_vertical|end"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
@ -5,8 +5,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
android:layout_marginBottom="50dp"
|
android:layout_marginBottom="56dp"
|
||||||
android:background="@drawable/gradient_second_background">
|
android:background="@color/summary_background">
|
||||||
|
|
||||||
<ViewFlipper
|
<ViewFlipper
|
||||||
android:id="@+id/viewFlipperSummary"
|
android:id="@+id/viewFlipperSummary"
|
||||||
@ -16,7 +16,24 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayoutWatchlist"
|
android:id="@+id/linearLayoutWatchlist"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonAddWatchlist"
|
||||||
|
android:text="Add to watchlist"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/button_dashed_background"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textColor="@color/separationColor"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBarWatchlist"
|
android:id="@+id/progressBarWatchlist"
|
||||||
@ -46,7 +63,19 @@
|
|||||||
android:id="@+id/currencyListLayout"
|
android:id="@+id/currencyListLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"/>
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonAddTransaction"
|
||||||
|
android:text="Add transaction"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/button_dashed_background"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textColor="@color/separationColor"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"/>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="2dp"
|
||||||
android:background="@color/separationLine"
|
android:background="@color/separationColor"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
82
app/src/main/res/layout/custom_trade_row.xml
Normal file
82
app/src/main/res/layout/custom_trade_row.xml
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.v7.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/rounded_corners">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/tradeIndicator"
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/mainLayout">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:padding="5dp"
|
||||||
|
android:background="#ffffffff"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<!--What you want to show in SurfaceView-->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/amountPurchased"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="15dp"
|
||||||
|
android:text="Amount"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/purchasedPrice"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="10dp"
|
||||||
|
android:text="Value"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="end">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/pair"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="15dp"
|
||||||
|
android:text="Pair"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tradeDate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="10dp"
|
||||||
|
android:text="Date"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
61
app/src/main/res/layout/fragment_marketcap_homeactivity.xml
Normal file
61
app/src/main/res/layout/fragment_marketcap_homeactivity.xml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/swiperefreshmarketcap"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:layout_marginBottom="56dp"
|
||||||
|
android:background="@color/summary_background">
|
||||||
|
<LinearLayout android:id="@+id/layoutMarketCap"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBarMarketCap"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/circular_progress_bar" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutProgressMarketCap"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/marketCapTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:gravity="center_horizontal"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dayVolumeTotalMarketCap"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textSize="18dp"
|
||||||
|
android:gravity="center_horizontal"/>
|
||||||
|
|
||||||
|
<com.github.mikephil.charting.charts.PieChart
|
||||||
|
android:id="@+id/marketCapPieChart"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="350dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
49
app/src/main/res/layout/fragment_summary_homeactivity.xml
Normal file
49
app/src/main/res/layout/fragment_summary_homeactivity.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/swiperefreshsummary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:layout_marginBottom="56dp"
|
||||||
|
android:background="@color/summary_background">
|
||||||
|
|
||||||
|
<android.support.v4.widget.NestedScrollView
|
||||||
|
android:id="@+id/nestedScrollViewLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.nauk.coinfolio.Activities.HomeActivity">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/currencyListLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonAddTransaction"
|
||||||
|
android:text="Add transaction"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/button_dashed_background"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textColor="@color/separationColor"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
57
app/src/main/res/layout/fragment_watchlist_homeactivity.xml
Normal file
57
app/src/main/res/layout/fragment_watchlist_homeactivity.xml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/swiperefreshwatchlist"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:layout_marginBottom="56dp"
|
||||||
|
android:background="@color/summary_background">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="10dp">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/linearLayoutWatchlist"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBarWatchlist"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/circular_progress_bar"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonAddWatchlist"
|
||||||
|
android:text="Add to watchlist"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/button_dashed_background"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textColor="@color/separationColor"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
@ -9,6 +9,7 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_dashboard"
|
android:id="@+id/navigation_dashboard"
|
||||||
android:icon="@drawable/ic_dashboard_black_24dp"
|
android:icon="@drawable/ic_dashboard_black_24dp"
|
||||||
|
android:enabled="false"
|
||||||
android:title="@string/title_infos" />
|
android:title="@string/title_infos" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_something"
|
android:id="@+id/navigation_watchlist"
|
||||||
android:icon="@drawable/ic_remove_red_eye_black_24dp"
|
android:icon="@drawable/ic_remove_red_eye_black_24dp"
|
||||||
android:title="@string/title_watchlist" />
|
android:title="@string/title_watchlist" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_view_list"
|
android:id="@+id/navigation_currencies_list"
|
||||||
android:icon="@drawable/ic_view_list_white_24dp"
|
android:icon="@drawable/ic_view_list_black_24dp"
|
||||||
android:title="@string/title_home" />
|
android:title="@string/title_home" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
@ -14,13 +14,13 @@
|
|||||||
<color name="listBackground2">#000046</color>
|
<color name="listBackground2">#000046</color>
|
||||||
<color name="separationLine">#FF999999</color>
|
<color name="separationLine">#FF999999</color>
|
||||||
<color name="red">#FFF44336</color>
|
<color name="red">#FFF44336</color>
|
||||||
<color name="green">#FF4CAF50</color>
|
<color name="green">#FF4CAF50</color>#FBFCFF
|
||||||
</resources>
|
</resources>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#000046</color>
|
<color name="colorPrimary">#004e92</color>
|
||||||
<color name="colorPrimaryDark">#111124</color>
|
<color name="colorPrimaryDark">#000428</color>
|
||||||
<color name="colorAccent">#1CB5E0</color>
|
<color name="colorAccent">#1CB5E0</color>
|
||||||
<color name="mainTextViewColor">#FF000000</color>
|
<color name="mainTextViewColor">#FF000000</color>
|
||||||
<color name="secondaryTextViewColor">#FF222222</color>
|
<color name="secondaryTextViewColor">#FF222222</color>
|
||||||
@ -29,9 +29,13 @@
|
|||||||
<color name="increase">#FF00E000</color>
|
<color name="increase">#FF00E000</color>
|
||||||
<color name="listBackground">#FFEEEEEE</color>
|
<color name="listBackground">#FFEEEEEE</color>
|
||||||
<color name="listBackground2">#FFFFFFFF</color>
|
<color name="listBackground2">#FFFFFFFF</color>
|
||||||
<color name="separationLine">#FF999999</color>
|
<color name="separationColor">#66999999</color>
|
||||||
<color name="buttonColor">#FFFFFFFF</color>
|
<color name="buttonColor">#FFFFFFFF</color>
|
||||||
<color name="red">#FFF44336</color>
|
<color name="red">#FFF44336</color>
|
||||||
<color name="green">#FF4CAF50</color>
|
<color name="green">#FF4CAF50</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="cardview_background">#FFFFFFFF</color>
|
||||||
|
<color name="summary_background">#FBFCFF</color>
|
||||||
|
<color name="decreaseCandle">#FFFF5754</color>
|
||||||
|
<color name="increaseCandle">#FF45B64A</color>
|
||||||
</resources>
|
</resources>
|
@ -15,4 +15,10 @@
|
|||||||
<dimen name="swirl_size">60dp</dimen>
|
<dimen name="swirl_size">60dp</dimen>
|
||||||
<dimen name="fingerprint_dialog_height">125dp</dimen>
|
<dimen name="fingerprint_dialog_height">125dp</dimen>
|
||||||
<dimen name="fingerprint_dialog_width">250dp</dimen>
|
<dimen name="fingerprint_dialog_width">250dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="separationLineSize">1dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="cardview_elevation">8dp</dimen>
|
||||||
|
<dimen name="toolbar_height">56dp</dimen>
|
||||||
|
<dimen name="toolbar_height_expand">70dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -12,10 +12,7 @@
|
|||||||
<!-- Example General settings -->
|
<!-- Example General settings -->
|
||||||
<string name="pref_header_general">General</string>
|
<string name="pref_header_general">General</string>
|
||||||
|
|
||||||
<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
<string name="pref_title_hide_balance">Hide balance</string>
|
||||||
<string name="pref_description_social_recommendations">Recommendations for people to contact
|
|
||||||
based on your message history
|
|
||||||
</string>
|
|
||||||
|
|
||||||
<string name="pref_title_display_name">Display name</string>
|
<string name="pref_title_display_name">Display name</string>
|
||||||
<string name="pref_default_display_name">John Smith</string>
|
<string name="pref_default_display_name">John Smith</string>
|
||||||
@ -120,6 +117,7 @@
|
|||||||
<!--Add transaction activity-->
|
<!--Add transaction activity-->
|
||||||
<string name="activity_add_amount">Amount</string>
|
<string name="activity_add_amount">Amount</string>
|
||||||
<string name="activity_purchased_price">Purchased price</string>
|
<string name="activity_purchased_price">Purchased price</string>
|
||||||
|
<string name="activity_purchased_date">Purchased date</string>
|
||||||
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
|
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
|
||||||
<string name="title_history">History charts</string>
|
<string name="title_history">History charts</string>
|
||||||
<string name="title_watchlist">Watchlist</string>
|
<string name="title_watchlist">Watchlist</string>
|
||||||
@ -145,6 +143,13 @@
|
|||||||
<string name="currencyDollarParenthesisPlaceholder">(US$%1$s)</string>
|
<string name="currencyDollarParenthesisPlaceholder">(US$%1$s)</string>
|
||||||
<string name="currencyDollarPlaceholder">US$%1$s</string>
|
<string name="currencyDollarPlaceholder">US$%1$s</string>
|
||||||
<string name="currencyPercentagePlaceholder">%1$s%%</string>
|
<string name="currencyPercentagePlaceholder">%1$s%%</string>
|
||||||
|
<string name="fluctuationDollarPercentagePlaceholder">US$%1$s (%2$s%)</string>
|
||||||
|
|
||||||
|
<!--DetailsActivity placeholders-->
|
||||||
|
<string name="volumePlaceholder">Volume\nUS$%1$s</string>
|
||||||
|
<string name="pricePlaceholder">Price\nUS$%1$s</string>
|
||||||
|
<string name="timestampPlaceholder">Date\n%1$s</string>
|
||||||
|
|
||||||
<string name="title_activity_main">MainActivity</string>
|
<string name="title_activity_main">MainActivity</string>
|
||||||
|
|
||||||
<string name="fingerprint_dialog_cancel">Cancel</string>
|
<string name="fingerprint_dialog_cancel">Cancel</string>
|
||||||
@ -153,5 +158,6 @@
|
|||||||
|
|
||||||
<string name="market_cap_textview">Total Market Capitalization :\nUS$%1$s</string>
|
<string name="market_cap_textview">Total Market Capitalization :\nUS$%1$s</string>
|
||||||
<string name="volume_market_cap_textview">24h volume :\nUS$%1$s</string>
|
<string name="volume_market_cap_textview">24h volume :\nUS$%1$s</string>
|
||||||
|
<string name="title_activity_scrolling">ScrollingActivity</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -6,8 +6,18 @@
|
|||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
<item name="swirl_ridgeColor">@color/separationLine</item>
|
<item name="swirl_ridgeColor">@color/separationColor</item>
|
||||||
<item name="swirl_errorColor">@color/decrease</item>
|
<item name="swirl_errorColor">@color/decrease</item>
|
||||||
|
|
||||||
|
<!--<item name="android:windowTranslucentStatus">false</item>
|
||||||
|
<item name="android:windowTranslucentNavigation">true</item>
|
||||||
|
<item name="android:navigationBarColor">@color/transparent</item>
|
||||||
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||||
|
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
|
||||||
|
<item name="android:windowActionBarOverlay">true</item>-->
|
||||||
|
<!-- Support library compatibility -->
|
||||||
|
<!--<item name="actionBarStyle">@style/ThemeActionBar</item>
|
||||||
|
<item name="windowActionBarOverlay">true</item>-->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.NoActionBar">
|
<style name="AppTheme.NoActionBar">
|
||||||
@ -24,4 +34,12 @@
|
|||||||
<item name="android:windowExitAnimation">@anim/zoom_in</item>
|
<item name="android:windowExitAnimation">@anim/zoom_in</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="ThemeActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid">
|
||||||
|
<item name="android:background"> @null </item>
|
||||||
|
<!-- Support library compatibility -->
|
||||||
|
<item name="background">@null</item>
|
||||||
|
<item name="android:displayOptions">showHome|useLogo</item>
|
||||||
|
<item name="displayOptions">showHome|useLogo</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="false"
|
||||||
android:key="example_switch"
|
android:key="hide_balance"
|
||||||
android:summary="@string/pref_description_social_recommendations"
|
android:title="@string/pref_title_hide_balance" />
|
||||||
android:title="@string/pref_title_social_recommendations" />
|
|
||||||
|
|
||||||
<!-- NOTE: EditTextPreference accepts EditText attributes. -->
|
<!-- NOTE: EditTextPreference accepts EditText attributes. -->
|
||||||
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
|
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
|
||||||
<EditTextPreference
|
<!--<EditTextPreference
|
||||||
android:capitalize="words"
|
android:capitalize="words"
|
||||||
android:defaultValue="@string/pref_default_display_name"
|
android:defaultValue="@string/pref_default_display_name"
|
||||||
android:inputType="textCapWords"
|
android:inputType="textCapWords"
|
||||||
@ -16,18 +15,18 @@
|
|||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:title="@string/pref_title_display_name" />
|
android:title="@string/pref_title_display_name" />-->
|
||||||
|
|
||||||
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
||||||
dismiss it. -->
|
dismiss it. -->
|
||||||
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
||||||
<ListPreference
|
<!--<ListPreference
|
||||||
android:defaultValue="-1"
|
android:defaultValue="-1"
|
||||||
android:entries="@array/pref_example_list_titles"
|
android:entries="@array/pref_example_list_titles"
|
||||||
android:entryValues="@array/pref_example_list_values"
|
android:entryValues="@array/pref_example_list_values"
|
||||||
android:key="example_list"
|
android:key="example_list"
|
||||||
android:negativeButtonText="@null"
|
android:negativeButtonText="@null"
|
||||||
android:positiveButtonText="@null"
|
android:positiveButtonText="@null"
|
||||||
android:title="@string/pref_title_add_friends_to_messages" />
|
android:title="@string/pref_title_add_friends_to_messages" />-->
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
<!-- These settings headers are only used on tablets. -->
|
<!-- These settings headers are only used on tablets. -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.nauk.coinfolio.Activities.SettingsActivity$GeneralPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_info_black_24dp"
|
||||||
|
android:title="@string/pref_header_general" />
|
||||||
|
|
||||||
<header
|
<header
|
||||||
android:fragment="com.nauk.coinfolio.Activities.SettingsActivity$ExchangePreferenceFragment"
|
android:fragment="com.nauk.coinfolio.Activities.SettingsActivity$ExchangePreferenceFragment"
|
||||||
android:icon="@drawable/ic_developer_board_black_24dp"
|
android:icon="@drawable/ic_developer_board_black_24dp"
|
||||||
@ -18,3 +23,5 @@
|
|||||||
android:title="@string/pref_header_data_sync" />-->
|
android:title="@string/pref_header_data_sync" />-->
|
||||||
|
|
||||||
</preference-headers>
|
</preference-headers>
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user