diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
index cad50d5..943e267 100644
--- a/.idea/assetWizardSettings.xml
+++ b/.idea/assetWizardSettings.xml
@@ -23,7 +23,7 @@
@@ -34,7 +34,7 @@
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 083b9b6..ade5747 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/app/build.gradle b/app/build.gradle
index 75960e0..e3946f2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -56,7 +56,7 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.mattprecious.swirl:swirl:1.1.0'
- implementation 'com.wdullaer:materialdatetimepicker:3.5.2'
+ implementation 'com.wdullaer:materialdatetimepicker:3.6.3'
implementation 'com.jmedeisis:draglinearlayout:1.1.0'
implementation 'com.applandeo:material-file-picker:1.0.0'
implementation 'com.daasuu:EasingInterpolator:1.0.0'
diff --git a/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Charts.java b/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Charts.java
index 7b510f8..10d0bbd 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Charts.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Charts.java
@@ -616,7 +616,7 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
}
@Override
- public void onTimestampPriveUpdated(String price) {
+ public void onTimestampPriceUpdated(String price) {
}
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 e3d3faf..2686cf4 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
@@ -560,7 +560,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
{
balance.get(i).updatePrice(getActivity(), defaultCurrency, new CurrencyInfoUpdateNotifierInterface() {
@Override
- public void onTimestampPriveUpdated(String price) {
+ public void onTimestampPriceUpdated(String price) {
}
diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java
index 9dba35c..48a9090 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java
@@ -435,7 +435,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
currency.setId(getCurrencyId(currency.getSymbol()));
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new CurrencyInfoUpdateNotifierInterface() {
@Override
- public void onTimestampPriveUpdated(String price) {
+ public void onTimestampPriceUpdated(String price) {
}
diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java
index 3e423b4..cbd133c 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java
@@ -3,10 +3,12 @@ package com.herbron.moodl.Activities;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.opengl.Visibility;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.design.widget.TextInputLayout;
+import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
@@ -15,6 +17,9 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
@@ -23,11 +28,13 @@ import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import com.herbron.moodl.CurrencyInfoUpdateNotifierInterface;
import com.herbron.moodl.CustomAdapters.PairRecordListAdapter;
+import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
import com.herbron.moodl.DataManagers.CurrencyData.Currency;
import com.herbron.moodl.DataManagers.ExchangeManager.Exchange;
import com.herbron.moodl.DataManagers.InfoAPIManagers.CryptocompareApiManager;
@@ -47,27 +54,11 @@ import com.herbron.moodl.R;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.List;
import java.util.Locale;
public class RecordTransactionActivity extends AppCompatActivity implements CurrencyInfoUpdateNotifierInterface, CryptocompareNotifierInterface {
- private String coin;
- private String symbol;
- private TextView symbolTxtView;
- private TextInputLayout purchasedDateLayout;
- private EditText purchaseDate;
- private TextView feesTxtView;
- private EditText amountTxtView;
- private Button buyButton;
- private Button sellButton;
- private Button transferButton;
- private DatabaseManager databaseManager;
- private Calendar calendar;
- private SimpleDateFormat sdf;
- private PreferencesManager preferenceManager;
- private EditText purchasedPriceEditText;
- private int transactionId;
-
private Toolbar toolbar;
private ImageView currencyIconImageView;
@@ -81,51 +72,19 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
private AutoCompleteTextView exchange_autoCompleteTextView;
private AutoCompleteTextView pair_autoCompleteTextView;
- private SearchView mainSearchView;
+ private CustomTabLayout tabLayout;
+ private ViewPager viewPager;
- /*@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_record:
+ private RecordTransactionPageAdapter pageAdapter;
- if(checkAmountText() && checkPriceText())
- {
- double amount = Double.parseDouble(amountTxtView.getText().toString());
- double purchasedPrice = Double.parseDouble(purchasedPriceEditText.getText().toString());
- double fees = Double.parseDouble(feesTxtView.getText().toString());
+ private Animation revealAnimation;
+ private Animation dismissAnimation;
- if(!sellButton.isEnabled())
- {
- amount *= -1;
- }
+ private LinearLayout globalTabLayouts;
- if(transactionId != -1)
- {
- databaseManager.updateTransactionWithId(transactionId, amount, calendar.getTime(), purchasedPrice, fees);
- }
- else
- {
- databaseManager.addCurrencyToManualCurrency(symbol, amount, calendar.getTime(), purchasedPrice, fees);
- }
+ private boolean isGlobalLayoutVisible;
- preferenceManager.setMustUpdateSummary(true);
- Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
- startActivity(intent);
- finish();
- }
- break;
- case android.R.id.home:
- //NavUtils.navigateUpFromSameTask(this);
- finish();
- break;
- default:
- break;
- }
- return true;
- }*/
-
- private boolean checkPriceText()
+ /*private boolean checkPriceText()
{
String purchasedPriceText = purchasedPriceEditText.getText().toString();
double purchasedPrice;
@@ -173,27 +132,13 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
}
return true;
- }
+ }*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_record_transaction);
- Intent intent = getIntent();
-
- sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.UK);
-
- calendar = Calendar.getInstance();
-
- databaseManager = new DatabaseManager(this);
- preferenceManager = new PreferencesManager(this);
-
- coin = intent.getStringExtra("coin");
- symbol = intent.getStringExtra("symbol");
-
- transactionId = intent.getIntExtra("transactionId", -1);
-
toolbar = findViewById(R.id.toolbar);
currencyIconImageView = findViewById(R.id.currencyIconImageView);
@@ -220,16 +165,23 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
setupBackButton();
}
+ public Currency getCurrency()
+ {
+ return currency;
+ }
+
private void setupTabLayout()
{
- CustomTabLayout tabLayout = findViewById(R.id.transactionsTabLayout);
+ globalTabLayouts = findViewById(R.id.globalTabLayouts);
+
+ tabLayout = findViewById(R.id.transactionsTabLayout);
tabLayout.addTab(0, "Buy");
tabLayout.addTab(1, "Sell");
- //tabLayout.addTab(2, "Transfer");
+ tabLayout.addTab(2, "Transfer");
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
- final ViewPager viewPager = findViewById(R.id.transactionsViewPager);
- final RecordTransactionPageAdapter pageAdapter = new RecordTransactionPageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
+ viewPager = findViewById(R.id.transactionsViewPager);
+ pageAdapter = new RecordTransactionPageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(pageAdapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@@ -248,6 +200,33 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
}
});
+
+ LinearLayout tabLayoutChildren = (LinearLayout) tabLayout.getChildAt(0);
+
+ for(int i = 0; i < tabLayoutChildren.getChildCount(); i++)
+ {
+ tabLayoutChildren.getChildAt(i).setEnabled(false);
+ }
+
+ revealAnimation = AnimationUtils.loadAnimation(this, R.anim.reveal);
+ dismissAnimation = AnimationUtils.loadAnimation(this, R.anim.dismiss);
+
+ dismissAnimation.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ isGlobalLayoutVisible = false;
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+
+ }
+ });
}
private void setupPairAutoCompleteTextView()
@@ -255,6 +234,27 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
pair_autoCompleteTextView.setThreshold(0);
pair_autoCompleteTextView.setTextColor(getResources().getColor(R.color.white));
+ pair_autoCompleteTextView.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
+ tabLayout.getTabAt(2).select();
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ });
+
pair_autoCompleteTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -284,6 +284,12 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
pair_autoCompleteTextView.setText(PlaceholderManager.getPairString(pair.getFrom(), pair.getTo(), getBaseContext()));
toolbar.requestFocus();
hideSoftKeyboard(RecordTransactionActivity.this);
+
+ updatePairData();
+
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(true);
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(true);
+ tabLayout.getTabAt(0).select();
}
});
}
@@ -303,6 +309,10 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
public void onTextChanged(CharSequence s, int start, int before, int count) {
pair_autoCompleteTextView.setEnabled(false);
pair_autoCompleteTextView.setText("");
+
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
+ tabLayout.getTabAt(2).select();
}
@Override
@@ -343,6 +353,8 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
updatePairAdapter();
pair_autoCompleteTextView.setEnabled(true);
+
+ updateExchangeData();
}
});
}
@@ -363,7 +375,7 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
private void setupCoinAutoCompleteTextView()
{
- CoinRecordListAdapter adapter = new CoinRecordListAdapter(this, R.layout.custom_summary_coin_row, new ArrayList<>(cryptocompareApiManager.getCurrenciesDenomination()));
+ CoinRecordListAdapter adapter = new CoinRecordListAdapter(getBaseContext(), R.layout.custom_summary_coin_row, new ArrayList<>(cryptocompareApiManager.getCurrenciesDenomination()));
coin_autoCompleteTextView.setThreshold(0);
coin_autoCompleteTextView.setAdapter(adapter);
@@ -379,6 +391,13 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
currencyIconImageView.setImageBitmap(null);
exchange_autoCompleteTextView.setEnabled(false);
exchange_autoCompleteTextView.setText("");
+
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(2).setEnabled(false);
+
+ if(isGlobalLayoutVisible && globalTabLayouts.getAnimation().hasEnded())
+ {
+ globalTabLayouts.startAnimation(dismissAnimation);
+ }
}
@Override
@@ -424,13 +443,53 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
IconDownloaderTask iconDownloaderTask = new IconDownloaderTask();
iconDownloaderTask.execute();
+
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
+ ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(2).setEnabled(true);
+ tabLayout.getTabAt(2).select();
+
+ updateCurrencyData();
+
+ if(globalTabLayouts.getVisibility() == View.GONE)
+ {
+ globalTabLayouts.setVisibility(View.VISIBLE);
+ }
+
+ globalTabLayouts.startAnimation(revealAnimation);
+
+ isGlobalLayoutVisible = true;
}
});
}
+ private void updateCurrencyData()
+ {
+ for(int i = 0; i < pageAdapter.getCount(); i++)
+ {
+ ((CustomRecordFragment) pageAdapter.getItem(i)).setCurrency(currency);
+ }
+ }
+
+ private void updateExchangeData()
+ {
+ for(int i = 0; i < pageAdapter.getCount(); i++)
+ {
+ ((CustomRecordFragment) pageAdapter.getItem(i)).setExchange(exchange);
+ }
+ }
+
+ private void updatePairData()
+ {
+ for(int i = 0; i < pageAdapter.getCount(); i++)
+ {
+ ((CustomRecordFragment) pageAdapter.getItem(i)).setPair(pair);
+ }
+ }
+
@Override
- public void onTimestampPriveUpdated(String price) {
- purchasedPriceEditText.setText(price);
+ public void onTimestampPriceUpdated(String price) {
+ //purchasedPriceEditText.setText(price);
}
@Override
@@ -543,54 +602,6 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
activity.getCurrentFocus().getWindowToken(), 0);
}
- /*private void initializeButtons()
- {
- buyButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- buyButton.setEnabled(false);
- sellButton.setEnabled(true);
- transferButton.setEnabled(true);
- findViewById(R.id.input_purchase_price).setVisibility(View.VISIBLE);
- findViewById(R.id.input_fees).setVisibility(View.GONE);
- }
- });
-
- sellButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- buyButton.setEnabled(true);
- sellButton.setEnabled(false);
- transferButton.setEnabled(true);
- findViewById(R.id.input_purchase_price).setVisibility(View.GONE);
- findViewById(R.id.input_fees).setVisibility(View.VISIBLE);
- }
- });
-
- transferButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- buyButton.setEnabled(true);
- sellButton.setEnabled(true);
- transferButton.setEnabled(false);
- // Prepare transfer interface
- }
- });
- }
-
- private void initializeViewElements()
- {
- symbolTxtView = findViewById(R.id.currencySymbol);
- amountTxtView = findViewById(R.id.currencyAmount);
- feesTxtView = findViewById(R.id.feesTextView);
- purchasedDateLayout = findViewById(R.id.input_purchase_date);
- purchaseDate = findViewById(R.id.purchaseDate);
- purchasedPriceEditText = findViewById(R.id.purchasePrice);
- buyButton = findViewById(R.id.buyButton);
- sellButton = findViewById(R.id.sellButton);
- transferButton = findViewById(R.id.transfertButton);
- }*/
-
private void setupBackButton()
{
ImageButton backButton = findViewById(R.id.back_button);
@@ -601,44 +612,4 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
}
});
}
-
- private void createDatePicker()
- {
- new android.app.DatePickerDialog(
- RecordTransactionActivity.this,
- new android.app.DatePickerDialog.OnDateSetListener() {
- @Override
- public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
- calendar.set(Calendar.YEAR, year);
- calendar.set(Calendar.MONTH, month);
- calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- purchaseDate.setText(sdf.format(calendar.getTime()));
- createTimePicker();
- }
- },
- calendar.get(Calendar.YEAR),
- calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH)
- ).show();
- }
-
- private void createTimePicker()
- {
- new android.app.TimePickerDialog(
- RecordTransactionActivity.this,
- new android.app.TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker view, int hour, int minute) {
- calendar.set(Calendar.HOUR_OF_DAY, hour);
- calendar.set(Calendar.MINUTE, minute);
- purchaseDate.setText(sdf.format(calendar.getTime()));
-
- currency.getTimestampPrice(RecordTransactionActivity.this, preferenceManager.getDefaultCurrency(),calendar.getTimeInMillis() / 1000);
- }
- },
- calendar.get(Calendar.HOUR_OF_DAY),
- calendar.get(Calendar.MINUTE),
- true
- ).show();
- }
}
diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java
index 41cac85..df49f70 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java
@@ -1,37 +1,312 @@
package com.herbron.moodl.Activities.RecordTransactionFragments;
+import android.app.DatePickerDialog;
+import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
+import android.support.design.widget.TextInputEditText;
+import android.support.v7.widget.AppCompatButton;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.DatePicker;
+import android.widget.Spinner;
+import android.widget.TimePicker;
-import com.herbron.moodl.DataNotifiers.CryptocompareNotifierInterface;
-import com.herbron.moodl.DataManagers.InfoAPIManagers.CryptocompareApiManager;
+import com.herbron.moodl.Activities.HomeActivity;
+import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
+import com.herbron.moodl.DataManagers.CurrencyData.Currency;
+import com.herbron.moodl.DataManagers.DatabaseManager;
+import com.herbron.moodl.DataManagers.ExchangeManager.Exchange;
+import com.herbron.moodl.DataManagers.InfoAPIManagers.Pair;
+import com.herbron.moodl.DataManagers.PreferencesManager;
+import com.herbron.moodl.PlaceholderManager;
import com.herbron.moodl.R;
-public class BuyFragment extends Fragment implements CryptocompareNotifierInterface {
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Locale;
- private CryptocompareApiManager cryptocompareApiManager;
+public class BuyFragment extends CustomRecordFragment {
+
+ private TextInputEditText amoutEditText;
+ private TextInputEditText buyPriceEditText;
+ private TextInputEditText buyDateEditText;
+ private TextInputEditText totalValueEditText;
+ private TextInputEditText fees_editText;
+ private TextInputEditText note_editText;
+ private AppCompatButton saveBuyButton;
+ private static Spinner feesCurrencySpinner;
+ private static View view;
+
+ private ArrayAdapter currencyAdapter;
+
+ private SimpleDateFormat sdf;
+ private Calendar calendar;
+ private PreferencesManager preferenceManager;
+
+ private static Context context;
+
+ private static Currency fragmentCurrency;
+ private static Exchange fragmentExchange;
+ private static Pair fragmentPair;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_buy, container, false);
+ view = inflater.inflate(R.layout.fragment_buy, container, false);
+
+ context = getActivity().getApplicationContext();
+
+ calendar = Calendar.getInstance();
+ sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.UK);
+
+ preferenceManager = new PreferencesManager(getContext());
+
+ initializeViewElements();
return view;
}
- @Override
- public void onDetailsUpdated() {
+ private void initializeViewElements()
+ {
+ totalValueEditText = view.findViewById(R.id.totalValue_editText);
+ amoutEditText = view.findViewById(R.id.amount_editText);
+ amoutEditText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ if(isFieldCorrectlyFilled(buyPriceEditText, false) && isFieldCorrectlyFilled(amoutEditText, false))
+ {
+ if(Double.parseDouble(amoutEditText.getText().toString()) > 0)
+ {
+ Double totalValue = Double.parseDouble(buyPriceEditText.getText().toString()) * Double.parseDouble(s.toString());
+ totalValueEditText.setText(String.format("%f", totalValue));
+ }
+ else
+ {
+ totalValueEditText.setText("0");
+ }
+ }
+ else
+ {
+ totalValueEditText.setText("");
+ }
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ });
+
+ buyPriceEditText = view.findViewById(R.id.buyPrice_editText);
+ buyDateEditText = view.findViewById(R.id.buyDate_editText);
+ buyDateEditText.setText(sdf.format(calendar.getTime()));
+
+ buyDateEditText.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ createDatePicker();
+ }
+ });
+ feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText);
+
+ currencyAdapter = new ArrayAdapter(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>());
+ currencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ feesCurrencySpinner.setAdapter(currencyAdapter);
+
+ if(fragmentPair != null)
+ {
+ updateAdapter();
+ }
+
+ saveBuyButton = view.findViewById(R.id.saveBuyButton);
+ saveBuyButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(isFieldCorrectlyFilled(amoutEditText, true) && isFieldCorrectlyFilled(buyPriceEditText, true) && isFieldCorrectlyFilled(totalValueEditText, true))
+ {
+ double amount = Double.parseDouble(amoutEditText.getText().toString());
+ double purchasedPrice = Double.parseDouble(buyPriceEditText.getText().toString());
+ double fees;
+
+ if(fees_editText.getText().toString().equals(""))
+ {
+ fees = 0;
+ }
+ else
+ {
+ fees = Double.parseDouble(fees_editText.getText().toString());
+ }
+
+ String note = note_editText.getText().toString();
+
+ DatabaseManager databaseManager = new DatabaseManager(getContext());
+
+ databaseManager.addTransaction(fragmentCurrency.getSymbol()
+ , amount
+ , calendar.getTime()
+ , purchasedPrice
+ , fees
+ , note
+ , fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom());
+
+ preferenceManager.setMustUpdateSummary(true);
+ Intent intent = new Intent(getActivity(), HomeActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ startActivity(intent);
+ getActivity().finish();
+ }
+ }
+ });
+
+ fees_editText = view.findViewById(R.id.fees_editText);
+ note_editText = view.findViewById(R.id.note_editText);
+ }
+
+ private boolean isFieldCorrectlyFilled(TextInputEditText editText, boolean displayError)
+ {
+ String purchasedPriceText = editText.getText().toString();
+ double purchasedPrice;
+
+ try {
+ purchasedPrice = Double.parseDouble(purchasedPriceText);
+
+ if(purchasedPrice < 0)
+ {
+ if(displayError) editText.setError(getResources().getString(R.string.field_negative));
+
+ return false;
+ }
+ } catch (NumberFormatException e) {
+ if(displayError) editText.setError(getResources().getString(R.string.field_nan));
+
+ return false;
+ }
+
+ if(purchasedPriceText.equals(""))
+ {
+ if(displayError) editText.setError(getResources().getString(R.string.field_empty));
+
+ return false;
+ }
+
+ return true;
+ }
+
+ private void updateAdapter()
+ {
+ List symbolStrings = new ArrayList<>();
+ symbolStrings.addAll(PlaceholderManager.getFeeOptionsForSymbol(fragmentPair.getFrom(), getSecureContext()));
+ symbolStrings.addAll(PlaceholderManager.getFeeOptionsForSymbol(fragmentPair.getTo(), getSecureContext()));
+
+ currencyAdapter.clear();
+ currencyAdapter.addAll(symbolStrings);
+ currencyAdapter.notifyDataSetChanged();
+ }
+
+ private void createDatePicker()
+ {
+ DatePickerDialog datePickerDialog = new DatePickerDialog(
+ getContext(),
+ new DatePickerDialog.OnDateSetListener() {
+ @Override
+ public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
+ calendar.set(Calendar.YEAR, year);
+ calendar.set(Calendar.MONTH, month);
+ calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ buyDateEditText.setText(sdf.format(calendar.getTime()));
+ createTimePicker();
+ }
+ },
+ calendar.get(Calendar.YEAR),
+ calendar.get(Calendar.MONTH),
+ calendar.get(Calendar.DAY_OF_MONTH)
+ );
+
+ datePickerDialog.getDatePicker().setMaxDate(Calendar.getInstance().getTimeInMillis());
+ datePickerDialog.show();
+ }
+
+ private void createTimePicker()
+ {
+ new android.app.TimePickerDialog(
+ getContext(),
+ new android.app.TimePickerDialog.OnTimeSetListener() {
+ @Override
+ public void onTimeSet(TimePicker view, int hour, int minute) {
+ calendar.set(Calendar.HOUR_OF_DAY, hour);
+ calendar.set(Calendar.MINUTE, minute);
+ buyDateEditText.setText(sdf.format(calendar.getTime()));
+
+ if(fragmentCurrency != null)
+ {
+ fragmentCurrency.getTimestampPrice(getContext(), preferenceManager.getDefaultCurrency(),calendar.getTimeInMillis() / 1000);
+ }
+ }
+ },
+ calendar.get(Calendar.HOUR_OF_DAY),
+ calendar.get(Calendar.MINUTE),
+ true
+ ).show();
+ }
+
+ private static Context getSecureContext()
+ {
+ return context;
}
@Override
- public void onExchangesUpdated() {
-
+ public void onCurrencyUpdated() {
+ fragmentCurrency = currency;
}
+
+ @Override
+ public void onExchangeUpdated() {
+ fragmentExchange = exchange;
+ }
+
+ @Override
+ public void onPairUpdated() {
+ fragmentPair = pair;
+
+ fragmentCurrency.setOnTimestampPriceUpdatedListener(new Currency.OnTimestampPriceUpdatedListener() {
+ @Override
+ public void onTimeStampPriceUpdated(String price) {
+ ((TextInputEditText) view.findViewById(R.id.buyPrice_editText)).setText(price);
+
+ if(currencyAdapter != null)
+ {
+ updateAdapter();
+ }
+ }
+ });
+
+ if(preferenceManager == null)
+ {
+ preferenceManager = new PreferencesManager(getSecureContext());
+ }
+
+ if(calendar == null)
+ {
+ calendar = Calendar.getInstance();
+ }
+
+ fragmentCurrency.getTimestampPrice(getSecureContext(), preferenceManager.getDefaultCurrency(), calendar.getTimeInMillis() / 1000);
+ }
+
}
diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java
index fd3a83f..7faf575 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java
@@ -8,9 +8,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
import com.herbron.moodl.R;
-public class SellFragment extends Fragment {
+public class SellFragment extends CustomRecordFragment {
@Nullable
@Override
@@ -18,4 +19,19 @@ public class SellFragment extends Fragment {
View view = inflater.inflate(R.layout.fragment_sell, container, false);
return view;
}
+
+ @Override
+ public void onCurrencyUpdated() {
+
+ }
+
+ @Override
+ public void onExchangeUpdated() {
+
+ }
+
+ @Override
+ public void onPairUpdated() {
+
+ }
}
diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java
index 49f2b2b..42121ee 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java
@@ -8,9 +8,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
import com.herbron.moodl.R;
-public class TransferFragment extends Fragment {
+public class TransferFragment extends CustomRecordFragment {
@Nullable
@Override
@@ -18,4 +19,19 @@ public class TransferFragment extends Fragment {
View view = inflater.inflate(R.layout.fragment_transfer, container, false);
return view;
}
+
+ @Override
+ public void onCurrencyUpdated() {
+
+ }
+
+ @Override
+ public void onExchangeUpdated() {
+
+ }
+
+ @Override
+ public void onPairUpdated() {
+
+ }
}
diff --git a/app/src/main/java/com/herbron/moodl/CurrencyInfoUpdateNotifierInterface.java b/app/src/main/java/com/herbron/moodl/CurrencyInfoUpdateNotifierInterface.java
index b8731cb..b93b101 100644
--- a/app/src/main/java/com/herbron/moodl/CurrencyInfoUpdateNotifierInterface.java
+++ b/app/src/main/java/com/herbron/moodl/CurrencyInfoUpdateNotifierInterface.java
@@ -4,7 +4,7 @@ import com.herbron.moodl.DataManagers.CurrencyData.Currency;
public interface CurrencyInfoUpdateNotifierInterface {
- void onTimestampPriveUpdated(String price);
+ void onTimestampPriceUpdated(String price);
void onHistoryDataUpdated();
diff --git a/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomRecordFragment.java b/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomRecordFragment.java
new file mode 100644
index 0000000..f2f5b2b
--- /dev/null
+++ b/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomRecordFragment.java
@@ -0,0 +1,41 @@
+package com.herbron.moodl.CustomLayouts;
+
+import android.support.v4.app.Fragment;
+
+import com.herbron.moodl.DataManagers.CurrencyData.Currency;
+import com.herbron.moodl.DataManagers.ExchangeManager.Exchange;
+import com.herbron.moodl.DataManagers.InfoAPIManagers.Pair;
+
+public abstract class CustomRecordFragment extends Fragment {
+
+ protected Currency currency;
+ protected Exchange exchange;
+ protected Pair pair;
+
+ public void setCurrency(Currency currency)
+ {
+ this.currency = currency;
+
+ onCurrencyUpdated();
+ }
+
+ public void setExchange(Exchange exchange)
+ {
+ this.exchange = exchange;
+
+ onExchangeUpdated();
+ }
+
+ public void setPair(Pair pair)
+ {
+ this.pair = pair;
+
+ onPairUpdated();
+ }
+
+ public abstract void onCurrencyUpdated();
+
+ public abstract void onExchangeUpdated();
+
+ public abstract void onPairUpdated();
+}
diff --git a/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomTabLayout.java b/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomTabLayout.java
index ccb3965..df32836 100644
--- a/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomTabLayout.java
+++ b/app/src/main/java/com/herbron/moodl/CustomLayouts/CustomTabLayout.java
@@ -27,39 +27,44 @@ public class CustomTabLayout extends TabLayout {
private StateListDrawable getSellStateListDrawable() {
StateListDrawable sld = new StateListDrawable();
sld.addState(new int[] {android.R.attr.state_pressed},
- ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_sell));
+ ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
sld.addState(new int[] {android.R.attr.state_selected},
ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_sell));
- sld.addState(new int[] { },
+ sld.addState(new int[] {android.R.attr.state_enabled },
ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
+ sld.addState(new int[] { },
+ ContextCompat.getDrawable(context, R.drawable.disabled_tab_background));
return sld;
}
private StateListDrawable getBuyStateListDrawable() {
StateListDrawable sld = new StateListDrawable();
sld.addState(new int[] {android.R.attr.state_pressed},
- ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_buy));
+ ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
sld.addState(new int[] {android.R.attr.state_selected},
ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_buy));
- sld.addState(new int[] { },
+ sld.addState(new int[] {android.R.attr.state_enabled },
ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
+ sld.addState(new int[] { },
+ ContextCompat.getDrawable(context, R.drawable.disabled_tab_background));
return sld;
}
private StateListDrawable getTransferStateListDrawable() {
StateListDrawable sld = new StateListDrawable();
sld.addState(new int[] {android.R.attr.state_pressed},
- ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_transfer));
+ ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
sld.addState(new int[] {android.R.attr.state_selected},
ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_transfer));
- sld.addState(new int[] { },
+ sld.addState(new int[] {android.R.attr.state_enabled },
ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
+ sld.addState(new int[] { },
+ ContextCompat.getDrawable(context, R.drawable.disabled_tab_background));
return sld;
}
public void addTab(int index, String label) {
TextView textView = new TextView(context);
- textView.setTextColor(getResources().getColor(R.color.white));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setText(label);
textView.setGravity(GRAVITY_CENTER);
diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/Currency.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/Currency.java
index 5371bd9..e9e855d 100644
--- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/Currency.java
+++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/Currency.java
@@ -4,13 +4,9 @@ import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
-import android.util.Log;
import com.herbron.moodl.CurrencyInfoUpdateNotifierInterface;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@@ -48,6 +44,7 @@ public class Currency implements Parcelable {
private int rank;
private String startDate;
private List socialMediaLinks;
+ private OnTimestampPriceUpdatedListener onTimestampPriceUpdatedListener;
//private String proofType
private CurrencyInfoUpdateNotifierInterface currencyInfoUpdateNotifierInterface;
@@ -97,7 +94,12 @@ public class Currency implements Parcelable {
@Override
public void onSuccess(String price) {
- currencyInfoUpdateNotifierInterface.onTimestampPriveUpdated(price);
+ currencyInfoUpdateNotifierInterface.onTimestampPriceUpdated(price);
+
+ if(onTimestampPriceUpdatedListener != null)
+ {
+ onTimestampPriceUpdatedListener.onTimeStampPriceUpdated(price);
+ }
}
}, timestamp);
}
@@ -534,4 +536,14 @@ public class Currency implements Parcelable {
return new Currency[size];
}
};
+
+ public interface OnTimestampPriceUpdatedListener
+ {
+ void onTimeStampPriceUpdated(String price);
+ }
+
+ public void setOnTimestampPriceUpdatedListener(OnTimestampPriceUpdatedListener onTimestampPriceUpdatedListener)
+ {
+ this.onTimestampPriceUpdatedListener = onTimestampPriceUpdatedListener;
+ }
}
diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java
index 1c44eeb..8e9333d 100644
--- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java
+++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java
@@ -357,7 +357,7 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti
}
@Override
- public void onTimestampPriveUpdated(String price) {
+ public void onTimestampPriceUpdated(String price) {
}
diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java
index a6b5297..988a3c5 100644
--- a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java
+++ b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java
@@ -19,6 +19,7 @@ import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -29,7 +30,7 @@ import java.util.List;
public class DatabaseManager extends SQLiteOpenHelper{
- private static final int DATABASE_VERSION = 10;
+ private static final int DATABASE_VERSION = 13;
private static final String DATABASE_NAME = "Currencies.db";
@@ -39,8 +40,9 @@ public class DatabaseManager extends SQLiteOpenHelper{
private static final String KEY_CURRENCY_ID = "idCurrency";
private static final String KEY_CURRENCY_SYMBOL = "symbol";
- private static final String KEY_CURRENCY_NAME = "name";
+ private static final String KEY_CURRENCY_NOTES = "notes";
private static final String KEY_CURRENCY_BALANCE = "balance";
+ private static final String KEY_CURRENCY_FROM = "symFrom";
private static final String KEY_CURRENCY_DATE = "addDate";
private static final String KEY_CURRENCY_PURCHASED_PRICE = "purchasedPrice";
private static final String KEY_CURRENCY_IS_MINED = "isMined";
@@ -73,12 +75,13 @@ public class DatabaseManager extends SQLiteOpenHelper{
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_MANUAL_CURRENCIES + "("
+ KEY_CURRENCY_ID + " INTEGER PRIMARY KEY,"
+ KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
- + KEY_CURRENCY_NAME + " VARCHAR(45),"
+ KEY_CURRENCY_BALANCE + " TEXT,"
+ KEY_CURRENCY_DATE + " TEXT,"
+ KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
+ KEY_CURRENCY_IS_MINED + " INTEGER,"
- + KEY_CURRENCY_FEES + " REAL"
+ + KEY_CURRENCY_FEES + " REAL,"
+ + KEY_CURRENCY_NOTES + " TEXT,"
+ + KEY_CURRENCY_FROM + " VARCHAR(4)"
+ ");");
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_EXCHANGE_KEYS + "("
@@ -118,6 +121,44 @@ public class DatabaseManager extends SQLiteOpenHelper{
case 9:
db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS
+ " ADD " + KEY_EXCHANGE_IS_ENABLED + " INTEGER");
+ case 10:
+ db.execSQL("CREATE TEMPORARY TABLE " + TABLE_MANUAL_CURRENCIES + "_back("
+ + KEY_CURRENCY_ID + " INTEGER PRIMARY KEY,"
+ + KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
+ + KEY_CURRENCY_BALANCE + " TEXT,"
+ + KEY_CURRENCY_DATE + " TEXT,"
+ + KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
+ + KEY_CURRENCY_IS_MINED + " INTEGER,"
+ + KEY_CURRENCY_FEES + " REAL"
+ + ");");
+ db.execSQL("INSERT INTO " + TABLE_MANUAL_CURRENCIES + "_back SELECT "
+ + KEY_CURRENCY_ID + ","
+ + KEY_CURRENCY_SYMBOL + ","
+ + KEY_CURRENCY_BALANCE + ","
+ + KEY_CURRENCY_DATE + ","
+ + KEY_CURRENCY_PURCHASED_PRICE + ","
+ + KEY_CURRENCY_IS_MINED + ","
+ + KEY_CURRENCY_FEES + " FROM " + TABLE_MANUAL_CURRENCIES);
+ db.execSQL("DROP TABLE " + TABLE_MANUAL_CURRENCIES);
+ db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_MANUAL_CURRENCIES + "("
+ + KEY_CURRENCY_ID + " INTEGER PRIMARY KEY,"
+ + KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
+ + KEY_CURRENCY_BALANCE + " TEXT,"
+ + KEY_CURRENCY_DATE + " TEXT,"
+ + KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
+ + KEY_CURRENCY_IS_MINED + " INTEGER,"
+ + KEY_CURRENCY_FEES + " REAL"
+ + ");");
+ db.execSQL("INSERT INTO " + TABLE_MANUAL_CURRENCIES + " SELECT * FROM " + TABLE_MANUAL_CURRENCIES + "_back");
+ db.execSQL("DROP TABLE " + TABLE_MANUAL_CURRENCIES + "_back");
+ case 11:
+ db.execSQL("ALTER TABLE " + TABLE_MANUAL_CURRENCIES
+ + " ADD " + KEY_CURRENCY_NOTES + " TEXT");
+ case 12:
+ db.execSQL("ALTER TABLE " + TABLE_MANUAL_CURRENCIES
+ + " ADD " + KEY_CURRENCY_FROM + " VARCHAR(4)");
+ db.execSQL("UPDATE " + TABLE_MANUAL_CURRENCIES
+ + " SET " + KEY_CURRENCY_FROM + "= 'USD'");
}
}
@@ -152,6 +193,23 @@ public class DatabaseManager extends SQLiteOpenHelper{
return false;
}
+ public void addTransaction(String symbol, Double amount, Date date, Double purchasedPrice, Double fees, String note, String symbolFrom)
+ {
+ SQLiteDatabase db = this.getWritableDatabase();
+ ContentValues values = new ContentValues();
+
+ values.put(KEY_CURRENCY_SYMBOL, symbol);
+ values.put(KEY_CURRENCY_BALANCE, amount);
+ values.put(KEY_CURRENCY_DATE, date.getTime());
+ values.put(KEY_CURRENCY_PURCHASED_PRICE, purchasedPrice);
+ values.put(KEY_CURRENCY_FEES, fees);
+ values.put(KEY_CURRENCY_NOTES, note);
+ values.put(KEY_CURRENCY_FROM, symbolFrom);
+
+ db.insert(TABLE_MANUAL_CURRENCIES, null, values);
+ db.close();
+ }
+
public void updateWatchlistPosition(String symbol, int position)
{
SQLiteDatabase db = this.getWritableDatabase();
@@ -397,7 +455,6 @@ public class DatabaseManager extends SQLiteOpenHelper{
if(decrypt)
{
values.put(KEY_CURRENCY_SYMBOL, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_SYMBOL)));
- values.put(KEY_CURRENCY_NAME, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_NAME)));
values.put(KEY_CURRENCY_BALANCE, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_BALANCE)));
values.put(KEY_CURRENCY_DATE, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_DATE)));
values.put(KEY_CURRENCY_PURCHASED_PRICE, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_PURCHASED_PRICE)));
@@ -407,7 +464,6 @@ public class DatabaseManager extends SQLiteOpenHelper{
else
{
values.put(KEY_CURRENCY_SYMBOL, rawValues.getString(KEY_CURRENCY_SYMBOL));
- values.put(KEY_CURRENCY_NAME, rawValues.getString(KEY_CURRENCY_NAME));
values.put(KEY_CURRENCY_BALANCE, rawValues.getString(KEY_CURRENCY_BALANCE));
values.put(KEY_CURRENCY_DATE, rawValues.getString(KEY_CURRENCY_DATE));
values.put(KEY_CURRENCY_PURCHASED_PRICE, rawValues.getString(KEY_CURRENCY_PURCHASED_PRICE));
@@ -497,7 +553,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
while(resultatList.moveToNext())
{
- currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3) - resultatList.getDouble(7)));
+ currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(2) - resultatList.getDouble(6)));
}
resultatList.close();
@@ -551,7 +607,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
while (resultatList.moveToNext())
{
- transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(3), resultatList.getLong(4), resultatList.getLong(5), resultatList.getDouble(7)));
+ transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(2), resultatList.getLong(3), resultatList.getLong(4), resultatList.getDouble(6)));
}
resultatList.close();
diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java
index 5ecd3a6..f33d9bb 100644
--- a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java
+++ b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java
@@ -68,7 +68,7 @@ public class BinanceManager extends Exchange {
if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0)
{
//balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
- if(!assets.get(i).getAsset().equals("VET"))
+ if(!assets.get(i).getAsset().equals("VEN"))
{
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
}
diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/PreferencesManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/PreferencesManager.java
index 4110957..65aeca6 100644
--- a/app/src/main/java/com/herbron/moodl/DataManagers/PreferencesManager.java
+++ b/app/src/main/java/com/herbron/moodl/DataManagers/PreferencesManager.java
@@ -38,31 +38,6 @@ public class PreferencesManager {
return settingPreferences.getString("default_currency", "USD");
}
- public String getHitBTCPublicKey()
- {
- return settingPreferences.getString("hitbtc_publickey", null);
- }
-
- public String getHitBTCPrivateKey()
- {
- return settingPreferences.getString("hitbtc_privatekey", null);
- }
-
- public String getBinancePublicKey()
- {
- return settingPreferences.getString("binance_publickey", null);
- }
-
- public String getBinancePrivateKey()
- {
- return settingPreferences.getString("binance_privatekey", null);
- }
-
- public boolean isHitBTCActivated()
- {
- return settingPreferences.getBoolean("enable_hitbtc", false);
- }
-
public boolean switchBalanceHiddenState()
{
SharedPreferences.Editor editor = settingPreferences.edit();
diff --git a/app/src/main/java/com/herbron/moodl/PlaceholderManager.java b/app/src/main/java/com/herbron/moodl/PlaceholderManager.java
index 8a2bd9a..b3ad52a 100644
--- a/app/src/main/java/com/herbron/moodl/PlaceholderManager.java
+++ b/app/src/main/java/com/herbron/moodl/PlaceholderManager.java
@@ -4,6 +4,9 @@ import android.content.Context;
import com.herbron.moodl.DataManagers.PreferencesManager;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Created by Tiji on 19/04/2018.
*/
@@ -34,6 +37,16 @@ public class PlaceholderManager {
return formattedString;
}
+ public static List getFeeOptionsForSymbol(String symbol, Context context)
+ {
+ List options = new ArrayList<>();
+
+ options.add(context.getResources().getString(R.string.fixedFee, symbol));
+ options.add(context.getResources().getString(R.string.percentageFee, symbol));
+
+ return options;
+ }
+
public static String getPairString(String pair1, String pair2, Context context)
{
return context.getResources().getString(R.string.pairPlaceholder, pair1, pair2);
diff --git a/app/src/main/res/anim/dismiss.xml b/app/src/main/res/anim/dismiss.xml
new file mode 100644
index 0000000..2eb244c
--- /dev/null
+++ b/app/src/main/res/anim/dismiss.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/reveal.xml b/app/src/main/res/anim/reveal.xml
new file mode 100644
index 0000000..c7eba3c
--- /dev/null
+++ b/app/src/main/res/anim/reveal.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/disabled_tab_background.xml b/app/src/main/res/drawable/disabled_tab_background.xml
new file mode 100644
index 0000000..ce071fd
--- /dev/null
+++ b/app/src/main/res/drawable/disabled_tab_background.xml
@@ -0,0 +1,17 @@
+
+
+ -
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml b/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml
new file mode 100644
index 0000000..1d266ce
--- /dev/null
+++ b/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/record_transaction_tab_background_buy.xml b/app/src/main/res/drawable/record_transaction_tab_background_buy.xml
index d703b75..e7e477b 100644
--- a/app/src/main/res/drawable/record_transaction_tab_background_buy.xml
+++ b/app/src/main/res/drawable/record_transaction_tab_background_buy.xml
@@ -1,18 +1,17 @@
-
- -
-
-
-
-
-
+
+-
+
+
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/app/src/main/res/drawable/record_transaction_tab_background_sell.xml b/app/src/main/res/drawable/record_transaction_tab_background_sell.xml
index 4c8dcf2..51acf4c 100644
--- a/app/src/main/res/drawable/record_transaction_tab_background_sell.xml
+++ b/app/src/main/res/drawable/record_transaction_tab_background_sell.xml
@@ -1,18 +1,17 @@
-
- -
-
-
-
-
-
+
+-
+
+
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml b/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml
index 344c1d1..0d00149 100644
--- a/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml
+++ b/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml
@@ -1,18 +1,17 @@
-
- -
-
-
-
-
-
+
+-
+
+
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_record_transaction.xml b/app/src/main/res/layout/activity_record_transaction.xml
index 716091c..f96a74e 100644
--- a/app/src/main/res/layout/activity_record_transaction.xml
+++ b/app/src/main/res/layout/activity_record_transaction.xml
@@ -111,11 +111,13 @@
+ android:orientation="vertical"
+ android:visibility="invisible">
@@ -26,7 +27,8 @@
+ android:orientation="horizontal"
+ android:baselineAligned="false">
@@ -68,6 +71,7 @@
android:id="@+id/totalValue_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:inputType="numberDecimal"
android:hint="@string/total_value"/>
@@ -81,21 +85,22 @@
android:id="@+id/input_fees"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="0.15">
+ android:layout_weight="0.7">
+ android:layout_weight="1"/>
@@ -116,7 +121,7 @@
+ android:text="@string/total_portfolio_value"/>
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_record_action.xml b/app/src/main/res/menu/menu_record_action.xml
deleted file mode 100644
index ba39a95..0000000
--- a/app/src/main/res/menu/menu_record_action.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 0bf9c38..5cca29f 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -153,4 +153,8 @@
Notes
Sélectionner un échange
Paire
+ Valeur totale :
+
+ Pourcentage de %1$s
+ %1$s fixe
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 64266be..2423a18 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -268,5 +268,9 @@
Notes
Select an exchange
Pair
+ Total portfolio value :
+
+ %1$s percentage
+ %1$s fixed
diff --git a/build.gradle b/build.gradle
index 6c02a11..04c6bc4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.3'
+ classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong