Default currencies and Snackbar
- Reimplemented Snackbar in case of error while refreshing and auto update if it's about exchanges' keys - Add Euro in addition to Dollar as a default currency
This commit is contained in:
parent
889fc3f889
commit
749c7792ba
@ -16,7 +16,6 @@ import android.support.v4.app.NavUtils;
|
|||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@ -300,7 +299,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
updateChartTab(DAY, 1);
|
updateChartTab(DAY, 1);
|
||||||
break;
|
break;
|
||||||
case "3d":
|
case "3d":
|
||||||
currency.updateHistoryHours(this, new Currency.CurrencyCallBack() {
|
currency.updateHistoryHours(this, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -313,7 +312,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "1w":
|
case "1w":
|
||||||
currency.updateHistoryHours(this, new Currency.CurrencyCallBack() {
|
currency.updateHistoryHours(this, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -326,7 +325,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "1M":
|
case "1M":
|
||||||
currency.updateHistoryHours(this, new Currency.CurrencyCallBack() {
|
currency.updateHistoryHours(this, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -339,7 +338,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "3M":
|
case "3M":
|
||||||
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
|
currency.updateHistoryDays(this, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -352,7 +351,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "6M":
|
case "6M":
|
||||||
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
|
currency.updateHistoryDays(this, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -365,7 +364,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "1y":
|
case "1y":
|
||||||
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
|
currency.updateHistoryDays(this, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -550,8 +549,8 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
date = getDate(dataChartList.get(index).getTimestamp() * 1000);
|
date = getDate(dataChartList.get(index).getTimestamp() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
volumePlaceholder = getResources().getString(R.string.volumePlaceholder, numberConformer(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getY()));
|
volumePlaceholder = getResources().getString(R.string.volumeDollarPlaceholder, numberConformer(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getY()));
|
||||||
pricePlaceholder = getResources().getString(R.string.pricePlaceholder, numberConformer(e.getY()));
|
pricePlaceholder = getResources().getString(R.string.priceDollarPlaceholder, numberConformer(e.getY()));
|
||||||
timestampPlaceholder = getResources().getString(R.string.timestampPlaceholder, date);
|
timestampPlaceholder = getResources().getString(R.string.timestampPlaceholder, date);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.volumeHightlight)).setText(volumePlaceholder);
|
((TextView) findViewById(R.id.volumeHightlight)).setText(volumePlaceholder);
|
||||||
|
@ -121,7 +121,10 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
//bottomNavigationView.getMenu().getItem(position).setChecked(true);
|
if(!bottomNavigationView.getMenu().getItem(position).isChecked())
|
||||||
|
{
|
||||||
|
bottomNavigationView.getMenu().getItem(position).setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
if(position % 2 == 0)
|
if(position % 2 == 0)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@ import com.github.mikephil.charting.data.PieEntry;
|
|||||||
import com.github.mikephil.charting.formatter.PercentFormatter;
|
import com.github.mikephil.charting.formatter.PercentFormatter;
|
||||||
import com.nauk.coinfolio.Activities.SettingsActivity;
|
import com.nauk.coinfolio.Activities.SettingsActivity;
|
||||||
import com.nauk.coinfolio.DataManagers.MarketCapManager;
|
import com.nauk.coinfolio.DataManagers.MarketCapManager;
|
||||||
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@ -44,6 +45,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
|
|
||||||
private int marketCapCounter;
|
private int marketCapCounter;
|
||||||
|
|
||||||
|
private PreferencesManager preferencesManager;
|
||||||
private MarketCapManager marketCapManager;
|
private MarketCapManager marketCapManager;
|
||||||
private HashMap<String, Integer> dominantCurrenciesColors;
|
private HashMap<String, Integer> dominantCurrenciesColors;
|
||||||
private SwipeRefreshLayout refreshLayout;
|
private SwipeRefreshLayout refreshLayout;
|
||||||
@ -54,6 +56,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
preferencesManager = new PreferencesManager(getContext());
|
||||||
view = inflater.inflate(R.layout.fragment_marketcap_homeactivity, container, false);
|
view = inflater.inflate(R.layout.fragment_marketcap_homeactivity, container, false);
|
||||||
|
|
||||||
setupDominantCurrenciesColors();
|
setupDominantCurrenciesColors();
|
||||||
@ -92,6 +95,8 @@ public class MarketCapitalization extends Fragment {
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
updateMarketCap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupDominantCurrenciesColors()
|
private void setupDominantCurrenciesColors()
|
||||||
@ -141,7 +146,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
countCompletedMarketCapRequest();
|
countCompletedMarketCapRequest();
|
||||||
}
|
}
|
||||||
});
|
}, preferencesManager.getDefaultCurrency());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -249,8 +254,20 @@ public class MarketCapitalization extends Fragment {
|
|||||||
symbols.setGroupingSeparator(' ');
|
symbols.setGroupingSeparator(' ');
|
||||||
formatter.setDecimalFormatSymbols(symbols);
|
formatter.setDecimalFormatSymbols(symbols);
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.marketCapTextView)).setText(getActivity().getResources().getString(R.string.market_cap_textview, formatter.format(marketCapManager.getMarketCap())));
|
switch (preferencesManager.getDefaultCurrency())
|
||||||
|
{
|
||||||
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap)).setText(getActivity().getResources().getString(R.string.volume_market_cap_textview, formatter.format(marketCapManager.getDayVolume())));
|
case "EUR":
|
||||||
|
((TextView) view.findViewById(R.id.marketCapTextView))
|
||||||
|
.setText(getActivity().getResources().getString(R.string.market_cap_euros_textview, formatter.format(marketCapManager.getMarketCap())));
|
||||||
|
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap))
|
||||||
|
.setText(getActivity().getResources().getString(R.string.volume_euros_market_cap_textview, formatter.format(marketCapManager.getDayVolume())));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
((TextView) view.findViewById(R.id.marketCapTextView))
|
||||||
|
.setText(getActivity().getResources().getString(R.string.market_cap_dollar_textview, formatter.format(marketCapManager.getMarketCap())));
|
||||||
|
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap))
|
||||||
|
.setText(getActivity().getResources().getString(R.string.volume_dollar_market_cap_textview, formatter.format(marketCapManager.getDayVolume())));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,9 @@ import android.graphics.Color;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.CollapsingToolbarLayout;
|
import android.support.design.widget.CollapsingToolbarLayout;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
@ -50,7 +52,6 @@ public class Summary extends Fragment {
|
|||||||
private PreferencesManager preferencesManager;
|
private PreferencesManager preferencesManager;
|
||||||
private BalanceManager balanceManager;
|
private BalanceManager balanceManager;
|
||||||
private HomeLayoutGenerator layoutGenerator;
|
private HomeLayoutGenerator layoutGenerator;
|
||||||
private View view;
|
|
||||||
private SwipeRefreshLayout refreshLayout;
|
private SwipeRefreshLayout refreshLayout;
|
||||||
private Dialog loadingDialog;
|
private Dialog loadingDialog;
|
||||||
|
|
||||||
@ -67,17 +68,18 @@ public class Summary extends Fragment {
|
|||||||
protected float totalFluctuation;
|
protected float totalFluctuation;
|
||||||
private long lastTimestamp;
|
private long lastTimestamp;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
view = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false);
|
View fragmentView = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false);
|
||||||
|
|
||||||
currencyLayout = view.findViewById(R.id.currencyListLayout);
|
currencyLayout = fragmentView.findViewById(R.id.currencyListLayout);
|
||||||
preferencesManager = new PreferencesManager(getActivity());
|
preferencesManager = new PreferencesManager(getActivity());
|
||||||
balanceManager = new BalanceManager(getActivity());
|
balanceManager = new BalanceManager(getActivity());
|
||||||
layoutGenerator = new HomeLayoutGenerator(getActivity());
|
layoutGenerator = new HomeLayoutGenerator(getActivity());
|
||||||
refreshLayout = view.findViewById(R.id.swiperefreshsummary);
|
refreshLayout = fragmentView.findViewById(R.id.swiperefreshsummary);
|
||||||
toolbarSubtitle = view.findViewById(R.id.toolbarSubtitle);
|
toolbarSubtitle = fragmentView.findViewById(R.id.toolbarSubtitle);
|
||||||
|
|
||||||
totalValue = 0;
|
totalValue = 0;
|
||||||
totalFluctuation = 0;
|
totalFluctuation = 0;
|
||||||
@ -114,12 +116,12 @@ public class Summary extends Fragment {
|
|||||||
);
|
);
|
||||||
|
|
||||||
handler.postDelayed(updateRunnable, 10000);
|
handler.postDelayed(updateRunnable, 10000);
|
||||||
toolbarLayout = view.findViewById(R.id.toolbar_layout);
|
toolbarLayout = fragmentView.findViewById(R.id.toolbar_layout);
|
||||||
toolbarLayout.setForegroundGravity(Gravity.CENTER);
|
toolbarLayout.setForegroundGravity(Gravity.CENTER);
|
||||||
|
|
||||||
Button addCurrencyButton = view.findViewById(R.id.buttonAddTransaction);
|
Button addCurrencyButton = fragmentView.findViewById(R.id.buttonAddTransaction);
|
||||||
|
|
||||||
ImageButton settingsButton = view.findViewById(R.id.settings_button);
|
ImageButton settingsButton = fragmentView.findViewById(R.id.settings_button);
|
||||||
|
|
||||||
settingsButton.setOnClickListener(new View.OnClickListener() {
|
settingsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -142,7 +144,7 @@ public class Summary extends Fragment {
|
|||||||
|
|
||||||
generateSplashScreen();
|
generateSplashScreen();
|
||||||
|
|
||||||
return view;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateSplashScreen()
|
private void generateSplashScreen()
|
||||||
@ -176,9 +178,9 @@ public class Summary extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
updateAll(preferencesManager.mustUpdateSummary());
|
|
||||||
|
|
||||||
displayBalance(preferencesManager.isBalanceHidden());
|
displayBalance(preferencesManager.isBalanceHidden());
|
||||||
|
|
||||||
|
updateAll(preferencesManager.mustUpdateSummary());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAll(boolean mustUpdate)
|
private void updateAll(boolean mustUpdate)
|
||||||
@ -197,7 +199,6 @@ public class Summary extends Fragment {
|
|||||||
resetCounters();
|
resetCounters();
|
||||||
DataUpdater updater = new DataUpdater();
|
DataUpdater updater = new DataUpdater();
|
||||||
updater.execute();
|
updater.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -236,7 +237,7 @@ public class Summary extends Fragment {
|
|||||||
|
|
||||||
final List<View> currencyView = new ArrayList<>();
|
final List<View> currencyView = new ArrayList<>();
|
||||||
|
|
||||||
Runnable newRunnabmle = new Runnable() {
|
Runnable newRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
@ -261,7 +262,7 @@ public class Summary extends Fragment {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
newRunnabmle.run();
|
newRunnable.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void countCoins(boolean isCoin, boolean isDetails)
|
private void countCoins(boolean isCoin, boolean isDetails)
|
||||||
@ -293,7 +294,6 @@ public class Summary extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void countIcons()
|
private void countIcons()
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -351,8 +351,6 @@ public class Summary extends Fragment {
|
|||||||
{
|
{
|
||||||
float totalFluctuationPercentage = totalFluctuation / (totalValue - totalFluctuation) * 100;
|
float totalFluctuationPercentage = totalFluctuation / (totalValue - totalFluctuation) * 100;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(preferencesManager.isBalanceHidden())
|
if(preferencesManager.isBalanceHidden())
|
||||||
{
|
{
|
||||||
toolbarLayout.setTitle(getResources().getString(R.string.currencyPercentagePlaceholder, String.format("%.2f", totalFluctuationPercentage)));
|
toolbarLayout.setTitle(getResources().getString(R.string.currencyPercentagePlaceholder, String.format("%.2f", totalFluctuationPercentage)));
|
||||||
@ -371,7 +369,15 @@ public class Summary extends Fragment {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
switch (preferencesManager.getDefaultCurrency())
|
||||||
|
{
|
||||||
|
case "EUR":
|
||||||
|
toolbarLayout.setTitle(getResources().getString(R.string.currencyEurosPlaceholder, String.format("%.2f", totalValue)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
toolbarLayout.setTitle(getResources().getString(R.string.currencyDollarPlaceholder, String.format("%.2f", totalValue)));
|
toolbarLayout.setTitle(getResources().getString(R.string.currencyDollarPlaceholder, String.format("%.2f", totalValue)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
toolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
|
toolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
|
||||||
toolbarLayout.setExpandedTitleColor(Color.WHITE);
|
toolbarLayout.setExpandedTitleColor(Color.WHITE);
|
||||||
|
|
||||||
@ -388,13 +394,29 @@ public class Summary extends Fragment {
|
|||||||
|
|
||||||
if(totalFluctuation == 0)
|
if(totalFluctuation == 0)
|
||||||
{
|
{
|
||||||
|
switch (preferencesManager.getDefaultCurrency())
|
||||||
|
{
|
||||||
|
case "EUR":
|
||||||
|
toolbarSubtitle.setText(getResources().getString(R.string.currencyEurosPlaceholder, "0.00"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
toolbarSubtitle.setText(getResources().getString(R.string.currencyDollarPlaceholder, "0.00"));
|
toolbarSubtitle.setText(getResources().getString(R.string.currencyDollarPlaceholder, "0.00"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
toolbarSubtitle.setTextColor(-1275068417);
|
toolbarSubtitle.setTextColor(-1275068417);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
switch (preferencesManager.getDefaultCurrency())
|
||||||
|
{
|
||||||
|
case "EUR":
|
||||||
|
toolbarSubtitle.setText(String.format("%.2f", totalFluctuation) + "€ (" + String.format("%.2f", totalFluctuationPercentage) + "%)");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
toolbarSubtitle.setText("US$" + String.format("%.2f", totalFluctuation) + " (" + String.format("%.2f", totalFluctuationPercentage) + "%)");
|
toolbarSubtitle.setText("US$" + String.format("%.2f", totalFluctuation) + " (" + String.format("%.2f", totalFluctuationPercentage) + "%)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -600,7 +622,7 @@ public class Summary extends Fragment {
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
{
|
{
|
||||||
balance.get(i).updatePrice(getActivity(), new Currency.CurrencyCallBack() {
|
balance.get(i).updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
countCoins(true, false);
|
countCoins(true, false);
|
||||||
@ -622,27 +644,34 @@ public class Summary extends Fragment {
|
|||||||
|
|
||||||
public void onError(String error)
|
public void onError(String error)
|
||||||
{
|
{
|
||||||
/*switch (error)
|
View view = getActivity().findViewById(R.id.snackbar_placer);
|
||||||
|
|
||||||
|
switch (error)
|
||||||
{
|
{
|
||||||
case "com.android.volley.AuthFailureError":
|
case "com.android.volley.AuthFailureError":
|
||||||
preferencesManager.disableHitBTC();
|
preferencesManager.disableHitBTC();
|
||||||
Snackbar.make(findViewById(R.id.viewFlipperSummary), "HitBTC synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
Snackbar.make(view, "HitBTC synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
refreshLayout.setRefreshing(false);
|
refreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
updateAll(true);
|
updateAll(true);
|
||||||
break;
|
break;
|
||||||
case "API-key format invalid.":
|
case "API-key format invalid.":
|
||||||
preferencesManager.disableBinance();
|
preferencesManager.disableBinance();
|
||||||
Snackbar.make(findViewById(R.id.viewFlipperSummary), "Binance synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
Snackbar.make(view, "Binance synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
updateAll(true);
|
updateAll(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Snackbar.make(findViewById(R.id.viewFlipperSummary), "Unexpected error", Snackbar.LENGTH_LONG)
|
Snackbar.make(view, "Unexpected error", Snackbar.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
Log.d("coinfolio", error);
|
Log.d("coinfolio", error);
|
||||||
|
|
||||||
updateAll(true);
|
updateAll(true);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -236,15 +236,58 @@ public class Watchlist extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for(final Currency currency : watchlistManager.getWatchlist())
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
|
{
|
||||||
|
watchlistViews.add(getCurrencyCardFor(currency));
|
||||||
|
}
|
||||||
|
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for(int i = 0; i < watchlistViews.size(); i++)
|
||||||
|
{
|
||||||
|
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(watchlistViews.get(i), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
newRunnable.run();
|
||||||
|
|
||||||
|
if(refreshLayout.isRefreshing())
|
||||||
|
{
|
||||||
|
refreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private View getCurrencyCardFor(final Currency currency)
|
||||||
{
|
{
|
||||||
View card = LayoutInflater.from(getContext()).inflate(R.layout.cardview_watchlist, null);
|
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())));
|
switch (preferencesManager.getDefaultCurrency())
|
||||||
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setText(getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
{
|
||||||
((TextView) card.findViewById(R.id.currencyNameTextView)).setText(currency.getName());
|
case "EUR":
|
||||||
((TextView) card.findViewById(R.id.currencySymbolTextView)).setText(getResources().getString(R.string.currencySymbolPlaceholder, currency.getSymbol()));
|
((TextView) card.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setText(getResources().getString(R.string.currencyEurosParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
|
((TextView) card.findViewById(R.id.currencyValueTextView))
|
||||||
|
.setText(getResources().getString(R.string.currencyEurosPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setText(getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
|
((TextView) card.findViewById(R.id.currencyValueTextView))
|
||||||
|
.setText(getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||||
|
.setText(getResources().getString(R.string.currencyPercentagePlaceholder, numberConformer(currency.getDayFluctuationPercentage())));
|
||||||
|
((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());
|
((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();
|
Drawable arrowDrawable = ((ImageView) card.findViewById(R.id.detailsArrow)).getDrawable();
|
||||||
arrowDrawable.mutate();
|
arrowDrawable.mutate();
|
||||||
@ -264,7 +307,7 @@ public class Watchlist extends Fragment {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (currency.getHistoryMinutes() == null) {
|
if (currency.getHistoryMinutes() == null) {
|
||||||
currency.updateHistoryMinutes(getActivity(), new Currency.CurrencyCallBack() {
|
currency.updateHistoryMinutes(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
extendView(view);
|
extendView(view);
|
||||||
@ -294,29 +337,9 @@ public class Watchlist extends Fragment {
|
|||||||
setupLineChart(card, currency);
|
setupLineChart(card, currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
watchlistViews.add(card);
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for(int i = 0; i < watchlistViews.size(); i++)
|
|
||||||
{
|
|
||||||
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(watchlistViews.get(i), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
newRunnable.run();
|
|
||||||
|
|
||||||
if(refreshLayout.isRefreshing())
|
|
||||||
{
|
|
||||||
refreshLayout.setRefreshing(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private LineData generateData(Currency currency)
|
private LineData generateData(Currency currency)
|
||||||
{
|
{
|
||||||
LineDataSet dataSet;
|
LineDataSet dataSet;
|
||||||
@ -456,7 +479,7 @@ public class Watchlist extends Fragment {
|
|||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
for(final Currency currency : watchlistManager.getWatchlist())
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
{
|
{
|
||||||
currency.updatePrice(getActivity(), new Currency.CurrencyCallBack() {
|
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final Currency sucessCurrency) {
|
public void onSuccess(final Currency sucessCurrency) {
|
||||||
if(getIconUrl(sucessCurrency.getSymbol()) != null)
|
if(getIconUrl(sucessCurrency.getSymbol()) != null)
|
||||||
|
@ -80,7 +80,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
currency.getTimestampPrice(this, new Currency.PriceCallBack() {
|
currency.getTimestampPrice(this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String price) {
|
public void onSuccess(String price) {
|
||||||
purchasedPrice.setText(price);
|
purchasedPrice.setText(price);
|
||||||
@ -119,7 +119,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
calendar.set(Calendar.MINUTE, minute);
|
calendar.set(Calendar.MINUTE, minute);
|
||||||
purchasedDate.setText(sdf.format(calendar.getTime()));
|
purchasedDate.setText(sdf.format(calendar.getTime()));
|
||||||
|
|
||||||
currency.getTimestampPrice(RecordTransactionActivity.this, new Currency.PriceCallBack() {
|
currency.getTimestampPrice(RecordTransactionActivity.this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String price) {
|
public void onSuccess(String price) {
|
||||||
purchasedPrice.setText(price);
|
purchasedPrice.setText(price);
|
||||||
|
@ -31,6 +31,7 @@ import android.util.Log;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
import com.nauk.coinfolio.FingerprintToolkit.FingerprintDialogFragment;
|
import com.nauk.coinfolio.FingerprintToolkit.FingerprintDialogFragment;
|
||||||
import com.nauk.coinfolio.FingerprintToolkit.FingerprintHandler;
|
import com.nauk.coinfolio.FingerprintToolkit.FingerprintHandler;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
@ -230,6 +231,20 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
return isChecked;
|
return isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bindPreferenceSummaryToValue(findPreference("default_currency"));
|
||||||
|
findPreference("default_currency").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
|
editor.putBoolean("refresh_default_currency", true);
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,7 +96,7 @@ public class BalanceManager {
|
|||||||
|
|
||||||
hitBtcManagers.clear();
|
hitBtcManagers.clear();
|
||||||
|
|
||||||
if(publicKey != null && privateKey != null && preferenceManager.isHitBTCActivated())
|
if(preferenceManager.isHitBTCActivated() && publicKey != null && privateKey != null)
|
||||||
{
|
{
|
||||||
hitBtcManagers.add(new HitBtcManager(context, publicKey, privateKey));
|
hitBtcManagers.add(new HitBtcManager(context, publicKey, privateKey));
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ public class BalanceManager {
|
|||||||
|
|
||||||
binanceManagers.clear();
|
binanceManagers.clear();
|
||||||
|
|
||||||
if(publicKey != null && privateKey != null && preferenceManager.isBinanceActivated())
|
if(preferenceManager.isBinanceActivated() && publicKey != null && privateKey != null)
|
||||||
{
|
{
|
||||||
binanceManagers.add(new BinanceManager(publicKey, privateKey));
|
binanceManagers.add(new BinanceManager(publicKey, privateKey));
|
||||||
}
|
}
|
||||||
@ -121,6 +121,8 @@ public class BalanceManager {
|
|||||||
{
|
{
|
||||||
boolean isUpdated = false;
|
boolean isUpdated = false;
|
||||||
|
|
||||||
|
balanceCounter = 0;
|
||||||
|
|
||||||
manualBalances = databaseManager.getAllCurrenciesFromManualCurrency();
|
manualBalances = databaseManager.getAllCurrenciesFromManualCurrency();
|
||||||
|
|
||||||
if(binanceManagers.size() > 0)
|
if(binanceManagers.size() > 0)
|
||||||
|
@ -64,11 +64,11 @@ public class Currency implements Parcelable {
|
|||||||
|
|
||||||
//public Currency(int id, String symbol, String name, String algorithm, String proofType, )
|
//public Currency(int id, String symbol, String name, String algorithm, String proofType, )
|
||||||
|
|
||||||
public void getTimestampPrice(android.content.Context context, final PriceCallBack callBack, long timestamp)
|
public void getTimestampPrice(android.content.Context context, String toSymbol, final PriceCallBack callBack, long timestamp)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
|
||||||
dataRetriver.getPriceTimestamp(symbol, new CurrencyDataRetriever.DataChartCallBack() {
|
dataRetriver.getPriceTimestamp(symbol, toSymbol, new CurrencyDataRetriever.DataChartCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<CurrencyDataChart> dataChart) {}
|
public void onSuccess(List<CurrencyDataChart> dataChart) {}
|
||||||
|
|
||||||
@ -97,11 +97,11 @@ public class Currency implements Parcelable {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePrice(android.content.Context context, final CurrencyCallBack callBack)
|
public void updatePrice(android.content.Context context, String toSymbol, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
|
||||||
dataRetriver.updatePrice(symbol, new CurrencyDataRetriever.PriceCallBack() {
|
dataRetriver.updatePrice(symbol, toSymbol, new CurrencyDataRetriever.PriceCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currencyInfo) {
|
public void onSuccess(Currency currencyInfo) {
|
||||||
if(currencyInfo != null)
|
if(currencyInfo != null)
|
||||||
@ -117,11 +117,11 @@ public class Currency implements Parcelable {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHistoryMinutes(android.content.Context context, final CurrencyCallBack callBack)
|
public void updateHistoryMinutes(android.content.Context context, String toSymbol, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
|
||||||
dataRetriver.updateHistory(symbol, new CurrencyDataRetriever.DataChartCallBack() {
|
dataRetriver.updateHistory(symbol, toSymbol, new CurrencyDataRetriever.DataChartCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<CurrencyDataChart> dataChart) {
|
public void onSuccess(List<CurrencyDataChart> dataChart) {
|
||||||
setHistoryMinutes(dataChart);
|
setHistoryMinutes(dataChart);
|
||||||
@ -134,10 +134,10 @@ public class Currency implements Parcelable {
|
|||||||
}, CurrencyDataRetriever.MINUTES);
|
}, CurrencyDataRetriever.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHistoryHours(android.content.Context context, final CurrencyCallBack callBack)
|
public void updateHistoryHours(android.content.Context context, String toSymbol, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
dataRetriver.updateHistory(symbol, new CurrencyDataRetriever.DataChartCallBack() {
|
dataRetriver.updateHistory(symbol, toSymbol, new CurrencyDataRetriever.DataChartCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<CurrencyDataChart> dataChart) {
|
public void onSuccess(List<CurrencyDataChart> dataChart) {
|
||||||
setHistoryHours(dataChart);
|
setHistoryHours(dataChart);
|
||||||
@ -150,10 +150,10 @@ public class Currency implements Parcelable {
|
|||||||
}, CurrencyDataRetriever.HOURS);
|
}, CurrencyDataRetriever.HOURS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHistoryDays(android.content.Context context, final CurrencyCallBack callBack)
|
public void updateHistoryDays(android.content.Context context, String toSymbol, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
dataRetriver.updateHistory(symbol, new CurrencyDataRetriever.DataChartCallBack() {
|
dataRetriver.updateHistory(symbol, toSymbol, new CurrencyDataRetriever.DataChartCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<CurrencyDataChart> dataChart) {
|
public void onSuccess(List<CurrencyDataChart> dataChart) {
|
||||||
setHistoryDays(dataChart);
|
setHistoryDays(dataChart);
|
||||||
|
@ -44,7 +44,7 @@ public class CurrencyDataRetriever {
|
|||||||
requestQueue = Volley.newRequestQueue(context);
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getPriceTimestamp(final String symbolCurrencyFrom, String symbolCurrencyTo, final DataChartCallBack callBack, long timestamp)
|
public 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;
|
final String requestUrl = "https://min-api.cryptocompare.com/data/pricehistorical?fsym=" + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo + "&ts=" + timestamp;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class CurrencyDataRetriever {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHistory(final String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
|
public void updateHistory(final String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
|
||||||
{
|
{
|
||||||
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public class CurrencyDataRetriever {
|
|||||||
requestQueue.add(stringRequest);
|
requestQueue.add(stringRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePrice(final String symbolCurrencyFrom, String symbolCurrencyTo, final PriceCallBack callBack)
|
public void updatePrice(final String symbolCurrencyFrom, String symbolCurrencyTo, final PriceCallBack callBack)
|
||||||
{
|
{
|
||||||
String requestUrl = priceUrl + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo;
|
String requestUrl = priceUrl + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo;
|
||||||
|
|
||||||
|
@ -145,7 +145,6 @@ 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();
|
||||||
|
@ -23,7 +23,7 @@ import java.util.regex.Pattern;
|
|||||||
public class MarketCapManager {
|
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/?convert=";
|
||||||
private RequestQueue requestQueue;
|
private RequestQueue requestQueue;
|
||||||
private String topRequestResult[];
|
private String topRequestResult[];
|
||||||
private long marketCap;
|
private long marketCap;
|
||||||
@ -57,9 +57,11 @@ public class MarketCapManager {
|
|||||||
requestQueue.add(strRequest);
|
requestQueue.add(strRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMarketCap(final VolleyCallBack callBack)
|
public void updateMarketCap(final VolleyCallBack callBack, String toSymbol)
|
||||||
{
|
{
|
||||||
StringRequest strRequest = new StringRequest(Request.Method.GET, marketCapUrl,
|
String requestString = marketCapUrl + toSymbol;
|
||||||
|
|
||||||
|
StringRequest strRequest = new StringRequest(Request.Method.GET, requestString,
|
||||||
new Response.Listener<String>() {
|
new Response.Listener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(String response) {
|
public void onResponse(String response) {
|
||||||
|
@ -34,6 +34,18 @@ public class PreferencesManager {
|
|||||||
return preferencesList.getBoolean("DetailOption", true);
|
return preferencesList.getBoolean("DetailOption", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disableRefreshDefaultCurrency()
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
|
editor.putBoolean("refresh_default_currency", false);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultCurrency()
|
||||||
|
{
|
||||||
|
return settingPreferences.getString("default_currency", "USD");
|
||||||
|
}
|
||||||
|
|
||||||
public String getHitBTCPublicKey()
|
public String getHitBTCPublicKey()
|
||||||
{
|
{
|
||||||
return settingPreferences.getString("hitbtc_publickey", null);
|
return settingPreferences.getString("hitbtc_publickey", null);
|
||||||
|
@ -7,6 +7,7 @@ import android.graphics.PorterDuff;
|
|||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.preference.PreferenceScreen;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -24,6 +25,7 @@ import com.github.mikephil.charting.data.LineDataSet;
|
|||||||
import com.nauk.coinfolio.Activities.CurrencyDetailsActivity;
|
import com.nauk.coinfolio.Activities.CurrencyDetailsActivity;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
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.DataManagers.PreferencesManager;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@ -53,11 +55,13 @@ public class HomeLayoutGenerator {
|
|||||||
view.setOnClickListener(new View.OnClickListener() {
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View view) {
|
public void onClick(final View view) {
|
||||||
|
PreferencesManager preferencesManager = new PreferencesManager(context);
|
||||||
|
|
||||||
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
||||||
collapseView(view);
|
collapseView(view);
|
||||||
} else {
|
} else {
|
||||||
if (currency.getHistoryMinutes() == null) {
|
if (currency.getHistoryMinutes() == null) {
|
||||||
currency.updateHistoryMinutes(context, new Currency.CurrencyCallBack() {
|
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
//setupLineChart(view, currency);
|
//setupLineChart(view, currency);
|
||||||
@ -202,6 +206,28 @@ public class HomeLayoutGenerator {
|
|||||||
double value = currency.getValue() * currency.getBalance();
|
double value = currency.getValue() * currency.getBalance();
|
||||||
double percentage = value / totalValue * 100;
|
double percentage = value / totalValue * 100;
|
||||||
DecimalFormat df = new DecimalFormat(".##");
|
DecimalFormat df = new DecimalFormat(".##");
|
||||||
|
PreferencesManager preferencesManager = new PreferencesManager(context);
|
||||||
|
|
||||||
|
switch (preferencesManager.getDefaultCurrency())
|
||||||
|
{
|
||||||
|
case "EUR":
|
||||||
|
((TextView) view.findViewById(R.id.currencyValueOwnedTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyEurosParenthesisPlaceholder, numberConformer(currency.getValue() * currency.getBalance())));
|
||||||
|
((TextView) view.findViewById(R.id.currencyValueTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyEurosPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyEurosParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
((TextView) view.findViewById(R.id.currencyValueOwnedTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getValue() * currency.getBalance())));
|
||||||
|
((TextView) view.findViewById(R.id.currencyValueTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
((ImageView) view.findViewById(R.id.currencyIcon))
|
((ImageView) view.findViewById(R.id.currencyIcon))
|
||||||
.setImageBitmap(currency.getIcon());
|
.setImageBitmap(currency.getIcon());
|
||||||
@ -211,15 +237,8 @@ public class HomeLayoutGenerator {
|
|||||||
.setText(context.getResources().getString(R.string.currencySymbolPlaceholder, currency.getSymbol()));
|
.setText(context.getResources().getString(R.string.currencySymbolPlaceholder, currency.getSymbol()));
|
||||||
((TextView) view.findViewById(R.id.currencyOwnedTextView))
|
((TextView) view.findViewById(R.id.currencyOwnedTextView))
|
||||||
.setText(context.getResources().getString(R.string.currencyBalancePlaceholder, numberConformer(currency.getBalance()), currency.getSymbol()));
|
.setText(context.getResources().getString(R.string.currencyBalancePlaceholder, numberConformer(currency.getBalance()), currency.getSymbol()));
|
||||||
((TextView) view.findViewById(R.id.currencyValueOwnedTextView))
|
|
||||||
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getValue() * currency.getBalance())));
|
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.currencyValueTextView))
|
|
||||||
.setText(context.getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
|
||||||
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||||
.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))
|
|
||||||
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
|
||||||
|
|
||||||
Drawable arrowDrawable = ((ImageView) view.findViewById(R.id.detailsArrow)).getDrawable();
|
Drawable arrowDrawable = ((ImageView) view.findViewById(R.id.detailsArrow)).getDrawable();
|
||||||
arrowDrawable.mutate();
|
arrowDrawable.mutate();
|
||||||
|
@ -13,8 +13,14 @@
|
|||||||
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="56dp"
|
android:layout_marginBottom="56dp"
|
||||||
|
android:orientation="vertical"
|
||||||
android:background="@color/summary_background">
|
android:background="@color/summary_background">
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
android:id="@+id/snackbar_placer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
android:id="@+id/viewPager"
|
android:id="@+id/viewPager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -32,22 +32,19 @@
|
|||||||
<!-- Example settings for Data & Sync -->
|
<!-- Example settings for Data & Sync -->
|
||||||
<string name="pref_header_data_sync">Data & sync</string>
|
<string name="pref_header_data_sync">Data & sync</string>
|
||||||
|
|
||||||
<string name="pref_title_sync_frequency">Sync frequency</string>
|
<string name="pref_title_default_currency">Default currency</string>
|
||||||
<string-array name="pref_sync_frequency_titles">
|
<string-array name="pref_default_currencies_titles">
|
||||||
<item>15 minutes</item>
|
<item>USD</item>
|
||||||
<item>30 minutes</item>
|
<item>EUR</item>
|
||||||
<item>1 hour</item>
|
<item>BTC</item>
|
||||||
<item>3 hours</item>
|
<item>ETH</item>
|
||||||
<item>6 hours</item>
|
|
||||||
<item>Never</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="pref_sync_frequency_values">
|
|
||||||
<item>15</item>
|
<string-array name="pref_default_currencies_values">
|
||||||
<item>30</item>
|
<item>USD</item>
|
||||||
<item>60</item>
|
<item>EUR</item>
|
||||||
<item>180</item>
|
<item>BTC</item>
|
||||||
<item>360</item>
|
<item>ETH</item>
|
||||||
<item>-1</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="list_preference_entries">
|
<string-array name="list_preference_entries">
|
||||||
@ -142,12 +139,17 @@
|
|||||||
<string name="currencyBalancePlaceholder">%1$s%2$s</string>
|
<string name="currencyBalancePlaceholder">%1$s%2$s</string>
|
||||||
<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="currencyEurosParenthesisPlaceholder">(%1$s€)</string>
|
||||||
|
<string name="currencyEurosPlaceholder">%1$s€</string>
|
||||||
<string name="currencyPercentagePlaceholder">%1$s%%</string>
|
<string name="currencyPercentagePlaceholder">%1$s%%</string>
|
||||||
<string name="fluctuationDollarPercentagePlaceholder">US$%1$s (%2$s%)</string>
|
<string name="fluctuationDollarPercentagePlaceholder">US$%1$s (%2$s%)</string>
|
||||||
|
<string name="fluctuationEurosPercentagePlaceholder">%1$s€ (%2$s%)</string>
|
||||||
|
|
||||||
<!--DetailsActivity placeholders-->
|
<!--DetailsActivity placeholders-->
|
||||||
<string name="volumePlaceholder">Volume\nUS$%1$s</string>
|
<string name="volumeDollarPlaceholder">Volume\nUS$%1$s</string>
|
||||||
<string name="pricePlaceholder">Price\nUS$%1$s</string>
|
<string name="priceDollarPlaceholder">Price\nUS$%1$s</string>
|
||||||
|
<string name="volumeEurosPlaceholder">Volume\n%1$s€</string>
|
||||||
|
<string name="priceEurosPlaceholder">Price\n%1$s€</string>
|
||||||
<string name="timestampPlaceholder">Date\n%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>
|
||||||
@ -156,8 +158,10 @@
|
|||||||
<string name="fingerprint_dialog_title">Verify your fingerprint to continue</string>
|
<string name="fingerprint_dialog_title">Verify your fingerprint to continue</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="market_cap_textview">Total Market Capitalization :\nUS$%1$s</string>
|
<string name="market_cap_dollar_textview">Total Market Capitalization :\nUS$%1$s</string>
|
||||||
<string name="volume_market_cap_textview">24h volume :\nUS$%1$s</string>
|
<string name="volume_dollar_market_cap_textview">24h volume :\nUS$%1$s</string>
|
||||||
|
<string name="market_cap_euros_textview">Total Market Capitalization :\n%1$s€</string>
|
||||||
|
<string name="volume_euros_market_cap_textview">24h volume :\n%1$s€</string>
|
||||||
<string name="title_activity_scrolling">ScrollingActivity</string>
|
<string name="title_activity_scrolling">ScrollingActivity</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
<!-- 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="180"
|
android:defaultValue="180"
|
||||||
android:entries="@array/pref_sync_frequency_titles"
|
android:entries="@array/pref_sync_frequency_titles"
|
||||||
android:entryValues="@array/pref_sync_frequency_values"
|
android:entryValues="@array/pref_sync_frequency_values"
|
||||||
android:key="sync_frequency"
|
android:key="sync_frequency"
|
||||||
android:negativeButtonText="@null"
|
android:negativeButtonText="@null"
|
||||||
android:positiveButtonText="@null"
|
android:positiveButtonText="@null"
|
||||||
android:title="@string/pref_title_sync_frequency" />
|
android:title="@string/pref_title_sync_frequency" />-->
|
||||||
|
|
||||||
<!-- This preference simply launches an intent when selected. Use this UI sparingly, per
|
<!-- This preference simply launches an intent when selected. Use this UI sparingly, per
|
||||||
design guidelines. -->
|
design guidelines. -->
|
||||||
|
@ -5,6 +5,16 @@
|
|||||||
android:key="hide_balance"
|
android:key="hide_balance"
|
||||||
android:title="@string/pref_title_hide_balance" />
|
android:title="@string/pref_title_hide_balance" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="USD"
|
||||||
|
android:entries="@array/pref_default_currencies_titles"
|
||||||
|
android:entryValues="@array/pref_default_currencies_values"
|
||||||
|
android:key="default_currency"
|
||||||
|
android:negativeButtonText="@null"
|
||||||
|
android:positiveButtonText="@null"
|
||||||
|
android:title="@string/pref_title_default_currency" />
|
||||||
|
|
||||||
|
|
||||||
<!-- 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
|
||||||
|
Loading…
Reference in New Issue
Block a user