Major updates
- Fix code typos - Add a 'fromSym' field in the transactions table - Fix translation in the drawer [RecordTransactionActivity rework] - New currency selection - Add Exchange selection - Add corresponding Pair selection - Add tabs to select Buy/Sell/Transaction > Buy fragment - Add note field - Add fee format selection - Limit date selection to the past (it's no longer possible to add a futur transaction) - Auto fill the price after date selection
This commit is contained in:
parent
7b5fd6e786
commit
3a1ac3c80b
4
.idea/assetWizardSettings.xml
generated
4
.idea/assetWizardSettings.xml
generated
@ -23,7 +23,7 @@
|
|||||||
<PersistentState>
|
<PersistentState>
|
||||||
<option name="values">
|
<option name="values">
|
||||||
<map>
|
<map>
|
||||||
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/alert/ic_error_black_24dp.xml" />
|
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/navigation/ic_arrow_drop_up_black_24dp.xml" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</PersistentState>
|
</PersistentState>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
<option name="values">
|
<option name="values">
|
||||||
<map>
|
<map>
|
||||||
<entry key="color" value="ffffff" />
|
<entry key="color" value="ffffff" />
|
||||||
<entry key="outputName" value="ic_error_24dp" />
|
<entry key="outputName" value="ic_arrow_drop_up_white_24dp" />
|
||||||
<entry key="sourceFile" value="C:\Users\Guitoune" />
|
<entry key="sourceFile" value="C:\Users\Guitoune" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
|
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -56,7 +56,7 @@ dependencies {
|
|||||||
implementation 'org.apache.commons:commons-lang3:3.6'
|
implementation 'org.apache.commons:commons-lang3:3.6'
|
||||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||||
implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
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.jmedeisis:draglinearlayout:1.1.0'
|
||||||
implementation 'com.applandeo:material-file-picker:1.0.0'
|
implementation 'com.applandeo:material-file-picker:1.0.0'
|
||||||
implementation 'com.daasuu:EasingInterpolator:1.0.0'
|
implementation 'com.daasuu:EasingInterpolator:1.0.0'
|
||||||
|
@ -616,7 +616,7 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimestampPriveUpdated(String price) {
|
public void onTimestampPriceUpdated(String price) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
|
|||||||
{
|
{
|
||||||
balance.get(i).updatePrice(getActivity(), defaultCurrency, new CurrencyInfoUpdateNotifierInterface() {
|
balance.get(i).updatePrice(getActivity(), defaultCurrency, new CurrencyInfoUpdateNotifierInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void onTimestampPriveUpdated(String price) {
|
public void onTimestampPriceUpdated(String price) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
|
|||||||
currency.setId(getCurrencyId(currency.getSymbol()));
|
currency.setId(getCurrencyId(currency.getSymbol()));
|
||||||
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new CurrencyInfoUpdateNotifierInterface() {
|
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new CurrencyInfoUpdateNotifierInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void onTimestampPriveUpdated(String price) {
|
public void onTimestampPriceUpdated(String price) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,12 @@ package com.herbron.moodl.Activities;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.opengl.Visibility;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
@ -15,6 +17,9 @@ import android.text.Editable;
|
|||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
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.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
@ -23,11 +28,13 @@ import android.widget.DatePicker;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
import com.herbron.moodl.CurrencyInfoUpdateNotifierInterface;
|
import com.herbron.moodl.CurrencyInfoUpdateNotifierInterface;
|
||||||
import com.herbron.moodl.CustomAdapters.PairRecordListAdapter;
|
import com.herbron.moodl.CustomAdapters.PairRecordListAdapter;
|
||||||
|
import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
|
||||||
import com.herbron.moodl.DataManagers.CurrencyData.Currency;
|
import com.herbron.moodl.DataManagers.CurrencyData.Currency;
|
||||||
import com.herbron.moodl.DataManagers.ExchangeManager.Exchange;
|
import com.herbron.moodl.DataManagers.ExchangeManager.Exchange;
|
||||||
import com.herbron.moodl.DataManagers.InfoAPIManagers.CryptocompareApiManager;
|
import com.herbron.moodl.DataManagers.InfoAPIManagers.CryptocompareApiManager;
|
||||||
@ -47,27 +54,11 @@ import com.herbron.moodl.R;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class RecordTransactionActivity extends AppCompatActivity implements CurrencyInfoUpdateNotifierInterface, CryptocompareNotifierInterface {
|
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 Toolbar toolbar;
|
||||||
private ImageView currencyIconImageView;
|
private ImageView currencyIconImageView;
|
||||||
|
|
||||||
@ -81,51 +72,19 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
private AutoCompleteTextView exchange_autoCompleteTextView;
|
private AutoCompleteTextView exchange_autoCompleteTextView;
|
||||||
private AutoCompleteTextView pair_autoCompleteTextView;
|
private AutoCompleteTextView pair_autoCompleteTextView;
|
||||||
|
|
||||||
private SearchView mainSearchView;
|
private CustomTabLayout tabLayout;
|
||||||
|
private ViewPager viewPager;
|
||||||
|
|
||||||
/*@Override
|
private RecordTransactionPageAdapter pageAdapter;
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_record:
|
|
||||||
|
|
||||||
if(checkAmountText() && checkPriceText())
|
private Animation revealAnimation;
|
||||||
{
|
private Animation dismissAnimation;
|
||||||
double amount = Double.parseDouble(amountTxtView.getText().toString());
|
|
||||||
double purchasedPrice = Double.parseDouble(purchasedPriceEditText.getText().toString());
|
|
||||||
double fees = Double.parseDouble(feesTxtView.getText().toString());
|
|
||||||
|
|
||||||
if(!sellButton.isEnabled())
|
private LinearLayout globalTabLayouts;
|
||||||
{
|
|
||||||
amount *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(transactionId != -1)
|
private boolean isGlobalLayoutVisible;
|
||||||
{
|
|
||||||
databaseManager.updateTransactionWithId(transactionId, amount, calendar.getTime(), purchasedPrice, fees);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
databaseManager.addCurrencyToManualCurrency(symbol, amount, calendar.getTime(), purchasedPrice, fees);
|
|
||||||
}
|
|
||||||
|
|
||||||
preferenceManager.setMustUpdateSummary(true);
|
/*private boolean checkPriceText()
|
||||||
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()
|
|
||||||
{
|
{
|
||||||
String purchasedPriceText = purchasedPriceEditText.getText().toString();
|
String purchasedPriceText = purchasedPriceEditText.getText().toString();
|
||||||
double purchasedPrice;
|
double purchasedPrice;
|
||||||
@ -173,27 +132,13 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_record_transaction);
|
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);
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
|
||||||
currencyIconImageView = findViewById(R.id.currencyIconImageView);
|
currencyIconImageView = findViewById(R.id.currencyIconImageView);
|
||||||
@ -220,16 +165,23 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
setupBackButton();
|
setupBackButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Currency getCurrency()
|
||||||
|
{
|
||||||
|
return currency;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupTabLayout()
|
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(0, "Buy");
|
||||||
tabLayout.addTab(1, "Sell");
|
tabLayout.addTab(1, "Sell");
|
||||||
//tabLayout.addTab(2, "Transfer");
|
tabLayout.addTab(2, "Transfer");
|
||||||
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
||||||
|
|
||||||
final ViewPager viewPager = findViewById(R.id.transactionsViewPager);
|
viewPager = findViewById(R.id.transactionsViewPager);
|
||||||
final RecordTransactionPageAdapter pageAdapter = new RecordTransactionPageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
|
pageAdapter = new RecordTransactionPageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
|
||||||
viewPager.setAdapter(pageAdapter);
|
viewPager.setAdapter(pageAdapter);
|
||||||
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||||
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
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()
|
private void setupPairAutoCompleteTextView()
|
||||||
@ -255,6 +234,27 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
pair_autoCompleteTextView.setThreshold(0);
|
pair_autoCompleteTextView.setThreshold(0);
|
||||||
pair_autoCompleteTextView.setTextColor(getResources().getColor(R.color.white));
|
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() {
|
pair_autoCompleteTextView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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()));
|
pair_autoCompleteTextView.setText(PlaceholderManager.getPairString(pair.getFrom(), pair.getTo(), getBaseContext()));
|
||||||
toolbar.requestFocus();
|
toolbar.requestFocus();
|
||||||
hideSoftKeyboard(RecordTransactionActivity.this);
|
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) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
pair_autoCompleteTextView.setEnabled(false);
|
pair_autoCompleteTextView.setEnabled(false);
|
||||||
pair_autoCompleteTextView.setText("");
|
pair_autoCompleteTextView.setText("");
|
||||||
|
|
||||||
|
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
|
||||||
|
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
|
||||||
|
tabLayout.getTabAt(2).select();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -343,6 +353,8 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
|
|
||||||
updatePairAdapter();
|
updatePairAdapter();
|
||||||
pair_autoCompleteTextView.setEnabled(true);
|
pair_autoCompleteTextView.setEnabled(true);
|
||||||
|
|
||||||
|
updateExchangeData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -363,7 +375,7 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
|
|
||||||
private void setupCoinAutoCompleteTextView()
|
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.setThreshold(0);
|
||||||
coin_autoCompleteTextView.setAdapter(adapter);
|
coin_autoCompleteTextView.setAdapter(adapter);
|
||||||
@ -379,6 +391,13 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
currencyIconImageView.setImageBitmap(null);
|
currencyIconImageView.setImageBitmap(null);
|
||||||
exchange_autoCompleteTextView.setEnabled(false);
|
exchange_autoCompleteTextView.setEnabled(false);
|
||||||
exchange_autoCompleteTextView.setText("");
|
exchange_autoCompleteTextView.setText("");
|
||||||
|
|
||||||
|
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(2).setEnabled(false);
|
||||||
|
|
||||||
|
if(isGlobalLayoutVisible && globalTabLayouts.getAnimation().hasEnded())
|
||||||
|
{
|
||||||
|
globalTabLayouts.startAnimation(dismissAnimation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -424,13 +443,53 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
|
|
||||||
IconDownloaderTask iconDownloaderTask = new IconDownloaderTask();
|
IconDownloaderTask iconDownloaderTask = new IconDownloaderTask();
|
||||||
iconDownloaderTask.execute();
|
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
|
@Override
|
||||||
public void onTimestampPriveUpdated(String price) {
|
public void onTimestampPriceUpdated(String price) {
|
||||||
purchasedPriceEditText.setText(price);
|
//purchasedPriceEditText.setText(price);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -543,54 +602,6 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
|
|||||||
activity.getCurrentFocus().getWindowToken(), 0);
|
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()
|
private void setupBackButton()
|
||||||
{
|
{
|
||||||
ImageButton backButton = findViewById(R.id.back_button);
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,312 @@
|
|||||||
package com.herbron.moodl.Activities.RecordTransactionFragments;
|
package com.herbron.moodl.Activities.RecordTransactionFragments;
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
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.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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.Activities.HomeActivity;
|
||||||
import com.herbron.moodl.DataManagers.InfoAPIManagers.CryptocompareApiManager;
|
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;
|
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<String> 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
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeViewElements()
|
||||||
|
{
|
||||||
|
totalValueEditText = view.findViewById(R.id.totalValue_editText);
|
||||||
|
amoutEditText = view.findViewById(R.id.amount_editText);
|
||||||
|
amoutEditText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetailsUpdated() {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExchangesUpdated() {
|
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<String>(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<String> 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 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,10 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
|
||||||
import com.herbron.moodl.R;
|
import com.herbron.moodl.R;
|
||||||
|
|
||||||
public class SellFragment extends Fragment {
|
public class SellFragment extends CustomRecordFragment {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -18,4 +19,19 @@ public class SellFragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_sell, container, false);
|
View view = inflater.inflate(R.layout.fragment_sell, container, false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCurrencyUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExchangeUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPairUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,10 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
|
||||||
import com.herbron.moodl.R;
|
import com.herbron.moodl.R;
|
||||||
|
|
||||||
public class TransferFragment extends Fragment {
|
public class TransferFragment extends CustomRecordFragment {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -18,4 +19,19 @@ public class TransferFragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_transfer, container, false);
|
View view = inflater.inflate(R.layout.fragment_transfer, container, false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCurrencyUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExchangeUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPairUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.herbron.moodl.DataManagers.CurrencyData.Currency;
|
|||||||
|
|
||||||
public interface CurrencyInfoUpdateNotifierInterface {
|
public interface CurrencyInfoUpdateNotifierInterface {
|
||||||
|
|
||||||
void onTimestampPriveUpdated(String price);
|
void onTimestampPriceUpdated(String price);
|
||||||
|
|
||||||
void onHistoryDataUpdated();
|
void onHistoryDataUpdated();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
}
|
@ -27,39 +27,44 @@ public class CustomTabLayout extends TabLayout {
|
|||||||
private StateListDrawable getSellStateListDrawable() {
|
private StateListDrawable getSellStateListDrawable() {
|
||||||
StateListDrawable sld = new StateListDrawable();
|
StateListDrawable sld = new StateListDrawable();
|
||||||
sld.addState(new int[] {android.R.attr.state_pressed},
|
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},
|
sld.addState(new int[] {android.R.attr.state_selected},
|
||||||
ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_sell));
|
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));
|
ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
|
||||||
|
sld.addState(new int[] { },
|
||||||
|
ContextCompat.getDrawable(context, R.drawable.disabled_tab_background));
|
||||||
return sld;
|
return sld;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StateListDrawable getBuyStateListDrawable() {
|
private StateListDrawable getBuyStateListDrawable() {
|
||||||
StateListDrawable sld = new StateListDrawable();
|
StateListDrawable sld = new StateListDrawable();
|
||||||
sld.addState(new int[] {android.R.attr.state_pressed},
|
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},
|
sld.addState(new int[] {android.R.attr.state_selected},
|
||||||
ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_buy));
|
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));
|
ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
|
||||||
|
sld.addState(new int[] { },
|
||||||
|
ContextCompat.getDrawable(context, R.drawable.disabled_tab_background));
|
||||||
return sld;
|
return sld;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StateListDrawable getTransferStateListDrawable() {
|
private StateListDrawable getTransferStateListDrawable() {
|
||||||
StateListDrawable sld = new StateListDrawable();
|
StateListDrawable sld = new StateListDrawable();
|
||||||
sld.addState(new int[] {android.R.attr.state_pressed},
|
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},
|
sld.addState(new int[] {android.R.attr.state_selected},
|
||||||
ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_transfer));
|
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));
|
ContextCompat.getDrawable(context, R.drawable.unselected_tab_background));
|
||||||
|
sld.addState(new int[] { },
|
||||||
|
ContextCompat.getDrawable(context, R.drawable.disabled_tab_background));
|
||||||
return sld;
|
return sld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTab(int index, String label) {
|
public void addTab(int index, String label) {
|
||||||
TextView textView = new TextView(context);
|
TextView textView = new TextView(context);
|
||||||
textView.setTextColor(getResources().getColor(R.color.white));
|
|
||||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||||
textView.setText(label);
|
textView.setText(label);
|
||||||
textView.setGravity(GRAVITY_CENTER);
|
textView.setGravity(GRAVITY_CENTER);
|
||||||
|
@ -4,13 +4,9 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.herbron.moodl.CurrencyInfoUpdateNotifierInterface;
|
import com.herbron.moodl.CurrencyInfoUpdateNotifierInterface;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,6 +44,7 @@ public class Currency implements Parcelable {
|
|||||||
private int rank;
|
private int rank;
|
||||||
private String startDate;
|
private String startDate;
|
||||||
private List<String> socialMediaLinks;
|
private List<String> socialMediaLinks;
|
||||||
|
private OnTimestampPriceUpdatedListener onTimestampPriceUpdatedListener;
|
||||||
//private String proofType
|
//private String proofType
|
||||||
|
|
||||||
private CurrencyInfoUpdateNotifierInterface currencyInfoUpdateNotifierInterface;
|
private CurrencyInfoUpdateNotifierInterface currencyInfoUpdateNotifierInterface;
|
||||||
@ -97,7 +94,12 @@ public class Currency implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String price) {
|
public void onSuccess(String price) {
|
||||||
currencyInfoUpdateNotifierInterface.onTimestampPriveUpdated(price);
|
currencyInfoUpdateNotifierInterface.onTimestampPriceUpdated(price);
|
||||||
|
|
||||||
|
if(onTimestampPriceUpdatedListener != null)
|
||||||
|
{
|
||||||
|
onTimestampPriceUpdatedListener.onTimeStampPriceUpdated(price);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, timestamp);
|
}, timestamp);
|
||||||
}
|
}
|
||||||
@ -534,4 +536,14 @@ public class Currency implements Parcelable {
|
|||||||
return new Currency[size];
|
return new Currency[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public interface OnTimestampPriceUpdatedListener
|
||||||
|
{
|
||||||
|
void onTimeStampPriceUpdated(String price);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnTimestampPriceUpdatedListener(OnTimestampPriceUpdatedListener onTimestampPriceUpdatedListener)
|
||||||
|
{
|
||||||
|
this.onTimestampPriceUpdatedListener = onTimestampPriceUpdatedListener;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimestampPriveUpdated(String price) {
|
public void onTimestampPriceUpdated(String price) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -29,7 +30,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DatabaseManager extends SQLiteOpenHelper{
|
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";
|
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_ID = "idCurrency";
|
||||||
private static final String KEY_CURRENCY_SYMBOL = "symbol";
|
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_BALANCE = "balance";
|
||||||
|
private static final String KEY_CURRENCY_FROM = "symFrom";
|
||||||
private static final String KEY_CURRENCY_DATE = "addDate";
|
private static final String KEY_CURRENCY_DATE = "addDate";
|
||||||
private static final String KEY_CURRENCY_PURCHASED_PRICE = "purchasedPrice";
|
private static final String KEY_CURRENCY_PURCHASED_PRICE = "purchasedPrice";
|
||||||
private static final String KEY_CURRENCY_IS_MINED = "isMined";
|
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 + "("
|
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_MANUAL_CURRENCIES + "("
|
||||||
+ KEY_CURRENCY_ID + " INTEGER PRIMARY KEY,"
|
+ KEY_CURRENCY_ID + " INTEGER PRIMARY KEY,"
|
||||||
+ KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
|
+ KEY_CURRENCY_SYMBOL + " VARCHAR(4),"
|
||||||
+ KEY_CURRENCY_NAME + " VARCHAR(45),"
|
|
||||||
+ KEY_CURRENCY_BALANCE + " TEXT,"
|
+ KEY_CURRENCY_BALANCE + " TEXT,"
|
||||||
+ KEY_CURRENCY_DATE + " TEXT,"
|
+ KEY_CURRENCY_DATE + " TEXT,"
|
||||||
+ KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
|
+ KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
|
||||||
+ KEY_CURRENCY_IS_MINED + " INTEGER,"
|
+ 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 + "("
|
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_EXCHANGE_KEYS + "("
|
||||||
@ -118,6 +121,44 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
case 9:
|
case 9:
|
||||||
db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS
|
db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS
|
||||||
+ " ADD " + KEY_EXCHANGE_IS_ENABLED + " INTEGER");
|
+ " 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;
|
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)
|
public void updateWatchlistPosition(String symbol, int position)
|
||||||
{
|
{
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
@ -397,7 +455,6 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
if(decrypt)
|
if(decrypt)
|
||||||
{
|
{
|
||||||
values.put(KEY_CURRENCY_SYMBOL, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_SYMBOL)));
|
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_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_DATE, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_DATE)));
|
||||||
values.put(KEY_CURRENCY_PURCHASED_PRICE, DataCrypter.decrypt(context, rawValues.getString(KEY_CURRENCY_PURCHASED_PRICE)));
|
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
|
else
|
||||||
{
|
{
|
||||||
values.put(KEY_CURRENCY_SYMBOL, rawValues.getString(KEY_CURRENCY_SYMBOL));
|
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_BALANCE, rawValues.getString(KEY_CURRENCY_BALANCE));
|
||||||
values.put(KEY_CURRENCY_DATE, rawValues.getString(KEY_CURRENCY_DATE));
|
values.put(KEY_CURRENCY_DATE, rawValues.getString(KEY_CURRENCY_DATE));
|
||||||
values.put(KEY_CURRENCY_PURCHASED_PRICE, rawValues.getString(KEY_CURRENCY_PURCHASED_PRICE));
|
values.put(KEY_CURRENCY_PURCHASED_PRICE, rawValues.getString(KEY_CURRENCY_PURCHASED_PRICE));
|
||||||
@ -497,7 +553,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
|
|
||||||
while(resultatList.moveToNext())
|
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();
|
resultatList.close();
|
||||||
@ -551,7 +607,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
|
|
||||||
while (resultatList.moveToNext())
|
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();
|
resultatList.close();
|
||||||
|
@ -68,7 +68,7 @@ public class BinanceManager extends Exchange {
|
|||||||
if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0)
|
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())));
|
//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())));
|
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
|
||||||
}
|
}
|
||||||
|
@ -38,31 +38,6 @@ public class PreferencesManager {
|
|||||||
return settingPreferences.getString("default_currency", "USD");
|
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()
|
public boolean switchBalanceHiddenState()
|
||||||
{
|
{
|
||||||
SharedPreferences.Editor editor = settingPreferences.edit();
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
|
@ -4,6 +4,9 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.herbron.moodl.DataManagers.PreferencesManager;
|
import com.herbron.moodl.DataManagers.PreferencesManager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tiji on 19/04/2018.
|
* Created by Tiji on 19/04/2018.
|
||||||
*/
|
*/
|
||||||
@ -34,6 +37,16 @@ public class PlaceholderManager {
|
|||||||
return formattedString;
|
return formattedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> getFeeOptionsForSymbol(String symbol, Context context)
|
||||||
|
{
|
||||||
|
List<String> 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)
|
public static String getPairString(String pair1, String pair2, Context context)
|
||||||
{
|
{
|
||||||
return context.getResources().getString(R.string.pairPlaceholder, pair1, pair2);
|
return context.getResources().getString(R.string.pairPlaceholder, pair1, pair2);
|
||||||
|
10
app/src/main/res/anim/dismiss.xml
Normal file
10
app/src/main/res/anim/dismiss.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shareInterpolator="false"
|
||||||
|
android:fillAfter="true">
|
||||||
|
|
||||||
|
<translate
|
||||||
|
android:fromXDelta="0%" android:toXDelta="0%"
|
||||||
|
android:fromYDelta="0%" android:toYDelta="200%"
|
||||||
|
android:duration="400" />
|
||||||
|
|
||||||
|
</set>
|
10
app/src/main/res/anim/reveal.xml
Normal file
10
app/src/main/res/anim/reveal.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shareInterpolator="false"
|
||||||
|
android:fillAfter="true">
|
||||||
|
|
||||||
|
<translate
|
||||||
|
android:fromXDelta="0%" android:toXDelta="0%"
|
||||||
|
android:fromYDelta="200%" android:toYDelta="0%"
|
||||||
|
android:duration="400"/>
|
||||||
|
|
||||||
|
</set>
|
17
app/src/main/res/drawable/disabled_tab_background.xml
Normal file
17
app/src/main/res/drawable/disabled_tab_background.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/softWhite"/>
|
||||||
|
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="5dp"
|
||||||
|
android:topRightRadius="5dp"/>
|
||||||
|
<padding
|
||||||
|
android:left="3dp"
|
||||||
|
android:right="3dp"
|
||||||
|
android:top="3dp"
|
||||||
|
android:bottom="3dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M7,14l5,-5 5,5z"/>
|
||||||
|
</vector>
|
@ -1,18 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_selected="true">
|
<item>
|
||||||
<shape>
|
<shape android:shape="rectangle">
|
||||||
<corners android:topLeftRadius="5dp"
|
|
||||||
android:topRightRadius="5dp"/>
|
|
||||||
<solid android:color="@color/increaseCandle"/>
|
<solid android:color="@color/increaseCandle"/>
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item android:state_selected="false" android:state_focused="false" android:state_pressed="false">
|
<corners
|
||||||
<shape>
|
android:topLeftRadius="5dp"
|
||||||
<corners android:topRightRadius="5dp"
|
android:topRightRadius="5dp"/>
|
||||||
android:topLeftRadius="5dp"/>
|
<padding
|
||||||
<solid android:color="@color/hardWhite"/>
|
android:left="3dp"
|
||||||
|
android:right="3dp"
|
||||||
|
android:top="3dp"
|
||||||
|
android:bottom="3dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</selector>
|
</layer-list>
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_selected="true">
|
<item>
|
||||||
<shape>
|
<shape android:shape="rectangle">
|
||||||
<corners android:topLeftRadius="5dp"
|
|
||||||
android:topRightRadius="5dp"/>
|
|
||||||
<solid android:color="@color/decreaseCandle"/>
|
<solid android:color="@color/decreaseCandle"/>
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item android:state_selected="false" android:state_focused="false" android:state_pressed="false">
|
<corners
|
||||||
<shape>
|
android:topLeftRadius="5dp"
|
||||||
<corners android:topRightRadius="5dp"
|
android:topRightRadius="5dp"/>
|
||||||
android:topLeftRadius="5dp"/>
|
<padding
|
||||||
<solid android:color="@color/hardWhite"/>
|
android:left="3dp"
|
||||||
|
android:right="3dp"
|
||||||
|
android:top="3dp"
|
||||||
|
android:bottom="3dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</selector>
|
</layer-list>
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_selected="true">
|
<item>
|
||||||
<shape>
|
<shape android:shape="rectangle">
|
||||||
<corners android:topLeftRadius="5dp"
|
|
||||||
android:topRightRadius="5dp"/>
|
|
||||||
<solid android:color="@color/blue"/>
|
<solid android:color="@color/blue"/>
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item android:state_selected="false" android:state_focused="false" android:state_pressed="false">
|
<corners
|
||||||
<shape>
|
android:topLeftRadius="5dp"
|
||||||
<corners android:topRightRadius="5dp"
|
android:topRightRadius="5dp"/>
|
||||||
android:topLeftRadius="5dp"/>
|
<padding
|
||||||
<solid android:color="@color/hardWhite"/>
|
android:left="3dp"
|
||||||
|
android:right="3dp"
|
||||||
|
android:top="3dp"
|
||||||
|
android:bottom="3dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</selector>
|
</layer-list>
|
||||||
|
@ -111,11 +111,13 @@
|
|||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/globalTabLayouts"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="@dimen/double_toolbarSpinner_size"
|
android:layout_marginTop="@dimen/double_toolbarSpinner_size"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:visibility="invisible">
|
||||||
|
|
||||||
<com.herbron.moodl.CustomLayouts.CustomTabLayout
|
<com.herbron.moodl.CustomLayouts.CustomTabLayout
|
||||||
android:id="@+id/transactionsTabLayout"
|
android:id="@+id/transactionsTabLayout"
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
android:id="@+id/amount_editText"
|
android:id="@+id/amount_editText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
android:hint="@string/activity_add_amount"/>
|
android:hint="@string/activity_add_amount"/>
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
@ -26,7 +27,8 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:baselineAligned="false">
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/input_buyPrice"
|
android:id="@+id/input_buyPrice"
|
||||||
@ -38,6 +40,7 @@
|
|||||||
android:id="@+id/buyPrice_editText"
|
android:id="@+id/buyPrice_editText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
android:hint="@string/activity_purchase_price"/>
|
android:hint="@string/activity_purchase_price"/>
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
@ -68,6 +71,7 @@
|
|||||||
android:id="@+id/totalValue_editText"
|
android:id="@+id/totalValue_editText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
android:hint="@string/total_value"/>
|
android:hint="@string/total_value"/>
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
@ -81,21 +85,22 @@
|
|||||||
android:id="@+id/input_fees"
|
android:id="@+id/input_fees"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.15">
|
android:layout_weight="0.7">
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
<android.support.design.widget.TextInputEditText
|
||||||
android:id="@+id/fees_editText"
|
android:id="@+id/fees_editText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
android:hint="@string/activity_fees"/>
|
android:hint="@string/activity_fees"/>
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/feesUnit_Spinner"
|
android:id="@+id/feesCurrency_editText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0.85"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -116,7 +121,7 @@
|
|||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatButton
|
<android.support.v7.widget.AppCompatButton
|
||||||
android:id="@+id/saveExchangeButton"
|
android:id="@+id/saveBuyButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@mipmap/ic_launcher_moodl"
|
android:src="@mipmap/ic_launcher_moodl"
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:layout_marginEnd="10dp"/>
|
android:layout_marginEnd="10dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -42,7 +41,7 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:text="Total portfolio value :"/>
|
android:text="@string/total_portfolio_value"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/balanceTextView"
|
android:id="@+id/balanceTextView"
|
||||||
@ -54,12 +53,4 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/totalValueDrawer"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:textSize="20sp"/>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_search"
|
|
||||||
android:icon="@android:drawable/ic_menu_search"
|
|
||||||
android:title="Search"
|
|
||||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
|
||||||
app:showAsAction="ifRoom|collapseActionView" />
|
|
||||||
|
|
||||||
</menu>
|
|
@ -153,4 +153,8 @@
|
|||||||
<string name="notes">Notes</string>
|
<string name="notes">Notes</string>
|
||||||
<string name="select_exchange">Sélectionner un échange</string>
|
<string name="select_exchange">Sélectionner un échange</string>
|
||||||
<string name="select_pair">Paire</string>
|
<string name="select_pair">Paire</string>
|
||||||
|
<string name="total_portfolio_value">Valeur totale :</string>
|
||||||
|
|
||||||
|
<string name="fixedFee">Pourcentage de %1$s</string>
|
||||||
|
<string name="percentageFee">%1$s fixe</string>
|
||||||
</resources>
|
</resources>
|
@ -268,5 +268,9 @@
|
|||||||
<string name="notes">Notes</string>
|
<string name="notes">Notes</string>
|
||||||
<string name="select_exchange">Select an exchange</string>
|
<string name="select_exchange">Select an exchange</string>
|
||||||
<string name="select_pair">Pair</string>
|
<string name="select_pair">Pair</string>
|
||||||
|
<string name="total_portfolio_value">Total portfolio value :</string>
|
||||||
|
|
||||||
|
<string name="fixedFee">%1$s percentage</string>
|
||||||
|
<string name="percentageFee">%1$s fixed</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -7,7 +7,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
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
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
Loading…
Reference in New Issue
Block a user