Lighter hide balance switch method

This commit is contained in:
Tanguy Herbron 2018-04-08 16:50:56 +02:00
parent 61e06beb82
commit 1bf8aea3d9
5 changed files with 56 additions and 21 deletions

View File

@ -657,8 +657,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
TextView valueTxtView = view.findViewById(R.id.puchasedValue); TextView valueTxtView = view.findViewById(R.id.puchasedValue);
TextView dateTxtView = view.findViewById(R.id.purchaseDate); TextView dateTxtView = view.findViewById(R.id.purchaseDate);
Log.d("coinfolio", "Timestamp " + transactionList.get(i).getTimestamp());
dateTxtView.setText(getDate(transactionList.get(i).getTimestamp())); dateTxtView.setText(getDate(transactionList.get(i).getTimestamp()));
LinearLayout deleteLayout = view.findViewById(R.id.deleteTransactionLayout); LinearLayout deleteLayout = view.findViewById(R.id.deleteTransactionLayout);

View File

@ -154,9 +154,7 @@ public class HomeActivity extends AppCompatActivity {
ImageButton settingsButton = findViewById(R.id.settings_button); ImageButton settingsButton = findViewById(R.id.settings_button);
toolbarLayout.setForegroundGravity(Gravity.CENTER); toolbarLayout.setForegroundGravity(Gravity.CENTER);
toolbarLayout.setTitle(getResources().getString(R.string.currencyDollarPlaceholder, "0.00")); updateTitle();
toolbarSubtitle.setText(getResources().getString(R.string.currencyDollarPlaceholder, "0.00"));
//Events setup //Events setup
detailsButton.setOnClickListener(new View.OnClickListener() { detailsButton.setOnClickListener(new View.OnClickListener() {
@ -225,6 +223,27 @@ public class HomeActivity extends AppCompatActivity {
setupDominantCurrenciesColors(); setupDominantCurrenciesColors();
} }
protected void updateTitle(float totalValue, float totalFluctuation)
{
float totalFluctuationPercentage = totalFluctuation / (totalValue - totalFluctuation) *100;
if(loadingDialog.isShowing())
{
loadingDialog.dismiss();
}
if(preferencesManager.isBalanceHidden())
{
}
else
{
toolbarLayout.setTitle(getResources().getString(R.string.currencyDollarPlaceholder, "0.00"));
toolbarSubtitle.setText(getResources().getString(R.string.currencyDollarPlaceholder, "0.00"));
toolbarSubtitle.setText("US$" + String.format("%.2f", totalFluctuation) + " (" + String.format("%.2f", totalFluctuationPercentage) + "%)");
}
}
private void setupDominantCurrenciesColors() private void setupDominantCurrenciesColors()
{ {
dominantCurrenciesColors = new HashMap<>(); dominantCurrenciesColors = new HashMap<>();
@ -347,7 +366,31 @@ public class HomeActivity extends AppCompatActivity {
updateAll(preferencesManager.mustUpdate()); updateAll(preferencesManager.mustUpdate());
((SpaceNavigationView) findViewById(R.id.space)).changeCenterButtonIcon(R.drawable.ic_view_list_white_24dp); displayBalance(preferencesManager.isBalanceHidden());
//((SpaceNavigationView) findViewById(R.id.space)).changeCenterButtonIcon(R.drawable.ic_view_list_white_24dp);
}
private void displayBalance(boolean hideBalance)
{
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 void addTestWatchlistCardview() private void addTestWatchlistCardview()
@ -421,8 +464,6 @@ public class HomeActivity extends AppCompatActivity {
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null)) if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
{ {
//currencyLayout.addView(new HomeLayoutGenerator(this, currencyLayout).getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
//currencyLayout.addView(new SummaryCurrencyCardView(this, currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden())); currencyLayout.addView(layoutGenerator.getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
} }
} }
@ -830,8 +871,6 @@ public class HomeActivity extends AppCompatActivity {
Currency currency = balanceManager.getTotalBalance().get(i); Currency currency = balanceManager.getTotalBalance().get(i);
if(!currency.getSymbol().equals("USD") && (currency.getBalance() * currency.getValue()) > 0.001) { if(!currency.getSymbol().equals("USD") && (currency.getBalance() * currency.getValue()) > 0.001) {
//currencyLayout.addView(new HomeLayoutGenerator(getApplicationContext(), currencyLayout).getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
//currencyLayout.addView(new SummaryCurrencyCardView(getApplicationContext(), currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden())); currencyLayout.addView(layoutGenerator.getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
} }
} }

View File

@ -225,7 +225,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("hide_balance", isChecked); editor.putBoolean("hide_balance", isChecked);
editor.putBoolean("mustUpdate", true);
editor.apply(); editor.apply();
return isChecked; return isChecked;

View File

@ -165,6 +165,10 @@ public class HomeLayoutGenerator {
private void updateCardViewInfos(View view, Currency currency, float totalValue, boolean isBalanceHidden) 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))
@ -193,23 +197,18 @@ public class HomeLayoutGenerator {
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN)); progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
progressBarDrawable.invalidateSelf(); progressBarDrawable.invalidateSelf();
if(isBalanceHidden)
{
double value = currency.getValue() * currency.getBalance();
double percentage = value / totalValue * 100;
DecimalFormat df = new DecimalFormat(".##");
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.VISIBLE);
((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).setProgress((int) Math.round(percentage)); ((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).setProgress((int) Math.round(percentage));
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.VISIBLE);
((TextView) view.findViewById(R.id.percentageOwnedTextView)).setText(context.getResources().getString(R.string.currencyPercentagePlaceholder, df.format(percentage))); ((TextView) view.findViewById(R.id.percentageOwnedTextView)).setText(context.getResources().getString(R.string.currencyPercentagePlaceholder, df.format(percentage)));
if(isBalanceHidden)
{
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.VISIBLE);
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.VISIBLE);
view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.GONE); view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.GONE);
} }
else else
{ {
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.GONE); view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.INVISIBLE);
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.GONE); view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.GONE);
view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.VISIBLE); view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.VISIBLE);
} }

View File

@ -30,7 +30,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dp" android:layout_height="2dp"
style="@style/Widget.AppCompat.ProgressBar.Horizontal" style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:visibility="gone"/> android:visibility="invisible"/>
<LinearLayout <LinearLayout
android:id="@+id/currencyInfoLayout" android:id="@+id/currencyInfoLayout"