diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencyDetailsActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencyDetailsActivity.java index bc27cb0..9a04959 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencyDetailsActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencyDetailsActivity.java @@ -1,17 +1,27 @@ package com.nauk.coinfolio.Activities; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v4.app.NavUtils; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; import android.widget.Button; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.ViewFlipper; @@ -28,6 +38,7 @@ import com.nauk.coinfolio.DataManagers.CurrencyData.Transaction; import com.nauk.coinfolio.DataManagers.DatabaseManager; import com.nauk.coinfolio.R; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -129,7 +140,21 @@ public class CurrencyDetailsActivity extends AppCompatActivity { chartLayout.addView(errorTextView, 0); } - setTitle(currency.getName()); + setTitle(" " + currency.getName()); + getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | + ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO); + + Bitmap result = Bitmap.createBitmap(150, 150, currency.getIcon().getConfig()); + + Paint paint = new Paint(); + paint.setStyle(Paint.Style.FILL); + paint.setColor(ContextCompat.getColor(this, R.color.white)); + + Canvas canvas = new Canvas(result); + canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint); + canvas.drawBitmap(Bitmap.createScaledBitmap(currency.getIcon(), 100, 100, false), result.getHeight()/2 - 50, result.getWidth()/2 - 50, null); + + getSupportActionBar().setIcon(new BitmapDrawable(Bitmap.createScaledBitmap(result, 120, 120, false))); BottomNavigationView navigation = findViewById(R.id.navigation_details); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); @@ -306,6 +331,8 @@ public class CurrencyDetailsActivity extends AppCompatActivity { chartView.setFadingEdgeLength(15); chartView.setLongClickable(true); + updateFluctuation(lineSet); + findViewById(R.id.chartView).setVisibility(View.VISIBLE); findViewById(R.id.progressLayoutChart).setVisibility(View.GONE); @@ -313,6 +340,31 @@ public class CurrencyDetailsActivity extends AppCompatActivity { chartView.show(new Animation().fromAlpha(0)); } + private void updateFluctuation(LineSet lineSet) + { + float fluctuation = lineSet.getEntry(lineSet.size() - 1).getValue() - lineSet.getEntry(0).getValue(); + float percentageFluctuation = (float) (fluctuation / lineSet.getEntry(0).getValue() * 100); + + /* + dayFluctuation = historyMinutes.get(historyMinutes.size() - 1).getOpen() - historyMinutes.get(0).getOpen(); + + dayFluctuationPercentage = (float) (dayFluctuation / historyMinutes.get(0).getOpen() * 100); + */ + + if(percentageFluctuation < 0) + { + ((TextView) findViewById(R.id.txtViewPercentage)).setTextColor(getResources().getColor(R.color.red)); + } + else + { + ((TextView) findViewById(R.id.txtViewPercentage)).setTextColor(getResources().getColor(R.color.green)); + } + + ((TextView) findViewById(R.id.txtViewPriceStart)).setText("$" + lineSet.getEntry(0).getValue()); + ((TextView) findViewById(R.id.txtViewPriceNow)).setText("$" + lineSet.getEntry(lineSet.size() - 1).getValue()); + ((TextView) findViewById(R.id.txtViewPercentage)).setText(percentageFluctuation + "%"); + } + private LineSet generateChartSet(int timeUnit, int amount) { List dataChartList = new ArrayList<>(); diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java index c918e10..b3f63a9 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java @@ -46,6 +46,7 @@ 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.github.mikephil.charting.utils.ColorTemplate; import com.luseen.spacenavigation.SpaceItem; import com.luseen.spacenavigation.SpaceNavigationView; @@ -304,8 +305,12 @@ public class HomeActivity extends AppCompatActivity { nav.changeCurrentItem(-1); findViewById(R.id.toolbar_layout).setFocusable(true); - findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(true); ((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(true, true); + findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(true); + + findViewById(R.id.app_bar).setEnabled(true); + findViewById(R.id.toolbar_layout).setNestedScrollingEnabled(true); + findViewById(R.id.coordinatorLayout).setNestedScrollingEnabled(true); findViewById(R.id.switch_button).setVisibility(View.VISIBLE); @@ -317,12 +322,16 @@ public class HomeActivity extends AppCompatActivity { ((FloatingActionButton) findViewById(R.id.floatingAddButton)).hide(); ((SpaceNavigationView) findViewById(R.id.space)).setCentreButtonIcon(R.drawable.ic_view_list_white_24dp); - //0 : Unknown + //0 : Watchlist //1 : Market cap findViewById(R.id.toolbar_layout).setFocusable(false); ((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true); findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(false); + findViewById(R.id.app_bar).setEnabled(false); + findViewById(R.id.toolbar_layout).setNestedScrollingEnabled(false); + findViewById(R.id.coordinatorLayout).setNestedScrollingEnabled(false); + findViewById(R.id.switch_button).setVisibility(View.GONE); @@ -592,6 +601,8 @@ public class HomeActivity extends AppCompatActivity { set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE); set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE); PieData data = new PieData(set); + data.setValueTextSize(10); + data.setValueFormatter(new PercentFormatter()); pieChart.setData(data); pieChart.setDrawSlicesUnderHole(false); diff --git a/app/src/main/res/drawable/ic_fiber_manual_record_white_24dp.xml b/app/src/main/res/drawable/ic_fiber_manual_record_white_24dp.xml new file mode 100644 index 0000000..5cc678f --- /dev/null +++ b/app/src/main/res/drawable/ic_fiber_manual_record_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_currency_details.xml b/app/src/main/res/layout/activity_currency_details.xml index 2729385..cd739c1 100644 --- a/app/src/main/res/layout/activity_currency_details.xml +++ b/app/src/main/res/layout/activity_currency_details.xml @@ -114,12 +114,48 @@ - - + --> + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_currency_summary.xml b/app/src/main/res/layout/activity_currency_summary.xml index db9d855..daf65a1 100644 --- a/app/src/main/res/layout/activity_currency_summary.xml +++ b/app/src/main/res/layout/activity_currency_summary.xml @@ -8,6 +8,7 @@ tools:context="com.nauk.coinfolio.Activities.HomeActivity"> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a939cca..e586471 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -33,4 +33,5 @@ #FFFFFFFF #FFF44336 #FF4CAF50 + #FFFFFFFF \ No newline at end of file