[BETA] Manually add cryptocurrencies
Possibility to manually add cryptocurrencies into the database It's yet impossible to remove any of those without uninstalling the app or manually send a SQLite request to the database
This commit is contained in:
parent
28c7d39466
commit
00fc47b4ec
@ -3,6 +3,7 @@ package com.nauk.coinfolio.Activities;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@ -46,9 +47,10 @@ public class CurrencySelectionActivity extends AppCompatActivity {
|
|||||||
searchAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
searchAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
Currency selectedCurrency = (Currency) adapterView.getItemAtPosition(i);
|
||||||
Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class);
|
Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class);
|
||||||
intent.putExtra("coin", searchAutoComplete.getText().toString());
|
intent.putExtra("coin", selectedCurrency.getName());
|
||||||
intent.putExtra("symbol", searchAutoComplete.getCompletionHint().toString());
|
intent.putExtra("symbol", selectedCurrency.getSymbol());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,6 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
databaseManager = new DatabaseManager(this);
|
databaseManager = new DatabaseManager(this);
|
||||||
databaseManager.getAllCurrencyFromManualCurrency();
|
|
||||||
|
|
||||||
updateViewButtonIcon();
|
updateViewButtonIcon();
|
||||||
}
|
}
|
||||||
@ -232,7 +231,6 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
{
|
{
|
||||||
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, 12369084));
|
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, 12369084));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,7 +407,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
final List<Currency> balance = balanceManager.getTotalBalance();
|
final List<Currency> balance = balanceManager.getTotalBalance();
|
||||||
|
|
||||||
if(balanceManager.getTotalBalance().size() < 0)
|
if(balanceManager.getTotalBalance().size() > 0)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -12,11 +12,12 @@ import com.nauk.coinfolio.R;
|
|||||||
|
|
||||||
public class RecordTransactionActivity extends AppCompatActivity {
|
public class RecordTransactionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
String coin;
|
private String coin;
|
||||||
String symbol;
|
private String symbol;
|
||||||
TextView symbolTxtView;
|
private TextView symbolTxtView;
|
||||||
Button validateButton;
|
private TextView amountTxtView;
|
||||||
DatabaseManager databaseManager;
|
private Button validateButton;
|
||||||
|
private DatabaseManager databaseManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -33,10 +34,16 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
validateButton = findViewById(R.id.validateButton);
|
validateButton = findViewById(R.id.validateButton);
|
||||||
|
|
||||||
|
amountTxtView = findViewById(R.id.currencyAmount);
|
||||||
|
|
||||||
validateButton.setOnClickListener(new View.OnClickListener() {
|
validateButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
//databaseManager.addCurrencyToManualCurrency();
|
databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString()));
|
||||||
|
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,13 @@ public class BalanceManager {
|
|||||||
final private String binanceTimeUrl = "https://api.binance.com/api/v1/time";
|
final private String binanceTimeUrl = "https://api.binance.com/api/v1/time";
|
||||||
private RequestQueue requestQueue;
|
private RequestQueue requestQueue;
|
||||||
private List<Currency> hitBalance;
|
private List<Currency> hitBalance;
|
||||||
private List<Currency> otherBalances;
|
private List<Currency> manualBalances;
|
||||||
private List<Currency> totalBalance;
|
private List<Currency> totalBalance;
|
||||||
private android.content.Context context;
|
private android.content.Context context;
|
||||||
private Map<String, String> iconUrlList;
|
private Map<String, String> iconUrlList;
|
||||||
private Map<String, String> coinList;
|
private Map<String, String> coinList;
|
||||||
private PreferencesManager preferenceManager;
|
private PreferencesManager preferenceManager;
|
||||||
|
private DatabaseManager databaseManager;
|
||||||
|
|
||||||
public BalanceManager(android.content.Context context)
|
public BalanceManager(android.content.Context context)
|
||||||
{
|
{
|
||||||
@ -56,7 +57,8 @@ public class BalanceManager {
|
|||||||
preferenceManager = new PreferencesManager(context);
|
preferenceManager = new PreferencesManager(context);
|
||||||
requestQueue = Volley.newRequestQueue(context);
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
hitBalance = new ArrayList<Currency>();
|
hitBalance = new ArrayList<Currency>();
|
||||||
otherBalances = new ArrayList<Currency>();
|
manualBalances = new ArrayList<Currency>();
|
||||||
|
databaseManager = new DatabaseManager(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCurrenciesName()
|
public List<String> getCurrenciesName()
|
||||||
@ -107,13 +109,15 @@ public class BalanceManager {
|
|||||||
return hitBalance;
|
return hitBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Currency> getOtherBalances()
|
public List<Currency> getManualBalances()
|
||||||
{
|
{
|
||||||
return otherBalances;
|
return manualBalances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTotalBalance(final VolleyCallBack callBack)
|
public void updateTotalBalance(final VolleyCallBack callBack)
|
||||||
{
|
{
|
||||||
|
manualBalances = databaseManager.getAllCurrencyFromManualCurrency();
|
||||||
|
|
||||||
if(privateHitKey != null && publicHitKey != null && preferenceManager.isHitBTCActivated())
|
if(privateHitKey != null && publicHitKey != null && preferenceManager.isHitBTCActivated())
|
||||||
{
|
{
|
||||||
updateHitBalance(callBack);
|
updateHitBalance(callBack);
|
||||||
@ -190,15 +194,15 @@ public class BalanceManager {
|
|||||||
|
|
||||||
totalBalance.addAll(hitBalance);
|
totalBalance.addAll(hitBalance);
|
||||||
|
|
||||||
for(int i = 0; i < otherBalances.size(); i++)
|
for(int i = 0; i < manualBalances.size(); i++)
|
||||||
{
|
{
|
||||||
boolean isIn = false;
|
boolean isIn = false;
|
||||||
|
|
||||||
for(int j = 0; j < totalBalance.size(); j++)
|
for(int j = 0; j < totalBalance.size(); j++)
|
||||||
{
|
{
|
||||||
if(otherBalances.get(i).getSymbol().equals(totalBalance.get(j).getSymbol()))
|
if(manualBalances.get(i).getSymbol().equals(totalBalance.get(j).getSymbol()))
|
||||||
{
|
{
|
||||||
totalBalance.get(j).setBalance(totalBalance.get(j).getBalance() + otherBalances.get(i).getBalance());
|
totalBalance.get(j).setBalance(totalBalance.get(j).getBalance() + manualBalances.get(i).getBalance());
|
||||||
|
|
||||||
isIn = true;
|
isIn = true;
|
||||||
}
|
}
|
||||||
@ -206,7 +210,7 @@ public class BalanceManager {
|
|||||||
|
|
||||||
if(!isIn)
|
if(!isIn)
|
||||||
{
|
{
|
||||||
totalBalance.add(otherBalances.get(i));
|
totalBalance.add(manualBalances.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +288,7 @@ public class BalanceManager {
|
|||||||
|
|
||||||
coinList.put(jsonObject.getString("Symbol"), jsonObject.getString("CoinName"));
|
coinList.put(jsonObject.getString("Symbol"), jsonObject.getString("CoinName"));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DatabaseManager extends SQLiteOpenHelper{
|
public class DatabaseManager extends SQLiteOpenHelper{
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 4;
|
private static final int DATABASE_VERSION = 5;
|
||||||
|
|
||||||
private static final String DATABASE_NAME = "Currencies.db";
|
private static final String DATABASE_NAME = "Currencies.db";
|
||||||
|
|
||||||
@ -99,9 +99,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
|
|
||||||
while(resultatList.moveToNext())
|
while(resultatList.moveToNext())
|
||||||
{
|
{
|
||||||
//Currency currency = new Currency(resultatList.getString(1), resultatList.getString(2));
|
currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3)));
|
||||||
Log.d("CrystalVault", "Database result : " + resultatList.getString(1) + " " + resultatList.getString(2) + " " + resultatList.getCount());
|
|
||||||
//currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultatList.close();
|
resultatList.close();
|
||||||
|
@ -54,7 +54,6 @@ public class CurrencyAdapter extends ArrayAdapter<Currency> {
|
|||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Filter getFilter() {
|
public Filter getFilter() {
|
||||||
return myFilter;
|
return myFilter;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
android:textSize="25dp"/>
|
android:textSize="25dp"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
android:id="@+id/currencyAmount"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/activity_add_amount"/>
|
android:hint="@string/activity_add_amount"/>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<string name="app_name">Coinfolio</string>
|
<string name="app_name">Coinfolio</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="donation">Fais un don wallah</string>
|
<string name="donation">Fais un don wallah</string>
|
||||||
<string name="debug">CrystalVault_debug</string>
|
<string name="debug">Coinfolio_debug</string>
|
||||||
<string name="debug_volley">CrystalVault_debugVolley</string>
|
<string name="debug_volley">Coinfolio_debugVolley</string>
|
||||||
<string name="quick_button">Switch view</string>
|
<string name="quick_button">Switch view</string>
|
||||||
<string name="title_activity_settings">Settings</string>
|
<string name="title_activity_settings">Settings</string>
|
||||||
|
|
||||||
@ -115,5 +115,5 @@
|
|||||||
|
|
||||||
<!--Add transaction activity-->
|
<!--Add transaction activity-->
|
||||||
<string name="activity_add_amount">Amount</string>
|
<string name="activity_add_amount">Amount</string>
|
||||||
<string name="activity_purchased_price">Purchased prive</string>
|
<string name="activity_purchased_price">Purchased price</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user