Icon & features
- Update Icon - Add balance value in the drawer
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
@ -3,6 +3,7 @@ package com.herbron.moodl.Activities;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@ -18,14 +19,20 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.herbron.moodl.Activities.HomeActivityFragments.MarketCapitalization;
|
import com.herbron.moodl.Activities.HomeActivityFragments.MarketCapitalization;
|
||||||
import com.herbron.moodl.Activities.HomeActivityFragments.Overview;
|
import com.herbron.moodl.Activities.HomeActivityFragments.Overview;
|
||||||
import com.herbron.moodl.Activities.HomeActivityFragments.Summary;
|
import com.herbron.moodl.Activities.HomeActivityFragments.Summary;
|
||||||
import com.herbron.moodl.Activities.HomeActivityFragments.Watchlist;
|
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 com.herbron.moodl.R;
|
||||||
|
|
||||||
|
import static com.herbron.moodl.MoodlBox.numberConformer;
|
||||||
|
|
||||||
//Use WilliamChart for charts https://github.com/diogobernardino/WilliamChart
|
//Use WilliamChart for charts https://github.com/diogobernardino/WilliamChart
|
||||||
|
|
||||||
//Auto refresh with predefined intervals
|
//Auto refresh with predefined intervals
|
||||||
@ -34,7 +41,7 @@ import com.herbron.moodl.R;
|
|||||||
//Add reddit link ?
|
//Add reddit link ?
|
||||||
//
|
//
|
||||||
|
|
||||||
public class HomeActivity extends AppCompatActivity {
|
public class HomeActivity extends AppCompatActivity implements BalanceUpdateInterface {
|
||||||
|
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
private Fragment watchlistFragment;
|
private Fragment watchlistFragment;
|
||||||
@ -44,7 +51,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
private Fragment currentFragment;
|
private Fragment currentFragment;
|
||||||
|
|
||||||
|
|
||||||
private HideBalanceSwitch switchInterface;
|
private BalanceSwitchManagerInterface switchInterface;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -65,7 +72,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
drawerLayout = findViewById(R.id.drawer_layout);
|
drawerLayout = findViewById(R.id.drawer_layout);
|
||||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
|
|
||||||
setListener((HideBalanceSwitch) holdingsFragment);
|
setListener((BalanceSwitchManagerInterface) holdingsFragment);
|
||||||
|
|
||||||
showFragment(holdingsFragment);
|
showFragment(holdingsFragment);
|
||||||
|
|
||||||
@ -112,7 +119,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
drawerLayout.openDrawer(GravityCompat.START);
|
drawerLayout.openDrawer(GravityCompat.START);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListener(HideBalanceSwitch switchInterface)
|
public void setListener(BalanceSwitchManagerInterface switchInterface)
|
||||||
{
|
{
|
||||||
this.switchInterface = switchInterface;
|
this.switchInterface = switchInterface;
|
||||||
}
|
}
|
||||||
@ -166,6 +173,22 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
return true;
|
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
|
public interface IconCallBack
|
||||||
{
|
{
|
||||||
void onSuccess(Bitmap bitmap);
|
void onSuccess(Bitmap bitmap);
|
||||||
|
@ -16,6 +16,7 @@ import android.support.v4.view.GravityCompat;
|
|||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.graphics.Palette;
|
import android.support.v7.graphics.Palette;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -28,12 +29,12 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.herbron.moodl.Activities.CurrencySelectionActivity;
|
import com.herbron.moodl.Activities.CurrencySelectionActivity;
|
||||||
import com.herbron.moodl.Activities.HomeActivity;
|
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.Currency;
|
||||||
import com.herbron.moodl.DataManagers.CurrencyData.CurrencyCardview;
|
import com.herbron.moodl.DataManagers.CurrencyData.CurrencyCardview;
|
||||||
import com.herbron.moodl.DataManagers.CurrencyData.CurrencyTickerList;
|
import com.herbron.moodl.DataManagers.CurrencyData.CurrencyTickerList;
|
||||||
import com.herbron.moodl.DataManagers.PreferencesManager;
|
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.MoodlBox;
|
||||||
import com.herbron.moodl.PlaceholderManager;
|
import com.herbron.moodl.PlaceholderManager;
|
||||||
import com.herbron.moodl.R;
|
import com.herbron.moodl.R;
|
||||||
@ -48,11 +49,11 @@ import static java.lang.Math.abs;
|
|||||||
* Created by Tiji on 13/04/2018.
|
* 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 LinearLayout currencyLayout;
|
||||||
private PreferencesManager preferencesManager;
|
private PreferencesManager preferencesManager;
|
||||||
private BalanceManager balanceManager;
|
private com.herbron.moodl.DataManagers.BalanceManager balanceManager;
|
||||||
private SwipeRefreshLayout refreshLayout;
|
private SwipeRefreshLayout refreshLayout;
|
||||||
private Dialog loadingDialog;
|
private Dialog loadingDialog;
|
||||||
private String defaultCurrency;
|
private String defaultCurrency;
|
||||||
@ -73,6 +74,8 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
protected float totalFluctuation;
|
protected float totalFluctuation;
|
||||||
private long lastTimestamp;
|
private long lastTimestamp;
|
||||||
|
|
||||||
|
private BalanceUpdateInterface balanceUpdateInterface;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
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);
|
View fragmentView = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false);
|
||||||
|
|
||||||
preferencesManager = new PreferencesManager(getActivity());
|
preferencesManager = new PreferencesManager(getActivity());
|
||||||
balanceManager = new BalanceManager(getActivity());
|
balanceManager = new com.herbron.moodl.DataManagers.BalanceManager(getActivity());
|
||||||
currencyTickerList = CurrencyTickerList.getInstance(getActivity());
|
currencyTickerList = CurrencyTickerList.getInstance(getActivity());
|
||||||
|
|
||||||
currencyLayout = fragmentView.findViewById(R.id.currencyListLayout);
|
currencyLayout = fragmentView.findViewById(R.id.currencyListLayout);
|
||||||
@ -89,6 +92,8 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
|
|
||||||
resetCounters();
|
resetCounters();
|
||||||
|
|
||||||
|
setListener((BalanceUpdateInterface) getActivity());
|
||||||
|
|
||||||
defaultCurrency = preferencesManager.getDefaultCurrency();
|
defaultCurrency = preferencesManager.getDefaultCurrency();
|
||||||
|
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
@ -121,6 +126,11 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setListener(BalanceUpdateInterface balanceUpdateInterface)
|
||||||
|
{
|
||||||
|
this.balanceUpdateInterface = balanceUpdateInterface;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupDrawerButton(View view)
|
private void setupDrawerButton(View view)
|
||||||
{
|
{
|
||||||
ImageButton drawerButton = view.findViewById(R.id.drawer_button);
|
ImageButton drawerButton = view.findViewById(R.id.drawer_button);
|
||||||
@ -416,10 +426,12 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
if(preferencesManager.isBalanceHidden())
|
if(preferencesManager.isBalanceHidden())
|
||||||
{
|
{
|
||||||
updateHideBalanceTitle(totalFluctuationPercentage);
|
updateHideBalanceTitle(totalFluctuationPercentage);
|
||||||
|
balanceUpdateInterface.onBalanceUpdated(totalFluctuationPercentage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
updateBalanceDisplayedTitle(totalFluctuationPercentage);
|
updateBalanceDisplayedTitle(totalFluctuationPercentage);
|
||||||
|
balanceUpdateInterface.onBalanceUpdated(totalValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,7 +699,7 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
{
|
{
|
||||||
if(!currencyTickerList.isUpToDate())
|
if(!currencyTickerList.isUpToDate())
|
||||||
{
|
{
|
||||||
currencyTickerList.updateListing(new BalanceManager.IconCallBack() {
|
currencyTickerList.updateListing(new com.herbron.moodl.DataManagers.BalanceManager.IconCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
countCoins(false, false, true);
|
countCoins(false, false, true);
|
||||||
@ -699,7 +711,7 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
countCoins(false, false, true);
|
countCoins(false, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceManager.updateDetails(new BalanceManager.IconCallBack() {
|
balanceManager.updateDetails(new com.herbron.moodl.DataManagers.BalanceManager.IconCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess()
|
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
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
final List<Currency> balance = balanceManager.getTotalBalance();
|
final List<Currency> balance = balanceManager.getTotalBalance();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.herbron.moodl;
|
package com.herbron.moodl;
|
||||||
|
|
||||||
public interface HideBalanceSwitch {
|
public interface BalanceSwitchManagerInterface {
|
||||||
|
|
||||||
void buttonCheckedChange();
|
void buttonCheckedChange();
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.herbron.moodl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Administrator on 04/06/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface BalanceUpdateInterface {
|
||||||
|
|
||||||
|
void onBalanceUpdated(float value);
|
||||||
|
}
|
@ -4,13 +4,13 @@
|
|||||||
android:layout_height="192dp"
|
android:layout_height="192dp"
|
||||||
android:background="@drawable/gradient_background"
|
android:background="@drawable/gradient_background"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:gravity="center">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -30,6 +30,30 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -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>
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_moodl_round.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_moodl_round.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_moodl_round.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_moodl_round.png
Normal file
After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_moodl_round.png
Normal file
After Width: | Height: | Size: 13 KiB |