diff --git a/app/build.gradle b/app/build.gradle index 137cede..15ddffa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,6 @@ dependencies { implementation 'com.android.support:support-v4:27.1.0' implementation 'com.android.support:palette-v7:27.1.0' 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-core:2.8.5' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5' 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 460cb8e..a905156 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencyDetailsActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencyDetailsActivity.java @@ -10,7 +10,6 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; -import android.preference.SwitchPreference; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v4.app.NavUtils; @@ -180,8 +179,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity { } }); - ((BottomNavigationView) findViewById(R.id.navigation_details)).getMenu().getItem(1).setEnabled(false); - setupActionBar(); drawTransactionList(); diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java index 0a7efbd..7b38663 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java @@ -1,7 +1,9 @@ package com.nauk.coinfolio.Activities; import android.content.Intent; +import android.os.AsyncTask; import android.os.Bundle; +import android.os.Looper; import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.view.Menu; @@ -25,6 +27,7 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear private CurrencyListAdapter adapter; private ListView listView; private android.widget.Filter filter; + private Intent comingIntent; @Override protected void onCreate(Bundle savedInstanceState) { @@ -35,18 +38,12 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear setContentView(R.layout.activity_add_currency); - Intent intent = getIntent(); - - currencySymbols = intent.getStringArrayExtra("currencyListSymbols"); - currencyNames = intent.getStringArrayExtra("currencyListNames"); + comingIntent = getIntent(); setTitle("Select a coin"); - setupAdapter(); - - setupList(); - - setupSearchView(); + ListLoader listLoader = new ListLoader(); + listLoader.execute(); } private void setupSearchView() @@ -141,4 +138,51 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear { return false; } + + private class ListLoader extends AsyncTask + { + @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(); + } + + currencySymbols = comingIntent.getStringArrayExtra("currencyListSymbols"); + currencyNames = comingIntent.getStringArrayExtra("currencyListNames"); + + setupAdapter(); + + setupList(); + + runOnUiThread(new Runnable() { + @Override + public void run() { + setupSearchView(); + } + }); + + return null; + } + + @Override + protected void onPostExecute(Void result) + { + findViewById(R.id.coinsPreview).setVisibility(View.VISIBLE); + findViewById(R.id.currencyListProgressBar).setVisibility(View.GONE); + } + } } 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 d2a3f9d..0c54ac9 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java @@ -10,9 +10,10 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Looper; +import android.support.annotation.NonNull; import android.support.design.widget.AppBarLayout; +import android.support.design.widget.BottomNavigationView; import android.support.design.widget.CollapsingToolbarLayout; -import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; @@ -27,6 +28,7 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -38,9 +40,6 @@ 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.luseen.spacenavigation.SpaceItem; -import com.luseen.spacenavigation.SpaceNavigationView; -import com.luseen.spacenavigation.SpaceOnClickListener; import com.nauk.coinfolio.DataManagers.BalanceManager; import com.nauk.coinfolio.DataManagers.CurrencyData.Currency; import com.nauk.coinfolio.DataManagers.MarketCapManager; @@ -94,9 +93,32 @@ public class HomeActivity extends AppCompatActivity { private Runnable updateRunnable; private ViewFlipper viewFlipper; private HomeLayoutGenerator layoutGenerator; + private BottomNavigationView bottomNavigationView; private HashMap dominantCurrenciesColors; + private BottomNavigationView.OnNavigationItemSelectedListener onNavigationItemSelectedListener + = new BottomNavigationView.OnNavigationItemSelectedListener() { + + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + item.setChecked(true); + switch (item.getItemId()) + { + case R.id.navigation_watchlist: + switchSecondaryViews(0); + break; + case R.id.navigation_currencies_list: + switchMainView(); + break; + case R.id.navigation_market_cap: + switchSecondaryViews(2); + break; + } + return false; + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -107,7 +129,7 @@ public class HomeActivity extends AppCompatActivity { //requestWindowFeature(Window.FEATURE_NO_TITLE); //getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); //this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); setContentView(R.layout.activity_currency_summary); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); @@ -146,11 +168,14 @@ public class HomeActivity extends AppCompatActivity { toolbarSubtitle = findViewById(R.id.toolbarSubtitle); currencyLayout = findViewById(R.id.currencyListLayout); viewFlipper = findViewById(R.id.viewFlipperSummary); - viewFlipper.setDisplayedChild(1); + + bottomNavigationView = findViewById(R.id.navigationSummary); + bottomNavigationView.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener); + bottomNavigationView.setSelectedItemId(R.id.navigation_currencies_list); layoutGenerator = new HomeLayoutGenerator(this); - ImageButton addCurrencyButton = findViewById(R.id.floatingAddButton); + Button addCurrencyButton = findViewById(R.id.buttonAddTransaction); ImageButton detailsButton = findViewById(R.id.switch_button); ImageButton settingsButton = findViewById(R.id.settings_button); @@ -223,8 +248,6 @@ public class HomeActivity extends AppCompatActivity { lastTimestamp = 0; - setupNavBar(savedInstanceState); - setupDominantCurrenciesColors(); } @@ -299,43 +322,8 @@ public class HomeActivity extends AppCompatActivity { dominantCurrenciesColors.put("ETC", -10448784); } - private void setupNavBar(Bundle savedInstanceState) + private void switchMainView() { - final SpaceNavigationView spaceNavigationView = findViewById(R.id.space); - spaceNavigationView.initWithSaveInstanceState(savedInstanceState); - spaceNavigationView.addSpaceItem(new SpaceItem("WatchList", R.drawable.ic_remove_red_eye_black_24dp)); - spaceNavigationView.addSpaceItem(new SpaceItem("Market Cap.", R.drawable.ic_pie_chart_black_24dp)); - spaceNavigationView.setSpaceBackgroundColor(getResources().getColor(R.color.colorPrimary)); - spaceNavigationView.setCentreButtonIcon(R.drawable.ic_view_list_white_24dp); - spaceNavigationView.setCentreButtonColor(getResources().getColor(R.color.colorPrimary)); - spaceNavigationView.setCentreButtonIconColorFilterEnabled(false); - spaceNavigationView.changeCurrentItem(-1); - - spaceNavigationView.setSpaceOnClickListener(new SpaceOnClickListener() { - @Override - public void onCentreButtonClick() { - spaceNavigationCentreButtonEvent(); - } - - @Override - public void onItemClick(int itemIndex, String itemName) { - spaceNavigationItemEvent(itemIndex); - } - - @Override - public void onItemReselected(int itemIndex, String itemName) { - } - }); - } - - private void spaceNavigationCentreButtonEvent() - { - //Toast.makeText(MainActivity.this,"onCentreButtonClick", Toast.LENGTH_SHORT).show(); - ((FloatingActionButton) findViewById(R.id.floatingAddButton)).show(); - SpaceNavigationView nav = findViewById(R.id.space); - - nav.changeCurrentItem(-1); - findViewById(R.id.toolbar_layout).setFocusable(true); ((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(true, true); findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(true); @@ -349,13 +337,8 @@ public class HomeActivity extends AppCompatActivity { viewFlipper.setDisplayedChild(1); } - private void spaceNavigationItemEvent(int itemIndex) + private void switchSecondaryViews(int itemIndex) { - ((FloatingActionButton) findViewById(R.id.floatingAddButton)).hide(); - ((SpaceNavigationView) findViewById(R.id.space)).setCentreButtonIcon(R.drawable.ic_view_list_white_24dp); - - //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); @@ -366,23 +349,12 @@ public class HomeActivity extends AppCompatActivity { findViewById(R.id.switch_button).setVisibility(View.GONE); - viewFlipper.setDisplayedChild(itemIndex * 2); - - if(itemIndex == 1) - { - ((PieChart) findViewById(R.id.marketCapPieChart)).animateX(1000); - } - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - ((SpaceNavigationView) findViewById(R.id.space)).onSaveInstanceState(outState); + viewFlipper.setDisplayedChild(itemIndex); } private void showErrorSnackbar() { - Snackbar.make(findViewById(R.id.currencyListLayout), "Error while updating data", Snackbar.LENGTH_LONG) + Snackbar.make(findViewById(R.id.viewFlipperSummary), "Error while updating data", Snackbar.LENGTH_LONG) .setAction("Update", new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java index 01ffb58..71a2463 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java @@ -215,7 +215,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { addPreferencesFromResource(R.xml.pref_general); setHasOptionsMenu(true); - ((SwitchPreference) findPreference("hide_balance")).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + findPreference("hide_balance").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { boolean isChecked = ((SwitchPreference) findPreference("hide_balance")).isChecked(); @@ -267,7 +267,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { bindPreferenceSummaryToValue(findPreference("hitbtc_privatekey")); bindPreferenceSummaryToValue(findPreference("binance_privatekey")); - ((SwitchPreference) findPreference("enable_hitbtc")).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + findPreference("enable_hitbtc").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { boolean isChecked = ((SwitchPreference) findPreference("enable_hitbtc")).isChecked(); @@ -283,7 +283,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { } }); - ((SwitchPreference) findPreference("enable_binance")).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + findPreference("enable_binance").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { boolean isChecked = ((SwitchPreference) findPreference("enable_binance")).isChecked(); diff --git a/app/src/main/res/drawable/button_dashed_background.xml b/app/src/main/res/drawable/button_dashed_background.xml new file mode 100644 index 0000000..9af5197 --- /dev/null +++ b/app/src/main/res/drawable/button_dashed_background.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_view_list_white_24dp.xml b/app/src/main/res/drawable/ic_view_list_black_24dp.xml similarity index 90% rename from app/src/main/res/drawable/ic_view_list_white_24dp.xml rename to app/src/main/res/drawable/ic_view_list_black_24dp.xml index 222dc3b..78118c1 100644 --- a/app/src/main/res/drawable/ic_view_list_white_24dp.xml +++ b/app/src/main/res/drawable/ic_view_list_black_24dp.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/layout/activity_add_currency.xml b/app/src/main/res/layout/activity_add_currency.xml index ee16a26..b8b39d7 100644 --- a/app/src/main/res/layout/activity_add_currency.xml +++ b/app/src/main/res/layout/activity_add_currency.xml @@ -22,7 +22,20 @@ + android:layout_height="wrap_content" + android:visibility="gone"/> + + + + + + diff --git a/app/src/main/res/layout/activity_currency_details.xml b/app/src/main/res/layout/activity_currency_details.xml index e13d831..bc20352 100644 --- a/app/src/main/res/layout/activity_currency_details.xml +++ b/app/src/main/res/layout/activity_currency_details.xml @@ -211,7 +211,7 @@ + android:background="@color/separationColor"/> + android:background="@color/separationColor"/> + android:background="@color/separationColor"/> + android:background="@color/separationColor"/> + android:background="@color/separationColor"/> - - + android:layout_height="@dimen/app_bar_height" + android:fitsSystemWindows="true" + android:theme="@style/AppTheme.AppBarOverlay" + android:background="@drawable/gradient_background"> - - - - - - - - - - - - - - - - - - - - - - - - - + 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:layout_marginEnd="0dp" + android:layout_marginStart="0dp" + android:background="?android:attr/windowBackground" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + android:layout_alignParentBottom="true" + app:menu="@menu/navigation_home" + android:layout_gravity="bottom" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/cardview_currency.xml b/app/src/main/res/layout/cardview_currency.xml index 193e044..419d7de 100644 --- a/app/src/main/res/layout/cardview_currency.xml +++ b/app/src/main/res/layout/cardview_currency.xml @@ -3,6 +3,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:card_view="http://schemas.android.com/tools" android:clickable="true" android:focusable="true" android:paddingBottom="4dp"> @@ -13,9 +14,9 @@ android:layout_margin="10dp" android:clickable="false" android:backgroundTint="@color/cardview_background" - android:elevation="@dimen/cardview_elevation" app:cardCornerRadius="2dp" - app:layout_constraintBottom_toBottomOf="parent"> + app:layout_constraintBottom_toBottomOf="parent" + card_view:cardElevation="@dimen/cardview_elevation"> + android:background="@color/separationColor" /> diff --git a/app/src/main/res/layout/cardview_watchlist.xml b/app/src/main/res/layout/cardview_watchlist.xml index 7a239b0..e8f4758 100644 --- a/app/src/main/res/layout/cardview_watchlist.xml +++ b/app/src/main/res/layout/cardview_watchlist.xml @@ -124,7 +124,7 @@ android:layout_gravity="center_vertical" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" - android:background="@color/separationLine" /> + android:background="@color/separationColor" /> diff --git a/app/src/main/res/layout/content_currency_summary.xml b/app/src/main/res/layout/content_currency_summary.xml index a3299e4..fe232ec 100644 --- a/app/src/main/res/layout/content_currency_summary.xml +++ b/app/src/main/res/layout/content_currency_summary.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" - android:layout_marginBottom="50dp" + android:layout_marginBottom="56dp" android:background="@color/summary_background"> + android:layout_height="match_parent" + android:orientation="vertical"> + +