diff --git a/app/src/main/ic_launcher_moodl-web.png b/app/src/main/ic_launcher_moodl-web.png index 99c5954..d3200e0 100644 Binary files a/app/src/main/ic_launcher_moodl-web.png and b/app/src/main/ic_launcher_moodl-web.png differ diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java index 7758bba..9e7b3df 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java @@ -3,6 +3,7 @@ package com.herbron.moodl.Activities; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.app.Fragment; @@ -18,14 +19,20 @@ import android.view.Window; import android.view.WindowManager; import android.widget.CompoundButton; import android.widget.Switch; +import android.widget.TextView; import com.herbron.moodl.Activities.HomeActivityFragments.MarketCapitalization; import com.herbron.moodl.Activities.HomeActivityFragments.Overview; import com.herbron.moodl.Activities.HomeActivityFragments.Summary; import com.herbron.moodl.Activities.HomeActivityFragments.Watchlist; -import com.herbron.moodl.HideBalanceSwitch; +import com.herbron.moodl.BalanceSwitchManagerInterface; +import com.herbron.moodl.BalanceUpdateInterface; +import com.herbron.moodl.DataManagers.PreferencesManager; +import com.herbron.moodl.PlaceholderManager; import com.herbron.moodl.R; +import static com.herbron.moodl.MoodlBox.numberConformer; + //Use WilliamChart for charts https://github.com/diogobernardino/WilliamChart //Auto refresh with predefined intervals @@ -34,7 +41,7 @@ import com.herbron.moodl.R; //Add reddit link ? // -public class HomeActivity extends AppCompatActivity { +public class HomeActivity extends AppCompatActivity implements BalanceUpdateInterface { private DrawerLayout drawerLayout; private Fragment watchlistFragment; @@ -44,7 +51,7 @@ public class HomeActivity extends AppCompatActivity { private Fragment currentFragment; - private HideBalanceSwitch switchInterface; + private BalanceSwitchManagerInterface switchInterface; @Override protected void onCreate(Bundle savedInstanceState) { @@ -65,7 +72,7 @@ public class HomeActivity extends AppCompatActivity { drawerLayout = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); - setListener((HideBalanceSwitch) holdingsFragment); + setListener((BalanceSwitchManagerInterface) holdingsFragment); showFragment(holdingsFragment); @@ -112,7 +119,7 @@ public class HomeActivity extends AppCompatActivity { drawerLayout.openDrawer(GravityCompat.START); } - public void setListener(HideBalanceSwitch switchInterface) + public void setListener(BalanceSwitchManagerInterface switchInterface) { this.switchInterface = switchInterface; } @@ -166,6 +173,22 @@ public class HomeActivity extends AppCompatActivity { return true; } + @Override + public void onBalanceUpdated(float value) { + PreferencesManager preferencesManager = new PreferencesManager(getApplicationContext()); + NavigationView navigationView = findViewById(R.id.nav_view); + TextView drawerBalanceTextView = navigationView.getHeaderView(0).findViewById(R.id.balanceTextView); + + if(preferencesManager.isBalanceHidden()) + { + drawerBalanceTextView.setText(PlaceholderManager.getPercentageString(numberConformer(value), getApplicationContext())); + } + else + { + drawerBalanceTextView.setText(PlaceholderManager.getValueString(numberConformer(value), getApplicationContext())); + } + } + public interface IconCallBack { void onSuccess(Bitmap bitmap); diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java index deb3279..816602d 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java @@ -16,6 +16,7 @@ import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.graphics.Palette; +import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -28,12 +29,12 @@ import android.widget.TextView; import com.herbron.moodl.Activities.CurrencySelectionActivity; import com.herbron.moodl.Activities.HomeActivity; -import com.herbron.moodl.DataManagers.BalanceManager; +import com.herbron.moodl.BalanceUpdateInterface; import com.herbron.moodl.DataManagers.CurrencyData.Currency; import com.herbron.moodl.DataManagers.CurrencyData.CurrencyCardview; import com.herbron.moodl.DataManagers.CurrencyData.CurrencyTickerList; import com.herbron.moodl.DataManagers.PreferencesManager; -import com.herbron.moodl.HideBalanceSwitch; +import com.herbron.moodl.BalanceSwitchManagerInterface; import com.herbron.moodl.MoodlBox; import com.herbron.moodl.PlaceholderManager; import com.herbron.moodl.R; @@ -48,11 +49,11 @@ import static java.lang.Math.abs; * Created by Tiji on 13/04/2018. */ -public class Summary extends Fragment implements HideBalanceSwitch { +public class Summary extends Fragment implements BalanceSwitchManagerInterface { private LinearLayout currencyLayout; private PreferencesManager preferencesManager; - private BalanceManager balanceManager; + private com.herbron.moodl.DataManagers.BalanceManager balanceManager; private SwipeRefreshLayout refreshLayout; private Dialog loadingDialog; private String defaultCurrency; @@ -73,6 +74,8 @@ public class Summary extends Fragment implements HideBalanceSwitch { protected float totalFluctuation; private long lastTimestamp; + private BalanceUpdateInterface balanceUpdateInterface; + @NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) @@ -80,7 +83,7 @@ public class Summary extends Fragment implements HideBalanceSwitch { View fragmentView = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false); preferencesManager = new PreferencesManager(getActivity()); - balanceManager = new BalanceManager(getActivity()); + balanceManager = new com.herbron.moodl.DataManagers.BalanceManager(getActivity()); currencyTickerList = CurrencyTickerList.getInstance(getActivity()); currencyLayout = fragmentView.findViewById(R.id.currencyListLayout); @@ -89,6 +92,8 @@ public class Summary extends Fragment implements HideBalanceSwitch { resetCounters(); + setListener((BalanceUpdateInterface) getActivity()); + defaultCurrency = preferencesManager.getDefaultCurrency(); handler = new Handler(); @@ -121,6 +126,11 @@ public class Summary extends Fragment implements HideBalanceSwitch { return fragmentView; } + public void setListener(BalanceUpdateInterface balanceUpdateInterface) + { + this.balanceUpdateInterface = balanceUpdateInterface; + } + private void setupDrawerButton(View view) { ImageButton drawerButton = view.findViewById(R.id.drawer_button); @@ -416,10 +426,12 @@ public class Summary extends Fragment implements HideBalanceSwitch { if(preferencesManager.isBalanceHidden()) { updateHideBalanceTitle(totalFluctuationPercentage); + balanceUpdateInterface.onBalanceUpdated(totalFluctuationPercentage); } else { updateBalanceDisplayedTitle(totalFluctuationPercentage); + balanceUpdateInterface.onBalanceUpdated(totalValue); } } @@ -687,7 +699,7 @@ public class Summary extends Fragment implements HideBalanceSwitch { { if(!currencyTickerList.isUpToDate()) { - currencyTickerList.updateListing(new BalanceManager.IconCallBack() { + currencyTickerList.updateListing(new com.herbron.moodl.DataManagers.BalanceManager.IconCallBack() { @Override public void onSuccess() { countCoins(false, false, true); @@ -699,7 +711,7 @@ public class Summary extends Fragment implements HideBalanceSwitch { countCoins(false, false, true); } - balanceManager.updateDetails(new BalanceManager.IconCallBack() { + balanceManager.updateDetails(new com.herbron.moodl.DataManagers.BalanceManager.IconCallBack() { @Override public void onSuccess() { @@ -707,7 +719,7 @@ public class Summary extends Fragment implements HideBalanceSwitch { } }); - balanceManager.updateTotalBalance(new BalanceManager.VolleyCallBack() { + balanceManager.updateTotalBalance(new com.herbron.moodl.DataManagers.BalanceManager.VolleyCallBack() { @Override public void onSuccess() { final List balance = balanceManager.getTotalBalance(); diff --git a/app/src/main/java/com/herbron/moodl/HideBalanceSwitch.java b/app/src/main/java/com/herbron/moodl/BalanceSwitchManagerInterface.java similarity index 56% rename from app/src/main/java/com/herbron/moodl/HideBalanceSwitch.java rename to app/src/main/java/com/herbron/moodl/BalanceSwitchManagerInterface.java index c1c7e1b..de54c9f 100644 --- a/app/src/main/java/com/herbron/moodl/HideBalanceSwitch.java +++ b/app/src/main/java/com/herbron/moodl/BalanceSwitchManagerInterface.java @@ -1,6 +1,6 @@ package com.herbron.moodl; -public interface HideBalanceSwitch { +public interface BalanceSwitchManagerInterface { void buttonCheckedChange(); diff --git a/app/src/main/java/com/herbron/moodl/BalanceUpdateInterface.java b/app/src/main/java/com/herbron/moodl/BalanceUpdateInterface.java new file mode 100644 index 0000000..810be19 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/BalanceUpdateInterface.java @@ -0,0 +1,10 @@ +package com.herbron.moodl; + +/** + * Created by Administrator on 04/06/2018. + */ + +public interface BalanceUpdateInterface { + + void onBalanceUpdated(float value); +} diff --git a/app/src/main/res/layout/summary_drawer_header.xml b/app/src/main/res/layout/summary_drawer_header.xml index a43ad98..9b78b18 100644 --- a/app/src/main/res/layout/summary_drawer_header.xml +++ b/app/src/main/res/layout/summary_drawer_header.xml @@ -4,13 +4,13 @@ android:layout_height="192dp" android:background="@drawable/gradient_background" android:padding="16dp" - android:orientation="vertical" - android:gravity="center"> + android:orientation="vertical"> + android:orientation="horizontal" + android:layout_gravity="center"> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index 2450e77..ae507c2 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_moodl.png b/app/src/main/res/mipmap-hdpi/ic_launcher_moodl.png index f9d4ca2..340c879 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_moodl.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_moodl.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_moodl_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_moodl_round.png new file mode 100644 index 0000000..b307b41 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_moodl_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 7ea5785..7d5f81c 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_moodl.png b/app/src/main/res/mipmap-mdpi/ic_launcher_moodl.png index 040815c..a7c458c 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_moodl.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_moodl.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_moodl_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_moodl_round.png new file mode 100644 index 0000000..a5dbab3 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_moodl_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index 5a6b53d..52c9547 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl.png index 5787ffa..0ba5230 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl_round.png new file mode 100644 index 0000000..5def546 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_moodl_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 6844d1e..ef6f5e1 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl.png index ac10c91..8d6d416 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl_round.png new file mode 100644 index 0000000..0fa7ef6 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 51a9ae7..bc949f4 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl.png index 9e8e8b5..8aec810 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl_round.png new file mode 100644 index 0000000..42350de Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl_round.png differ