Icon & features

- Update Icon
- Add balance value in the drawer
This commit is contained in:
Tanguy Herbron 2018-06-04 02:57:46 +02:00
parent 38a84e0f1e
commit 7505d8a1be
22 changed files with 91 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -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);

View File

@ -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<Currency> balance = balanceManager.getTotalBalance();

View File

@ -1,6 +1,6 @@
package com.herbron.moodl;
public interface HideBalanceSwitch {
public interface BalanceSwitchManagerInterface {
void buttonCheckedChange();

View File

@ -0,0 +1,10 @@
package com.herbron.moodl;
/**
* Created by Administrator on 04/06/2018.
*/
public interface BalanceUpdateInterface {
void onBalanceUpdated(float value);
}

View File

@ -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">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
@ -30,6 +30,30 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/white"
android:textSize="20sp"
android:text="Total portfolio value :"/>
<TextView
android:id="@+id/balanceTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/white"
android:textSize="22sp"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB